@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /* |
23 | 23 | * Initialize DB connection |
24 | 24 | */ |
25 | - public function __construct($dbc = null,$fromACARSscript = false) { |
|
25 | + public function __construct($dbc = null, $fromACARSscript = false) { |
|
26 | 26 | $Connection = new Connection($dbc); |
27 | 27 | $this->db = $Connection->db(); |
28 | 28 | if ($this->db === null) die('Error: No DB connection. (ACARS)'); |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | * @return String the icao |
40 | 40 | */ |
41 | 41 | public function ident2icao($ident) { |
42 | - if (substr($ident,0,2) == 'AF') { |
|
43 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
44 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
42 | + if (substr($ident, 0, 2) == 'AF') { |
|
43 | + if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
44 | + else $icao = 'AFR'.ltrim(substr($ident, 2), '0'); |
|
45 | 45 | } else { |
46 | 46 | $Spotter = new Spotter($this->db); |
47 | - $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
|
47 | + $identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2)); |
|
48 | 48 | if (isset($identicao[0])) { |
49 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
49 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
50 | 50 | } else $icao = $ident; |
51 | 51 | } |
52 | 52 | return $icao; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $sth = $this->db->prepare($query); |
72 | 72 | $sth->execute(); |
73 | - } catch(PDOException $e) { |
|
73 | + } catch (PDOException $e) { |
|
74 | 74 | return "error"; |
75 | 75 | } |
76 | 76 | return "success"; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | $sth = $this->db->prepare($query); |
96 | 96 | $sth->execute(); |
97 | - } catch(PDOException $e) { |
|
97 | + } catch (PDOException $e) { |
|
98 | 98 | return "error"; |
99 | 99 | } |
100 | 100 | return "success"; |
@@ -120,15 +120,15 @@ discard block |
||
120 | 120 | $ident = ''; |
121 | 121 | $message = ''; |
122 | 122 | $result = array(); |
123 | - $n = sscanf($data,'%*[0-9a-z.] %*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); |
|
124 | - if ($n == 0 || $message == '') $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); |
|
125 | - if ($n == 0 || $message == '') $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); |
|
126 | - if ($n == 0 || $message == '') $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
127 | - if ($n == 0 || $message == '') $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); |
|
128 | - if ($n == 0 || $message == '') $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); |
|
123 | + $n = sscanf($data, '%*[0-9a-z.] %*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); |
|
124 | + if ($n == 0 || $message == '') $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); |
|
125 | + if ($n == 0 || $message == '') $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); |
|
126 | + if ($n == 0 || $message == '') $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
127 | + if ($n == 0 || $message == '') $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); |
|
128 | + if ($n == 0 || $message == '') $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); |
|
129 | 129 | if ($n != 0 && ($registration != '' || $ident != '' || $label != '' || $block_id != '' || $msg_no != '')) { |
130 | - $registration = str_replace('.','',$registration); |
|
131 | - $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
|
130 | + $registration = str_replace('.', '', $registration); |
|
131 | + $result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message); |
|
132 | 132 | if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
133 | 133 | } else $message = $data; |
134 | 134 | $decode = array(); |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | $temp = ''; |
149 | 149 | $n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp); |
150 | 150 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
151 | - $latitude = $la / 10000.0; |
|
152 | - $longitude = $ln / 10000.0; |
|
151 | + $latitude = $la/10000.0; |
|
152 | + $longitude = $ln/10000.0; |
|
153 | 153 | if ($lac == 'S') $latitude = '-'.$latitude; |
154 | 154 | if ($lnc == 'W') $longitude = '-'.$longitude; |
155 | 155 | // Temp not always available |
156 | 156 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
157 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
158 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
157 | + if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt); |
|
158 | + else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C'); |
|
159 | 159 | |
160 | 160 | //$icao = $Translation->checkTranslation($ident); |
161 | 161 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -167,19 +167,19 @@ discard block |
||
167 | 167 | $dhour = ''; |
168 | 168 | $darr = ''; |
169 | 169 | $ahour = ''; |
170 | - $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
|
170 | + $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour); |
|
171 | 171 | if ($n == 4 && strlen($darr) == 4) { |
172 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
173 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
174 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
172 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
173 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
174 | + if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n"; |
|
175 | 175 | //$icao = ACARS->ident2icao($ident); |
176 | 176 | //$icao = $Translation->checkTranslation($ident); |
177 | 177 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
178 | 178 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
179 | 179 | $found = true; |
180 | 180 | } |
181 | - elseif ($n == 2 || $n == 4) { |
|
182 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
181 | + elseif ($n == 2 || $n == 4) { |
|
182 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
183 | 183 | if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
184 | 184 | //$icao = ACARS->ident2icao($ident); |
185 | 185 | //$icao = $Translation->checkTranslation($ident); |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | $ahour = ''; |
238 | 238 | $aair = ''; |
239 | 239 | $apiste = ''; |
240 | - $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); |
|
240 | + $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); |
|
241 | 241 | if ($n > 8) { |
242 | - 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"; |
|
243 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
244 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
242 | + 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"; |
|
243 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
244 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
245 | 245 | $icao = trim($aident); |
246 | 246 | |
247 | 247 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
267 | 267 | $las = $las.'.'.$lass; |
268 | 268 | $lns = $lns.'.'.$lns; |
269 | - $latitude = $las / 1000.0; |
|
270 | - $longitude = $lns / 1000.0; |
|
269 | + $latitude = $las/1000.0; |
|
270 | + $longitude = $lns/1000.0; |
|
271 | 271 | if ($lac == 'S') $latitude = '-'.$latitude; |
272 | 272 | if ($lnc == 'W') $longitude = '-'.$longitude; |
273 | 273 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
@@ -362,17 +362,17 @@ discard block |
||
362 | 362 | $alt = ''; |
363 | 363 | $fuel = ''; |
364 | 364 | $speed = ''; |
365 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
365 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
366 | 366 | if ($n == 9) { |
367 | 367 | //if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
368 | 368 | $icao = trim($aident); |
369 | 369 | $decode['icao'] = $icao; |
370 | - $latitude = $las / 100.0; |
|
371 | - $longitude = $lns / 100.0; |
|
370 | + $latitude = $las/100.0; |
|
371 | + $longitude = $lns/100.0; |
|
372 | 372 | if ($lac == 'S') $latitude = '-'.$latitude; |
373 | 373 | if ($lnc == 'W') $longitude = '-'.$longitude; |
374 | 374 | |
375 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
|
375 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed); |
|
376 | 376 | $found = true; |
377 | 377 | } |
378 | 378 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | if ($lac == 'S') $latitude = '-'.$latitude; |
392 | 392 | if ($lnc == 'W') $longitude = '-'.$longitude; |
393 | 393 | |
394 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
|
394 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
|
395 | 395 | $found = true; |
396 | 396 | } |
397 | 397 | } |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | $dair = ''; |
425 | 425 | $darr = ''; |
426 | 426 | $aident = ''; |
427 | - $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); |
|
427 | + $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); |
|
428 | 428 | if ($n == 8) { |
429 | 429 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
430 | 430 | $icao = trim($aident); |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | */ |
457 | 457 | $dair = ''; |
458 | 458 | $darr = ''; |
459 | - $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
|
459 | + $n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr); |
|
460 | 460 | if ($n == 3) { |
461 | 461 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
462 | 462 | //$icao = $Translation->checkTranslation($ident); |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | */ |
472 | 472 | $dair = ''; |
473 | 473 | $darr = ''; |
474 | - $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
|
474 | + $n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr); |
|
475 | 475 | if ($n == 3) { |
476 | 476 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
477 | 477 | //$icao = $Translation->checkTranslation($ident); |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | } |
482 | 482 | } |
483 | 483 | if (!$found) { |
484 | - $n = sscanf($message,'MET01%4c',$airport); |
|
484 | + $n = sscanf($message, 'MET01%4c', $airport); |
|
485 | 485 | if ($n == 1) { |
486 | 486 | if ($globalDebug) echo 'airport name : '.$airport; |
487 | 487 | $decode = array('Airport/Waypoint name' => $airport); |
@@ -489,241 +489,241 @@ discard block |
||
489 | 489 | } |
490 | 490 | } |
491 | 491 | if ($label == 'H1') { |
492 | - if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
|
493 | - $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
|
492 | + if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) { |
|
493 | + $decode = array_merge(array('Message nature' => 'Equipment failure'), $decode); |
|
494 | 494 | } |
495 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
496 | - $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
|
495 | + elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) { |
|
496 | + $decode = array_merge(array('Message nature' => 'Take off performance data'), $decode); |
|
497 | 497 | } |
498 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
499 | - $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
|
498 | + elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) { |
|
499 | + $decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode); |
|
500 | 500 | } |
501 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
502 | - $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
|
501 | + elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) { |
|
502 | + $decode = array_merge(array('Message nature' => 'Weather observation'), $decode); |
|
503 | 503 | } |
504 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
505 | - $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
|
504 | + elseif (preg_match(':^#DFB/PIREP:', $message)) { |
|
505 | + $decode = array_merge(array('Message nature' => 'Pilot Report'), $decode); |
|
506 | 506 | } |
507 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
508 | - $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
|
507 | + elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) { |
|
508 | + $decode = array_merge(array('Message nature' => 'Engine Data'), $decode); |
|
509 | 509 | } |
510 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
511 | - $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
|
510 | + elseif (preg_match(':^#M1AAEP:', $message)) { |
|
511 | + $decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode); |
|
512 | 512 | } |
513 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
514 | - $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
|
513 | + elseif (preg_match(':^#M2APWD:', $message)) { |
|
514 | + $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode); |
|
515 | 515 | } |
516 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
517 | - $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
|
516 | + elseif (preg_match(':^#M1BREQPWI:', $message)) { |
|
517 | + $decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode); |
|
518 | 518 | } |
519 | - elseif (preg_match(':^#CF:',$message)) { |
|
520 | - $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
|
519 | + elseif (preg_match(':^#CF:', $message)) { |
|
520 | + $decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode); |
|
521 | 521 | } |
522 | - elseif (preg_match(':^#DF:',$message)) { |
|
523 | - $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
|
522 | + elseif (preg_match(':^#DF:', $message)) { |
|
523 | + $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode); |
|
524 | 524 | } |
525 | - elseif (preg_match(':^#EC:',$message)) { |
|
526 | - $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
|
525 | + elseif (preg_match(':^#EC:', $message)) { |
|
526 | + $decode = array_merge(array('Message nature' => 'Engine Display System'), $decode); |
|
527 | 527 | } |
528 | - elseif (preg_match(':^#EI:',$message)) { |
|
529 | - $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
|
528 | + elseif (preg_match(':^#EI:', $message)) { |
|
529 | + $decode = array_merge(array('Message nature' => 'Engine Report'), $decode); |
|
530 | 530 | } |
531 | - elseif (preg_match(':^#H1:',$message)) { |
|
532 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
|
531 | + elseif (preg_match(':^#H1:', $message)) { |
|
532 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode); |
|
533 | 533 | } |
534 | - elseif (preg_match(':^#H2:',$message)) { |
|
535 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
|
534 | + elseif (preg_match(':^#H2:', $message)) { |
|
535 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode); |
|
536 | 536 | } |
537 | - elseif (preg_match(':^#HD:',$message)) { |
|
538 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
|
537 | + elseif (preg_match(':^#HD:', $message)) { |
|
538 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode); |
|
539 | 539 | } |
540 | - elseif (preg_match(':^#M1:',$message)) { |
|
541 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
|
540 | + elseif (preg_match(':^#M1:', $message)) { |
|
541 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode); |
|
542 | 542 | } |
543 | - elseif (preg_match(':^#M2:',$message)) { |
|
544 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
|
543 | + elseif (preg_match(':^#M2:', $message)) { |
|
544 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode); |
|
545 | 545 | } |
546 | - elseif (preg_match(':^#M3:',$message)) { |
|
547 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
|
546 | + elseif (preg_match(':^#M3:', $message)) { |
|
547 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode); |
|
548 | 548 | } |
549 | - elseif (preg_match(':^#MD:',$message)) { |
|
550 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
|
549 | + elseif (preg_match(':^#MD:', $message)) { |
|
550 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode); |
|
551 | 551 | } |
552 | - elseif (preg_match(':^#PS:',$message)) { |
|
553 | - $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
|
552 | + elseif (preg_match(':^#PS:', $message)) { |
|
553 | + $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode); |
|
554 | 554 | } |
555 | - elseif (preg_match(':^#S1:',$message)) { |
|
556 | - $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
|
555 | + elseif (preg_match(':^#S1:', $message)) { |
|
556 | + $decode = array_merge(array('Message nature' => 'SDU - Left'), $decode); |
|
557 | 557 | } |
558 | - elseif (preg_match(':^#S2:',$message)) { |
|
559 | - $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
|
558 | + elseif (preg_match(':^#S2:', $message)) { |
|
559 | + $decode = array_merge(array('Message nature' => 'SDU - Right'), $decode); |
|
560 | 560 | } |
561 | - elseif (preg_match(':^#SD:',$message)) { |
|
562 | - $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
|
561 | + elseif (preg_match(':^#SD:', $message)) { |
|
562 | + $decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode); |
|
563 | 563 | } |
564 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
565 | - $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
|
564 | + elseif (preg_match(':^#T[0-8]:', $message)) { |
|
565 | + $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode); |
|
566 | 566 | } |
567 | - elseif (preg_match(':^#WO:',$message)) { |
|
568 | - $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
|
567 | + elseif (preg_match(':^#WO:', $message)) { |
|
568 | + $decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode); |
|
569 | 569 | } |
570 | - elseif (preg_match(':^#A1:',$message)) { |
|
571 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
|
570 | + elseif (preg_match(':^#A1:', $message)) { |
|
571 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode); |
|
572 | 572 | } |
573 | - elseif (preg_match(':^#A3:',$message)) { |
|
574 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
|
573 | + elseif (preg_match(':^#A3:', $message)) { |
|
574 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode); |
|
575 | 575 | } |
576 | - elseif (preg_match(':^#A4:',$message)) { |
|
577 | - $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
|
576 | + elseif (preg_match(':^#A4:', $message)) { |
|
577 | + $decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode); |
|
578 | 578 | } |
579 | - elseif (preg_match(':^#A6:',$message)) { |
|
580 | - $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
|
579 | + elseif (preg_match(':^#A6:', $message)) { |
|
580 | + $decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode); |
|
581 | 581 | } |
582 | - elseif (preg_match(':^#A8:',$message)) { |
|
583 | - $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
|
582 | + elseif (preg_match(':^#A8:', $message)) { |
|
583 | + $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode); |
|
584 | 584 | } |
585 | - elseif (preg_match(':^#A9:',$message)) { |
|
586 | - $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
|
585 | + elseif (preg_match(':^#A9:', $message)) { |
|
586 | + $decode = array_merge(array('Message nature' => 'ATIS report'), $decode); |
|
587 | 587 | } |
588 | - elseif (preg_match(':^#A0:',$message)) { |
|
589 | - $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
|
588 | + elseif (preg_match(':^#A0:', $message)) { |
|
589 | + $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode); |
|
590 | 590 | } |
591 | - elseif (preg_match(':^#AA:',$message)) { |
|
592 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
591 | + elseif (preg_match(':^#AA:', $message)) { |
|
592 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
593 | 593 | } |
594 | - elseif (preg_match(':^#AB:',$message)) { |
|
595 | - $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
|
594 | + elseif (preg_match(':^#AB:', $message)) { |
|
595 | + $decode = array_merge(array('Message nature' => 'TWIP Report'), $decode); |
|
596 | 596 | } |
597 | - elseif (preg_match(':^#AC:',$message)) { |
|
598 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
|
597 | + elseif (preg_match(':^#AC:', $message)) { |
|
598 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode); |
|
599 | 599 | } |
600 | - elseif (preg_match(':^#AD:',$message)) { |
|
601 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
|
600 | + elseif (preg_match(':^#AD:', $message)) { |
|
601 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode); |
|
602 | 602 | } |
603 | - elseif (preg_match(':^#AF:',$message)) { |
|
604 | - $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
|
603 | + elseif (preg_match(':^#AF:', $message)) { |
|
604 | + $decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode); |
|
605 | 605 | } |
606 | - elseif (preg_match(':^#B1:',$message)) { |
|
607 | - $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
|
606 | + elseif (preg_match(':^#B1:', $message)) { |
|
607 | + $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode); |
|
608 | 608 | } |
609 | - elseif (preg_match(':^#B2:',$message)) { |
|
610 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
|
609 | + elseif (preg_match(':^#B2:', $message)) { |
|
610 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode); |
|
611 | 611 | } |
612 | - elseif (preg_match(':^#B3:',$message)) { |
|
613 | - $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
|
612 | + elseif (preg_match(':^#B3:', $message)) { |
|
613 | + $decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode); |
|
614 | 614 | } |
615 | - elseif (preg_match(':^#B4:',$message)) { |
|
616 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
|
615 | + elseif (preg_match(':^#B4:', $message)) { |
|
616 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode); |
|
617 | 617 | } |
618 | - elseif (preg_match(':^#B6:',$message)) { |
|
619 | - $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
|
618 | + elseif (preg_match(':^#B6:', $message)) { |
|
619 | + $decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode); |
|
620 | 620 | } |
621 | - elseif (preg_match(':^#B8:',$message)) { |
|
622 | - $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
|
621 | + elseif (preg_match(':^#B8:', $message)) { |
|
622 | + $decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode); |
|
623 | 623 | } |
624 | - elseif (preg_match(':^#B9:',$message)) { |
|
625 | - $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
|
624 | + elseif (preg_match(':^#B9:', $message)) { |
|
625 | + $decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode); |
|
626 | 626 | } |
627 | - elseif (preg_match(':^#B0:',$message)) { |
|
628 | - $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
|
627 | + elseif (preg_match(':^#B0:', $message)) { |
|
628 | + $decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode); |
|
629 | 629 | } |
630 | - elseif (preg_match(':^#BA:',$message)) { |
|
631 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
630 | + elseif (preg_match(':^#BA:', $message)) { |
|
631 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
632 | 632 | } |
633 | - elseif (preg_match(':^#BB:',$message)) { |
|
634 | - $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
|
633 | + elseif (preg_match(':^#BB:', $message)) { |
|
634 | + $decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode); |
|
635 | 635 | } |
636 | - elseif (preg_match(':^#BC:',$message)) { |
|
637 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
|
636 | + elseif (preg_match(':^#BC:', $message)) { |
|
637 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode); |
|
638 | 638 | } |
639 | - elseif (preg_match(':^#BD:',$message)) { |
|
640 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
|
639 | + elseif (preg_match(':^#BD:', $message)) { |
|
640 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode); |
|
641 | 641 | } |
642 | - elseif (preg_match(':^#BE:',$message)) { |
|
643 | - $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
|
642 | + elseif (preg_match(':^#BE:', $message)) { |
|
643 | + $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode); |
|
644 | 644 | } |
645 | - elseif (preg_match(':^#BF:',$message)) { |
|
646 | - $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
|
645 | + elseif (preg_match(':^#BF:', $message)) { |
|
646 | + $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode); |
|
647 | 647 | } |
648 | - elseif (preg_match(':^#H3:',$message)) { |
|
649 | - $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
|
648 | + elseif (preg_match(':^#H3:', $message)) { |
|
649 | + $decode = array_merge(array('Message nature' => 'Icing Report'), $decode); |
|
650 | 650 | } |
651 | 651 | } |
652 | 652 | if ($label == '10') { |
653 | - if (preg_match(':^DTO01:',$message)) { |
|
654 | - $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
|
653 | + if (preg_match(':^DTO01:', $message)) { |
|
654 | + $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode); |
|
655 | 655 | } |
656 | - elseif (preg_match(':^AIS01:',$message)) { |
|
657 | - $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
|
656 | + elseif (preg_match(':^AIS01:', $message)) { |
|
657 | + $decode = array_merge(array('Message nature' => 'AIS Request'), $decode); |
|
658 | 658 | } |
659 | - elseif (preg_match(':^FTX01:',$message)) { |
|
660 | - $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
|
659 | + elseif (preg_match(':^FTX01:', $message)) { |
|
660 | + $decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode); |
|
661 | 661 | } |
662 | - elseif (preg_match(':^FPL01:',$message)) { |
|
663 | - $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
|
662 | + elseif (preg_match(':^FPL01:', $message)) { |
|
663 | + $decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode); |
|
664 | 664 | } |
665 | - elseif (preg_match(':^WAB01:',$message)) { |
|
666 | - $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
|
665 | + elseif (preg_match(':^WAB01:', $message)) { |
|
666 | + $decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode); |
|
667 | 667 | } |
668 | - elseif (preg_match(':^MET01:',$message)) { |
|
669 | - $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
|
668 | + elseif (preg_match(':^MET01:', $message)) { |
|
669 | + $decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode); |
|
670 | 670 | } |
671 | - elseif (preg_match(':^WAB02:',$message)) { |
|
672 | - $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
|
671 | + elseif (preg_match(':^WAB02:', $message)) { |
|
672 | + $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode); |
|
673 | 673 | } |
674 | 674 | } |
675 | 675 | if ($label == '15') { |
676 | - if (preg_match(':^FST01:',$message)) { |
|
677 | - $decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode); |
|
676 | + if (preg_match(':^FST01:', $message)) { |
|
677 | + $decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode); |
|
678 | 678 | } |
679 | 679 | } |
680 | 680 | if (!$found && $label == 'SA') { |
681 | - $n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at); |
|
681 | + $n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at); |
|
682 | 682 | if ($n == 4) { |
683 | 683 | $vsta = array('Version' => $version); |
684 | 684 | if ($state == 'E') { |
685 | - $vsta = array_merge($vsta,array('Link state' => 'Established')); |
|
685 | + $vsta = array_merge($vsta, array('Link state' => 'Established')); |
|
686 | 686 | } |
687 | 687 | elseif ($state == 'L') { |
688 | - $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
|
688 | + $vsta = array_merge($vsta, array('Link state' => 'Lost')); |
|
689 | 689 | } |
690 | 690 | else { |
691 | - $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
|
691 | + $vsta = array_merge($vsta, array('Link state' => 'Unknown')); |
|
692 | 692 | } |
693 | 693 | if ($type == 'V') { |
694 | - $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
|
694 | + $vsta = array_merge($vsta, array('Link type' => 'VHF ACARS')); |
|
695 | 695 | } |
696 | 696 | elseif ($type == 'S') { |
697 | - $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
|
697 | + $vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM')); |
|
698 | 698 | } |
699 | 699 | elseif ($type == 'H') { |
700 | - $vsta = array_merge($vsta,array('Link type' => 'HF')); |
|
700 | + $vsta = array_merge($vsta, array('Link type' => 'HF')); |
|
701 | 701 | } |
702 | 702 | elseif ($type == 'G') { |
703 | - $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
|
703 | + $vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM')); |
|
704 | 704 | } |
705 | 705 | elseif ($type == 'C') { |
706 | - $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
|
706 | + $vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM')); |
|
707 | 707 | } |
708 | 708 | elseif ($type == '2') { |
709 | - $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
|
709 | + $vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2')); |
|
710 | 710 | } |
711 | 711 | elseif ($type == 'X') { |
712 | - $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
|
712 | + $vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero')); |
|
713 | 713 | } |
714 | 714 | elseif ($type == 'I') { |
715 | - $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
|
715 | + $vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM')); |
|
716 | 716 | } |
717 | 717 | else { |
718 | - $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
|
718 | + $vsta = array_merge($vsta, array('Link type' => 'Unknown')); |
|
719 | 719 | } |
720 | - $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
|
721 | - $decode = array_merge($vsta,$decode); |
|
720 | + $vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2)))); |
|
721 | + $decode = array_merge($vsta, $decode); |
|
722 | 722 | } |
723 | 723 | } |
724 | 724 | |
725 | 725 | $title = $this->getTitlefromLabel($label); |
726 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
726 | + if ($title != '') $decode = array_merge(array('Message title' => $title), $decode); |
|
727 | 727 | /* |
728 | 728 | // Business jets always use GS0001 |
729 | 729 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -744,21 +744,21 @@ discard block |
||
744 | 744 | * @param String ACARS data in acarsdec data |
745 | 745 | * |
746 | 746 | */ |
747 | - public function add($data,$message = array()) { |
|
747 | + public function add($data, $message = array()) { |
|
748 | 748 | global $globalDebug, $globalACARSArchive; |
749 | 749 | $Image = new Image($this->db); |
750 | 750 | $Schedule = new Schedule($this->db); |
751 | 751 | $Translation = new Translation($this->db); |
752 | 752 | |
753 | - $message = array_merge($message,$this->parse($data)); |
|
753 | + $message = array_merge($message, $this->parse($data)); |
|
754 | 754 | if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') { |
755 | - $ident = (string)$message['ident']; |
|
755 | + $ident = (string) $message['ident']; |
|
756 | 756 | $label = $message['label']; |
757 | 757 | $block_id = $message['block_id']; |
758 | 758 | $msg_no = $message['msg_no']; |
759 | 759 | $msg = $message['message']; |
760 | 760 | $decode = $message['decode']; |
761 | - $registration = (string)$message['registration']; |
|
761 | + $registration = (string) $message['registration']; |
|
762 | 762 | if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
763 | 763 | else $latitude = ''; |
764 | 764 | if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
@@ -772,20 +772,20 @@ discard block |
||
772 | 772 | $Image->addSpotterImage($registration); |
773 | 773 | } |
774 | 774 | // Business jets always use GS0001 |
775 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
775 | + if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude); |
|
776 | 776 | if ($globalDebug && isset($info) && $info != '') echo $info; |
777 | 777 | if (count($decode) > 0) $decode_json = json_encode($decode); |
778 | 778 | else $decode_json = ''; |
779 | 779 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
780 | - $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
|
780 | + $Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS'); |
|
781 | 781 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
782 | - $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
|
782 | + $Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS'); |
|
783 | 783 | } |
784 | - $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
785 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
786 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
784 | + $result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
785 | + if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F'); |
|
786 | + if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
787 | 787 | if ($globalDebug && count($decode) > 0) { |
788 | - echo "Human readable data : ".implode(' - ',$decode)."\n"; |
|
788 | + echo "Human readable data : ".implode(' - ', $decode)."\n"; |
|
789 | 789 | } |
790 | 790 | } |
791 | 791 | } |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | * @param string $decode |
803 | 803 | * @return bool |
804 | 804 | */ |
805 | - public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
805 | + public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
806 | 806 | global $globalDebug; |
807 | 807 | date_default_timezone_set('UTC'); |
808 | 808 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
@@ -810,22 +810,22 @@ discard block |
||
810 | 810 | $this->db = $Connection->db; |
811 | 811 | if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
812 | 812 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
813 | - $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
|
813 | + $query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message); |
|
814 | 814 | try { |
815 | 815 | $stht = $this->db->prepare($query_test); |
816 | 816 | $stht->execute($query_test_values); |
817 | - } catch(PDOException $e) { |
|
817 | + } catch (PDOException $e) { |
|
818 | 818 | echo "error : ".$e->getMessage(); |
819 | 819 | return false; |
820 | 820 | } |
821 | 821 | if ($stht->fetchColumn() == 0) { |
822 | 822 | if ($globalDebug) echo "Add Live ACARS data..."; |
823 | 823 | $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)"; |
824 | - $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")); |
|
824 | + $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")); |
|
825 | 825 | try { |
826 | 826 | $sth = $this->db->prepare($query); |
827 | 827 | $sth->execute($query_values); |
828 | - } catch(PDOException $e) { |
|
828 | + } catch (PDOException $e) { |
|
829 | 829 | echo "error : ".$e->getMessage(); |
830 | 830 | return false; |
831 | 831 | } |
@@ -851,10 +851,10 @@ discard block |
||
851 | 851 | * @param string $decode |
852 | 852 | * @return string |
853 | 853 | */ |
854 | - public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
854 | + public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
855 | 855 | global $globalDebug; |
856 | 856 | date_default_timezone_set('UTC'); |
857 | - if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) { |
|
857 | + if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) { |
|
858 | 858 | /* |
859 | 859 | if ($globalDebug) echo "Test if not already in Archive ACARS table..."; |
860 | 860 | $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message"; |
@@ -869,11 +869,11 @@ discard block |
||
869 | 869 | */ |
870 | 870 | if ($globalDebug) echo "Add Live ACARS data..."; |
871 | 871 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
872 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
872 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
873 | 873 | try { |
874 | 874 | $sth = $this->db->prepare($query); |
875 | 875 | $sth->execute($query_values); |
876 | - } catch(PDOException $e) { |
|
876 | + } catch (PDOException $e) { |
|
877 | 877 | return "error : ".$e->getMessage(); |
878 | 878 | } |
879 | 879 | if ($globalDebug) echo "Done\n"; |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | try { |
896 | 896 | $sth = $this->db->prepare($query); |
897 | 897 | $sth->execute($query_values); |
898 | - } catch(PDOException $e) { |
|
898 | + } catch (PDOException $e) { |
|
899 | 899 | echo "error : ".$e->getMessage(); |
900 | 900 | return ''; |
901 | 901 | } |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | try { |
916 | 916 | $sth = $this->db->prepare($query); |
917 | 917 | $sth->execute($query_values); |
918 | - } catch(PDOException $e) { |
|
918 | + } catch (PDOException $e) { |
|
919 | 919 | echo "error : ".$e->getMessage(); |
920 | 920 | return array(); |
921 | 921 | } |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | try { |
937 | 937 | $sth = $this->db->prepare($query); |
938 | 938 | $sth->execute($query_values); |
939 | - } catch(PDOException $e) { |
|
939 | + } catch (PDOException $e) { |
|
940 | 940 | echo "error : ".$e->getMessage(); |
941 | 941 | return array(); |
942 | 942 | } |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | * @param string $label |
953 | 953 | * @return array Return ACARS data in array |
954 | 954 | */ |
955 | - public function getLatestAcarsData($limit = '',$label = '') { |
|
955 | + public function getLatestAcarsData($limit = '', $label = '') { |
|
956 | 956 | global $globalURL; |
957 | 957 | $Image = new Image($this->db); |
958 | 958 | $Spotter = new Spotter($this->db); |
@@ -963,8 +963,8 @@ discard block |
||
963 | 963 | if ($limit != "") |
964 | 964 | { |
965 | 965 | $limit_array = explode(",", $limit); |
966 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
967 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
966 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
967 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
968 | 968 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
969 | 969 | { |
970 | 970 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -980,7 +980,7 @@ discard block |
||
980 | 980 | try { |
981 | 981 | $sth = $this->db->prepare($query); |
982 | 982 | $sth->execute($query_values); |
983 | - } catch(PDOException $e) { |
|
983 | + } catch (PDOException $e) { |
|
984 | 984 | echo "error : ".$e->getMessage(); |
985 | 985 | return array(); |
986 | 986 | } |
@@ -988,39 +988,39 @@ discard block |
||
988 | 988 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
989 | 989 | $data = array(); |
990 | 990 | if ($row['registration'] != '') { |
991 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
991 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
992 | 992 | $image_array = $Image->getSpotterImage($row['registration']); |
993 | - 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'])); |
|
994 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
995 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
993 | + 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'])); |
|
994 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
995 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
996 | 996 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
997 | 997 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
998 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
998 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
999 | 999 | if (isset($identicao[0])) { |
1000 | - if (substr($row['ident'],0,2) == 'AF') { |
|
1001 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1002 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1003 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1004 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
1000 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
1001 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1002 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
1003 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
1004 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
1005 | 1005 | } else $icao = $row['ident']; |
1006 | - $icao = $Translation->checkTranslation($icao,false); |
|
1007 | - $decode = json_decode($row['decode'],true); |
|
1006 | + $icao = $Translation->checkTranslation($icao, false); |
|
1007 | + $decode = json_decode($row['decode'], true); |
|
1008 | 1008 | $found = false; |
1009 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
1009 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
1010 | 1010 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1011 | 1011 | if (isset($airport_info[0]['icao'])) { |
1012 | 1012 | $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1013 | 1013 | $found = true; |
1014 | 1014 | } |
1015 | 1015 | } |
1016 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
1016 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
1017 | 1017 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1018 | 1018 | if (isset($airport_info[0]['icao'])) { |
1019 | 1019 | $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1020 | 1020 | $found = true; |
1021 | 1021 | } |
1022 | 1022 | } |
1023 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
1023 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
1024 | 1024 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
1025 | 1025 | if (isset($airport_info[0]['icao'])) { |
1026 | 1026 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1028,7 +1028,7 @@ discard block |
||
1028 | 1028 | } |
1029 | 1029 | } |
1030 | 1030 | if ($found) $row['decode'] = json_encode($decode); |
1031 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1031 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1032 | 1032 | $result[] = $data; |
1033 | 1033 | $i++; |
1034 | 1034 | } |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | * @param string $label |
1047 | 1047 | * @return array Return ACARS data in array |
1048 | 1048 | */ |
1049 | - public function getArchiveAcarsData($limit = '',$label = '') { |
|
1049 | + public function getArchiveAcarsData($limit = '', $label = '') { |
|
1050 | 1050 | global $globalURL; |
1051 | 1051 | $Image = new Image($this->db); |
1052 | 1052 | $Spotter = new Spotter($this->db); |
@@ -1056,8 +1056,8 @@ discard block |
||
1056 | 1056 | if ($limit != "") |
1057 | 1057 | { |
1058 | 1058 | $limit_array = explode(",", $limit); |
1059 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1060 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1059 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1060 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1061 | 1061 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1062 | 1062 | { |
1063 | 1063 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1078,45 +1078,45 @@ discard block |
||
1078 | 1078 | try { |
1079 | 1079 | $sth = $this->db->prepare($query); |
1080 | 1080 | $sth->execute($query_values); |
1081 | - } catch(PDOException $e) { |
|
1081 | + } catch (PDOException $e) { |
|
1082 | 1082 | echo "error : ".$e->getMessage(); |
1083 | 1083 | return array(); |
1084 | 1084 | } |
1085 | - $i=0; |
|
1085 | + $i = 0; |
|
1086 | 1086 | $result = array(); |
1087 | 1087 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
1088 | 1088 | $data = array(); |
1089 | 1089 | if ($row['registration'] != '') { |
1090 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
1090 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
1091 | 1091 | $image_array = $Image->getSpotterImage($row['registration']); |
1092 | - 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'])); |
|
1093 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1094 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1092 | + 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'])); |
|
1093 | + else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1094 | + } else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1095 | 1095 | $icao = ''; |
1096 | 1096 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
1097 | 1097 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
1098 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
1098 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
1099 | 1099 | if (isset($identicao[0])) { |
1100 | - if (substr($row['ident'],0,2) == 'AF') { |
|
1101 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1102 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1103 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1104 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
1100 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
1101 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1102 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
1103 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
1104 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
1105 | 1105 | } else $icao = $row['ident']; |
1106 | 1106 | $icao = $Translation->checkTranslation($icao); |
1107 | - $decode = json_decode($row['decode'],true); |
|
1107 | + $decode = json_decode($row['decode'], true); |
|
1108 | 1108 | $found = false; |
1109 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
1109 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
1110 | 1110 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1111 | 1111 | 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>'; |
1112 | 1112 | $found = true; |
1113 | 1113 | } |
1114 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
1114 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
1115 | 1115 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1116 | 1116 | 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>'; |
1117 | 1117 | $found = true; |
1118 | 1118 | } |
1119 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
1119 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
1120 | 1120 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
1121 | 1121 | if (isset($airport_info[0]['icao'])) { |
1122 | 1122 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1124,7 +1124,7 @@ discard block |
||
1124 | 1124 | } |
1125 | 1125 | } |
1126 | 1126 | if ($found) $row['decode'] = json_encode($decode); |
1127 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1127 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1128 | 1128 | $result[] = $data; |
1129 | 1129 | $i++; |
1130 | 1130 | } |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | * @param string $longitude |
1146 | 1146 | * @return string |
1147 | 1147 | */ |
1148 | - public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
|
1148 | + public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') { |
|
1149 | 1149 | global $globalDebug, $globalDBdriver; |
1150 | 1150 | $ident = trim($ident); |
1151 | 1151 | $Translation = new Translation($this->db); |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | if ($globalDebug) echo "Ident or registration null, exit\n"; |
1159 | 1159 | return ''; |
1160 | 1160 | } |
1161 | - $registration = str_replace('.','',$registration); |
|
1161 | + $registration = str_replace('.', '', $registration); |
|
1162 | 1162 | $ident = $Translation->ident2icao($ident); |
1163 | 1163 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1164 | 1164 | if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | try { |
1168 | 1168 | $sthsi = $this->db->prepare($querysi); |
1169 | 1169 | $sthsi->execute($querysi_values); |
1170 | - } catch(PDOException $e) { |
|
1170 | + } catch (PDOException $e) { |
|
1171 | 1171 | if ($globalDebug) echo $e->getMessage(); |
1172 | 1172 | return "error : ".$e->getMessage(); |
1173 | 1173 | } |
@@ -1177,8 +1177,8 @@ discard block |
||
1177 | 1177 | $Translation = new Translation($this->db); |
1178 | 1178 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1179 | 1179 | if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
1180 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1181 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1180 | + if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1181 | + elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1182 | 1182 | } else { |
1183 | 1183 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1184 | 1184 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | try { |
1187 | 1187 | $sth = $this->db->prepare($query); |
1188 | 1188 | $sth->execute($query_values); |
1189 | - } catch(PDOException $e) { |
|
1189 | + } catch (PDOException $e) { |
|
1190 | 1190 | if ($globalDebug) echo $e->getMessage(); |
1191 | 1191 | return "error : ".$e->getMessage(); |
1192 | 1192 | } |
@@ -1194,7 +1194,7 @@ discard block |
||
1194 | 1194 | $sth->closeCursor(); |
1195 | 1195 | if (isset($result['modes'])) $hex = $result['modes']; |
1196 | 1196 | else $hex = ''; |
1197 | - $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
|
1197 | + $SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS'); |
|
1198 | 1198 | if ($this->fromACARSscript) $this->SI->add($SI_data); |
1199 | 1199 | } |
1200 | 1200 | } |
@@ -1204,7 +1204,7 @@ discard block |
||
1204 | 1204 | try { |
1205 | 1205 | $sth = $this->db->prepare($query); |
1206 | 1206 | $sth->execute($query_values); |
1207 | - } catch(PDOException $e) { |
|
1207 | + } catch (PDOException $e) { |
|
1208 | 1208 | if ($globalDebug) echo $e->getMessage(); |
1209 | 1209 | return "error : ".$e->getMessage(); |
1210 | 1210 | } |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
1215 | 1215 | else $ModeS = ''; |
1216 | 1216 | if ($ModeS == '') { |
1217 | - $id = explode('-',$result['flightaware_id']); |
|
1217 | + $id = explode('-', $result['flightaware_id']); |
|
1218 | 1218 | $ModeS = $id[0]; |
1219 | 1219 | } |
1220 | 1220 | if ($ModeS != '') { |
@@ -1224,20 +1224,20 @@ discard block |
||
1224 | 1224 | try { |
1225 | 1225 | $sthc = $this->db->prepare($queryc); |
1226 | 1226 | $sthc->execute($queryc_values); |
1227 | - } catch(PDOException $e) { |
|
1227 | + } catch (PDOException $e) { |
|
1228 | 1228 | if ($globalDebug) echo $e->getMessage(); |
1229 | 1229 | return "error : ".$e->getMessage(); |
1230 | 1230 | } |
1231 | 1231 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1232 | 1232 | $sthc->closeCursor(); |
1233 | - if (count($row) == 0) { |
|
1233 | + if (count($row) == 0) { |
|
1234 | 1234 | if ($globalDebug) echo " Add to ModeS table - "; |
1235 | 1235 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1236 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1236 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1237 | 1237 | try { |
1238 | 1238 | $sthi = $this->db->prepare($queryi); |
1239 | 1239 | $sthi->execute($queryi_values); |
1240 | - } catch(PDOException $e) { |
|
1240 | + } catch (PDOException $e) { |
|
1241 | 1241 | if ($globalDebug) echo $e->getMessage(); |
1242 | 1242 | return "error : ".$e->getMessage(); |
1243 | 1243 | } |
@@ -1245,15 +1245,15 @@ discard block |
||
1245 | 1245 | if ($globalDebug) echo " Update ModeS table - "; |
1246 | 1246 | if ($ICAOTypeCode != '') { |
1247 | 1247 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1248 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1248 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1249 | 1249 | } else { |
1250 | 1250 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1251 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration); |
|
1251 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration); |
|
1252 | 1252 | } |
1253 | 1253 | try { |
1254 | 1254 | $sthi = $this->db->prepare($queryi); |
1255 | 1255 | $sthi->execute($queryi_values); |
1256 | - } catch(PDOException $e) { |
|
1256 | + } catch (PDOException $e) { |
|
1257 | 1257 | if ($globalDebug) echo $e->getMessage(); |
1258 | 1258 | return "error : ".$e->getMessage(); |
1259 | 1259 | } |
@@ -1290,12 +1290,12 @@ discard block |
||
1290 | 1290 | elseif ($globalDBdriver == 'pgsql') { |
1291 | 1291 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1292 | 1292 | } |
1293 | - $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
|
1293 | + $queryi_values = array(':Registration' => $registration, ':ident' => $icao); |
|
1294 | 1294 | } |
1295 | 1295 | try { |
1296 | 1296 | $sthi = $this->db->prepare($queryi); |
1297 | 1297 | $sthi->execute($queryi_values); |
1298 | - } catch(PDOException $e) { |
|
1298 | + } catch (PDOException $e) { |
|
1299 | 1299 | if ($globalDebug) echo $e->getMessage(); |
1300 | 1300 | return "error : ".$e->getMessage(); |
1301 | 1301 | } |
@@ -25,7 +25,9 @@ discard block |
||
25 | 25 | public function __construct($dbc = null,$fromACARSscript = false) { |
26 | 26 | $Connection = new Connection($dbc); |
27 | 27 | $this->db = $Connection->db(); |
28 | - if ($this->db === null) die('Error: No DB connection. (ACARS)'); |
|
28 | + if ($this->db === null) { |
|
29 | + die('Error: No DB connection. (ACARS)'); |
|
30 | + } |
|
29 | 31 | if ($fromACARSscript) { |
30 | 32 | $this->fromACARSscript = true; |
31 | 33 | $this->SI = new SpotterImport($this->db); |
@@ -40,14 +42,19 @@ discard block |
||
40 | 42 | */ |
41 | 43 | public function ident2icao($ident) { |
42 | 44 | if (substr($ident,0,2) == 'AF') { |
43 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
44 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
45 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
46 | + $icao = $ident; |
|
47 | + } else { |
|
48 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
49 | + } |
|
45 | 50 | } else { |
46 | 51 | $Spotter = new Spotter($this->db); |
47 | 52 | $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
48 | 53 | if (isset($identicao[0])) { |
49 | 54 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
50 | - } else $icao = $ident; |
|
55 | + } else { |
|
56 | + $icao = $ident; |
|
57 | + } |
|
51 | 58 | } |
52 | 59 | return $icao; |
53 | 60 | } |
@@ -121,16 +128,30 @@ discard block |
||
121 | 128 | $message = ''; |
122 | 129 | $result = array(); |
123 | 130 | $n = sscanf($data,'%*[0-9a-z.] %*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); |
124 | - if ($n == 0 || $message == '') $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); |
|
125 | - if ($n == 0 || $message == '') $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); |
|
126 | - if ($n == 0 || $message == '') $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
127 | - if ($n == 0 || $message == '') $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); |
|
128 | - if ($n == 0 || $message == '') $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); |
|
131 | + if ($n == 0 || $message == '') { |
|
132 | + $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); |
|
133 | + } |
|
134 | + if ($n == 0 || $message == '') { |
|
135 | + $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); |
|
136 | + } |
|
137 | + if ($n == 0 || $message == '') { |
|
138 | + $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
139 | + } |
|
140 | + if ($n == 0 || $message == '') { |
|
141 | + $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); |
|
142 | + } |
|
143 | + if ($n == 0 || $message == '') { |
|
144 | + $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); |
|
145 | + } |
|
129 | 146 | if ($n != 0 && ($registration != '' || $ident != '' || $label != '' || $block_id != '' || $msg_no != '')) { |
130 | 147 | $registration = str_replace('.','',$registration); |
131 | 148 | $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
132 | - if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
133 | - } else $message = $data; |
|
149 | + if ($globalDebug) { |
|
150 | + echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
151 | + } |
|
152 | + } else { |
|
153 | + $message = $data; |
|
154 | + } |
|
134 | 155 | $decode = array(); |
135 | 156 | $found = false; |
136 | 157 | // if ($registration != '' && $ident != '' && $registration != '!') { |
@@ -150,12 +171,21 @@ discard block |
||
150 | 171 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
151 | 172 | $latitude = $la / 10000.0; |
152 | 173 | $longitude = $ln / 10000.0; |
153 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
154 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
174 | + if ($lac == 'S') { |
|
175 | + $latitude = '-'.$latitude; |
|
176 | + } |
|
177 | + if ($lnc == 'W') { |
|
178 | + $longitude = '-'.$longitude; |
|
179 | + } |
|
155 | 180 | // Temp not always available |
156 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
157 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
158 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
181 | + if ($globalDebug) { |
|
182 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
183 | + } |
|
184 | + if ($temp == '') { |
|
185 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
186 | + } else { |
|
187 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
188 | + } |
|
159 | 189 | |
160 | 190 | //$icao = $Translation->checkTranslation($ident); |
161 | 191 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -169,25 +199,35 @@ discard block |
||
169 | 199 | $ahour = ''; |
170 | 200 | $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
171 | 201 | if ($n == 4 && strlen($darr) == 4) { |
172 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
173 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
174 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
202 | + if ($dhour != '') { |
|
203 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
204 | + } |
|
205 | + if ($ahour != '') { |
|
206 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
207 | + } |
|
208 | + if ($globalDebug) { |
|
209 | + echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
210 | + } |
|
175 | 211 | //$icao = ACARS->ident2icao($ident); |
176 | 212 | //$icao = $Translation->checkTranslation($ident); |
177 | 213 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
178 | 214 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
179 | 215 | $found = true; |
180 | - } |
|
181 | - elseif ($n == 2 || $n == 4) { |
|
182 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
183 | - if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
216 | + } elseif ($n == 2 || $n == 4) { |
|
217 | + if ($dhour != '') { |
|
218 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
219 | + } |
|
220 | + if ($globalDebug) { |
|
221 | + echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
222 | + } |
|
184 | 223 | //$icao = ACARS->ident2icao($ident); |
185 | 224 | //$icao = $Translation->checkTranslation($ident); |
186 | 225 | $decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour); |
187 | 226 | $found = true; |
188 | - } |
|
189 | - elseif ($n == 1) { |
|
190 | - if ($globalDebug) echo 'airport arrival : '.$darr."\n"; |
|
227 | + } elseif ($n == 1) { |
|
228 | + if ($globalDebug) { |
|
229 | + echo 'airport arrival : '.$darr."\n"; |
|
230 | + } |
|
191 | 231 | //$icao = ACARS->ident2icao($ident); |
192 | 232 | //$icao = $Translation->checkTranslation($ident); |
193 | 233 | $decode = array('Arrival airport' => $darr); |
@@ -205,7 +245,9 @@ discard block |
||
205 | 245 | $darr = ''; |
206 | 246 | $n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr); |
207 | 247 | if ($n == 4) { |
208 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
248 | + if ($globalDebug) { |
|
249 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
250 | + } |
|
209 | 251 | //$icao = ACARS->ident2icao($ident); |
210 | 252 | //$icao = $Translation->checkTranslation($ident); |
211 | 253 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -239,14 +281,23 @@ discard block |
||
239 | 281 | $apiste = ''; |
240 | 282 | $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); |
241 | 283 | if ($n > 8) { |
242 | - 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"; |
|
243 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
244 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
284 | + if ($globalDebug) { |
|
285 | + 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"; |
|
286 | + } |
|
287 | + if ($dhour != '') { |
|
288 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
289 | + } |
|
290 | + if ($ahour != '') { |
|
291 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
292 | + } |
|
245 | 293 | $icao = trim($aident); |
246 | 294 | |
247 | 295 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
248 | - if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
249 | - else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
296 | + if ($ahour == '') { |
|
297 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
298 | + } else { |
|
299 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
300 | + } |
|
250 | 301 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
251 | 302 | $decode['icao'] = $icao; |
252 | 303 | $found = true; |
@@ -268,9 +319,15 @@ discard block |
||
268 | 319 | $lns = $lns.'.'.$lns; |
269 | 320 | $latitude = $las / 1000.0; |
270 | 321 | $longitude = $lns / 1000.0; |
271 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
272 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
273 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
322 | + if ($lac == 'S') { |
|
323 | + $latitude = '-'.$latitude; |
|
324 | + } |
|
325 | + if ($lnc == 'W') { |
|
326 | + $longitude = '-'.$longitude; |
|
327 | + } |
|
328 | + if ($globalDebug) { |
|
329 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
330 | + } |
|
274 | 331 | $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
275 | 332 | $found = true; |
276 | 333 | } |
@@ -288,7 +345,9 @@ discard block |
||
288 | 345 | $darr = ''; |
289 | 346 | $n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr); |
290 | 347 | if ($n == 4) { |
291 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
348 | + if ($globalDebug) { |
|
349 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
350 | + } |
|
292 | 351 | //$icao = $Translation->checkTranslation($ident); |
293 | 352 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
294 | 353 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -301,7 +360,9 @@ discard block |
||
301 | 360 | $darr = ''; |
302 | 361 | $n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr); |
303 | 362 | if ($n == 4) { |
304 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
363 | + if ($globalDebug) { |
|
364 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
365 | + } |
|
305 | 366 | //$icao = $Translation->checkTranslation($ident); |
306 | 367 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
307 | 368 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -314,7 +375,9 @@ discard block |
||
314 | 375 | $darr = ''; |
315 | 376 | $n = sscanf($message, "002AF %4c %4c ", $dair, $darr); |
316 | 377 | if ($n == 2) { |
317 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
378 | + if ($globalDebug) { |
|
379 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
380 | + } |
|
318 | 381 | //$icao = $Translation->checkTranslation($ident); |
319 | 382 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
320 | 383 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -328,7 +391,9 @@ discard block |
||
328 | 391 | $darr = ''; |
329 | 392 | $n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
330 | 393 | if ($n == 6) { |
331 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
394 | + if ($globalDebug) { |
|
395 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
396 | + } |
|
332 | 397 | //$icao = $Translation->checkTranslation($ident); |
333 | 398 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
334 | 399 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -341,7 +406,9 @@ discard block |
||
341 | 406 | $darr = ''; |
342 | 407 | $n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
343 | 408 | if ($n == 7) { |
344 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
409 | + if ($globalDebug) { |
|
410 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
411 | + } |
|
345 | 412 | //$icao = $Translation->checkTranslation($ident); |
346 | 413 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
347 | 414 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -369,8 +436,12 @@ discard block |
||
369 | 436 | $decode['icao'] = $icao; |
370 | 437 | $latitude = $las / 100.0; |
371 | 438 | $longitude = $lns / 100.0; |
372 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
373 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
439 | + if ($lac == 'S') { |
|
440 | + $latitude = '-'.$latitude; |
|
441 | + } |
|
442 | + if ($lnc == 'W') { |
|
443 | + $longitude = '-'.$longitude; |
|
444 | + } |
|
374 | 445 | |
375 | 446 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
376 | 447 | $found = true; |
@@ -388,8 +459,12 @@ discard block |
||
388 | 459 | if ($n == 4) { |
389 | 460 | $latitude = $las; |
390 | 461 | $longitude = $lns; |
391 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
392 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
462 | + if ($lac == 'S') { |
|
463 | + $latitude = '-'.$latitude; |
|
464 | + } |
|
465 | + if ($lnc == 'W') { |
|
466 | + $longitude = '-'.$longitude; |
|
467 | + } |
|
393 | 468 | |
394 | 469 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
395 | 470 | $found = true; |
@@ -405,7 +480,9 @@ discard block |
||
405 | 480 | $darr = ''; |
406 | 481 | $n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr); |
407 | 482 | if ($n == 5) { |
408 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
483 | + if ($globalDebug) { |
|
484 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
485 | + } |
|
409 | 486 | //$icao = $Translation->checkTranslation($ident); |
410 | 487 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
411 | 488 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -426,7 +503,9 @@ discard block |
||
426 | 503 | $aident = ''; |
427 | 504 | $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); |
428 | 505 | if ($n == 8) { |
429 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
506 | + if ($globalDebug) { |
|
507 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
508 | + } |
|
430 | 509 | $icao = trim($aident); |
431 | 510 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
432 | 511 | $decode['icao'] = $icao; |
@@ -443,7 +522,9 @@ discard block |
||
443 | 522 | $darr = ''; |
444 | 523 | $n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr); |
445 | 524 | if ($n == 5) { |
446 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
525 | + if ($globalDebug) { |
|
526 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
527 | + } |
|
447 | 528 | //$icao = $Translation->checkTranslation($ident); |
448 | 529 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
449 | 530 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -458,7 +539,9 @@ discard block |
||
458 | 539 | $darr = ''; |
459 | 540 | $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
460 | 541 | if ($n == 3) { |
461 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
542 | + if ($globalDebug) { |
|
543 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
544 | + } |
|
462 | 545 | //$icao = $Translation->checkTranslation($ident); |
463 | 546 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
464 | 547 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -473,7 +556,9 @@ discard block |
||
473 | 556 | $darr = ''; |
474 | 557 | $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
475 | 558 | if ($n == 3) { |
476 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
559 | + if ($globalDebug) { |
|
560 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
561 | + } |
|
477 | 562 | //$icao = $Translation->checkTranslation($ident); |
478 | 563 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
479 | 564 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -483,7 +568,9 @@ discard block |
||
483 | 568 | if (!$found) { |
484 | 569 | $n = sscanf($message,'MET01%4c',$airport); |
485 | 570 | if ($n == 1) { |
486 | - if ($globalDebug) echo 'airport name : '.$airport; |
|
571 | + if ($globalDebug) { |
|
572 | + echo 'airport name : '.$airport; |
|
573 | + } |
|
487 | 574 | $decode = array('Airport/Waypoint name' => $airport); |
488 | 575 | $found = true; |
489 | 576 | } |
@@ -491,184 +578,126 @@ discard block |
||
491 | 578 | if ($label == 'H1') { |
492 | 579 | if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
493 | 580 | $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
494 | - } |
|
495 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
581 | + } elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
496 | 582 | $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
497 | - } |
|
498 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
583 | + } elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
499 | 584 | $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
500 | - } |
|
501 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
585 | + } elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
502 | 586 | $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
503 | - } |
|
504 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
587 | + } elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
505 | 588 | $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
506 | - } |
|
507 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
589 | + } elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
508 | 590 | $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
509 | - } |
|
510 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
591 | + } elseif (preg_match(':^#M1AAEP:',$message)) { |
|
511 | 592 | $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
512 | - } |
|
513 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
593 | + } elseif (preg_match(':^#M2APWD:',$message)) { |
|
514 | 594 | $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
515 | - } |
|
516 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
595 | + } elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
517 | 596 | $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
518 | - } |
|
519 | - elseif (preg_match(':^#CF:',$message)) { |
|
597 | + } elseif (preg_match(':^#CF:',$message)) { |
|
520 | 598 | $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
521 | - } |
|
522 | - elseif (preg_match(':^#DF:',$message)) { |
|
599 | + } elseif (preg_match(':^#DF:',$message)) { |
|
523 | 600 | $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
524 | - } |
|
525 | - elseif (preg_match(':^#EC:',$message)) { |
|
601 | + } elseif (preg_match(':^#EC:',$message)) { |
|
526 | 602 | $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
527 | - } |
|
528 | - elseif (preg_match(':^#EI:',$message)) { |
|
603 | + } elseif (preg_match(':^#EI:',$message)) { |
|
529 | 604 | $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
530 | - } |
|
531 | - elseif (preg_match(':^#H1:',$message)) { |
|
605 | + } elseif (preg_match(':^#H1:',$message)) { |
|
532 | 606 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
533 | - } |
|
534 | - elseif (preg_match(':^#H2:',$message)) { |
|
607 | + } elseif (preg_match(':^#H2:',$message)) { |
|
535 | 608 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
536 | - } |
|
537 | - elseif (preg_match(':^#HD:',$message)) { |
|
609 | + } elseif (preg_match(':^#HD:',$message)) { |
|
538 | 610 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
539 | - } |
|
540 | - elseif (preg_match(':^#M1:',$message)) { |
|
611 | + } elseif (preg_match(':^#M1:',$message)) { |
|
541 | 612 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
542 | - } |
|
543 | - elseif (preg_match(':^#M2:',$message)) { |
|
613 | + } elseif (preg_match(':^#M2:',$message)) { |
|
544 | 614 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
545 | - } |
|
546 | - elseif (preg_match(':^#M3:',$message)) { |
|
615 | + } elseif (preg_match(':^#M3:',$message)) { |
|
547 | 616 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
548 | - } |
|
549 | - elseif (preg_match(':^#MD:',$message)) { |
|
617 | + } elseif (preg_match(':^#MD:',$message)) { |
|
550 | 618 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
551 | - } |
|
552 | - elseif (preg_match(':^#PS:',$message)) { |
|
619 | + } elseif (preg_match(':^#PS:',$message)) { |
|
553 | 620 | $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
554 | - } |
|
555 | - elseif (preg_match(':^#S1:',$message)) { |
|
621 | + } elseif (preg_match(':^#S1:',$message)) { |
|
556 | 622 | $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
557 | - } |
|
558 | - elseif (preg_match(':^#S2:',$message)) { |
|
623 | + } elseif (preg_match(':^#S2:',$message)) { |
|
559 | 624 | $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
560 | - } |
|
561 | - elseif (preg_match(':^#SD:',$message)) { |
|
625 | + } elseif (preg_match(':^#SD:',$message)) { |
|
562 | 626 | $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
563 | - } |
|
564 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
627 | + } elseif (preg_match(':^#T[0-8]:',$message)) { |
|
565 | 628 | $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
566 | - } |
|
567 | - elseif (preg_match(':^#WO:',$message)) { |
|
629 | + } elseif (preg_match(':^#WO:',$message)) { |
|
568 | 630 | $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
569 | - } |
|
570 | - elseif (preg_match(':^#A1:',$message)) { |
|
631 | + } elseif (preg_match(':^#A1:',$message)) { |
|
571 | 632 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
572 | - } |
|
573 | - elseif (preg_match(':^#A3:',$message)) { |
|
633 | + } elseif (preg_match(':^#A3:',$message)) { |
|
574 | 634 | $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
575 | - } |
|
576 | - elseif (preg_match(':^#A4:',$message)) { |
|
635 | + } elseif (preg_match(':^#A4:',$message)) { |
|
577 | 636 | $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
578 | - } |
|
579 | - elseif (preg_match(':^#A6:',$message)) { |
|
637 | + } elseif (preg_match(':^#A6:',$message)) { |
|
580 | 638 | $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
581 | - } |
|
582 | - elseif (preg_match(':^#A8:',$message)) { |
|
639 | + } elseif (preg_match(':^#A8:',$message)) { |
|
583 | 640 | $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
584 | - } |
|
585 | - elseif (preg_match(':^#A9:',$message)) { |
|
641 | + } elseif (preg_match(':^#A9:',$message)) { |
|
586 | 642 | $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
587 | - } |
|
588 | - elseif (preg_match(':^#A0:',$message)) { |
|
643 | + } elseif (preg_match(':^#A0:',$message)) { |
|
589 | 644 | $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
590 | - } |
|
591 | - elseif (preg_match(':^#AA:',$message)) { |
|
645 | + } elseif (preg_match(':^#AA:',$message)) { |
|
592 | 646 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
593 | - } |
|
594 | - elseif (preg_match(':^#AB:',$message)) { |
|
647 | + } elseif (preg_match(':^#AB:',$message)) { |
|
595 | 648 | $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
596 | - } |
|
597 | - elseif (preg_match(':^#AC:',$message)) { |
|
649 | + } elseif (preg_match(':^#AC:',$message)) { |
|
598 | 650 | $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
599 | - } |
|
600 | - elseif (preg_match(':^#AD:',$message)) { |
|
651 | + } elseif (preg_match(':^#AD:',$message)) { |
|
601 | 652 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
602 | - } |
|
603 | - elseif (preg_match(':^#AF:',$message)) { |
|
653 | + } elseif (preg_match(':^#AF:',$message)) { |
|
604 | 654 | $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
605 | - } |
|
606 | - elseif (preg_match(':^#B1:',$message)) { |
|
655 | + } elseif (preg_match(':^#B1:',$message)) { |
|
607 | 656 | $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
608 | - } |
|
609 | - elseif (preg_match(':^#B2:',$message)) { |
|
657 | + } elseif (preg_match(':^#B2:',$message)) { |
|
610 | 658 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
611 | - } |
|
612 | - elseif (preg_match(':^#B3:',$message)) { |
|
659 | + } elseif (preg_match(':^#B3:',$message)) { |
|
613 | 660 | $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
614 | - } |
|
615 | - elseif (preg_match(':^#B4:',$message)) { |
|
661 | + } elseif (preg_match(':^#B4:',$message)) { |
|
616 | 662 | $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
617 | - } |
|
618 | - elseif (preg_match(':^#B6:',$message)) { |
|
663 | + } elseif (preg_match(':^#B6:',$message)) { |
|
619 | 664 | $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
620 | - } |
|
621 | - elseif (preg_match(':^#B8:',$message)) { |
|
665 | + } elseif (preg_match(':^#B8:',$message)) { |
|
622 | 666 | $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
623 | - } |
|
624 | - elseif (preg_match(':^#B9:',$message)) { |
|
667 | + } elseif (preg_match(':^#B9:',$message)) { |
|
625 | 668 | $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
626 | - } |
|
627 | - elseif (preg_match(':^#B0:',$message)) { |
|
669 | + } elseif (preg_match(':^#B0:',$message)) { |
|
628 | 670 | $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
629 | - } |
|
630 | - elseif (preg_match(':^#BA:',$message)) { |
|
671 | + } elseif (preg_match(':^#BA:',$message)) { |
|
631 | 672 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
632 | - } |
|
633 | - elseif (preg_match(':^#BB:',$message)) { |
|
673 | + } elseif (preg_match(':^#BB:',$message)) { |
|
634 | 674 | $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
635 | - } |
|
636 | - elseif (preg_match(':^#BC:',$message)) { |
|
675 | + } elseif (preg_match(':^#BC:',$message)) { |
|
637 | 676 | $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
638 | - } |
|
639 | - elseif (preg_match(':^#BD:',$message)) { |
|
677 | + } elseif (preg_match(':^#BD:',$message)) { |
|
640 | 678 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
641 | - } |
|
642 | - elseif (preg_match(':^#BE:',$message)) { |
|
679 | + } elseif (preg_match(':^#BE:',$message)) { |
|
643 | 680 | $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
644 | - } |
|
645 | - elseif (preg_match(':^#BF:',$message)) { |
|
681 | + } elseif (preg_match(':^#BF:',$message)) { |
|
646 | 682 | $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
647 | - } |
|
648 | - elseif (preg_match(':^#H3:',$message)) { |
|
683 | + } elseif (preg_match(':^#H3:',$message)) { |
|
649 | 684 | $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
650 | 685 | } |
651 | 686 | } |
652 | 687 | if ($label == '10') { |
653 | 688 | if (preg_match(':^DTO01:',$message)) { |
654 | 689 | $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
655 | - } |
|
656 | - elseif (preg_match(':^AIS01:',$message)) { |
|
690 | + } elseif (preg_match(':^AIS01:',$message)) { |
|
657 | 691 | $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
658 | - } |
|
659 | - elseif (preg_match(':^FTX01:',$message)) { |
|
692 | + } elseif (preg_match(':^FTX01:',$message)) { |
|
660 | 693 | $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
661 | - } |
|
662 | - elseif (preg_match(':^FPL01:',$message)) { |
|
694 | + } elseif (preg_match(':^FPL01:',$message)) { |
|
663 | 695 | $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
664 | - } |
|
665 | - elseif (preg_match(':^WAB01:',$message)) { |
|
696 | + } elseif (preg_match(':^WAB01:',$message)) { |
|
666 | 697 | $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
667 | - } |
|
668 | - elseif (preg_match(':^MET01:',$message)) { |
|
698 | + } elseif (preg_match(':^MET01:',$message)) { |
|
669 | 699 | $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
670 | - } |
|
671 | - elseif (preg_match(':^WAB02:',$message)) { |
|
700 | + } elseif (preg_match(':^WAB02:',$message)) { |
|
672 | 701 | $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
673 | 702 | } |
674 | 703 | } |
@@ -683,38 +712,28 @@ discard block |
||
683 | 712 | $vsta = array('Version' => $version); |
684 | 713 | if ($state == 'E') { |
685 | 714 | $vsta = array_merge($vsta,array('Link state' => 'Established')); |
686 | - } |
|
687 | - elseif ($state == 'L') { |
|
715 | + } elseif ($state == 'L') { |
|
688 | 716 | $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
689 | - } |
|
690 | - else { |
|
717 | + } else { |
|
691 | 718 | $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
692 | 719 | } |
693 | 720 | if ($type == 'V') { |
694 | 721 | $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
695 | - } |
|
696 | - elseif ($type == 'S') { |
|
722 | + } elseif ($type == 'S') { |
|
697 | 723 | $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
698 | - } |
|
699 | - elseif ($type == 'H') { |
|
724 | + } elseif ($type == 'H') { |
|
700 | 725 | $vsta = array_merge($vsta,array('Link type' => 'HF')); |
701 | - } |
|
702 | - elseif ($type == 'G') { |
|
726 | + } elseif ($type == 'G') { |
|
703 | 727 | $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
704 | - } |
|
705 | - elseif ($type == 'C') { |
|
728 | + } elseif ($type == 'C') { |
|
706 | 729 | $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
707 | - } |
|
708 | - elseif ($type == '2') { |
|
730 | + } elseif ($type == '2') { |
|
709 | 731 | $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
710 | - } |
|
711 | - elseif ($type == 'X') { |
|
732 | + } elseif ($type == 'X') { |
|
712 | 733 | $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
713 | - } |
|
714 | - elseif ($type == 'I') { |
|
734 | + } elseif ($type == 'I') { |
|
715 | 735 | $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
716 | - } |
|
717 | - else { |
|
736 | + } else { |
|
718 | 737 | $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
719 | 738 | } |
720 | 739 | $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
@@ -723,7 +742,9 @@ discard block |
||
723 | 742 | } |
724 | 743 | |
725 | 744 | $title = $this->getTitlefromLabel($label); |
726 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
745 | + if ($title != '') { |
|
746 | + $decode = array_merge(array('Message title' => $title),$decode); |
|
747 | + } |
|
727 | 748 | /* |
728 | 749 | // Business jets always use GS0001 |
729 | 750 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -759,31 +780,54 @@ discard block |
||
759 | 780 | $msg = $message['message']; |
760 | 781 | $decode = $message['decode']; |
761 | 782 | $registration = (string)$message['registration']; |
762 | - if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
|
763 | - else $latitude = ''; |
|
764 | - if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
|
765 | - else $longitude = ''; |
|
766 | - if (isset($decode['airicao'])) $airicao = $decode['airicao']; |
|
767 | - else $airicao = ''; |
|
768 | - if (isset($decode['icao'])) $icao = $decode['icao']; |
|
769 | - else $icao = $Translation->checkTranslation($ident); |
|
783 | + if (isset($decode['latitude'])) { |
|
784 | + $latitude = $decode['latitude']; |
|
785 | + } else { |
|
786 | + $latitude = ''; |
|
787 | + } |
|
788 | + if (isset($decode['longitude'])) { |
|
789 | + $longitude = $decode['longitude']; |
|
790 | + } else { |
|
791 | + $longitude = ''; |
|
792 | + } |
|
793 | + if (isset($decode['airicao'])) { |
|
794 | + $airicao = $decode['airicao']; |
|
795 | + } else { |
|
796 | + $airicao = ''; |
|
797 | + } |
|
798 | + if (isset($decode['icao'])) { |
|
799 | + $icao = $decode['icao']; |
|
800 | + } else { |
|
801 | + $icao = $Translation->checkTranslation($ident); |
|
802 | + } |
|
770 | 803 | $image_array = $Image->getSpotterImage($registration); |
771 | 804 | if (!isset($image_array[0]['registration'])) { |
772 | 805 | $Image->addSpotterImage($registration); |
773 | 806 | } |
774 | 807 | // Business jets always use GS0001 |
775 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
776 | - if ($globalDebug && isset($info) && $info != '') echo $info; |
|
777 | - if (count($decode) > 0) $decode_json = json_encode($decode); |
|
778 | - else $decode_json = ''; |
|
808 | + if ($ident != 'GS0001') { |
|
809 | + $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
810 | + } |
|
811 | + if ($globalDebug && isset($info) && $info != '') { |
|
812 | + echo $info; |
|
813 | + } |
|
814 | + if (count($decode) > 0) { |
|
815 | + $decode_json = json_encode($decode); |
|
816 | + } else { |
|
817 | + $decode_json = ''; |
|
818 | + } |
|
779 | 819 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
780 | 820 | $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
781 | 821 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
782 | 822 | $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
783 | 823 | } |
784 | 824 | $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
785 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
786 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
825 | + if (!isset($globalACARSArchive)) { |
|
826 | + $globalACARSArchive = array('10','80','81','82','3F'); |
|
827 | + } |
|
828 | + if ($result && in_array($label,$globalACARSArchive)) { |
|
829 | + $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
830 | + } |
|
787 | 831 | if ($globalDebug && count($decode) > 0) { |
788 | 832 | echo "Human readable data : ".implode(' - ',$decode)."\n"; |
789 | 833 | } |
@@ -808,7 +852,9 @@ discard block |
||
808 | 852 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
809 | 853 | $Connection = new Connection($this->db); |
810 | 854 | $this->db = $Connection->db; |
811 | - if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
|
855 | + if ($globalDebug) { |
|
856 | + echo "Test if not already in Live ACARS table..."; |
|
857 | + } |
|
812 | 858 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
813 | 859 | $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
814 | 860 | try { |
@@ -819,7 +865,9 @@ discard block |
||
819 | 865 | return false; |
820 | 866 | } |
821 | 867 | if ($stht->fetchColumn() == 0) { |
822 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
868 | + if ($globalDebug) { |
|
869 | + echo "Add Live ACARS data..."; |
|
870 | + } |
|
823 | 871 | $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)"; |
824 | 872 | $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")); |
825 | 873 | try { |
@@ -830,10 +878,14 @@ discard block |
||
830 | 878 | return false; |
831 | 879 | } |
832 | 880 | } else { |
833 | - if ($globalDebug) echo "Data already in DB...\n"; |
|
881 | + if ($globalDebug) { |
|
882 | + echo "Data already in DB...\n"; |
|
883 | + } |
|
834 | 884 | return false; |
835 | 885 | } |
836 | - if ($globalDebug) echo "Done\n"; |
|
886 | + if ($globalDebug) { |
|
887 | + echo "Done\n"; |
|
888 | + } |
|
837 | 889 | return true; |
838 | 890 | } |
839 | 891 | return false; |
@@ -867,7 +919,9 @@ discard block |
||
867 | 919 | } |
868 | 920 | if ($stht->fetchColumn() == 0) { |
869 | 921 | */ |
870 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
922 | + if ($globalDebug) { |
|
923 | + echo "Add Live ACARS data..."; |
|
924 | + } |
|
871 | 925 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
872 | 926 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
873 | 927 | try { |
@@ -876,7 +930,9 @@ discard block |
||
876 | 930 | } catch(PDOException $e) { |
877 | 931 | return "error : ".$e->getMessage(); |
878 | 932 | } |
879 | - if ($globalDebug) echo "Done\n"; |
|
933 | + if ($globalDebug) { |
|
934 | + echo "Done\n"; |
|
935 | + } |
|
880 | 936 | } |
881 | 937 | return ''; |
882 | 938 | } |
@@ -900,8 +956,11 @@ discard block |
||
900 | 956 | return ''; |
901 | 957 | } |
902 | 958 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
903 | - if (count($row) > 0) return $row[0]['title']; |
|
904 | - else return ''; |
|
959 | + if (count($row) > 0) { |
|
960 | + return $row[0]['title']; |
|
961 | + } else { |
|
962 | + return ''; |
|
963 | + } |
|
905 | 964 | } |
906 | 965 | |
907 | 966 | /** |
@@ -920,8 +979,11 @@ discard block |
||
920 | 979 | return array(); |
921 | 980 | } |
922 | 981 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
923 | - if (count($row) > 0) return $row; |
|
924 | - else return array(); |
|
982 | + if (count($row) > 0) { |
|
983 | + return $row; |
|
984 | + } else { |
|
985 | + return array(); |
|
986 | + } |
|
925 | 987 | } |
926 | 988 | |
927 | 989 | /** |
@@ -941,8 +1003,11 @@ discard block |
||
941 | 1003 | return array(); |
942 | 1004 | } |
943 | 1005 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
944 | - if (count($row) > 0) return $row[0]; |
|
945 | - else return array(); |
|
1006 | + if (count($row) > 0) { |
|
1007 | + return $row[0]; |
|
1008 | + } else { |
|
1009 | + return array(); |
|
1010 | + } |
|
946 | 1011 | } |
947 | 1012 | |
948 | 1013 | /** |
@@ -990,19 +1055,35 @@ discard block |
||
990 | 1055 | if ($row['registration'] != '') { |
991 | 1056 | $row['registration'] = str_replace('.','',$row['registration']); |
992 | 1057 | $image_array = $Image->getSpotterImage($row['registration']); |
993 | - 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'])); |
|
994 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
995 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
996 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
997 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
1058 | + if (count($image_array) > 0) { |
|
1059 | + $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'])); |
|
1060 | + } else { |
|
1061 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1062 | + } |
|
1063 | + } else { |
|
1064 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1065 | + } |
|
1066 | + if ($row['registration'] == '') { |
|
1067 | + $row['registration'] = 'NA'; |
|
1068 | + } |
|
1069 | + if ($row['ident'] == '') { |
|
1070 | + $row['ident'] = 'NA'; |
|
1071 | + } |
|
998 | 1072 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
999 | 1073 | if (isset($identicao[0])) { |
1000 | 1074 | if (substr($row['ident'],0,2) == 'AF') { |
1001 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1002 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1003 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1075 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
1076 | + $icao = $row['ident']; |
|
1077 | + } else { |
|
1078 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1079 | + } |
|
1080 | + } else { |
|
1081 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1082 | + } |
|
1004 | 1083 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
1005 | - } else $icao = $row['ident']; |
|
1084 | + } else { |
|
1085 | + $icao = $row['ident']; |
|
1086 | + } |
|
1006 | 1087 | $icao = $Translation->checkTranslation($icao,false); |
1007 | 1088 | $decode = json_decode($row['decode'],true); |
1008 | 1089 | $found = false; |
@@ -1027,7 +1108,9 @@ discard block |
||
1027 | 1108 | $found = true; |
1028 | 1109 | } |
1029 | 1110 | } |
1030 | - if ($found) $row['decode'] = json_encode($decode); |
|
1111 | + if ($found) { |
|
1112 | + $row['decode'] = json_encode($decode); |
|
1113 | + } |
|
1031 | 1114 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
1032 | 1115 | $result[] = $data; |
1033 | 1116 | $i++; |
@@ -1035,8 +1118,9 @@ discard block |
||
1035 | 1118 | if (isset($result)) { |
1036 | 1119 | $result[0]['query_number_rows'] = $i; |
1037 | 1120 | return $result; |
1121 | + } else { |
|
1122 | + return array(); |
|
1038 | 1123 | } |
1039 | - else return array(); |
|
1040 | 1124 | } |
1041 | 1125 | |
1042 | 1126 | /** |
@@ -1089,31 +1173,51 @@ discard block |
||
1089 | 1173 | if ($row['registration'] != '') { |
1090 | 1174 | $row['registration'] = str_replace('.','',$row['registration']); |
1091 | 1175 | $image_array = $Image->getSpotterImage($row['registration']); |
1092 | - 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'])); |
|
1093 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1094 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1176 | + if (count($image_array) > 0) { |
|
1177 | + $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'])); |
|
1178 | + } else { |
|
1179 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1180 | + } |
|
1181 | + } else { |
|
1182 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1183 | + } |
|
1095 | 1184 | $icao = ''; |
1096 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
1097 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
1185 | + if ($row['registration'] == '') { |
|
1186 | + $row['registration'] = 'NA'; |
|
1187 | + } |
|
1188 | + if ($row['ident'] == '') { |
|
1189 | + $row['ident'] = 'NA'; |
|
1190 | + } |
|
1098 | 1191 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
1099 | 1192 | if (isset($identicao[0])) { |
1100 | 1193 | if (substr($row['ident'],0,2) == 'AF') { |
1101 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1102 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1103 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1194 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
1195 | + $icao = $row['ident']; |
|
1196 | + } else { |
|
1197 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1198 | + } |
|
1199 | + } else { |
|
1200 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1201 | + } |
|
1104 | 1202 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
1105 | - } else $icao = $row['ident']; |
|
1203 | + } else { |
|
1204 | + $icao = $row['ident']; |
|
1205 | + } |
|
1106 | 1206 | $icao = $Translation->checkTranslation($icao); |
1107 | 1207 | $decode = json_decode($row['decode'],true); |
1108 | 1208 | $found = false; |
1109 | 1209 | if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
1110 | 1210 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1111 | - 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>'; |
|
1211 | + if (isset($airport_info[0]['icao'])) { |
|
1212 | + $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1213 | + } |
|
1112 | 1214 | $found = true; |
1113 | 1215 | } |
1114 | 1216 | if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
1115 | 1217 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1116 | - 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>'; |
|
1218 | + if (isset($airport_info[0]['icao'])) { |
|
1219 | + $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1220 | + } |
|
1117 | 1221 | $found = true; |
1118 | 1222 | } |
1119 | 1223 | if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
@@ -1123,7 +1227,9 @@ discard block |
||
1123 | 1227 | $found = true; |
1124 | 1228 | } |
1125 | 1229 | } |
1126 | - if ($found) $row['decode'] = json_encode($decode); |
|
1230 | + if ($found) { |
|
1231 | + $row['decode'] = json_encode($decode); |
|
1232 | + } |
|
1127 | 1233 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
1128 | 1234 | $result[] = $data; |
1129 | 1235 | $i++; |
@@ -1131,7 +1237,9 @@ discard block |
||
1131 | 1237 | if (!empty($result)) { |
1132 | 1238 | $result[0]['query_number_rows'] = $i; |
1133 | 1239 | return $result; |
1134 | - } else return array(); |
|
1240 | + } else { |
|
1241 | + return array(); |
|
1242 | + } |
|
1135 | 1243 | } |
1136 | 1244 | |
1137 | 1245 | /** |
@@ -1150,25 +1258,37 @@ discard block |
||
1150 | 1258 | $ident = trim($ident); |
1151 | 1259 | $Translation = new Translation($this->db); |
1152 | 1260 | $Spotter = new Spotter($this->db); |
1153 | - if ($globalDebug) echo "Test if we add ModeS data..."; |
|
1261 | + if ($globalDebug) { |
|
1262 | + echo "Test if we add ModeS data..."; |
|
1263 | + } |
|
1154 | 1264 | //if ($icao == '') $icao = ACARS->ident2icao($ident); |
1155 | - if ($icao == '') $icao = $Translation->checkTranslation($ident); |
|
1156 | - if ($globalDebug) echo '- Ident : '.$icao.' - '; |
|
1265 | + if ($icao == '') { |
|
1266 | + $icao = $Translation->checkTranslation($ident); |
|
1267 | + } |
|
1268 | + if ($globalDebug) { |
|
1269 | + echo '- Ident : '.$icao.' - '; |
|
1270 | + } |
|
1157 | 1271 | if ($ident == '' || $registration == '') { |
1158 | - if ($globalDebug) echo "Ident or registration null, exit\n"; |
|
1272 | + if ($globalDebug) { |
|
1273 | + echo "Ident or registration null, exit\n"; |
|
1274 | + } |
|
1159 | 1275 | return ''; |
1160 | 1276 | } |
1161 | 1277 | $registration = str_replace('.','',$registration); |
1162 | 1278 | $ident = $Translation->ident2icao($ident); |
1163 | 1279 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1164 | - if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
|
1280 | + if ($globalDebug) { |
|
1281 | + echo "Check if needed to add translation ".$ident.'... '; |
|
1282 | + } |
|
1165 | 1283 | $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"; |
1166 | 1284 | $querysi_values = array(':registration' => $registration); |
1167 | 1285 | try { |
1168 | 1286 | $sthsi = $this->db->prepare($querysi); |
1169 | 1287 | $sthsi->execute($querysi_values); |
1170 | 1288 | } catch(PDOException $e) { |
1171 | - if ($globalDebug) echo $e->getMessage(); |
|
1289 | + if ($globalDebug) { |
|
1290 | + echo $e->getMessage(); |
|
1291 | + } |
|
1172 | 1292 | return "error : ".$e->getMessage(); |
1173 | 1293 | } |
1174 | 1294 | $resultsi = $sthsi->fetch(PDO::FETCH_ASSOC); |
@@ -1176,9 +1296,14 @@ discard block |
||
1176 | 1296 | if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') { |
1177 | 1297 | $Translation = new Translation($this->db); |
1178 | 1298 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1179 | - if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
1180 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1181 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1299 | + if ($globalDebug) { |
|
1300 | + echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
1301 | + } |
|
1302 | + if ($ident != $trans_ident) { |
|
1303 | + $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1304 | + } elseif ($trans_ident == $ident) { |
|
1305 | + $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1306 | + } |
|
1182 | 1307 | } else { |
1183 | 1308 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1184 | 1309 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1187,32 +1312,46 @@ discard block |
||
1187 | 1312 | $sth = $this->db->prepare($query); |
1188 | 1313 | $sth->execute($query_values); |
1189 | 1314 | } catch(PDOException $e) { |
1190 | - if ($globalDebug) echo $e->getMessage(); |
|
1315 | + if ($globalDebug) { |
|
1316 | + echo $e->getMessage(); |
|
1317 | + } |
|
1191 | 1318 | return "error : ".$e->getMessage(); |
1192 | 1319 | } |
1193 | 1320 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
1194 | 1321 | $sth->closeCursor(); |
1195 | - if (isset($result['modes'])) $hex = $result['modes']; |
|
1196 | - else $hex = ''; |
|
1322 | + if (isset($result['modes'])) { |
|
1323 | + $hex = $result['modes']; |
|
1324 | + } else { |
|
1325 | + $hex = ''; |
|
1326 | + } |
|
1197 | 1327 | $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
1198 | - if ($this->fromACARSscript) $this->SI->add($SI_data); |
|
1328 | + if ($this->fromACARSscript) { |
|
1329 | + $this->SI->add($SI_data); |
|
1330 | + } |
|
1199 | 1331 | } |
1200 | 1332 | } |
1201 | - if ($globalDebug) echo 'Done'."\n"; |
|
1333 | + if ($globalDebug) { |
|
1334 | + echo 'Done'."\n"; |
|
1335 | + } |
|
1202 | 1336 | $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1"; |
1203 | 1337 | $query_values = array(':ident' => $icao); |
1204 | 1338 | try { |
1205 | 1339 | $sth = $this->db->prepare($query); |
1206 | 1340 | $sth->execute($query_values); |
1207 | 1341 | } catch(PDOException $e) { |
1208 | - if ($globalDebug) echo $e->getMessage(); |
|
1342 | + if ($globalDebug) { |
|
1343 | + echo $e->getMessage(); |
|
1344 | + } |
|
1209 | 1345 | return "error : ".$e->getMessage(); |
1210 | 1346 | } |
1211 | 1347 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
1212 | 1348 | $sth->closeCursor(); |
1213 | 1349 | if (isset($result['flightaware_id'])) { |
1214 | - if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
|
1215 | - else $ModeS = ''; |
|
1350 | + if (isset($result['ModeS'])) { |
|
1351 | + $ModeS = $result['ModeS']; |
|
1352 | + } else { |
|
1353 | + $ModeS = ''; |
|
1354 | + } |
|
1216 | 1355 | if ($ModeS == '') { |
1217 | 1356 | $id = explode('-',$result['flightaware_id']); |
1218 | 1357 | $ModeS = $id[0]; |
@@ -1225,24 +1364,32 @@ discard block |
||
1225 | 1364 | $sthc = $this->db->prepare($queryc); |
1226 | 1365 | $sthc->execute($queryc_values); |
1227 | 1366 | } catch(PDOException $e) { |
1228 | - if ($globalDebug) echo $e->getMessage(); |
|
1367 | + if ($globalDebug) { |
|
1368 | + echo $e->getMessage(); |
|
1369 | + } |
|
1229 | 1370 | return "error : ".$e->getMessage(); |
1230 | 1371 | } |
1231 | 1372 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1232 | 1373 | $sthc->closeCursor(); |
1233 | 1374 | if (count($row) == 0) { |
1234 | - if ($globalDebug) echo " Add to ModeS table - "; |
|
1375 | + if ($globalDebug) { |
|
1376 | + echo " Add to ModeS table - "; |
|
1377 | + } |
|
1235 | 1378 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1236 | 1379 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
1237 | 1380 | try { |
1238 | 1381 | $sthi = $this->db->prepare($queryi); |
1239 | 1382 | $sthi->execute($queryi_values); |
1240 | 1383 | } catch(PDOException $e) { |
1241 | - if ($globalDebug) echo $e->getMessage(); |
|
1384 | + if ($globalDebug) { |
|
1385 | + echo $e->getMessage(); |
|
1386 | + } |
|
1242 | 1387 | return "error : ".$e->getMessage(); |
1243 | 1388 | } |
1244 | 1389 | } else { |
1245 | - if ($globalDebug) echo " Update ModeS table - "; |
|
1390 | + if ($globalDebug) { |
|
1391 | + echo " Update ModeS table - "; |
|
1392 | + } |
|
1246 | 1393 | if ($ICAOTypeCode != '') { |
1247 | 1394 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1248 | 1395 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
@@ -1254,7 +1401,9 @@ discard block |
||
1254 | 1401 | $sthi = $this->db->prepare($queryi); |
1255 | 1402 | $sthi->execute($queryi_values); |
1256 | 1403 | } catch(PDOException $e) { |
1257 | - if ($globalDebug) echo $e->getMessage(); |
|
1404 | + if ($globalDebug) { |
|
1405 | + echo $e->getMessage(); |
|
1406 | + } |
|
1258 | 1407 | return "error : ".$e->getMessage(); |
1259 | 1408 | } |
1260 | 1409 | } |
@@ -1275,7 +1424,9 @@ discard block |
||
1275 | 1424 | return "error : ".$e->getMessage(); |
1276 | 1425 | } |
1277 | 1426 | */ |
1278 | - if ($globalDebug) echo " Update Spotter_output table - "; |
|
1427 | + if ($globalDebug) { |
|
1428 | + echo " Update Spotter_output table - "; |
|
1429 | + } |
|
1279 | 1430 | if ($ICAOTypeCode != '') { |
1280 | 1431 | if ($globalDBdriver == 'mysql') { |
1281 | 1432 | $queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
@@ -1286,8 +1437,7 @@ discard block |
||
1286 | 1437 | } else { |
1287 | 1438 | if ($globalDBdriver == 'mysql') { |
1288 | 1439 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
1289 | - } |
|
1290 | - elseif ($globalDBdriver == 'pgsql') { |
|
1440 | + } elseif ($globalDBdriver == 'pgsql') { |
|
1291 | 1441 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1292 | 1442 | } |
1293 | 1443 | $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
@@ -1296,14 +1446,20 @@ discard block |
||
1296 | 1446 | $sthi = $this->db->prepare($queryi); |
1297 | 1447 | $sthi->execute($queryi_values); |
1298 | 1448 | } catch(PDOException $e) { |
1299 | - if ($globalDebug) echo $e->getMessage(); |
|
1449 | + if ($globalDebug) { |
|
1450 | + echo $e->getMessage(); |
|
1451 | + } |
|
1300 | 1452 | return "error : ".$e->getMessage(); |
1301 | 1453 | } |
1302 | 1454 | } |
1303 | 1455 | } else { |
1304 | - if ($globalDebug) echo " Can't find ModeS in spotter_output - "; |
|
1456 | + if ($globalDebug) { |
|
1457 | + echo " Can't find ModeS in spotter_output - "; |
|
1458 | + } |
|
1459 | + } |
|
1460 | + if ($globalDebug) { |
|
1461 | + echo "Done\n"; |
|
1305 | 1462 | } |
1306 | - if ($globalDebug) echo "Done\n"; |
|
1307 | 1463 | return ''; |
1308 | 1464 | } |
1309 | 1465 | } |
@@ -16,20 +16,20 @@ discard block |
||
16 | 16 | require_once(dirname(__FILE__).'/class.Source.php'); |
17 | 17 | require_once(dirname(__FILE__).'/class.GeoidHeight.php'); |
18 | 18 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
19 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
19 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | class SpotterImport { |
23 | - private $all_flights = array(); |
|
24 | - private $last_delete_hourly = 0; |
|
25 | - private $last_delete = 0; |
|
26 | - private $stats = array(); |
|
27 | - private $tmd = 0; |
|
28 | - private $source_location = array(); |
|
29 | - public $db = null; |
|
30 | - public $nb = 0; |
|
23 | + private $all_flights = array(); |
|
24 | + private $last_delete_hourly = 0; |
|
25 | + private $last_delete = 0; |
|
26 | + private $stats = array(); |
|
27 | + private $tmd = 0; |
|
28 | + private $source_location = array(); |
|
29 | + public $db = null; |
|
30 | + public $nb = 0; |
|
31 | 31 | |
32 | - public function __construct($dbc = null) { |
|
32 | + public function __construct($dbc = null) { |
|
33 | 33 | global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid; |
34 | 34 | if (!(isset($globalNoDB) && $globalNoDB)) { |
35 | 35 | $Connection = new Connection($dbc); |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | $currentdate = date('Y-m-d'); |
42 | 42 | $sourcestat = $Stats->getStatsSource($currentdate); |
43 | 43 | if (!empty($sourcestat)) { |
44 | - foreach($sourcestat as $srcst) { |
|
45 | - $type = $srcst['stats_type']; |
|
44 | + foreach($sourcestat as $srcst) { |
|
45 | + $type = $srcst['stats_type']; |
|
46 | 46 | if ($type == 'polar' || $type == 'hist') { |
47 | - $source = $srcst['source_name']; |
|
48 | - $data = $srcst['source_data']; |
|
49 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
50 | - } |
|
51 | - } |
|
47 | + $source = $srcst['source_name']; |
|
48 | + $data = $srcst['source_data']; |
|
49 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
50 | + } |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | $GeoidClass = FALSE; |
64 | 64 | } |
65 | 65 | } |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | - public function get_Schedule($id,$ident) { |
|
68 | + public function get_Schedule($id,$ident) { |
|
69 | 69 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
70 | 70 | // Get schedule here, so it's done only one time |
71 | 71 | |
@@ -85,43 +85,43 @@ discard block |
||
85 | 85 | $operator = $Spotter->getOperator($ident); |
86 | 86 | $scheduleexist = false; |
87 | 87 | if ($Schedule->checkSchedule($operator) == 0) { |
88 | - $operator = $Translation->checkTranslation($ident); |
|
89 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
88 | + $operator = $Translation->checkTranslation($ident); |
|
89 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
90 | 90 | $schedule = $Schedule->fetchSchedule($operator); |
91 | 91 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
92 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
93 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
94 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
95 | - // Should also check if route schedule = route from DB |
|
96 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
92 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
93 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
94 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
95 | + // Should also check if route schedule = route from DB |
|
96 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
97 | 97 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
98 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
99 | - if (trim($airport_icao) != '') { |
|
98 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
99 | + if (trim($airport_icao) != '') { |
|
100 | 100 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
101 | 101 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
102 | - } |
|
102 | + } |
|
103 | + } |
|
103 | 104 | } |
104 | - } |
|
105 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
105 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
106 | 106 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
107 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
108 | - if (trim($airport_icao) != '') { |
|
107 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
108 | + if (trim($airport_icao) != '') { |
|
109 | 109 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
110 | 110 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
111 | - } |
|
111 | + } |
|
112 | 112 | } |
113 | - } |
|
114 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
113 | + } |
|
114 | + $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
115 | 115 | } |
116 | - } else $scheduleexist = true; |
|
116 | + } else $scheduleexist = true; |
|
117 | 117 | } else $scheduleexist = true; |
118 | 118 | // close connection, at least one way will work ? |
119 | - if ($scheduleexist) { |
|
119 | + if ($scheduleexist) { |
|
120 | 120 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
121 | - $sch = $Schedule->getSchedule($operator); |
|
121 | + $sch = $Schedule->getSchedule($operator); |
|
122 | 122 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
123 | 123 | if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
124 | - } |
|
124 | + } |
|
125 | 125 | $Spotter->db = null; |
126 | 126 | $Schedule->db = null; |
127 | 127 | $Translation->db = null; |
@@ -136,65 +136,65 @@ discard block |
||
136 | 136 | } |
137 | 137 | */ |
138 | 138 | } |
139 | - } |
|
139 | + } |
|
140 | 140 | |
141 | - public function checkAll() { |
|
141 | + public function checkAll() { |
|
142 | 142 | global $globalDebug, $globalNoImport; |
143 | 143 | if ($globalDebug) echo "Update last seen flights data...\n"; |
144 | 144 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
145 | - foreach ($this->all_flights as $key => $flight) { |
|
145 | + foreach ($this->all_flights as $key => $flight) { |
|
146 | 146 | if (isset($this->all_flights[$key]['id'])) { |
147 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
148 | - $Spotter = new Spotter($this->db); |
|
149 | - $real_arrival = $this->arrival($key); |
|
150 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],'',$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
151 | - } |
|
152 | - } |
|
147 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
148 | + $Spotter = new Spotter($this->db); |
|
149 | + $real_arrival = $this->arrival($key); |
|
150 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],'',$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
151 | + } |
|
152 | + } |
|
153 | + } |
|
153 | 154 | } |
154 | - } |
|
155 | 155 | |
156 | - public function arrival($key) { |
|
156 | + public function arrival($key) { |
|
157 | 157 | global $globalClosestMinDist, $globalDebug; |
158 | 158 | if ($globalDebug) echo 'Update arrival...'."\n"; |
159 | 159 | $Spotter = new Spotter($this->db); |
160 | - $airport_icao = ''; |
|
161 | - $airport_time = ''; |
|
162 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
160 | + $airport_icao = ''; |
|
161 | + $airport_time = ''; |
|
162 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
163 | 163 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
164 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
165 | - if (isset($closestAirports[0])) { |
|
166 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
167 | - $airport_icao = $closestAirports[0]['icao']; |
|
168 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
169 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
170 | - } elseif (count($closestAirports) > 1 && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
171 | - foreach ($closestAirports as $airport) { |
|
172 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
173 | - $airport_icao = $airport['icao']; |
|
174 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
175 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
176 | - break; |
|
177 | - } |
|
178 | - } |
|
179 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
180 | - $airport_icao = $closestAirports[0]['icao']; |
|
181 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
182 | - } else { |
|
183 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
184 | - } |
|
185 | - } else { |
|
186 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
187 | - } |
|
164 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
165 | + if (isset($closestAirports[0])) { |
|
166 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
167 | + $airport_icao = $closestAirports[0]['icao']; |
|
168 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
169 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
170 | + } elseif (count($closestAirports) > 1 && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
171 | + foreach ($closestAirports as $airport) { |
|
172 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
173 | + $airport_icao = $airport['icao']; |
|
174 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
175 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
176 | + break; |
|
177 | + } |
|
178 | + } |
|
179 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
180 | + $airport_icao = $closestAirports[0]['icao']; |
|
181 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
182 | + } else { |
|
183 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
184 | + } |
|
185 | + } else { |
|
186 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
187 | + } |
|
188 | 188 | |
189 | - } else { |
|
190 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
191 | - } |
|
192 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
193 | - } |
|
189 | + } else { |
|
190 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
191 | + } |
|
192 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
193 | + } |
|
194 | 194 | |
195 | 195 | |
196 | 196 | |
197 | - public function del() { |
|
197 | + public function del() { |
|
198 | 198 | global $globalDebug, $globalNoImport, $globalNoDB; |
199 | 199 | // Delete old infos |
200 | 200 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | } |
207 | 207 | } |
208 | 208 | } |
209 | - } |
|
209 | + } |
|
210 | 210 | |
211 | - public function delKey($key) { |
|
211 | + public function delKey($key) { |
|
212 | 212 | global $globalDebug, $globalNoImport, $globalNoDB; |
213 | 213 | // Delete old infos |
214 | 214 | if (isset($this->all_flights[$key]['id'])) { |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | if ($globalDebug) echo "\n"; |
231 | 231 | } |
232 | 232 | unset($this->all_flights[$key]); |
233 | - } |
|
233 | + } |
|
234 | 234 | |
235 | - public function add($line) { |
|
235 | + public function add($line) { |
|
236 | 236 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive, $globalAPRSdelete; |
237 | 237 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
238 | 238 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
@@ -258,20 +258,20 @@ discard block |
||
258 | 258 | |
259 | 259 | // SBS format is CSV format |
260 | 260 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
261 | - //print_r($line); |
|
262 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
263 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
261 | + //print_r($line); |
|
262 | + if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
263 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
264 | 264 | |
265 | 265 | // Increment message number |
266 | 266 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
267 | - $current_date = date('Y-m-d'); |
|
268 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
269 | - else $source = ''; |
|
270 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
271 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
272 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
273 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
274 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
267 | + $current_date = date('Y-m-d'); |
|
268 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
269 | + else $source = ''; |
|
270 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
271 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
272 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
273 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
274 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /* |
@@ -287,54 +287,54 @@ discard block |
||
287 | 287 | //$this->db = $dbc; |
288 | 288 | |
289 | 289 | //$hex = trim($line['hex']); |
290 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
291 | - else $id = trim($line['id']); |
|
290 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
291 | + else $id = trim($line['id']); |
|
292 | 292 | |
293 | 293 | if (!isset($this->all_flights[$id])) { |
294 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
295 | - $this->all_flights[$id] = array(); |
|
296 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
297 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0)); |
|
298 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
299 | - if (!isset($line['id'])) { |
|
294 | + if ($globalDebug) echo 'New flight...'."\n"; |
|
295 | + $this->all_flights[$id] = array(); |
|
296 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
297 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0)); |
|
298 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
299 | + if (!isset($line['id'])) { |
|
300 | 300 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
301 | 301 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
302 | 302 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
303 | 303 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
304 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
305 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
306 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
304 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
305 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
306 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
307 | 307 | } |
308 | 308 | if (isset($line['source_type']) && $line['source_type'] != '') { |
309 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
309 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | //print_r($this->all_flights); |
313 | 313 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
314 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
315 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
314 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
315 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
316 | 316 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
317 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
318 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
317 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
318 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
319 | 319 | $timeelapsed = microtime(true); |
320 | 320 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
321 | - $Spotter = new Spotter($this->db); |
|
322 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
321 | + $Spotter = new Spotter($this->db); |
|
322 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
323 | 323 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
324 | - } else { |
|
324 | + } else { |
|
325 | 325 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
326 | - } |
|
327 | - $Spotter->db = null; |
|
328 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
329 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
326 | + } |
|
327 | + $Spotter->db = null; |
|
328 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
329 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
330 | 330 | } |
331 | - } |
|
332 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
333 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
331 | + } |
|
332 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
333 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
334 | 334 | } |
335 | - if (isset($line['id']) && !isset($line['hex'])) { |
|
336 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
337 | - } |
|
335 | + if (isset($line['id']) && !isset($line['hex'])) { |
|
336 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
337 | + } |
|
338 | 338 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
339 | 339 | $icao = $line['aircraft_icao']; |
340 | 340 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | } |
365 | 365 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
366 | 366 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
367 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
367 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
368 | 368 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
369 | - } else { |
|
369 | + } else { |
|
370 | 370 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
371 | 371 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
372 | 372 | /* |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | print_r($line); |
376 | 376 | */ |
377 | 377 | return ''; |
378 | - } |
|
378 | + } |
|
379 | 379 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
380 | 380 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
381 | 381 | return ''; |
@@ -391,21 +391,21 @@ discard block |
||
391 | 391 | } |
392 | 392 | |
393 | 393 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
395 | 395 | } |
396 | 396 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
397 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
397 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
398 | 398 | } |
399 | 399 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
401 | 401 | } |
402 | 402 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
403 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
403 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
407 | 407 | |
408 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
408 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
409 | 409 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 800) { |
410 | 410 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
411 | 411 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -414,23 +414,23 @@ discard block |
||
414 | 414 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
415 | 415 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
416 | 416 | } else { |
417 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
418 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
417 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
418 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
419 | 419 | $timeelapsed = microtime(true); |
420 | - $Spotter = new Spotter($this->db); |
|
421 | - $fromsource = NULL; |
|
422 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
423 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
420 | + $Spotter = new Spotter($this->db); |
|
421 | + $fromsource = NULL; |
|
422 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
423 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
424 | 424 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
425 | 425 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
426 | 426 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
427 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
|
427 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
|
428 | 428 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
429 | 429 | $Spotter->db = null; |
430 | 430 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
431 | - } |
|
431 | + } |
|
432 | 432 | } |
433 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
433 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
434 | 434 | |
435 | 435 | /* |
436 | 436 | if (!isset($line['id'])) { |
@@ -440,63 +440,63 @@ discard block |
||
440 | 440 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
441 | 441 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
442 | 442 | */ |
443 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
443 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
444 | 444 | |
445 | - //$putinarchive = true; |
|
446 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
445 | + //$putinarchive = true; |
|
446 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
447 | 447 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
448 | - } |
|
449 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
448 | + } |
|
449 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
450 | 450 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
451 | - } |
|
452 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
453 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
454 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
451 | + } |
|
452 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
453 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
454 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
455 | 455 | $timeelapsed = microtime(true); |
456 | 456 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
457 | 457 | $Spotter = new Spotter($this->db); |
458 | 458 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
459 | 459 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
460 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
460 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
461 | 461 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
462 | - } |
|
463 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
462 | + } |
|
463 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
464 | 464 | $timeelapsed = microtime(true); |
465 | 465 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
466 | - $Spotter = new Spotter($this->db); |
|
467 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
468 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
466 | + $Spotter = new Spotter($this->db); |
|
467 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
468 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
469 | 469 | $Translation = new Translation($this->db); |
470 | 470 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
471 | 471 | $route = $Spotter->getRouteInfo($ident); |
472 | 472 | $Translation->db = null; |
473 | - } |
|
474 | - $Spotter->db = null; |
|
475 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
476 | - } |
|
473 | + } |
|
474 | + $Spotter->db = null; |
|
475 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
476 | + } |
|
477 | 477 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
478 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
479 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
478 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
479 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
480 | 480 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
481 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
482 | - } |
|
481 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
482 | + } |
|
483 | 483 | } |
484 | 484 | if (!isset($globalFork)) $globalFork = TRUE; |
485 | 485 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
486 | 486 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
487 | 487 | } |
488 | - } |
|
488 | + } |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
492 | 492 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
493 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
494 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
495 | - //$dataFound = true; |
|
493 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
494 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
495 | + //$dataFound = true; |
|
496 | 496 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
497 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
498 | - if ($distance > 1000 && $distance < 10000) { |
|
499 | - // use datetime |
|
497 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
498 | + if ($distance > 1000 && $distance < 10000) { |
|
499 | + // use datetime |
|
500 | 500 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
501 | 501 | $speed = $speed*3.6; |
502 | 502 | if ($speed < 1000) { |
@@ -505,56 +505,56 @@ discard block |
||
505 | 505 | } else { |
506 | 506 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
507 | 507 | } |
508 | - } |
|
508 | + } |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
512 | 512 | |
513 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
514 | - if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
515 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
516 | - return false; |
|
517 | - } |
|
518 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
519 | - else unset($timediff); |
|
520 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
521 | - else unset($timediff_archive); |
|
522 | - if ($this->tmd > 5 |
|
523 | - || (isset($line['format_source']) |
|
524 | - && $line['format_source'] == 'airwhere' |
|
525 | - && ((!isset($this->all_flights[$id]['latitude']) |
|
526 | - || !isset($this->all_flights[$id]['longitude'])) |
|
527 | - || (isset($this->all_flights[$id]['latitude']) |
|
528 | - && isset($this->all_flights[$id]['longitude']) |
|
529 | - && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
530 | - && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
531 | - ) |
|
532 | - ) |
|
533 | - ) |
|
534 | - || (isset($globalVA) && $globalVA) |
|
535 | - || (isset($globalIVAO) && $globalIVAO) |
|
536 | - || (isset($globalVATSIM) && $globalVATSIM) |
|
537 | - || (isset($globalphpVMS) && $globalphpVMS) |
|
538 | - || (isset($globalVAM) && $globalVAM) |
|
539 | - || !isset($timediff) |
|
540 | - || (isset($timediff) && $timediff > $globalLiveInterval) |
|
541 | - || $globalArchive |
|
542 | - || (isset($timediff) && $timediff > 30 |
|
543 | - && isset($this->all_flights[$id]['latitude']) |
|
544 | - && isset($this->all_flights[$id]['longitude']) |
|
545 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
546 | - ) |
|
547 | - ) { |
|
513 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
514 | + if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
515 | + if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
516 | + return false; |
|
517 | + } |
|
518 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
519 | + else unset($timediff); |
|
520 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
521 | + else unset($timediff_archive); |
|
522 | + if ($this->tmd > 5 |
|
523 | + || (isset($line['format_source']) |
|
524 | + && $line['format_source'] == 'airwhere' |
|
525 | + && ((!isset($this->all_flights[$id]['latitude']) |
|
526 | + || !isset($this->all_flights[$id]['longitude'])) |
|
527 | + || (isset($this->all_flights[$id]['latitude']) |
|
528 | + && isset($this->all_flights[$id]['longitude']) |
|
529 | + && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
530 | + && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
531 | + ) |
|
532 | + ) |
|
533 | + ) |
|
534 | + || (isset($globalVA) && $globalVA) |
|
535 | + || (isset($globalIVAO) && $globalIVAO) |
|
536 | + || (isset($globalVATSIM) && $globalVATSIM) |
|
537 | + || (isset($globalphpVMS) && $globalphpVMS) |
|
538 | + || (isset($globalVAM) && $globalVAM) |
|
539 | + || !isset($timediff) |
|
540 | + || (isset($timediff) && $timediff > $globalLiveInterval) |
|
541 | + || $globalArchive |
|
542 | + || (isset($timediff) && $timediff > 30 |
|
543 | + && isset($this->all_flights[$id]['latitude']) |
|
544 | + && isset($this->all_flights[$id]['longitude']) |
|
545 | + && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
546 | + ) |
|
547 | + ) { |
|
548 | 548 | |
549 | 549 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
550 | - if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
550 | + if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
551 | 551 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
552 | 552 | || ( |
553 | - (isset($this->all_flights[$id]['archive_latitude']) |
|
554 | - && isset($this->all_flights[$id]['archive_longitude']) |
|
555 | - && isset($this->all_flights[$id]['livedb_latitude']) |
|
556 | - && isset($this->all_flights[$id]['livedb_longitude'])) |
|
557 | - && !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude']) |
|
553 | + (isset($this->all_flights[$id]['archive_latitude']) |
|
554 | + && isset($this->all_flights[$id]['archive_longitude']) |
|
555 | + && isset($this->all_flights[$id]['livedb_latitude']) |
|
556 | + && isset($this->all_flights[$id]['livedb_longitude'])) |
|
557 | + && !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude']) |
|
558 | 558 | ) |
559 | 559 | ) { |
560 | 560 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -566,9 +566,9 @@ discard block |
||
566 | 566 | } |
567 | 567 | $this->tmd = 0; |
568 | 568 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
569 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
570 | - $timeelapsed = microtime(true); |
|
571 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
569 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
570 | + $timeelapsed = microtime(true); |
|
571 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
572 | 572 | $Spotter = new Spotter($this->db); |
573 | 573 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
574 | 574 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
@@ -576,11 +576,11 @@ discard block |
||
576 | 576 | $Spotter->db = null; |
577 | 577 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
578 | 578 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
579 | - } |
|
579 | + } |
|
580 | 580 | } |
581 | 581 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
582 | - } |
|
583 | - /* |
|
582 | + } |
|
583 | + /* |
|
584 | 584 | else { |
585 | 585 | if (!isset($timediff)) echo 'NO TIMEDIFF'; |
586 | 586 | else { |
@@ -594,16 +594,16 @@ discard block |
||
594 | 594 | } |
595 | 595 | |
596 | 596 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
597 | - //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
597 | + //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
598 | 598 | if (!isset($this->all_flights[$id]['archive_latitude'])) { |
599 | 599 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
600 | 600 | $this->all_flights[$id]['time_last_coord'] = time(); |
601 | 601 | } |
602 | 602 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
603 | 603 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
604 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
605 | - $dataFound = true; |
|
606 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
604 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
605 | + $dataFound = true; |
|
606 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
607 | 607 | } |
608 | 608 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
609 | 609 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -614,25 +614,25 @@ discard block |
||
614 | 614 | //$putinarchive = true; |
615 | 615 | } |
616 | 616 | */ |
617 | - /* |
|
617 | + /* |
|
618 | 618 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
619 | 619 | if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n"; |
620 | 620 | } |
621 | 621 | */ |
622 | 622 | } |
623 | 623 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
624 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
625 | - //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
624 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
625 | + //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
626 | 626 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
627 | 627 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
628 | 628 | $this->all_flights[$id]['time_last_coord'] = time(); |
629 | 629 | } |
630 | 630 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
631 | 631 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
632 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
633 | - $dataFound = true; |
|
634 | - $this->all_flights[$id]['coordinates'] += 1; |
|
635 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
632 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
633 | + $dataFound = true; |
|
634 | + $this->all_flights[$id]['coordinates'] += 1; |
|
635 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
636 | 636 | } |
637 | 637 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
638 | 638 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -650,76 +650,76 @@ discard block |
||
650 | 650 | */ |
651 | 651 | } |
652 | 652 | if ($globalDaemon === TRUE && isset($updateinitial) && $updateinitial && $this->all_flights[$id]['addedSpotter'] == 1) { |
653 | - if ($globalDebug) echo "\n".'>>> Update initial data !'."\n"; |
|
654 | - unset($updateinitial); |
|
655 | - $SpotterArchive = new SpotterArchive(); |
|
656 | - $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']); |
|
657 | - $SpotterArchive->db = null; |
|
658 | - $Spotter = new Spotter(); |
|
659 | - $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime']); |
|
660 | - $Spotter->db = null; |
|
653 | + if ($globalDebug) echo "\n".'>>> Update initial data !'."\n"; |
|
654 | + unset($updateinitial); |
|
655 | + $SpotterArchive = new SpotterArchive(); |
|
656 | + $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']); |
|
657 | + $SpotterArchive->db = null; |
|
658 | + $Spotter = new Spotter(); |
|
659 | + $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime']); |
|
660 | + $Spotter->db = null; |
|
661 | 661 | } |
662 | - } else if ($globalDebug && $timediff > 30) { |
|
662 | + } else if ($globalDebug && $timediff > 30) { |
|
663 | 663 | $this->tmd = $this->tmd + 1; |
664 | 664 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
665 | 665 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
666 | 666 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
667 | 667 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
668 | - } |
|
668 | + } |
|
669 | 669 | } |
670 | 670 | if (isset($line['last_update']) && $line['last_update'] != '') { |
671 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
672 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
671 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
672 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
673 | 673 | } |
674 | 674 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
675 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
676 | - //$dataFound = true; |
|
675 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
676 | + //$dataFound = true; |
|
677 | 677 | } |
678 | 678 | if (isset($line['format_source']) && $line['format_source'] != '') { |
679 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
679 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
680 | 680 | } |
681 | 681 | if (isset($line['source_name']) && $line['source_name'] != '') { |
682 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
682 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
683 | 683 | } |
684 | 684 | if (isset($line['emergency']) && $line['emergency'] != '') { |
685 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
686 | - //$dataFound = true; |
|
685 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
686 | + //$dataFound = true; |
|
687 | 687 | } |
688 | 688 | if (isset($line['ground']) && $line['ground'] != '') { |
689 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
689 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
690 | 690 | // Here we force archive of flight because after ground it's a new one (or should be) |
691 | 691 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
692 | 692 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
693 | 693 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
694 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
694 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
695 | 695 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
696 | - } |
|
697 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
698 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
699 | - //$dataFound = true; |
|
696 | + } |
|
697 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
698 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
699 | + //$dataFound = true; |
|
700 | 700 | } |
701 | 701 | if (isset($line['squawk']) && $line['squawk'] != '') { |
702 | - if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
703 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
704 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
705 | - $highlight = ''; |
|
706 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
707 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
708 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
709 | - if ($highlight != '') { |
|
702 | + if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
703 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
704 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
705 | + $highlight = ''; |
|
706 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
707 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
708 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
709 | + if ($highlight != '') { |
|
710 | 710 | $timeelapsed = microtime(true); |
711 | 711 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
712 | - $Spotter = new Spotter($this->db); |
|
713 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
714 | - $Spotter->db = null; |
|
715 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
712 | + $Spotter = new Spotter($this->db); |
|
713 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
714 | + $Spotter->db = null; |
|
715 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
716 | 716 | } |
717 | 717 | //$putinarchive = true; |
718 | 718 | //$highlight = ''; |
719 | - } |
|
719 | + } |
|
720 | 720 | |
721 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
722 | - //$dataFound = true; |
|
721 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
722 | + //$dataFound = true; |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | if (isset($line['altitude']) && $line['altitude'] != '' && is_numeric($line['altitude'])) { |
@@ -730,13 +730,13 @@ discard block |
||
730 | 730 | $line['altitude'] = $line['altitude'] - $geoid; |
731 | 731 | } |
732 | 732 | } |
733 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
733 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
734 | 734 | if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
735 | 735 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
736 | 736 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
737 | 737 | //$dataFound = true; |
738 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
739 | - if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
738 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
739 | + if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
740 | 740 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
741 | 741 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
742 | 742 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -745,27 +745,27 @@ discard block |
||
745 | 745 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
746 | 746 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
747 | 747 | } |
748 | - } |
|
749 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
748 | + } |
|
749 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
753 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
753 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | if (isset($line['heading']) && $line['heading'] != '') { |
757 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
758 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
759 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
760 | - //$dataFound = true; |
|
757 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
758 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
759 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
760 | + //$dataFound = true; |
|
761 | 761 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
762 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
763 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
764 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
765 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
762 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
763 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
764 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
765 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
766 | 766 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
767 | - // If not enough messages and ACARS set heading to 0 |
|
768 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
767 | + // If not enough messages and ACARS set heading to 0 |
|
768 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
769 | 769 | } |
770 | 770 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
771 | 771 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -778,133 +778,133 @@ discard block |
||
778 | 778 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
779 | 779 | //if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
780 | 780 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
781 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
782 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
783 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
784 | - //print_r($this->all_flights); |
|
785 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
786 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
787 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
781 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
782 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
783 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
784 | + //print_r($this->all_flights); |
|
785 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
786 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
787 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
788 | 788 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
789 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
790 | - $timeelapsed = microtime(true); |
|
791 | - $SpotterLive = new SpotterLive($this->db); |
|
792 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
789 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
790 | + $timeelapsed = microtime(true); |
|
791 | + $SpotterLive = new SpotterLive($this->db); |
|
792 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
793 | 793 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
794 | 794 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
795 | - } elseif (isset($line['id'])) { |
|
795 | + } elseif (isset($line['id'])) { |
|
796 | 796 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
797 | 797 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
798 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
798 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
799 | 799 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
800 | 800 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
801 | - } else $recent_ident = ''; |
|
802 | - $SpotterLive->db=null; |
|
803 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
804 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
801 | + } else $recent_ident = ''; |
|
802 | + $SpotterLive->db=null; |
|
803 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
804 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
805 | 805 | } else $recent_ident = ''; |
806 | - } else { |
|
806 | + } else { |
|
807 | 807 | $recent_ident = ''; |
808 | 808 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
809 | - } |
|
810 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
811 | - if($recent_ident == "") |
|
812 | - { |
|
809 | + } |
|
810 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
811 | + if($recent_ident == "") |
|
812 | + { |
|
813 | 813 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
814 | 814 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
815 | 815 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
816 | 816 | //adds the spotter data for the archive |
817 | 817 | $ignoreImport = false; |
818 | 818 | foreach($globalAirportIgnore as $airportIgnore) { |
819 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
819 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
820 | 820 | $ignoreImport = true; |
821 | - } |
|
821 | + } |
|
822 | 822 | } |
823 | 823 | if (count($globalAirportAccept) > 0) { |
824 | - $ignoreImport = true; |
|
825 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
824 | + $ignoreImport = true; |
|
825 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
826 | 826 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
827 | - $ignoreImport = false; |
|
827 | + $ignoreImport = false; |
|
828 | + } |
|
828 | 829 | } |
829 | - } |
|
830 | 830 | } |
831 | 831 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
832 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
832 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
833 | 833 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
834 | - $ignoreImport = true; |
|
834 | + $ignoreImport = true; |
|
835 | + } |
|
835 | 836 | } |
836 | - } |
|
837 | 837 | } |
838 | 838 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
839 | - $ignoreImport = true; |
|
840 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
839 | + $ignoreImport = true; |
|
840 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
841 | 841 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
842 | - $ignoreImport = false; |
|
842 | + $ignoreImport = false; |
|
843 | + } |
|
843 | 844 | } |
844 | - } |
|
845 | 845 | } |
846 | 846 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
847 | - $ignoreImport = true; |
|
848 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
847 | + $ignoreImport = true; |
|
848 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
849 | 849 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
850 | - $ignoreImport = false; |
|
850 | + $ignoreImport = false; |
|
851 | + } |
|
851 | 852 | } |
852 | - } |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | if (!$ignoreImport) { |
856 | - $highlight = ''; |
|
857 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
858 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
859 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
860 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
861 | - $timeelapsed = microtime(true); |
|
862 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
856 | + $highlight = ''; |
|
857 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
858 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
859 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
860 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
861 | + $timeelapsed = microtime(true); |
|
862 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
863 | 863 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
864 | - $Spotter = new Spotter($this->db); |
|
865 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
866 | - $Spotter->db = null; |
|
867 | - if ($globalDebug) { |
|
864 | + $Spotter = new Spotter($this->db); |
|
865 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
866 | + $Spotter->db = null; |
|
867 | + if ($globalDebug) { |
|
868 | 868 | if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
869 | 869 | else echo 'Success'; |
870 | - } |
|
871 | - if (count($result) > 1) { |
|
872 | - // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
|
870 | + } |
|
871 | + if (count($result) > 1) { |
|
872 | + // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
|
873 | 873 | if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
874 | 874 | if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration']; |
875 | - } |
|
875 | + } |
|
876 | + } |
|
876 | 877 | } |
877 | - } |
|
878 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
879 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
878 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
879 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
880 | 880 | |
881 | - // Add source stat in DB |
|
882 | - $Stats = new Stats($this->db); |
|
883 | - if (!empty($this->stats)) { |
|
881 | + // Add source stat in DB |
|
882 | + $Stats = new Stats($this->db); |
|
883 | + if (!empty($this->stats)) { |
|
884 | 884 | if ($globalDebug) echo 'Add source stats : '; |
885 | - foreach($this->stats as $date => $data) { |
|
886 | - foreach($data as $source => $sourced) { |
|
887 | - //print_r($sourced); |
|
888 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
889 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
890 | - if (isset($sourced['msg'])) { |
|
891 | - if (time() - $sourced['msg']['date'] > 10) { |
|
892 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
893 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
894 | - unset($this->stats[$date][$source]['msg']); |
|
895 | - } |
|
896 | - } |
|
897 | - } |
|
898 | - if ($date != date('Y-m-d')) { |
|
899 | - unset($this->stats[$date]); |
|
900 | - } |
|
901 | - } |
|
902 | - if ($globalDebug) echo 'Done'."\n"; |
|
885 | + foreach($this->stats as $date => $data) { |
|
886 | + foreach($data as $source => $sourced) { |
|
887 | + //print_r($sourced); |
|
888 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
889 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
890 | + if (isset($sourced['msg'])) { |
|
891 | + if (time() - $sourced['msg']['date'] > 10) { |
|
892 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
893 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
894 | + unset($this->stats[$date][$source]['msg']); |
|
895 | + } |
|
896 | + } |
|
897 | + } |
|
898 | + if ($date != date('Y-m-d')) { |
|
899 | + unset($this->stats[$date]); |
|
900 | + } |
|
901 | + } |
|
902 | + if ($globalDebug) echo 'Done'."\n"; |
|
903 | 903 | |
904 | - } |
|
905 | - $Stats->db = null; |
|
906 | - } |
|
907 | - $this->del(); |
|
904 | + } |
|
905 | + $Stats->db = null; |
|
906 | + } |
|
907 | + $this->del(); |
|
908 | 908 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
909 | 909 | //$ignoreImport = false; |
910 | 910 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -922,41 +922,41 @@ discard block |
||
922 | 922 | */ |
923 | 923 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
924 | 924 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
925 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
926 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
927 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
925 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
926 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
927 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
928 | 928 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
929 | - $SpotterLive = new SpotterLive($this->db); |
|
930 | - $SpotterLive->deleteLiveSpotterData(); |
|
931 | - $SpotterLive->db=null; |
|
929 | + $SpotterLive = new SpotterLive($this->db); |
|
930 | + $SpotterLive->deleteLiveSpotterData(); |
|
931 | + $SpotterLive->db=null; |
|
932 | + } |
|
932 | 933 | } |
933 | - } |
|
934 | - if ($globalDebug) echo " Done\n"; |
|
935 | - $this->last_delete = time(); |
|
934 | + if ($globalDebug) echo " Done\n"; |
|
935 | + $this->last_delete = time(); |
|
936 | 936 | } |
937 | - } else { |
|
937 | + } else { |
|
938 | 938 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
939 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
940 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
939 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
940 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
941 | 941 | } |
942 | 942 | if (isset($globalDaemon) && !$globalDaemon) { |
943 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
943 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
944 | 944 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
945 | - $Spotter = new Spotter($this->db); |
|
946 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
947 | - $Spotter->db = null; |
|
945 | + $Spotter = new Spotter($this->db); |
|
946 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
947 | + $Spotter->db = null; |
|
948 | + } |
|
948 | 949 | } |
949 | - } |
|
950 | 950 | } |
951 | 951 | |
952 | - } |
|
952 | + } |
|
953 | 953 | } |
954 | - } |
|
955 | - //adds the spotter LIVE data |
|
956 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
957 | - //echo "\nAdd in Live !! \n"; |
|
958 | - //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
959 | - if ($globalDebug) { |
|
954 | + } |
|
955 | + //adds the spotter LIVE data |
|
956 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
957 | + //echo "\nAdd in Live !! \n"; |
|
958 | + //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
959 | + if ($globalDebug) { |
|
960 | 960 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
961 | 961 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
962 | 962 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
@@ -964,61 +964,61 @@ discard block |
||
964 | 964 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
965 | 965 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
966 | 966 | } |
967 | - } |
|
968 | - $ignoreImport = false; |
|
969 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
970 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
967 | + } |
|
968 | + $ignoreImport = false; |
|
969 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
970 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
971 | 971 | |
972 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
973 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
974 | - $ignoreImport = true; |
|
972 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
973 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
974 | + $ignoreImport = true; |
|
975 | + } |
|
975 | 976 | } |
976 | - } |
|
977 | - if (count($globalAirportAccept) > 0) { |
|
978 | - $ignoreImport = true; |
|
979 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
980 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
977 | + if (count($globalAirportAccept) > 0) { |
|
978 | + $ignoreImport = true; |
|
979 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
980 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
981 | 981 | $ignoreImport = false; |
982 | - } |
|
982 | + } |
|
983 | 983 | } |
984 | - } |
|
985 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
984 | + } |
|
985 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
986 | 986 | foreach($globalAirlineIgnore as $airlineIgnore) { |
987 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
987 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
988 | 988 | $ignoreImport = true; |
989 | - } |
|
989 | + } |
|
990 | 990 | } |
991 | - } |
|
992 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
991 | + } |
|
992 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
993 | 993 | $ignoreImport = true; |
994 | 994 | foreach($globalAirlineAccept as $airlineAccept) { |
995 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
995 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
996 | 996 | $ignoreImport = false; |
997 | - } |
|
997 | + } |
|
998 | + } |
|
998 | 999 | } |
999 | - } |
|
1000 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
1000 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
1001 | 1001 | $ignoreImport = true; |
1002 | 1002 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
1003 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
1004 | - $ignoreImport = false; |
|
1005 | - } |
|
1003 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
1004 | + $ignoreImport = false; |
|
1005 | + } |
|
1006 | + } |
|
1006 | 1007 | } |
1007 | - } |
|
1008 | 1008 | |
1009 | - if (!$ignoreImport) { |
|
1009 | + if (!$ignoreImport) { |
|
1010 | 1010 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
1011 | 1011 | if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
1012 | 1012 | $timeelapsed = microtime(true); |
1013 | 1013 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
1014 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
1014 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
1015 | 1015 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
1016 | 1016 | $SpotterLive = new SpotterLive($this->db); |
1017 | 1017 | //var_dump($this->all_flights[$id]); |
1018 | 1018 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
1019 | 1019 | $SpotterLive->db = null; |
1020 | 1020 | if ($globalDebug) echo $result."\n"; |
1021 | - } |
|
1021 | + } |
|
1022 | 1022 | } |
1023 | 1023 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
1024 | 1024 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | //if ($line['format_source'] != 'aprs') { |
1031 | 1031 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
1032 | 1032 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
1033 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
1033 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
1034 | 1034 | $source = $this->all_flights[$id]['source_name']; |
1035 | 1035 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
1036 | 1036 | if (!isset($this->source_location[$source])) { |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | if ($stats_heading == 16) $stats_heading = 0; |
1057 | 1057 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1058 | 1058 | for ($i=0;$i<=15;$i++) { |
1059 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1059 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1060 | 1060 | } |
1061 | 1061 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
1062 | 1062 | } else { |
@@ -1069,17 +1069,17 @@ discard block |
||
1069 | 1069 | //var_dump($this->stats); |
1070 | 1070 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1071 | 1071 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1072 | - end($this->stats[$current_date][$source]['hist']); |
|
1073 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1072 | + end($this->stats[$current_date][$source]['hist']); |
|
1073 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1074 | 1074 | } else $mini = 0; |
1075 | 1075 | for ($i=$mini;$i<=$distance;$i+=10) { |
1076 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1076 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1077 | 1077 | } |
1078 | 1078 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
1079 | 1079 | } else { |
1080 | 1080 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
1081 | 1081 | } |
1082 | - } |
|
1082 | + } |
|
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | //$this->del(); |
1090 | 1090 | |
1091 | 1091 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1092 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1092 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1093 | 1093 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
1094 | 1094 | $SpotterLive = new SpotterLive($this->db); |
1095 | 1095 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -1104,19 +1104,19 @@ discard block |
||
1104 | 1104 | if ($globalDebug) echo " Done\n"; |
1105 | 1105 | } |
1106 | 1106 | $this->last_delete_hourly = time(); |
1107 | - } else { |
|
1107 | + } else { |
|
1108 | 1108 | $this->del(); |
1109 | 1109 | $this->last_delete_hourly = time(); |
1110 | - } |
|
1110 | + } |
|
1111 | 1111 | } |
1112 | 1112 | |
1113 | - } |
|
1114 | - //$ignoreImport = false; |
|
1113 | + } |
|
1114 | + //$ignoreImport = false; |
|
1115 | 1115 | } |
1116 | 1116 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1117 | 1117 | if ($send) return $this->all_flights[$id]; |
1118 | - } |
|
1118 | + } |
|
1119 | + } |
|
1119 | 1120 | } |
1120 | - } |
|
1121 | 1121 | } |
1122 | 1122 | ?> |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | $currentdate = date('Y-m-d'); |
42 | 42 | $sourcestat = $Stats->getStatsSource($currentdate); |
43 | 43 | if (!empty($sourcestat)) { |
44 | - foreach($sourcestat as $srcst) { |
|
44 | + foreach ($sourcestat as $srcst) { |
|
45 | 45 | $type = $srcst['stats_type']; |
46 | 46 | if ($type == 'polar' || $type == 'hist') { |
47 | 47 | $source = $srcst['source_name']; |
48 | 48 | $data = $srcst['source_data']; |
49 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
49 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | if (isset($globalGeoid) && $globalGeoid) { |
59 | 59 | try { |
60 | 60 | $GeoidClass = new GeoidHeight(); |
61 | - } catch(Exception $e) { |
|
61 | + } catch (Exception $e) { |
|
62 | 62 | if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
63 | 63 | $GeoidClass = FALSE; |
64 | 64 | } |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - public function get_Schedule($id,$ident) { |
|
68 | + public function get_Schedule($id, $ident) { |
|
69 | 69 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
70 | 70 | // Get schedule here, so it's done only one time |
71 | 71 | |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | $schedule = $Schedule->fetchSchedule($operator); |
91 | 91 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
92 | 92 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
93 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
94 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
93 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
94 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
95 | 95 | // Should also check if route schedule = route from DB |
96 | 96 | if ($schedule['DepartureAirportIATA'] != '') { |
97 | 97 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
114 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
114 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
115 | 115 | } |
116 | 116 | } else $scheduleexist = true; |
117 | 117 | } else $scheduleexist = true; |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | if ($scheduleexist) { |
120 | 120 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
121 | 121 | $sch = $Schedule->getSchedule($operator); |
122 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
123 | - if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
|
122 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
123 | + if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'], $sch['departure_airport_icao'], $sch['departure_airport_time'], $sch['arrival_airport_icao'], $sch['arrival_airport_time']); |
|
124 | 124 | } |
125 | 125 | $Spotter->db = null; |
126 | 126 | $Schedule->db = null; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
148 | 148 | $Spotter = new Spotter($this->db); |
149 | 149 | $real_arrival = $this->arrival($key); |
150 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],'',$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
150 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], '', $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $airport_time = ''; |
162 | 162 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
163 | 163 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
164 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
164 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
165 | 165 | if (isset($closestAirports[0])) { |
166 | 166 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
167 | 167 | $airport_icao = $closestAirports[0]['icao']; |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | break; |
177 | 177 | } |
178 | 178 | } |
179 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
179 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
180 | 180 | $airport_icao = $closestAirports[0]['icao']; |
181 | 181 | $airport_time = $this->all_flights[$key]['datetime']; |
182 | 182 | } else { |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | } else { |
190 | 190 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
191 | 191 | } |
192 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
192 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | |
202 | 202 | foreach ($this->all_flights as $key => $flight) { |
203 | 203 | if (isset($flight['lastupdate'])) { |
204 | - if ($flight['lastupdate'] < (time()-1800)) { |
|
204 | + if ($flight['lastupdate'] < (time() - 1800)) { |
|
205 | 205 | $this->delKey($key); |
206 | 206 | } |
207 | 207 | } |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | $Spotter = new Spotter($this->db); |
219 | 219 | $SpotterLive = new SpotterLive($this->db); |
220 | 220 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
221 | - $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],'',$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
221 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], '', $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
222 | 222 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
223 | 223 | $this->all_flights[$key]['putinarchive'] = true; |
224 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']); |
|
224 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'], $this->all_flights[$key]['route_stop'], $this->all_flights[$key]['hex'], $this->all_flights[$key]['putinarchive'], $this->all_flights[$key]['registration'], $this->all_flights[$key]['pilot_id'], $this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['format_source'], $this->all_flights[$key]['source_name'], $this->all_flights[$key]['over_country']); |
|
225 | 225 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
226 | 226 | } |
227 | 227 | $Spotter->db = null; |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | $send = false; |
258 | 258 | |
259 | 259 | // SBS format is CSV format |
260 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
260 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
261 | 261 | //print_r($line); |
262 | 262 | if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
263 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
263 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'], 0, 1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
264 | 264 | |
265 | 265 | // Increment message number |
266 | 266 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
@@ -293,25 +293,25 @@ discard block |
||
293 | 293 | if (!isset($this->all_flights[$id])) { |
294 | 294 | if ($globalDebug) echo 'New flight...'."\n"; |
295 | 295 | $this->all_flights[$id] = array(); |
296 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
297 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0)); |
|
298 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
296 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
297 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '', 'coordinates' => 0)); |
|
298 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
299 | 299 | if (!isset($line['id'])) { |
300 | 300 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
301 | 301 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
302 | 302 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
303 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
303 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
304 | 304 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
305 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
305 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
306 | 306 | if ($globalAllFlights !== FALSE) $dataFound = true; |
307 | 307 | } |
308 | 308 | if (isset($line['source_type']) && $line['source_type'] != '') { |
309 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
309 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | //print_r($this->all_flights); |
313 | 313 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
314 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
314 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
315 | 315 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
316 | 316 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
317 | 317 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -320,20 +320,20 @@ discard block |
||
320 | 320 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
321 | 321 | $Spotter = new Spotter($this->db); |
322 | 322 | if (isset($this->all_flights[$id]['source_type'])) { |
323 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
323 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
324 | 324 | } else { |
325 | 325 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
326 | 326 | } |
327 | 327 | $Spotter->db = null; |
328 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
329 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
328 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
329 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | if ($globalAllFlights !== FALSE) $dataFound = true; |
333 | 333 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
334 | 334 | } |
335 | 335 | if (isset($line['id']) && !isset($line['hex'])) { |
336 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
336 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
337 | 337 | } |
338 | 338 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
339 | 339 | $icao = $line['aircraft_icao']; |
@@ -342,14 +342,14 @@ discard block |
||
342 | 342 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
343 | 343 | $Spotter->db = null; |
344 | 344 | } |
345 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
345 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
346 | 346 | } elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
347 | 347 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
348 | 348 | // Get aircraft ICAO from aircraft name |
349 | 349 | $Spotter = new Spotter($this->db); |
350 | 350 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
351 | 351 | $Spotter->db = null; |
352 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
352 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -357,15 +357,15 @@ discard block |
||
357 | 357 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
358 | 358 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
359 | 359 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
360 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
360 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
361 | 361 | } |
362 | 362 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
363 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
363 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
364 | 364 | } |
365 | 365 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
366 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
366 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
367 | 367 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
368 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
368 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
369 | 369 | } else { |
370 | 370 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
371 | 371 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -376,31 +376,31 @@ discard block |
||
376 | 376 | */ |
377 | 377 | return ''; |
378 | 378 | } |
379 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
379 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
380 | 380 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
381 | 381 | return ''; |
382 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
382 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
383 | 383 | if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
384 | 384 | return ''; |
385 | 385 | } elseif (!isset($line['datetime'])) { |
386 | 386 | date_default_timezone_set('UTC'); |
387 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
387 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
388 | 388 | } else { |
389 | 389 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
390 | 390 | return ''; |
391 | 391 | } |
392 | 392 | |
393 | 393 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
395 | 395 | } |
396 | 396 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
397 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
397 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
398 | 398 | } |
399 | 399 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
401 | 401 | } |
402 | 402 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
403 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
403 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
@@ -408,13 +408,13 @@ discard block |
||
408 | 408 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
409 | 409 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 800) { |
410 | 410 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
411 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
412 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
413 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
414 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
415 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
411 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
412 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
413 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
414 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
415 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
416 | 416 | } else { |
417 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
417 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
418 | 418 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
419 | 419 | $timeelapsed = microtime(true); |
420 | 420 | $Spotter = new Spotter($this->db); |
@@ -424,13 +424,13 @@ discard block |
||
424 | 424 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
425 | 425 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
426 | 426 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
427 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
|
427 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource, $this->all_flights[$id]['source_type']); |
|
428 | 428 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
429 | 429 | $Spotter->db = null; |
430 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
430 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
431 | 431 | } |
432 | 432 | } |
433 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
433 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
434 | 434 | |
435 | 435 | /* |
436 | 436 | if (!isset($line['id'])) { |
@@ -440,25 +440,25 @@ discard block |
||
440 | 440 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
441 | 441 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
442 | 442 | */ |
443 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
443 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
444 | 444 | |
445 | 445 | //$putinarchive = true; |
446 | 446 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
447 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
447 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
448 | 448 | } |
449 | 449 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
450 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
450 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
451 | 451 | } |
452 | 452 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
453 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
453 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
454 | 454 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
455 | 455 | $timeelapsed = microtime(true); |
456 | 456 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
457 | 457 | $Spotter = new Spotter($this->db); |
458 | 458 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
459 | 459 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
460 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
461 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
460 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
461 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
462 | 462 | } |
463 | 463 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
464 | 464 | $timeelapsed = microtime(true); |
@@ -472,35 +472,35 @@ discard block |
||
472 | 472 | $Translation->db = null; |
473 | 473 | } |
474 | 474 | $Spotter->db = null; |
475 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
475 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
476 | 476 | } |
477 | 477 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
478 | 478 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
479 | 479 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
480 | 480 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
481 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
481 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
482 | 482 | } |
483 | 483 | } |
484 | 484 | if (!isset($globalFork)) $globalFork = TRUE; |
485 | 485 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
486 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
486 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | } |
490 | 490 | |
491 | 491 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
492 | 492 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
493 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
494 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
493 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
494 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
495 | 495 | //$dataFound = true; |
496 | 496 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
497 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
497 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
498 | 498 | if ($distance > 1000 && $distance < 10000) { |
499 | 499 | // use datetime |
500 | 500 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
501 | 501 | $speed = $speed*3.6; |
502 | 502 | if ($speed < 1000) { |
503 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
503 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
504 | 504 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
505 | 505 | } else { |
506 | 506 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
@@ -515,9 +515,9 @@ discard block |
||
515 | 515 | if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
516 | 516 | return false; |
517 | 517 | } |
518 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
518 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
519 | 519 | else unset($timediff); |
520 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
520 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
521 | 521 | else unset($timediff_archive); |
522 | 522 | if ($this->tmd > 5 |
523 | 523 | || (isset($line['format_source']) |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | || (isset($timediff) && $timediff > 30 |
543 | 543 | && isset($this->all_flights[$id]['latitude']) |
544 | 544 | && isset($this->all_flights[$id]['longitude']) |
545 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
545 | + && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
546 | 546 | ) |
547 | 547 | ) { |
548 | 548 | |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | && isset($this->all_flights[$id]['archive_longitude']) |
555 | 555 | && isset($this->all_flights[$id]['livedb_latitude']) |
556 | 556 | && isset($this->all_flights[$id]['livedb_longitude'])) |
557 | - && !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude']) |
|
557 | + && !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude']) |
|
558 | 558 | ) |
559 | 559 | ) { |
560 | 560 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -570,11 +570,11 @@ discard block |
||
570 | 570 | $timeelapsed = microtime(true); |
571 | 571 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
572 | 572 | $Spotter = new Spotter($this->db); |
573 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
573 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
574 | 574 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
575 | 575 | else $this->all_flights[$id]['over_country'] = ''; |
576 | 576 | $Spotter->db = null; |
577 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
577 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
578 | 578 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
579 | 579 | } |
580 | 580 | } |
@@ -600,13 +600,13 @@ discard block |
||
600 | 600 | $this->all_flights[$id]['time_last_coord'] = time(); |
601 | 601 | } |
602 | 602 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
603 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
|
603 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) { |
|
604 | 604 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
605 | 605 | $dataFound = true; |
606 | 606 | $this->all_flights[$id]['time_last_coord'] = time(); |
607 | 607 | } |
608 | 608 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
609 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
609 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
610 | 610 | /* |
611 | 611 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
612 | 612 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -628,14 +628,14 @@ discard block |
||
628 | 628 | $this->all_flights[$id]['time_last_coord'] = time(); |
629 | 629 | } |
630 | 630 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
631 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
|
631 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) { |
|
632 | 632 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
633 | 633 | $dataFound = true; |
634 | 634 | $this->all_flights[$id]['coordinates'] += 1; |
635 | 635 | $this->all_flights[$id]['time_last_coord'] = time(); |
636 | 636 | } |
637 | 637 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
638 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
638 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
639 | 639 | /* |
640 | 640 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
641 | 641 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -656,52 +656,52 @@ discard block |
||
656 | 656 | $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']); |
657 | 657 | $SpotterArchive->db = null; |
658 | 658 | $Spotter = new Spotter(); |
659 | - $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime']); |
|
659 | + $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime']); |
|
660 | 660 | $Spotter->db = null; |
661 | 661 | } |
662 | 662 | } else if ($globalDebug && $timediff > 30) { |
663 | 663 | $this->tmd = $this->tmd + 1; |
664 | 664 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
665 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
666 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
665 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
666 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
667 | 667 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
668 | 668 | } |
669 | 669 | } |
670 | 670 | if (isset($line['last_update']) && $line['last_update'] != '') { |
671 | 671 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
672 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
672 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
673 | 673 | } |
674 | 674 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
675 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
675 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
676 | 676 | //$dataFound = true; |
677 | 677 | } |
678 | 678 | if (isset($line['format_source']) && $line['format_source'] != '') { |
679 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
679 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
680 | 680 | } |
681 | 681 | if (isset($line['source_name']) && $line['source_name'] != '') { |
682 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
682 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
683 | 683 | } |
684 | 684 | if (isset($line['emergency']) && $line['emergency'] != '') { |
685 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
685 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
686 | 686 | //$dataFound = true; |
687 | 687 | } |
688 | 688 | if (isset($line['ground']) && $line['ground'] != '') { |
689 | 689 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
690 | 690 | // Here we force archive of flight because after ground it's a new one (or should be) |
691 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
692 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
693 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
694 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
695 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
691 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
692 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
693 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
694 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
695 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
696 | 696 | } |
697 | 697 | if ($line['ground'] != 1) $line['ground'] = 0; |
698 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
698 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
699 | 699 | //$dataFound = true; |
700 | 700 | } |
701 | 701 | if (isset($line['squawk']) && $line['squawk'] != '') { |
702 | 702 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
703 | 703 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
704 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
704 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
705 | 705 | $highlight = ''; |
706 | 706 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
707 | 707 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -710,66 +710,66 @@ discard block |
||
710 | 710 | $timeelapsed = microtime(true); |
711 | 711 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
712 | 712 | $Spotter = new Spotter($this->db); |
713 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
713 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
714 | 714 | $Spotter->db = null; |
715 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
715 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
716 | 716 | } |
717 | 717 | //$putinarchive = true; |
718 | 718 | //$highlight = ''; |
719 | 719 | } |
720 | 720 | |
721 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
721 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
722 | 722 | //$dataFound = true; |
723 | 723 | } |
724 | 724 | |
725 | 725 | if (isset($line['altitude']) && $line['altitude'] != '' && is_numeric($line['altitude'])) { |
726 | 726 | if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) { |
727 | 727 | if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') { |
728 | - $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2); |
|
728 | + $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2); |
|
729 | 729 | //if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n"; |
730 | 730 | $line['altitude'] = $line['altitude'] - $geoid; |
731 | 731 | } |
732 | 732 | } |
733 | 733 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
734 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
735 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
736 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
734 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
735 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
736 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
737 | 737 | //$dataFound = true; |
738 | 738 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
739 | 739 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
740 | 740 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
741 | 741 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
742 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
743 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
744 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
745 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
746 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
742 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
743 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
744 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
745 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
746 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
747 | 747 | } |
748 | 748 | } |
749 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
749 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
753 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
753 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | if (isset($line['heading']) && $line['heading'] != '') { |
757 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
758 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
759 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
757 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
758 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
759 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
760 | 760 | //$dataFound = true; |
761 | 761 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
762 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
763 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
764 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
762 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
763 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
764 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
765 | 765 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
766 | 766 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
767 | 767 | // If not enough messages and ACARS set heading to 0 |
768 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
768 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
769 | 769 | } |
770 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
771 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
772 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) $dataFound = false; |
|
770 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
771 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
772 | + elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) $dataFound = false; |
|
773 | 773 | |
774 | 774 | // print_r($this->all_flights[$id]); |
775 | 775 | //gets the callsign from the last hour |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
781 | 781 | $this->all_flights[$id]['lastupdate'] = time(); |
782 | 782 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
783 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
783 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
784 | 784 | //print_r($this->all_flights); |
785 | 785 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
786 | 786 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -791,61 +791,61 @@ discard block |
||
791 | 791 | $SpotterLive = new SpotterLive($this->db); |
792 | 792 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
793 | 793 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
794 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
794 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
795 | 795 | } elseif (isset($line['id'])) { |
796 | 796 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
797 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
797 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
798 | 798 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
799 | 799 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
800 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
800 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
801 | 801 | } else $recent_ident = ''; |
802 | - $SpotterLive->db=null; |
|
802 | + $SpotterLive->db = null; |
|
803 | 803 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
804 | 804 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
805 | 805 | } else $recent_ident = ''; |
806 | 806 | } else { |
807 | 807 | $recent_ident = ''; |
808 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
808 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
809 | 809 | } |
810 | 810 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
811 | - if($recent_ident == "") |
|
811 | + if ($recent_ident == "") |
|
812 | 812 | { |
813 | 813 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
814 | 814 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
815 | 815 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
816 | 816 | //adds the spotter data for the archive |
817 | 817 | $ignoreImport = false; |
818 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
818 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
819 | 819 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
820 | 820 | $ignoreImport = true; |
821 | 821 | } |
822 | 822 | } |
823 | 823 | if (count($globalAirportAccept) > 0) { |
824 | 824 | $ignoreImport = true; |
825 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
825 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
826 | 826 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
827 | 827 | $ignoreImport = false; |
828 | 828 | } |
829 | 829 | } |
830 | 830 | } |
831 | 831 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
832 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
833 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
832 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
833 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
834 | 834 | $ignoreImport = true; |
835 | 835 | } |
836 | 836 | } |
837 | 837 | } |
838 | 838 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
839 | 839 | $ignoreImport = true; |
840 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
841 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
840 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
841 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
842 | 842 | $ignoreImport = false; |
843 | 843 | } |
844 | 844 | } |
845 | 845 | } |
846 | 846 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
847 | 847 | $ignoreImport = true; |
848 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
848 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
849 | 849 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
850 | 850 | $ignoreImport = false; |
851 | 851 | } |
@@ -857,12 +857,12 @@ discard block |
||
857 | 857 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
858 | 858 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
859 | 859 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
860 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
860 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
861 | 861 | $timeelapsed = microtime(true); |
862 | 862 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
863 | 863 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
864 | 864 | $Spotter = new Spotter($this->db); |
865 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
865 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
866 | 866 | $Spotter->db = null; |
867 | 867 | if ($globalDebug) { |
868 | 868 | if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
@@ -875,22 +875,22 @@ discard block |
||
875 | 875 | } |
876 | 876 | } |
877 | 877 | } |
878 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
878 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
879 | 879 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
880 | 880 | |
881 | 881 | // Add source stat in DB |
882 | 882 | $Stats = new Stats($this->db); |
883 | 883 | if (!empty($this->stats)) { |
884 | 884 | if ($globalDebug) echo 'Add source stats : '; |
885 | - foreach($this->stats as $date => $data) { |
|
886 | - foreach($data as $source => $sourced) { |
|
885 | + foreach ($this->stats as $date => $data) { |
|
886 | + foreach ($data as $source => $sourced) { |
|
887 | 887 | //print_r($sourced); |
888 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
889 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
888 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
889 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
890 | 890 | if (isset($sourced['msg'])) { |
891 | 891 | if (time() - $sourced['msg']['date'] > 10) { |
892 | 892 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
893 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
893 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
894 | 894 | unset($this->stats[$date][$source]['msg']); |
895 | 895 | } |
896 | 896 | } |
@@ -928,14 +928,14 @@ discard block |
||
928 | 928 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
929 | 929 | $SpotterLive = new SpotterLive($this->db); |
930 | 930 | $SpotterLive->deleteLiveSpotterData(); |
931 | - $SpotterLive->db=null; |
|
931 | + $SpotterLive->db = null; |
|
932 | 932 | } |
933 | 933 | } |
934 | 934 | if ($globalDebug) echo " Done\n"; |
935 | 935 | $this->last_delete = time(); |
936 | 936 | } |
937 | 937 | } else { |
938 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
938 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
939 | 939 | $this->all_flights[$id]['id'] = $recent_ident; |
940 | 940 | $this->all_flights[$id]['addedSpotter'] = 1; |
941 | 941 | } |
@@ -943,7 +943,7 @@ discard block |
||
943 | 943 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
944 | 944 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
945 | 945 | $Spotter = new Spotter($this->db); |
946 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
946 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
947 | 947 | $Spotter->db = null; |
948 | 948 | } |
949 | 949 | } |
@@ -969,37 +969,37 @@ discard block |
||
969 | 969 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
970 | 970 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
971 | 971 | |
972 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
972 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
973 | 973 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
974 | 974 | $ignoreImport = true; |
975 | 975 | } |
976 | 976 | } |
977 | 977 | if (count($globalAirportAccept) > 0) { |
978 | 978 | $ignoreImport = true; |
979 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
979 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
980 | 980 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
981 | 981 | $ignoreImport = false; |
982 | 982 | } |
983 | 983 | } |
984 | 984 | } |
985 | 985 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
986 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
987 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
986 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
987 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
988 | 988 | $ignoreImport = true; |
989 | 989 | } |
990 | 990 | } |
991 | 991 | } |
992 | 992 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
993 | 993 | $ignoreImport = true; |
994 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
995 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
994 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
995 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
996 | 996 | $ignoreImport = false; |
997 | 997 | } |
998 | 998 | } |
999 | 999 | } |
1000 | 1000 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
1001 | 1001 | $ignoreImport = true; |
1002 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
1002 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
1003 | 1003 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
1004 | 1004 | $ignoreImport = false; |
1005 | 1005 | } |
@@ -1007,24 +1007,24 @@ discard block |
||
1007 | 1007 | } |
1008 | 1008 | |
1009 | 1009 | if (!$ignoreImport) { |
1010 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
1011 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1010 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
1011 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1012 | 1012 | $timeelapsed = microtime(true); |
1013 | 1013 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
1014 | 1014 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
1015 | 1015 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
1016 | 1016 | $SpotterLive = new SpotterLive($this->db); |
1017 | 1017 | //var_dump($this->all_flights[$id]); |
1018 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
1018 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
1019 | 1019 | $SpotterLive->db = null; |
1020 | 1020 | if ($globalDebug) echo $result."\n"; |
1021 | 1021 | } |
1022 | 1022 | } |
1023 | 1023 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
1024 | - $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
1024 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
1025 | 1025 | } |
1026 | 1026 | $this->all_flights[$id]['putinarchive'] = false; |
1027 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1027 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
1028 | 1028 | |
1029 | 1029 | // Put statistics in $this->stats variable |
1030 | 1030 | //if ($line['format_source'] != 'aprs') { |
@@ -1043,19 +1043,19 @@ discard block |
||
1043 | 1043 | $latitude = $globalCenterLatitude; |
1044 | 1044 | $longitude = $globalCenterLongitude; |
1045 | 1045 | } |
1046 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
1046 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
1047 | 1047 | } else { |
1048 | 1048 | $latitude = $this->source_location[$source]['latitude']; |
1049 | 1049 | $longitude = $this->source_location[$source]['longitude']; |
1050 | 1050 | } |
1051 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1051 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1052 | 1052 | //$stats_heading = $stats_heading%22.5; |
1053 | 1053 | $stats_heading = round($stats_heading/22.5); |
1054 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1054 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1055 | 1055 | $current_date = date('Y-m-d'); |
1056 | 1056 | if ($stats_heading == 16) $stats_heading = 0; |
1057 | 1057 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1058 | - for ($i=0;$i<=15;$i++) { |
|
1058 | + for ($i = 0; $i <= 15; $i++) { |
|
1059 | 1059 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
1060 | 1060 | } |
1061 | 1061 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -1070,9 +1070,9 @@ discard block |
||
1070 | 1070 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1071 | 1071 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1072 | 1072 | end($this->stats[$current_date][$source]['hist']); |
1073 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1073 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
1074 | 1074 | } else $mini = 0; |
1075 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
1075 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
1076 | 1076 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1077 | 1077 | } |
1078 | 1078 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | $this->all_flights[$id]['lastupdate'] = time(); |
1086 | 1086 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
1087 | 1087 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1088 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1088 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
1089 | 1089 | //$this->del(); |
1090 | 1090 | |
1091 | 1091 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |