@@ -24,7 +24,9 @@ discard block |
||
| 24 | 24 | public function __construct($dbc = null,$fromACARSscript = false) { |
| 25 | 25 | $Connection = new Connection($dbc); |
| 26 | 26 | $this->db = $Connection->db(); |
| 27 | - if ($this->db === null) die('Error: No DB connection. (ACARS)'); |
|
| 27 | + if ($this->db === null) { |
|
| 28 | + die('Error: No DB connection. (ACARS)'); |
|
| 29 | + } |
|
| 28 | 30 | if ($fromACARSscript) { |
| 29 | 31 | $this->fromACARSscript = true; |
| 30 | 32 | $this->SI = new SpotterImport($this->db); |
@@ -39,14 +41,19 @@ discard block |
||
| 39 | 41 | */ |
| 40 | 42 | public function ident2icao($ident) { |
| 41 | 43 | if (substr($ident,0,2) == 'AF') { |
| 42 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 43 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 44 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 45 | + $icao = $ident; |
|
| 46 | + } else { |
|
| 47 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 48 | + } |
|
| 44 | 49 | } else { |
| 45 | 50 | $Spotter = new Spotter($this->db); |
| 46 | 51 | $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
| 47 | 52 | if (isset($identicao[0])) { |
| 48 | 53 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
| 49 | - } else $icao = $ident; |
|
| 54 | + } else { |
|
| 55 | + $icao = $ident; |
|
| 56 | + } |
|
| 50 | 57 | } |
| 51 | 58 | return $icao; |
| 52 | 59 | } |
@@ -120,14 +127,24 @@ discard block |
||
| 120 | 127 | $message = ''; |
| 121 | 128 | $result = array(); |
| 122 | 129 | $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); |
| 123 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 124 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 125 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 130 | + if ($n == 0) { |
|
| 131 | + $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); |
|
| 132 | + } |
|
| 133 | + if ($n == 0) { |
|
| 134 | + $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); |
|
| 135 | + } |
|
| 136 | + if ($n == 0) { |
|
| 137 | + $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); |
|
| 138 | + } |
|
| 126 | 139 | if ($n != 0 && ($registration != '' || $ident != '' || $label != '' || $block_id != '' || $msg_no != '')) { |
| 127 | 140 | $registration = str_replace('.','',$registration); |
| 128 | 141 | $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
| 129 | - if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
| 130 | - } else $message = $data; |
|
| 142 | + if ($globalDebug) { |
|
| 143 | + echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
| 144 | + } |
|
| 145 | + } else { |
|
| 146 | + $message = $data; |
|
| 147 | + } |
|
| 131 | 148 | $decode = array(); |
| 132 | 149 | $found = false; |
| 133 | 150 | // if ($registration != '' && $ident != '' && $registration != '!') { |
@@ -147,12 +164,21 @@ discard block |
||
| 147 | 164 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
| 148 | 165 | $latitude = $la / 10000.0; |
| 149 | 166 | $longitude = $ln / 10000.0; |
| 150 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 151 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 167 | + if ($lac == 'S') { |
|
| 168 | + $latitude = '-'.$latitude; |
|
| 169 | + } |
|
| 170 | + if ($lnc == 'W') { |
|
| 171 | + $longitude = '-'.$longitude; |
|
| 172 | + } |
|
| 152 | 173 | // Temp not always available |
| 153 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
| 154 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 155 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 174 | + if ($globalDebug) { |
|
| 175 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
| 176 | + } |
|
| 177 | + if ($temp == '') { |
|
| 178 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 179 | + } else { |
|
| 180 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 181 | + } |
|
| 156 | 182 | |
| 157 | 183 | //$icao = $Translation->checkTranslation($ident); |
| 158 | 184 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -166,25 +192,35 @@ discard block |
||
| 166 | 192 | $ahour = ''; |
| 167 | 193 | $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
| 168 | 194 | if ($n == 4 && strlen($darr) == 4) { |
| 169 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 170 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 171 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 195 | + if ($dhour != '') { |
|
| 196 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 197 | + } |
|
| 198 | + if ($ahour != '') { |
|
| 199 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 200 | + } |
|
| 201 | + if ($globalDebug) { |
|
| 202 | + echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 203 | + } |
|
| 172 | 204 | //$icao = ACARS->ident2icao($ident); |
| 173 | 205 | //$icao = $Translation->checkTranslation($ident); |
| 174 | 206 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 175 | 207 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
| 176 | 208 | $found = true; |
| 177 | - } |
|
| 178 | - elseif ($n == 2 || $n == 4) { |
|
| 179 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 180 | - if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
| 209 | + } elseif ($n == 2 || $n == 4) { |
|
| 210 | + if ($dhour != '') { |
|
| 211 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 212 | + } |
|
| 213 | + if ($globalDebug) { |
|
| 214 | + echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
| 215 | + } |
|
| 181 | 216 | //$icao = ACARS->ident2icao($ident); |
| 182 | 217 | //$icao = $Translation->checkTranslation($ident); |
| 183 | 218 | $decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour); |
| 184 | 219 | $found = true; |
| 185 | - } |
|
| 186 | - elseif ($n == 1) { |
|
| 187 | - if ($globalDebug) echo 'airport arrival : '.$darr."\n"; |
|
| 220 | + } elseif ($n == 1) { |
|
| 221 | + if ($globalDebug) { |
|
| 222 | + echo 'airport arrival : '.$darr."\n"; |
|
| 223 | + } |
|
| 188 | 224 | //$icao = ACARS->ident2icao($ident); |
| 189 | 225 | //$icao = $Translation->checkTranslation($ident); |
| 190 | 226 | $decode = array('Arrival airport' => $darr); |
@@ -202,7 +238,9 @@ discard block |
||
| 202 | 238 | $darr = ''; |
| 203 | 239 | $n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr); |
| 204 | 240 | if ($n == 4) { |
| 205 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 241 | + if ($globalDebug) { |
|
| 242 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 243 | + } |
|
| 206 | 244 | //$icao = ACARS->ident2icao($ident); |
| 207 | 245 | //$icao = $Translation->checkTranslation($ident); |
| 208 | 246 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -236,14 +274,23 @@ discard block |
||
| 236 | 274 | $apiste = ''; |
| 237 | 275 | $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); |
| 238 | 276 | if ($n > 8) { |
| 239 | - 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"; |
|
| 240 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 241 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 277 | + if ($globalDebug) { |
|
| 278 | + 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"; |
|
| 279 | + } |
|
| 280 | + if ($dhour != '') { |
|
| 281 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 282 | + } |
|
| 283 | + if ($ahour != '') { |
|
| 284 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 285 | + } |
|
| 242 | 286 | $icao = trim($aident); |
| 243 | 287 | |
| 244 | 288 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
| 245 | - if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
| 246 | - else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
| 289 | + if ($ahour == '') { |
|
| 290 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
| 291 | + } else { |
|
| 292 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
| 293 | + } |
|
| 247 | 294 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 248 | 295 | $decode['icao'] = $icao; |
| 249 | 296 | $found = true; |
@@ -265,9 +312,15 @@ discard block |
||
| 265 | 312 | $lns = $lns.'.'.$lns; |
| 266 | 313 | $latitude = $las / 1000.0; |
| 267 | 314 | $longitude = $lns / 1000.0; |
| 268 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 269 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 270 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
| 315 | + if ($lac == 'S') { |
|
| 316 | + $latitude = '-'.$latitude; |
|
| 317 | + } |
|
| 318 | + if ($lnc == 'W') { |
|
| 319 | + $longitude = '-'.$longitude; |
|
| 320 | + } |
|
| 321 | + if ($globalDebug) { |
|
| 322 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
| 323 | + } |
|
| 271 | 324 | $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
| 272 | 325 | $found = true; |
| 273 | 326 | } |
@@ -285,7 +338,9 @@ discard block |
||
| 285 | 338 | $darr = ''; |
| 286 | 339 | $n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr); |
| 287 | 340 | if ($n == 4) { |
| 288 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 341 | + if ($globalDebug) { |
|
| 342 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 343 | + } |
|
| 289 | 344 | //$icao = $Translation->checkTranslation($ident); |
| 290 | 345 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 291 | 346 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -298,7 +353,9 @@ discard block |
||
| 298 | 353 | $darr = ''; |
| 299 | 354 | $n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr); |
| 300 | 355 | if ($n == 4) { |
| 301 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 356 | + if ($globalDebug) { |
|
| 357 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 358 | + } |
|
| 302 | 359 | //$icao = $Translation->checkTranslation($ident); |
| 303 | 360 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 304 | 361 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -311,7 +368,9 @@ discard block |
||
| 311 | 368 | $darr = ''; |
| 312 | 369 | $n = sscanf($message, "002AF %4c %4c ", $dair, $darr); |
| 313 | 370 | if ($n == 2) { |
| 314 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 371 | + if ($globalDebug) { |
|
| 372 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 373 | + } |
|
| 315 | 374 | //$icao = $Translation->checkTranslation($ident); |
| 316 | 375 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
| 317 | 376 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -325,7 +384,9 @@ discard block |
||
| 325 | 384 | $darr = ''; |
| 326 | 385 | $n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
| 327 | 386 | if ($n == 6) { |
| 328 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 387 | + if ($globalDebug) { |
|
| 388 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 389 | + } |
|
| 329 | 390 | //$icao = $Translation->checkTranslation($ident); |
| 330 | 391 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 331 | 392 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -338,7 +399,9 @@ discard block |
||
| 338 | 399 | $darr = ''; |
| 339 | 400 | $n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
| 340 | 401 | if ($n == 7) { |
| 341 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 402 | + if ($globalDebug) { |
|
| 403 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 404 | + } |
|
| 342 | 405 | //$icao = $Translation->checkTranslation($ident); |
| 343 | 406 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 344 | 407 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -366,8 +429,12 @@ discard block |
||
| 366 | 429 | $decode['icao'] = $icao; |
| 367 | 430 | $latitude = $las / 100.0; |
| 368 | 431 | $longitude = $lns / 100.0; |
| 369 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 370 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 432 | + if ($lac == 'S') { |
|
| 433 | + $latitude = '-'.$latitude; |
|
| 434 | + } |
|
| 435 | + if ($lnc == 'W') { |
|
| 436 | + $longitude = '-'.$longitude; |
|
| 437 | + } |
|
| 371 | 438 | |
| 372 | 439 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
| 373 | 440 | $found = true; |
@@ -385,8 +452,12 @@ discard block |
||
| 385 | 452 | if ($n == 4) { |
| 386 | 453 | $latitude = $las; |
| 387 | 454 | $longitude = $lns; |
| 388 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 389 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 455 | + if ($lac == 'S') { |
|
| 456 | + $latitude = '-'.$latitude; |
|
| 457 | + } |
|
| 458 | + if ($lnc == 'W') { |
|
| 459 | + $longitude = '-'.$longitude; |
|
| 460 | + } |
|
| 390 | 461 | |
| 391 | 462 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
| 392 | 463 | $found = true; |
@@ -402,7 +473,9 @@ discard block |
||
| 402 | 473 | $darr = ''; |
| 403 | 474 | $n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr); |
| 404 | 475 | if ($n == 5) { |
| 405 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 476 | + if ($globalDebug) { |
|
| 477 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 478 | + } |
|
| 406 | 479 | //$icao = $Translation->checkTranslation($ident); |
| 407 | 480 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 408 | 481 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -423,7 +496,9 @@ discard block |
||
| 423 | 496 | $aident = ''; |
| 424 | 497 | $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); |
| 425 | 498 | if ($n == 8) { |
| 426 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 499 | + if ($globalDebug) { |
|
| 500 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 501 | + } |
|
| 427 | 502 | $icao = trim($aident); |
| 428 | 503 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 429 | 504 | $decode['icao'] = $icao; |
@@ -440,7 +515,9 @@ discard block |
||
| 440 | 515 | $darr = ''; |
| 441 | 516 | $n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr); |
| 442 | 517 | if ($n == 5) { |
| 443 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 518 | + if ($globalDebug) { |
|
| 519 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 520 | + } |
|
| 444 | 521 | //$icao = $Translation->checkTranslation($ident); |
| 445 | 522 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 446 | 523 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -455,7 +532,9 @@ discard block |
||
| 455 | 532 | $darr = ''; |
| 456 | 533 | $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
| 457 | 534 | if ($n == 3) { |
| 458 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 535 | + if ($globalDebug) { |
|
| 536 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 537 | + } |
|
| 459 | 538 | //$icao = $Translation->checkTranslation($ident); |
| 460 | 539 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 461 | 540 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -470,7 +549,9 @@ discard block |
||
| 470 | 549 | $darr = ''; |
| 471 | 550 | $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
| 472 | 551 | if ($n == 3) { |
| 473 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 552 | + if ($globalDebug) { |
|
| 553 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 554 | + } |
|
| 474 | 555 | //$icao = $Translation->checkTranslation($ident); |
| 475 | 556 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 476 | 557 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -480,7 +561,9 @@ discard block |
||
| 480 | 561 | if (!$found) { |
| 481 | 562 | $n = sscanf($message,'MET01%4c',$airport); |
| 482 | 563 | if ($n == 1) { |
| 483 | - if ($globalDebug) echo 'airport name : '.$airport; |
|
| 564 | + if ($globalDebug) { |
|
| 565 | + echo 'airport name : '.$airport; |
|
| 566 | + } |
|
| 484 | 567 | $decode = array('Airport/Waypoint name' => $airport); |
| 485 | 568 | $found = true; |
| 486 | 569 | } |
@@ -488,184 +571,126 @@ discard block |
||
| 488 | 571 | if ($label == 'H1') { |
| 489 | 572 | if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
| 490 | 573 | $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
| 491 | - } |
|
| 492 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 574 | + } elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 493 | 575 | $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
| 494 | - } |
|
| 495 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 576 | + } elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 496 | 577 | $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
| 497 | - } |
|
| 498 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 578 | + } elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 499 | 579 | $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
| 500 | - } |
|
| 501 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 580 | + } elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 502 | 581 | $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
| 503 | - } |
|
| 504 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 582 | + } elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 505 | 583 | $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
| 506 | - } |
|
| 507 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 584 | + } elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 508 | 585 | $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
| 509 | - } |
|
| 510 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 586 | + } elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 511 | 587 | $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
| 512 | - } |
|
| 513 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 588 | + } elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 514 | 589 | $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
| 515 | - } |
|
| 516 | - elseif (preg_match(':^#CF:',$message)) { |
|
| 590 | + } elseif (preg_match(':^#CF:',$message)) { |
|
| 517 | 591 | $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
| 518 | - } |
|
| 519 | - elseif (preg_match(':^#DF:',$message)) { |
|
| 592 | + } elseif (preg_match(':^#DF:',$message)) { |
|
| 520 | 593 | $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
| 521 | - } |
|
| 522 | - elseif (preg_match(':^#EC:',$message)) { |
|
| 594 | + } elseif (preg_match(':^#EC:',$message)) { |
|
| 523 | 595 | $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
| 524 | - } |
|
| 525 | - elseif (preg_match(':^#EI:',$message)) { |
|
| 596 | + } elseif (preg_match(':^#EI:',$message)) { |
|
| 526 | 597 | $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
| 527 | - } |
|
| 528 | - elseif (preg_match(':^#H1:',$message)) { |
|
| 598 | + } elseif (preg_match(':^#H1:',$message)) { |
|
| 529 | 599 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
| 530 | - } |
|
| 531 | - elseif (preg_match(':^#H2:',$message)) { |
|
| 600 | + } elseif (preg_match(':^#H2:',$message)) { |
|
| 532 | 601 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
| 533 | - } |
|
| 534 | - elseif (preg_match(':^#HD:',$message)) { |
|
| 602 | + } elseif (preg_match(':^#HD:',$message)) { |
|
| 535 | 603 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
| 536 | - } |
|
| 537 | - elseif (preg_match(':^#M1:',$message)) { |
|
| 604 | + } elseif (preg_match(':^#M1:',$message)) { |
|
| 538 | 605 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
| 539 | - } |
|
| 540 | - elseif (preg_match(':^#M2:',$message)) { |
|
| 606 | + } elseif (preg_match(':^#M2:',$message)) { |
|
| 541 | 607 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
| 542 | - } |
|
| 543 | - elseif (preg_match(':^#M3:',$message)) { |
|
| 608 | + } elseif (preg_match(':^#M3:',$message)) { |
|
| 544 | 609 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
| 545 | - } |
|
| 546 | - elseif (preg_match(':^#MD:',$message)) { |
|
| 610 | + } elseif (preg_match(':^#MD:',$message)) { |
|
| 547 | 611 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
| 548 | - } |
|
| 549 | - elseif (preg_match(':^#PS:',$message)) { |
|
| 612 | + } elseif (preg_match(':^#PS:',$message)) { |
|
| 550 | 613 | $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
| 551 | - } |
|
| 552 | - elseif (preg_match(':^#S1:',$message)) { |
|
| 614 | + } elseif (preg_match(':^#S1:',$message)) { |
|
| 553 | 615 | $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
| 554 | - } |
|
| 555 | - elseif (preg_match(':^#S2:',$message)) { |
|
| 616 | + } elseif (preg_match(':^#S2:',$message)) { |
|
| 556 | 617 | $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
| 557 | - } |
|
| 558 | - elseif (preg_match(':^#SD:',$message)) { |
|
| 618 | + } elseif (preg_match(':^#SD:',$message)) { |
|
| 559 | 619 | $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
| 560 | - } |
|
| 561 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 620 | + } elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 562 | 621 | $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
| 563 | - } |
|
| 564 | - elseif (preg_match(':^#WO:',$message)) { |
|
| 622 | + } elseif (preg_match(':^#WO:',$message)) { |
|
| 565 | 623 | $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
| 566 | - } |
|
| 567 | - elseif (preg_match(':^#A1:',$message)) { |
|
| 624 | + } elseif (preg_match(':^#A1:',$message)) { |
|
| 568 | 625 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
| 569 | - } |
|
| 570 | - elseif (preg_match(':^#A3:',$message)) { |
|
| 626 | + } elseif (preg_match(':^#A3:',$message)) { |
|
| 571 | 627 | $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
| 572 | - } |
|
| 573 | - elseif (preg_match(':^#A4:',$message)) { |
|
| 628 | + } elseif (preg_match(':^#A4:',$message)) { |
|
| 574 | 629 | $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
| 575 | - } |
|
| 576 | - elseif (preg_match(':^#A6:',$message)) { |
|
| 630 | + } elseif (preg_match(':^#A6:',$message)) { |
|
| 577 | 631 | $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
| 578 | - } |
|
| 579 | - elseif (preg_match(':^#A8:',$message)) { |
|
| 632 | + } elseif (preg_match(':^#A8:',$message)) { |
|
| 580 | 633 | $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
| 581 | - } |
|
| 582 | - elseif (preg_match(':^#A9:',$message)) { |
|
| 634 | + } elseif (preg_match(':^#A9:',$message)) { |
|
| 583 | 635 | $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
| 584 | - } |
|
| 585 | - elseif (preg_match(':^#A0:',$message)) { |
|
| 636 | + } elseif (preg_match(':^#A0:',$message)) { |
|
| 586 | 637 | $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
| 587 | - } |
|
| 588 | - elseif (preg_match(':^#AA:',$message)) { |
|
| 638 | + } elseif (preg_match(':^#AA:',$message)) { |
|
| 589 | 639 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
| 590 | - } |
|
| 591 | - elseif (preg_match(':^#AB:',$message)) { |
|
| 640 | + } elseif (preg_match(':^#AB:',$message)) { |
|
| 592 | 641 | $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
| 593 | - } |
|
| 594 | - elseif (preg_match(':^#AC:',$message)) { |
|
| 642 | + } elseif (preg_match(':^#AC:',$message)) { |
|
| 595 | 643 | $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
| 596 | - } |
|
| 597 | - elseif (preg_match(':^#AD:',$message)) { |
|
| 644 | + } elseif (preg_match(':^#AD:',$message)) { |
|
| 598 | 645 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
| 599 | - } |
|
| 600 | - elseif (preg_match(':^#AF:',$message)) { |
|
| 646 | + } elseif (preg_match(':^#AF:',$message)) { |
|
| 601 | 647 | $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
| 602 | - } |
|
| 603 | - elseif (preg_match(':^#B1:',$message)) { |
|
| 648 | + } elseif (preg_match(':^#B1:',$message)) { |
|
| 604 | 649 | $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
| 605 | - } |
|
| 606 | - elseif (preg_match(':^#B2:',$message)) { |
|
| 650 | + } elseif (preg_match(':^#B2:',$message)) { |
|
| 607 | 651 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
| 608 | - } |
|
| 609 | - elseif (preg_match(':^#B3:',$message)) { |
|
| 652 | + } elseif (preg_match(':^#B3:',$message)) { |
|
| 610 | 653 | $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
| 611 | - } |
|
| 612 | - elseif (preg_match(':^#B4:',$message)) { |
|
| 654 | + } elseif (preg_match(':^#B4:',$message)) { |
|
| 613 | 655 | $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
| 614 | - } |
|
| 615 | - elseif (preg_match(':^#B6:',$message)) { |
|
| 656 | + } elseif (preg_match(':^#B6:',$message)) { |
|
| 616 | 657 | $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
| 617 | - } |
|
| 618 | - elseif (preg_match(':^#B8:',$message)) { |
|
| 658 | + } elseif (preg_match(':^#B8:',$message)) { |
|
| 619 | 659 | $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
| 620 | - } |
|
| 621 | - elseif (preg_match(':^#B9:',$message)) { |
|
| 660 | + } elseif (preg_match(':^#B9:',$message)) { |
|
| 622 | 661 | $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
| 623 | - } |
|
| 624 | - elseif (preg_match(':^#B0:',$message)) { |
|
| 662 | + } elseif (preg_match(':^#B0:',$message)) { |
|
| 625 | 663 | $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
| 626 | - } |
|
| 627 | - elseif (preg_match(':^#BA:',$message)) { |
|
| 664 | + } elseif (preg_match(':^#BA:',$message)) { |
|
| 628 | 665 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
| 629 | - } |
|
| 630 | - elseif (preg_match(':^#BB:',$message)) { |
|
| 666 | + } elseif (preg_match(':^#BB:',$message)) { |
|
| 631 | 667 | $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
| 632 | - } |
|
| 633 | - elseif (preg_match(':^#BC:',$message)) { |
|
| 668 | + } elseif (preg_match(':^#BC:',$message)) { |
|
| 634 | 669 | $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
| 635 | - } |
|
| 636 | - elseif (preg_match(':^#BD:',$message)) { |
|
| 670 | + } elseif (preg_match(':^#BD:',$message)) { |
|
| 637 | 671 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
| 638 | - } |
|
| 639 | - elseif (preg_match(':^#BE:',$message)) { |
|
| 672 | + } elseif (preg_match(':^#BE:',$message)) { |
|
| 640 | 673 | $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
| 641 | - } |
|
| 642 | - elseif (preg_match(':^#BF:',$message)) { |
|
| 674 | + } elseif (preg_match(':^#BF:',$message)) { |
|
| 643 | 675 | $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
| 644 | - } |
|
| 645 | - elseif (preg_match(':^#H3:',$message)) { |
|
| 676 | + } elseif (preg_match(':^#H3:',$message)) { |
|
| 646 | 677 | $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
| 647 | 678 | } |
| 648 | 679 | } |
| 649 | 680 | if ($label == '10') { |
| 650 | 681 | if (preg_match(':^DTO01:',$message)) { |
| 651 | 682 | $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
| 652 | - } |
|
| 653 | - elseif (preg_match(':^AIS01:',$message)) { |
|
| 683 | + } elseif (preg_match(':^AIS01:',$message)) { |
|
| 654 | 684 | $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
| 655 | - } |
|
| 656 | - elseif (preg_match(':^FTX01:',$message)) { |
|
| 685 | + } elseif (preg_match(':^FTX01:',$message)) { |
|
| 657 | 686 | $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
| 658 | - } |
|
| 659 | - elseif (preg_match(':^FPL01:',$message)) { |
|
| 687 | + } elseif (preg_match(':^FPL01:',$message)) { |
|
| 660 | 688 | $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
| 661 | - } |
|
| 662 | - elseif (preg_match(':^WAB01:',$message)) { |
|
| 689 | + } elseif (preg_match(':^WAB01:',$message)) { |
|
| 663 | 690 | $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
| 664 | - } |
|
| 665 | - elseif (preg_match(':^MET01:',$message)) { |
|
| 691 | + } elseif (preg_match(':^MET01:',$message)) { |
|
| 666 | 692 | $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
| 667 | - } |
|
| 668 | - elseif (preg_match(':^WAB02:',$message)) { |
|
| 693 | + } elseif (preg_match(':^WAB02:',$message)) { |
|
| 669 | 694 | $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
| 670 | 695 | } |
| 671 | 696 | } |
@@ -680,38 +705,28 @@ discard block |
||
| 680 | 705 | $vsta = array('Version' => $version); |
| 681 | 706 | if ($state == 'E') { |
| 682 | 707 | $vsta = array_merge($vsta,array('Link state' => 'Established')); |
| 683 | - } |
|
| 684 | - elseif ($state == 'L') { |
|
| 708 | + } elseif ($state == 'L') { |
|
| 685 | 709 | $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
| 686 | - } |
|
| 687 | - else { |
|
| 710 | + } else { |
|
| 688 | 711 | $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
| 689 | 712 | } |
| 690 | 713 | if ($type == 'V') { |
| 691 | 714 | $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
| 692 | - } |
|
| 693 | - elseif ($type == 'S') { |
|
| 715 | + } elseif ($type == 'S') { |
|
| 694 | 716 | $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
| 695 | - } |
|
| 696 | - elseif ($type == 'H') { |
|
| 717 | + } elseif ($type == 'H') { |
|
| 697 | 718 | $vsta = array_merge($vsta,array('Link type' => 'HF')); |
| 698 | - } |
|
| 699 | - elseif ($type == 'G') { |
|
| 719 | + } elseif ($type == 'G') { |
|
| 700 | 720 | $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
| 701 | - } |
|
| 702 | - elseif ($type == 'C') { |
|
| 721 | + } elseif ($type == 'C') { |
|
| 703 | 722 | $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
| 704 | - } |
|
| 705 | - elseif ($type == '2') { |
|
| 723 | + } elseif ($type == '2') { |
|
| 706 | 724 | $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
| 707 | - } |
|
| 708 | - elseif ($type == 'X') { |
|
| 725 | + } elseif ($type == 'X') { |
|
| 709 | 726 | $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
| 710 | - } |
|
| 711 | - elseif ($type == 'I') { |
|
| 727 | + } elseif ($type == 'I') { |
|
| 712 | 728 | $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
| 713 | - } |
|
| 714 | - else { |
|
| 729 | + } else { |
|
| 715 | 730 | $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
| 716 | 731 | } |
| 717 | 732 | $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
@@ -720,7 +735,9 @@ discard block |
||
| 720 | 735 | } |
| 721 | 736 | |
| 722 | 737 | $title = $this->getTitlefromLabel($label); |
| 723 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
| 738 | + if ($title != '') { |
|
| 739 | + $decode = array_merge(array('Message title' => $title),$decode); |
|
| 740 | + } |
|
| 724 | 741 | /* |
| 725 | 742 | // Business jets always use GS0001 |
| 726 | 743 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -756,31 +773,54 @@ discard block |
||
| 756 | 773 | $msg = $message['message']; |
| 757 | 774 | $decode = $message['decode']; |
| 758 | 775 | $registration = (string)$message['registration']; |
| 759 | - if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
|
| 760 | - else $latitude = ''; |
|
| 761 | - if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
|
| 762 | - else $longitude = ''; |
|
| 763 | - if (isset($decode['airicao'])) $airicao = $decode['airicao']; |
|
| 764 | - else $airicao = ''; |
|
| 765 | - if (isset($decode['icao'])) $icao = $decode['icao']; |
|
| 766 | - else $icao = $Translation->checkTranslation($ident); |
|
| 776 | + if (isset($decode['latitude'])) { |
|
| 777 | + $latitude = $decode['latitude']; |
|
| 778 | + } else { |
|
| 779 | + $latitude = ''; |
|
| 780 | + } |
|
| 781 | + if (isset($decode['longitude'])) { |
|
| 782 | + $longitude = $decode['longitude']; |
|
| 783 | + } else { |
|
| 784 | + $longitude = ''; |
|
| 785 | + } |
|
| 786 | + if (isset($decode['airicao'])) { |
|
| 787 | + $airicao = $decode['airicao']; |
|
| 788 | + } else { |
|
| 789 | + $airicao = ''; |
|
| 790 | + } |
|
| 791 | + if (isset($decode['icao'])) { |
|
| 792 | + $icao = $decode['icao']; |
|
| 793 | + } else { |
|
| 794 | + $icao = $Translation->checkTranslation($ident); |
|
| 795 | + } |
|
| 767 | 796 | $image_array = $Image->getSpotterImage($registration); |
| 768 | 797 | if (!isset($image_array[0]['registration'])) { |
| 769 | 798 | $Image->addSpotterImage($registration); |
| 770 | 799 | } |
| 771 | 800 | // Business jets always use GS0001 |
| 772 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 773 | - if ($globalDebug && isset($info) && $info != '') echo $info; |
|
| 774 | - if (count($decode) > 0) $decode_json = json_encode($decode); |
|
| 775 | - else $decode_json = ''; |
|
| 801 | + if ($ident != 'GS0001') { |
|
| 802 | + $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 803 | + } |
|
| 804 | + if ($globalDebug && isset($info) && $info != '') { |
|
| 805 | + echo $info; |
|
| 806 | + } |
|
| 807 | + if (count($decode) > 0) { |
|
| 808 | + $decode_json = json_encode($decode); |
|
| 809 | + } else { |
|
| 810 | + $decode_json = ''; |
|
| 811 | + } |
|
| 776 | 812 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
| 777 | 813 | $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
| 778 | 814 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
| 779 | 815 | $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
| 780 | 816 | } |
| 781 | 817 | $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
| 782 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 783 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 818 | + if (!isset($globalACARSArchive)) { |
|
| 819 | + $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 820 | + } |
|
| 821 | + if ($result && in_array($label,$globalACARSArchive)) { |
|
| 822 | + $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 823 | + } |
|
| 784 | 824 | if ($globalDebug && count($decode) > 0) { |
| 785 | 825 | echo "Human readable data : ".implode(' - ',$decode)."\n"; |
| 786 | 826 | } |
@@ -805,7 +845,9 @@ discard block |
||
| 805 | 845 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
| 806 | 846 | $Connection = new Connection($this->db); |
| 807 | 847 | $this->db = $Connection->db; |
| 808 | - if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
|
| 848 | + if ($globalDebug) { |
|
| 849 | + echo "Test if not already in Live ACARS table..."; |
|
| 850 | + } |
|
| 809 | 851 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
| 810 | 852 | $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
| 811 | 853 | try { |
@@ -816,7 +858,9 @@ discard block |
||
| 816 | 858 | return false; |
| 817 | 859 | } |
| 818 | 860 | if ($stht->fetchColumn() == 0) { |
| 819 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
| 861 | + if ($globalDebug) { |
|
| 862 | + echo "Add Live ACARS data..."; |
|
| 863 | + } |
|
| 820 | 864 | $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)"; |
| 821 | 865 | $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")); |
| 822 | 866 | try { |
@@ -827,10 +871,14 @@ discard block |
||
| 827 | 871 | return false; |
| 828 | 872 | } |
| 829 | 873 | } else { |
| 830 | - if ($globalDebug) echo "Data already in DB...\n"; |
|
| 874 | + if ($globalDebug) { |
|
| 875 | + echo "Data already in DB...\n"; |
|
| 876 | + } |
|
| 831 | 877 | return false; |
| 832 | 878 | } |
| 833 | - if ($globalDebug) echo "Done\n"; |
|
| 879 | + if ($globalDebug) { |
|
| 880 | + echo "Done\n"; |
|
| 881 | + } |
|
| 834 | 882 | return true; |
| 835 | 883 | } |
| 836 | 884 | return false; |
@@ -864,7 +912,9 @@ discard block |
||
| 864 | 912 | } |
| 865 | 913 | if ($stht->fetchColumn() == 0) { |
| 866 | 914 | */ |
| 867 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
| 915 | + if ($globalDebug) { |
|
| 916 | + echo "Add Live ACARS data..."; |
|
| 917 | + } |
|
| 868 | 918 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
| 869 | 919 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
| 870 | 920 | try { |
@@ -873,7 +923,9 @@ discard block |
||
| 873 | 923 | } catch(PDOException $e) { |
| 874 | 924 | return "error : ".$e->getMessage(); |
| 875 | 925 | } |
| 876 | - if ($globalDebug) echo "Done\n"; |
|
| 926 | + if ($globalDebug) { |
|
| 927 | + echo "Done\n"; |
|
| 928 | + } |
|
| 877 | 929 | } |
| 878 | 930 | return ''; |
| 879 | 931 | } |
@@ -897,8 +949,11 @@ discard block |
||
| 897 | 949 | return ''; |
| 898 | 950 | } |
| 899 | 951 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 900 | - if (count($row) > 0) return $row[0]['title']; |
|
| 901 | - else return ''; |
|
| 952 | + if (count($row) > 0) { |
|
| 953 | + return $row[0]['title']; |
|
| 954 | + } else { |
|
| 955 | + return ''; |
|
| 956 | + } |
|
| 902 | 957 | } |
| 903 | 958 | |
| 904 | 959 | /** |
@@ -917,8 +972,11 @@ discard block |
||
| 917 | 972 | return array(); |
| 918 | 973 | } |
| 919 | 974 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 920 | - if (count($row) > 0) return $row; |
|
| 921 | - else return array(); |
|
| 975 | + if (count($row) > 0) { |
|
| 976 | + return $row; |
|
| 977 | + } else { |
|
| 978 | + return array(); |
|
| 979 | + } |
|
| 922 | 980 | } |
| 923 | 981 | |
| 924 | 982 | /** |
@@ -938,8 +996,11 @@ discard block |
||
| 938 | 996 | return array(); |
| 939 | 997 | } |
| 940 | 998 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 941 | - if (count($row) > 0) return $row[0]; |
|
| 942 | - else return array(); |
|
| 999 | + if (count($row) > 0) { |
|
| 1000 | + return $row[0]; |
|
| 1001 | + } else { |
|
| 1002 | + return array(); |
|
| 1003 | + } |
|
| 943 | 1004 | } |
| 944 | 1005 | |
| 945 | 1006 | /** |
@@ -987,19 +1048,35 @@ discard block |
||
| 987 | 1048 | if ($row['registration'] != '') { |
| 988 | 1049 | $row['registration'] = str_replace('.','',$row['registration']); |
| 989 | 1050 | $image_array = $Image->getSpotterImage($row['registration']); |
| 990 | - 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'])); |
|
| 991 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 992 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 993 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 994 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 1051 | + if (count($image_array) > 0) { |
|
| 1052 | + $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'])); |
|
| 1053 | + } else { |
|
| 1054 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1055 | + } |
|
| 1056 | + } else { |
|
| 1057 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1058 | + } |
|
| 1059 | + if ($row['registration'] == '') { |
|
| 1060 | + $row['registration'] = 'NA'; |
|
| 1061 | + } |
|
| 1062 | + if ($row['ident'] == '') { |
|
| 1063 | + $row['ident'] = 'NA'; |
|
| 1064 | + } |
|
| 995 | 1065 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
| 996 | 1066 | if (isset($identicao[0])) { |
| 997 | 1067 | if (substr($row['ident'],0,2) == 'AF') { |
| 998 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 999 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1000 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1068 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 1069 | + $icao = $row['ident']; |
|
| 1070 | + } else { |
|
| 1071 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1072 | + } |
|
| 1073 | + } else { |
|
| 1074 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1075 | + } |
|
| 1001 | 1076 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 1002 | - } else $icao = $row['ident']; |
|
| 1077 | + } else { |
|
| 1078 | + $icao = $row['ident']; |
|
| 1079 | + } |
|
| 1003 | 1080 | $icao = $Translation->checkTranslation($icao,false); |
| 1004 | 1081 | $decode = json_decode($row['decode'],true); |
| 1005 | 1082 | $found = false; |
@@ -1024,7 +1101,9 @@ discard block |
||
| 1024 | 1101 | $found = true; |
| 1025 | 1102 | } |
| 1026 | 1103 | } |
| 1027 | - if ($found) $row['decode'] = json_encode($decode); |
|
| 1104 | + if ($found) { |
|
| 1105 | + $row['decode'] = json_encode($decode); |
|
| 1106 | + } |
|
| 1028 | 1107 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
| 1029 | 1108 | $result[] = $data; |
| 1030 | 1109 | $i++; |
@@ -1032,8 +1111,9 @@ discard block |
||
| 1032 | 1111 | if (isset($result)) { |
| 1033 | 1112 | $result[0]['query_number_rows'] = $i; |
| 1034 | 1113 | return $result; |
| 1114 | + } else { |
|
| 1115 | + return array(); |
|
| 1035 | 1116 | } |
| 1036 | - else return array(); |
|
| 1037 | 1117 | } |
| 1038 | 1118 | |
| 1039 | 1119 | /** |
@@ -1086,31 +1166,51 @@ discard block |
||
| 1086 | 1166 | if ($row['registration'] != '') { |
| 1087 | 1167 | $row['registration'] = str_replace('.','',$row['registration']); |
| 1088 | 1168 | $image_array = $Image->getSpotterImage($row['registration']); |
| 1089 | - 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'])); |
|
| 1090 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1091 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1169 | + if (count($image_array) > 0) { |
|
| 1170 | + $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'])); |
|
| 1171 | + } else { |
|
| 1172 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1173 | + } |
|
| 1174 | + } else { |
|
| 1175 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1176 | + } |
|
| 1092 | 1177 | $icao = ''; |
| 1093 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 1094 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 1178 | + if ($row['registration'] == '') { |
|
| 1179 | + $row['registration'] = 'NA'; |
|
| 1180 | + } |
|
| 1181 | + if ($row['ident'] == '') { |
|
| 1182 | + $row['ident'] = 'NA'; |
|
| 1183 | + } |
|
| 1095 | 1184 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
| 1096 | 1185 | if (isset($identicao[0])) { |
| 1097 | 1186 | if (substr($row['ident'],0,2) == 'AF') { |
| 1098 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 1099 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1100 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1187 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 1188 | + $icao = $row['ident']; |
|
| 1189 | + } else { |
|
| 1190 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1191 | + } |
|
| 1192 | + } else { |
|
| 1193 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1194 | + } |
|
| 1101 | 1195 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 1102 | - } else $icao = $row['ident']; |
|
| 1196 | + } else { |
|
| 1197 | + $icao = $row['ident']; |
|
| 1198 | + } |
|
| 1103 | 1199 | $icao = $Translation->checkTranslation($icao); |
| 1104 | 1200 | $decode = json_decode($row['decode'],true); |
| 1105 | 1201 | $found = false; |
| 1106 | 1202 | if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
| 1107 | 1203 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
| 1108 | - 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>'; |
|
| 1204 | + if (isset($airport_info[0]['icao'])) { |
|
| 1205 | + $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1206 | + } |
|
| 1109 | 1207 | $found = true; |
| 1110 | 1208 | } |
| 1111 | 1209 | if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
| 1112 | 1210 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
| 1113 | - 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>'; |
|
| 1211 | + if (isset($airport_info[0]['icao'])) { |
|
| 1212 | + $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1213 | + } |
|
| 1114 | 1214 | $found = true; |
| 1115 | 1215 | } |
| 1116 | 1216 | if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
@@ -1120,7 +1220,9 @@ discard block |
||
| 1120 | 1220 | $found = true; |
| 1121 | 1221 | } |
| 1122 | 1222 | } |
| 1123 | - if ($found) $row['decode'] = json_encode($decode); |
|
| 1223 | + if ($found) { |
|
| 1224 | + $row['decode'] = json_encode($decode); |
|
| 1225 | + } |
|
| 1124 | 1226 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
| 1125 | 1227 | $result[] = $data; |
| 1126 | 1228 | $i++; |
@@ -1128,7 +1230,9 @@ discard block |
||
| 1128 | 1230 | if (!empty($result)) { |
| 1129 | 1231 | $result[0]['query_number_rows'] = $i; |
| 1130 | 1232 | return $result; |
| 1131 | - } else return array(); |
|
| 1233 | + } else { |
|
| 1234 | + return array(); |
|
| 1235 | + } |
|
| 1132 | 1236 | } |
| 1133 | 1237 | |
| 1134 | 1238 | /** |
@@ -1147,25 +1251,37 @@ discard block |
||
| 1147 | 1251 | $ident = trim($ident); |
| 1148 | 1252 | $Translation = new Translation($this->db); |
| 1149 | 1253 | $Spotter = new Spotter($this->db); |
| 1150 | - if ($globalDebug) echo "Test if we add ModeS data..."; |
|
| 1254 | + if ($globalDebug) { |
|
| 1255 | + echo "Test if we add ModeS data..."; |
|
| 1256 | + } |
|
| 1151 | 1257 | //if ($icao == '') $icao = ACARS->ident2icao($ident); |
| 1152 | - if ($icao == '') $icao = $Translation->checkTranslation($ident); |
|
| 1153 | - if ($globalDebug) echo '- Ident : '.$icao.' - '; |
|
| 1258 | + if ($icao == '') { |
|
| 1259 | + $icao = $Translation->checkTranslation($ident); |
|
| 1260 | + } |
|
| 1261 | + if ($globalDebug) { |
|
| 1262 | + echo '- Ident : '.$icao.' - '; |
|
| 1263 | + } |
|
| 1154 | 1264 | if ($ident == '' || $registration == '') { |
| 1155 | - if ($globalDebug) echo "Ident or registration null, exit\n"; |
|
| 1265 | + if ($globalDebug) { |
|
| 1266 | + echo "Ident or registration null, exit\n"; |
|
| 1267 | + } |
|
| 1156 | 1268 | return ''; |
| 1157 | 1269 | } |
| 1158 | 1270 | $registration = str_replace('.','',$registration); |
| 1159 | 1271 | $ident = $Translation->ident2icao($ident); |
| 1160 | 1272 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
| 1161 | - if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
|
| 1273 | + if ($globalDebug) { |
|
| 1274 | + echo "Check if needed to add translation ".$ident.'... '; |
|
| 1275 | + } |
|
| 1162 | 1276 | $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"; |
| 1163 | 1277 | $querysi_values = array(':registration' => $registration); |
| 1164 | 1278 | try { |
| 1165 | 1279 | $sthsi = $this->db->prepare($querysi); |
| 1166 | 1280 | $sthsi->execute($querysi_values); |
| 1167 | 1281 | } catch(PDOException $e) { |
| 1168 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1282 | + if ($globalDebug) { |
|
| 1283 | + echo $e->getMessage(); |
|
| 1284 | + } |
|
| 1169 | 1285 | return "error : ".$e->getMessage(); |
| 1170 | 1286 | } |
| 1171 | 1287 | $resultsi = $sthsi->fetch(PDO::FETCH_ASSOC); |
@@ -1173,9 +1289,14 @@ discard block |
||
| 1173 | 1289 | if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') { |
| 1174 | 1290 | $Translation = new Translation($this->db); |
| 1175 | 1291 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
| 1176 | - if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
| 1177 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1178 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1292 | + if ($globalDebug) { |
|
| 1293 | + echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
| 1294 | + } |
|
| 1295 | + if ($ident != $trans_ident) { |
|
| 1296 | + $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1297 | + } elseif ($trans_ident == $ident) { |
|
| 1298 | + $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1299 | + } |
|
| 1179 | 1300 | } else { |
| 1180 | 1301 | if ($registration != '' && $latitude != '' && $longitude != '') { |
| 1181 | 1302 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1184,32 +1305,46 @@ discard block |
||
| 1184 | 1305 | $sth = $this->db->prepare($query); |
| 1185 | 1306 | $sth->execute($query_values); |
| 1186 | 1307 | } catch(PDOException $e) { |
| 1187 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1308 | + if ($globalDebug) { |
|
| 1309 | + echo $e->getMessage(); |
|
| 1310 | + } |
|
| 1188 | 1311 | return "error : ".$e->getMessage(); |
| 1189 | 1312 | } |
| 1190 | 1313 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 1191 | 1314 | $sth->closeCursor(); |
| 1192 | - if (isset($result['modes'])) $hex = $result['modes']; |
|
| 1193 | - else $hex = ''; |
|
| 1315 | + if (isset($result['modes'])) { |
|
| 1316 | + $hex = $result['modes']; |
|
| 1317 | + } else { |
|
| 1318 | + $hex = ''; |
|
| 1319 | + } |
|
| 1194 | 1320 | $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
| 1195 | - if ($this->fromACARSscript) $this->SI->add($SI_data); |
|
| 1321 | + if ($this->fromACARSscript) { |
|
| 1322 | + $this->SI->add($SI_data); |
|
| 1323 | + } |
|
| 1196 | 1324 | } |
| 1197 | 1325 | } |
| 1198 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 1326 | + if ($globalDebug) { |
|
| 1327 | + echo 'Done'."\n"; |
|
| 1328 | + } |
|
| 1199 | 1329 | $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1"; |
| 1200 | 1330 | $query_values = array(':ident' => $icao); |
| 1201 | 1331 | try { |
| 1202 | 1332 | $sth = $this->db->prepare($query); |
| 1203 | 1333 | $sth->execute($query_values); |
| 1204 | 1334 | } catch(PDOException $e) { |
| 1205 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1335 | + if ($globalDebug) { |
|
| 1336 | + echo $e->getMessage(); |
|
| 1337 | + } |
|
| 1206 | 1338 | return "error : ".$e->getMessage(); |
| 1207 | 1339 | } |
| 1208 | 1340 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 1209 | 1341 | $sth->closeCursor(); |
| 1210 | 1342 | if (isset($result['flightaware_id'])) { |
| 1211 | - if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
|
| 1212 | - else $ModeS = ''; |
|
| 1343 | + if (isset($result['ModeS'])) { |
|
| 1344 | + $ModeS = $result['ModeS']; |
|
| 1345 | + } else { |
|
| 1346 | + $ModeS = ''; |
|
| 1347 | + } |
|
| 1213 | 1348 | if ($ModeS == '') { |
| 1214 | 1349 | $id = explode('-',$result['flightaware_id']); |
| 1215 | 1350 | $ModeS = $id[0]; |
@@ -1222,24 +1357,32 @@ discard block |
||
| 1222 | 1357 | $sthc = $this->db->prepare($queryc); |
| 1223 | 1358 | $sthc->execute($queryc_values); |
| 1224 | 1359 | } catch(PDOException $e) { |
| 1225 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1360 | + if ($globalDebug) { |
|
| 1361 | + echo $e->getMessage(); |
|
| 1362 | + } |
|
| 1226 | 1363 | return "error : ".$e->getMessage(); |
| 1227 | 1364 | } |
| 1228 | 1365 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
| 1229 | 1366 | $sthc->closeCursor(); |
| 1230 | 1367 | if (count($row) == 0) { |
| 1231 | - if ($globalDebug) echo " Add to ModeS table - "; |
|
| 1368 | + if ($globalDebug) { |
|
| 1369 | + echo " Add to ModeS table - "; |
|
| 1370 | + } |
|
| 1232 | 1371 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
| 1233 | 1372 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
| 1234 | 1373 | try { |
| 1235 | 1374 | $sthi = $this->db->prepare($queryi); |
| 1236 | 1375 | $sthi->execute($queryi_values); |
| 1237 | 1376 | } catch(PDOException $e) { |
| 1238 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1377 | + if ($globalDebug) { |
|
| 1378 | + echo $e->getMessage(); |
|
| 1379 | + } |
|
| 1239 | 1380 | return "error : ".$e->getMessage(); |
| 1240 | 1381 | } |
| 1241 | 1382 | } else { |
| 1242 | - if ($globalDebug) echo " Update ModeS table - "; |
|
| 1383 | + if ($globalDebug) { |
|
| 1384 | + echo " Update ModeS table - "; |
|
| 1385 | + } |
|
| 1243 | 1386 | if ($ICAOTypeCode != '') { |
| 1244 | 1387 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
| 1245 | 1388 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
@@ -1251,7 +1394,9 @@ discard block |
||
| 1251 | 1394 | $sthi = $this->db->prepare($queryi); |
| 1252 | 1395 | $sthi->execute($queryi_values); |
| 1253 | 1396 | } catch(PDOException $e) { |
| 1254 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1397 | + if ($globalDebug) { |
|
| 1398 | + echo $e->getMessage(); |
|
| 1399 | + } |
|
| 1255 | 1400 | return "error : ".$e->getMessage(); |
| 1256 | 1401 | } |
| 1257 | 1402 | } |
@@ -1272,7 +1417,9 @@ discard block |
||
| 1272 | 1417 | return "error : ".$e->getMessage(); |
| 1273 | 1418 | } |
| 1274 | 1419 | */ |
| 1275 | - if ($globalDebug) echo " Update Spotter_output table - "; |
|
| 1420 | + if ($globalDebug) { |
|
| 1421 | + echo " Update Spotter_output table - "; |
|
| 1422 | + } |
|
| 1276 | 1423 | if ($ICAOTypeCode != '') { |
| 1277 | 1424 | if ($globalDBdriver == 'mysql') { |
| 1278 | 1425 | $queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
@@ -1283,8 +1430,7 @@ discard block |
||
| 1283 | 1430 | } else { |
| 1284 | 1431 | if ($globalDBdriver == 'mysql') { |
| 1285 | 1432 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
| 1286 | - } |
|
| 1287 | - elseif ($globalDBdriver == 'pgsql') { |
|
| 1433 | + } elseif ($globalDBdriver == 'pgsql') { |
|
| 1288 | 1434 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
| 1289 | 1435 | } |
| 1290 | 1436 | $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
@@ -1293,14 +1439,20 @@ discard block |
||
| 1293 | 1439 | $sthi = $this->db->prepare($queryi); |
| 1294 | 1440 | $sthi->execute($queryi_values); |
| 1295 | 1441 | } catch(PDOException $e) { |
| 1296 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1442 | + if ($globalDebug) { |
|
| 1443 | + echo $e->getMessage(); |
|
| 1444 | + } |
|
| 1297 | 1445 | return "error : ".$e->getMessage(); |
| 1298 | 1446 | } |
| 1299 | 1447 | } |
| 1300 | 1448 | } else { |
| 1301 | - if ($globalDebug) echo " Can't find ModeS in spotter_output - "; |
|
| 1449 | + if ($globalDebug) { |
|
| 1450 | + echo " Can't find ModeS in spotter_output - "; |
|
| 1451 | + } |
|
| 1452 | + } |
|
| 1453 | + if ($globalDebug) { |
|
| 1454 | + echo "Done\n"; |
|
| 1302 | 1455 | } |
| 1303 | - if ($globalDebug) echo "Done\n"; |
|
| 1304 | 1456 | return ''; |
| 1305 | 1457 | } |
| 1306 | 1458 | } |
@@ -22,7 +22,9 @@ discard block |
||
| 22 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 25 | +if (!isset($globalDebug)) { |
|
| 26 | + $globalDebug = FALSE; |
|
| 27 | +} |
|
| 26 | 28 | |
| 27 | 29 | if ($globalInstalled === FALSE) { |
| 28 | 30 | echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
@@ -68,66 +70,107 @@ discard block |
||
| 68 | 70 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 69 | 71 | if (isset($options['s'])) { |
| 70 | 72 | $globalSources = array(); |
| 71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 72 | - else $globalSources[] = array('host' => $options['s']); |
|
| 73 | -} elseif (isset($options['source'])) { |
|
| 73 | + if (isset($options['format'])) { |
|
| 74 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 75 | + } else { |
|
| 76 | + $globalSources[] = array('host' => $options['s']); |
|
| 77 | + } |
|
| 78 | + } elseif (isset($options['source'])) { |
|
| 74 | 79 | $globalSources = array(); |
| 75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 76 | - else $globalSources[] = array('host' => $options['source']); |
|
| 77 | -} |
|
| 80 | + if (isset($options['format'])) { |
|
| 81 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 82 | + } else { |
|
| 83 | + $globalSources[] = array('host' => $options['source']); |
|
| 84 | + } |
|
| 85 | + } |
|
| 78 | 86 | if (isset($options['aprsserverhost'])) { |
| 79 | 87 | $globalServerAPRS = TRUE; |
| 80 | 88 | $globalServerAPRShost = $options['aprsserverhost']; |
| 81 | 89 | } |
| 82 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
| 83 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 84 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 85 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
| 90 | +if (isset($options['aprsserverport'])) { |
|
| 91 | + $globalServerAPRSport = $options['aprsserverport']; |
|
| 92 | +} |
|
| 93 | +if (isset($options['aprsserverssid'])) { |
|
| 94 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 95 | +} |
|
| 96 | +if (isset($options['aprsserverpass'])) { |
|
| 97 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 98 | +} |
|
| 99 | +if (isset($options['noaprsserver'])) { |
|
| 100 | + $globalServerAPRS = FALSE; |
|
| 101 | +} |
|
| 86 | 102 | if (isset($options['enable-aircraft'])) { |
| 87 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
| 103 | + if ($globalDebug) { |
|
| 104 | + echo 'Enable Aircraft mode'."\n"; |
|
| 105 | + } |
|
| 88 | 106 | $globalAircraft = TRUE; |
| 89 | 107 | } |
| 90 | 108 | if (isset($options['disable-aircraft'])) { |
| 91 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
| 109 | + if ($globalDebug) { |
|
| 110 | + echo 'Disable Aircraft mode'."\n"; |
|
| 111 | + } |
|
| 92 | 112 | $globalAircraft = FALSE; |
| 93 | 113 | } |
| 94 | 114 | if (isset($options['enable-tracker'])) { |
| 95 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
| 115 | + if ($globalDebug) { |
|
| 116 | + echo 'Enable Tracker mode'."\n"; |
|
| 117 | + } |
|
| 96 | 118 | $globalTracker = TRUE; |
| 97 | 119 | } |
| 98 | 120 | if (isset($options['disable-tracker'])) { |
| 99 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
| 121 | + if ($globalDebug) { |
|
| 122 | + echo 'Disable Tracker mode'."\n"; |
|
| 123 | + } |
|
| 100 | 124 | $globalTracker = FALSE; |
| 101 | 125 | } |
| 102 | 126 | if (isset($options['enable-marine'])) { |
| 103 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
| 127 | + if ($globalDebug) { |
|
| 128 | + echo 'Enable Marine mode'."\n"; |
|
| 129 | + } |
|
| 104 | 130 | $globalMarine = TRUE; |
| 105 | 131 | } |
| 106 | 132 | if (isset($options['disable-marine'])) { |
| 107 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
| 133 | + if ($globalDebug) { |
|
| 134 | + echo 'Disable Marine mode'."\n"; |
|
| 135 | + } |
|
| 108 | 136 | $globalMarine = FALSE; |
| 109 | 137 | } |
| 110 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 111 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 112 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 113 | -else $id_source = 1; |
|
| 138 | +if (isset($options['nodaemon'])) { |
|
| 139 | + $globalDaemon = FALSE; |
|
| 140 | +} |
|
| 141 | +if (isset($options['server'])) { |
|
| 142 | + $globalServer = TRUE; |
|
| 143 | +} |
|
| 144 | +if (isset($options['idsource'])) { |
|
| 145 | + $id_source = $options['idsource']; |
|
| 146 | +} else { |
|
| 147 | + $id_source = 1; |
|
| 148 | +} |
|
| 114 | 149 | if (isset($globalServer) && $globalServer) { |
| 115 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 150 | + if ($globalDebug) { |
|
| 151 | + echo "Using Server Mode\n"; |
|
| 152 | + } |
|
| 116 | 153 | $SI=new SpotterServer(); |
| 117 | 154 | /* |
| 118 | 155 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 119 | 156 | $SI = new adsb2aprs(); |
| 120 | 157 | $SI->connect(); |
| 121 | 158 | */ |
| 122 | -} else $SI=new SpotterImport($Connection->db); |
|
| 159 | +} else { |
|
| 160 | + $SI=new SpotterImport($Connection->db); |
|
| 161 | +} |
|
| 123 | 162 | |
| 124 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 163 | +if (isset($globalTracker) && $globalTracker) { |
|
| 164 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 165 | +} |
|
| 125 | 166 | if (isset($globalMarine) && $globalMarine) { |
| 126 | 167 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 127 | 168 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 128 | 169 | } |
| 129 | 170 | |
| 130 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 171 | +if (isset($globalTracker) && $globalTracker) { |
|
| 172 | + $TI = new TrackerImport($Connection->db); |
|
| 173 | +} |
|
| 131 | 174 | if (isset($globalMarine) && $globalMarine) { |
| 132 | 175 | $AIS = new AIS(); |
| 133 | 176 | $MI = new MarineImport($Connection->db); |
@@ -152,7 +195,9 @@ discard block |
||
| 152 | 195 | } |
| 153 | 196 | |
| 154 | 197 | // let's try and connect |
| 155 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 198 | +if ($globalDebug) { |
|
| 199 | + echo "Connecting...\n"; |
|
| 200 | +} |
|
| 156 | 201 | $use_aprs = false; |
| 157 | 202 | $aprs_full = false; |
| 158 | 203 | $reset = 0; |
@@ -161,7 +206,9 @@ discard block |
||
| 161 | 206 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 162 | 207 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 163 | 208 | $reset++; |
| 164 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 209 | + if ($globalDebug) { |
|
| 210 | + echo 'Connect to all...'."\n"; |
|
| 211 | + } |
|
| 165 | 212 | foreach ($hosts as $id => $value) { |
| 166 | 213 | $host = $value['host']; |
| 167 | 214 | $udp = false; |
@@ -172,32 +219,44 @@ discard block |
||
| 172 | 219 | //$formats[$id] = 'deltadbtxt'; |
| 173 | 220 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 174 | 221 | //$last_exec['deltadbtxt'] = 0; |
| 175 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 222 | + if ($globalDebug) { |
|
| 223 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 224 | + } |
|
| 176 | 225 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 177 | 226 | //$formats[$id] = 'vatsimtxt'; |
| 178 | 227 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 179 | 228 | //$last_exec['vatsimtxt'] = 0; |
| 180 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 229 | + if ($globalDebug) { |
|
| 230 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 231 | + } |
|
| 181 | 232 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 182 | 233 | //$formats[$id] = 'aircraftlistjson'; |
| 183 | 234 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 184 | 235 | //$last_exec['aircraftlistjson'] = 0; |
| 185 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 236 | + if ($globalDebug) { |
|
| 237 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 238 | + } |
|
| 186 | 239 | } else if (preg_match('/aircraft.json$/i',$host)) { |
| 187 | 240 | //$formats[$id] = 'aircraftjson'; |
| 188 | 241 | $globalSources[$id]['format'] = 'aircraftjson'; |
| 189 | 242 | //$last_exec['aircraftlistjson'] = 0; |
| 190 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 243 | + if ($globalDebug) { |
|
| 244 | + echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 245 | + } |
|
| 191 | 246 | } else if (preg_match('/aircraft$/i',$host)) { |
| 192 | 247 | //$formats[$id] = 'planefinderclient'; |
| 193 | 248 | $globalSources[$id]['format'] = 'planefinderclient'; |
| 194 | 249 | //$last_exec['aircraftlistjson'] = 0; |
| 195 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 250 | + if ($globalDebug) { |
|
| 251 | + echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 252 | + } |
|
| 196 | 253 | } else if (preg_match('/opensky/i',$host)) { |
| 197 | 254 | //$formats[$id] = 'aircraftlistjson'; |
| 198 | 255 | $globalSources[$id]['format'] = 'opensky'; |
| 199 | 256 | //$last_exec['aircraftlistjson'] = 0; |
| 200 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 257 | + if ($globalDebug) { |
|
| 258 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 259 | + } |
|
| 201 | 260 | /* |
| 202 | 261 | // Disabled for now, site change source format |
| 203 | 262 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -214,7 +273,9 @@ discard block |
||
| 214 | 273 | //$formats[$id] = 'planeupdatefaa'; |
| 215 | 274 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 216 | 275 | //$last_exec['planeupdatefaa'] = 0; |
| 217 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 276 | + if ($globalDebug) { |
|
| 277 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 278 | + } |
|
| 218 | 279 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 219 | 280 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 220 | 281 | exit(0); |
@@ -223,37 +284,53 @@ discard block |
||
| 223 | 284 | //$formats[$id] = 'phpvmacars'; |
| 224 | 285 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 225 | 286 | //$last_exec['phpvmacars'] = 0; |
| 226 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 287 | + if ($globalDebug) { |
|
| 288 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 289 | + } |
|
| 227 | 290 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
| 228 | 291 | //$formats[$id] = 'phpvmacars'; |
| 229 | 292 | $globalSources[$id]['format'] = 'vaos'; |
| 230 | 293 | //$last_exec['phpvmacars'] = 0; |
| 231 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 294 | + if ($globalDebug) { |
|
| 295 | + echo "Connect to vaos source (".$host.")...\n"; |
|
| 296 | + } |
|
| 232 | 297 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 233 | 298 | //$formats[$id] = 'phpvmacars'; |
| 234 | 299 | $globalSources[$id]['format'] = 'vam'; |
| 235 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 300 | + if ($globalDebug) { |
|
| 301 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 302 | + } |
|
| 236 | 303 | } else if (preg_match('/whazzup/i',$host)) { |
| 237 | 304 | //$formats[$id] = 'whazzup'; |
| 238 | 305 | $globalSources[$id]['format'] = 'whazzup'; |
| 239 | 306 | //$last_exec['whazzup'] = 0; |
| 240 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 307 | + if ($globalDebug) { |
|
| 308 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 309 | + } |
|
| 241 | 310 | } else if (preg_match('/blitzortung/i',$host)) { |
| 242 | 311 | $globalSources[$id]['format'] = 'blitzortung'; |
| 243 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 312 | + if ($globalDebug) { |
|
| 313 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 314 | + } |
|
| 244 | 315 | } else if (preg_match('/airwhere/i',$host)) { |
| 245 | 316 | $globalSources[$id]['format'] = 'airwhere'; |
| 246 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 317 | + if ($globalDebug) { |
|
| 318 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
| 319 | + } |
|
| 247 | 320 | } else if (preg_match('/recentpireps/i',$host)) { |
| 248 | 321 | //$formats[$id] = 'pirepsjson'; |
| 249 | 322 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 250 | 323 | //$last_exec['pirepsjson'] = 0; |
| 251 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 324 | + if ($globalDebug) { |
|
| 325 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 326 | + } |
|
| 252 | 327 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 253 | 328 | //$formats[$id] = 'fr24json'; |
| 254 | 329 | $globalSources[$id]['format'] = 'fr24json'; |
| 255 | 330 | //$last_exec['fr24json'] = 0; |
| 256 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 331 | + if ($globalDebug) { |
|
| 332 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 333 | + } |
|
| 257 | 334 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 258 | 335 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 259 | 336 | exit(0); |
@@ -262,7 +339,9 @@ discard block |
||
| 262 | 339 | //$formats[$id] = 'fr24json'; |
| 263 | 340 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 264 | 341 | //$last_exec['fr24json'] = 0; |
| 265 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 342 | + if ($globalDebug) { |
|
| 343 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 344 | + } |
|
| 266 | 345 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 267 | 346 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 268 | 347 | exit(0); |
@@ -271,17 +350,26 @@ discard block |
||
| 271 | 350 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 272 | 351 | //$formats[$id] = 'tsv'; |
| 273 | 352 | $globalSources[$id]['format'] = 'tsv'; |
| 274 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 353 | + if ($globalDebug) { |
|
| 354 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 355 | + } |
|
| 275 | 356 | } |
| 276 | 357 | } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
| 277 | 358 | if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
| 278 | 359 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 279 | 360 | if ($idf !== false) { |
| 280 | 361 | $httpfeeds[$id] = $idf; |
| 281 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 282 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 283 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 284 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 362 | + if ($globalDebug) { |
|
| 363 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 364 | + } |
|
| 365 | + } elseif ($globalDebug) { |
|
| 366 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 367 | + } |
|
| 368 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') { |
|
| 369 | + echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 370 | + } elseif ($globalDebug) { |
|
| 371 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 372 | + } |
|
| 285 | 373 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 286 | 374 | $hostport = explode(':',$host); |
| 287 | 375 | if (isset($hostport[1])) { |
@@ -322,20 +410,29 @@ discard block |
||
| 322 | 410 | //$formats[$id] = 'beast'; |
| 323 | 411 | $globalSources[$id]['format'] = 'beast'; |
| 324 | 412 | //} else $formats[$id] = 'sbs'; |
| 325 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 413 | + } else { |
|
| 414 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 415 | + } |
|
| 326 | 416 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 327 | 417 | } |
| 328 | - if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 329 | - elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 418 | + if ($globalDebug && $udp) { |
|
| 419 | + echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 420 | + } elseif ($globalDebug) { |
|
| 421 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 422 | + } |
|
| 330 | 423 | } else { |
| 331 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 424 | + if ($globalDebug) { |
|
| 425 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 426 | + } |
|
| 332 | 427 | sleep(10); |
| 333 | 428 | connect_all($hosts); |
| 334 | 429 | } |
| 335 | 430 | } |
| 336 | 431 | } |
| 337 | 432 | } |
| 338 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 433 | +if (!isset($globalMinFetch)) { |
|
| 434 | + $globalMinFetch = 15; |
|
| 435 | +} |
|
| 339 | 436 | |
| 340 | 437 | // Initialize all |
| 341 | 438 | $status = array(); |
@@ -344,13 +441,19 @@ discard block |
||
| 344 | 441 | $formats = array(); |
| 345 | 442 | $last_exec = array(); |
| 346 | 443 | $time = time(); |
| 347 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 348 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 349 | -else $timeout = 20; |
|
| 444 | +if (isset($globalSourcesTimeout)) { |
|
| 445 | + $timeout = $globalSourcesTimeOut; |
|
| 446 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 447 | + $timeout = $globalSBS1TimeOut; |
|
| 448 | +} else { |
|
| 449 | + $timeout = 20; |
|
| 450 | +} |
|
| 350 | 451 | $errno = ''; |
| 351 | 452 | $errstr=''; |
| 352 | 453 | |
| 353 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 454 | +if (!isset($globalDaemon)) { |
|
| 455 | + $globalDaemon = TRUE; |
|
| 456 | +} |
|
| 354 | 457 | /* Initiate connections to all the hosts simultaneously */ |
| 355 | 458 | //connect_all($hosts); |
| 356 | 459 | //connect_all($globalSources); |
@@ -379,7 +482,9 @@ discard block |
||
| 379 | 482 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 380 | 483 | $aprs_connect = 0; |
| 381 | 484 | $use_aprs = true; |
| 382 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 485 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 486 | + $aprs_full = true; |
|
| 487 | + } |
|
| 383 | 488 | break; |
| 384 | 489 | } |
| 385 | 490 | } |
@@ -390,25 +495,46 @@ discard block |
||
| 390 | 495 | $aprs_connect = 0; |
| 391 | 496 | $aprs_keep = 120; |
| 392 | 497 | $aprs_last_tx = time(); |
| 393 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 394 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 395 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 396 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 397 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 398 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 399 | - if ($aprs_full) $aprs_filter = ''; |
|
| 400 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 401 | - else $aprs_pass = '-1'; |
|
| 498 | + if (isset($globalAPRSversion)) { |
|
| 499 | + $aprs_version = $globalAPRSversion; |
|
| 500 | + } else { |
|
| 501 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 502 | + } |
|
| 503 | + if (isset($globalAPRSssid)) { |
|
| 504 | + $aprs_ssid = $globalAPRSssid; |
|
| 505 | + } else { |
|
| 506 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 507 | + } |
|
| 508 | + if (isset($globalAPRSfilter)) { |
|
| 509 | + $aprs_filter = $globalAPRSfilter; |
|
| 510 | + } else { |
|
| 511 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 512 | + } |
|
| 513 | + if ($aprs_full) { |
|
| 514 | + $aprs_filter = ''; |
|
| 515 | + } |
|
| 516 | + if (isset($globalAPRSpass)) { |
|
| 517 | + $aprs_pass = $globalAPRSpass; |
|
| 518 | + } else { |
|
| 519 | + $aprs_pass = '-1'; |
|
| 520 | + } |
|
| 402 | 521 | |
| 403 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 404 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 405 | -} |
|
| 522 | + if ($aprs_filter != '') { |
|
| 523 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 524 | + } else { |
|
| 525 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 526 | + } |
|
| 527 | + } |
|
| 406 | 528 | |
| 407 | 529 | // connected - lets do some work |
| 408 | 530 | //if ($globalDebug) echo "Connected!\n"; |
| 409 | 531 | sleep(1); |
| 410 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 411 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 532 | +if ($globalDebug) { |
|
| 533 | + echo "SCAN MODE \n\n"; |
|
| 534 | +} |
|
| 535 | +if (!isset($globalCronEnd)) { |
|
| 536 | + $globalCronEnd = 60; |
|
| 537 | +} |
|
| 412 | 538 | $endtime = time()+$globalCronEnd; |
| 413 | 539 | $i = 1; |
| 414 | 540 | $tt = array(); |
@@ -422,22 +548,32 @@ discard block |
||
| 422 | 548 | |
| 423 | 549 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 424 | 550 | while ($i > 0) { |
| 425 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 551 | + if (function_exists('pcntl_fork')) { |
|
| 552 | + pcntl_signal_dispatch(); |
|
| 553 | + } |
|
| 426 | 554 | |
| 427 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 555 | + if (!$globalDaemon) { |
|
| 556 | + $i = $endtime-time(); |
|
| 557 | + } |
|
| 428 | 558 | // Delete old ATC |
| 429 | 559 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 430 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 560 | + if ($globalDebug) { |
|
| 561 | + echo 'Delete old ATC...'."\n"; |
|
| 562 | + } |
|
| 431 | 563 | $ATC->deleteOldATC(); |
| 432 | 564 | } |
| 433 | 565 | |
| 434 | 566 | if (count($last_exec) == count($globalSources)) { |
| 435 | 567 | $max = $globalMinFetch; |
| 436 | 568 | foreach ($last_exec as $last) { |
| 437 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 569 | + if ((time() - $last['last']) < $max) { |
|
| 570 | + $max = time() - $last['last']; |
|
| 571 | + } |
|
| 438 | 572 | } |
| 439 | 573 | if ($max < $globalMinFetch) { |
| 440 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 574 | + if ($globalDebug) { |
|
| 575 | + echo 'Sleeping...'."\n"; |
|
| 576 | + } |
|
| 441 | 577 | sleep($globalMinFetch-$max+2); |
| 442 | 578 | } |
| 443 | 579 | } |
@@ -447,7 +583,9 @@ discard block |
||
| 447 | 583 | foreach ($globalSources as $id => $value) { |
| 448 | 584 | date_default_timezone_set('UTC'); |
| 449 | 585 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 450 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 586 | + if (!isset($last_exec[$id]['last'])) { |
|
| 587 | + $last_exec[$id]['last'] = 0; |
|
| 588 | + } |
|
| 451 | 589 | if ($value['format'] === 'deltadbtxt' && |
| 452 | 590 | ( |
| 453 | 591 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -456,7 +594,9 @@ discard block |
||
| 456 | 594 | ) { |
| 457 | 595 | //$buffer = $Common->getData($hosts[$id]); |
| 458 | 596 | $buffer = $Common->getData($value['host']); |
| 459 | - if ($buffer != '') $reset = 0; |
|
| 597 | + if ($buffer != '') { |
|
| 598 | + $reset = 0; |
|
| 599 | + } |
|
| 460 | 600 | $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
| 461 | 601 | $buffer = explode('\n', $buffer); |
| 462 | 602 | foreach ($buffer as $line) { |
@@ -465,20 +605,41 @@ discard block |
||
| 465 | 605 | $data = array(); |
| 466 | 606 | $data['hex'] = $line[1]; // hex |
| 467 | 607 | $data['ident'] = $line[2]; // ident |
| 468 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 469 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 470 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 471 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 472 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 608 | + if (isset($line[3])) { |
|
| 609 | + $data['altitude'] = $line[3]; |
|
| 610 | + } |
|
| 611 | + // altitude |
|
| 612 | + if (isset($line[4])) { |
|
| 613 | + $data['speed'] = $line[4]; |
|
| 614 | + } |
|
| 615 | + // speed |
|
| 616 | + if (isset($line[5])) { |
|
| 617 | + $data['heading'] = $line[5]; |
|
| 618 | + } |
|
| 619 | + // heading |
|
| 620 | + if (isset($line[6])) { |
|
| 621 | + $data['latitude'] = $line[6]; |
|
| 622 | + } |
|
| 623 | + // lat |
|
| 624 | + if (isset($line[7])) { |
|
| 625 | + $data['longitude'] = $line[7]; |
|
| 626 | + } |
|
| 627 | + // long |
|
| 473 | 628 | $data['verticalrate'] = ''; // vertical rate |
| 474 | 629 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 475 | 630 | $data['emergency'] = ''; // emergency |
| 476 | 631 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 477 | 632 | $data['format_source'] = 'deltadbtxt'; |
| 478 | 633 | $data['id_source'] = $id_source; |
| 479 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 480 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 481 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 634 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 635 | + $data['source_name'] = $value['name']; |
|
| 636 | + } |
|
| 637 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 638 | + $data['noarchive'] = true; |
|
| 639 | + } |
|
| 640 | + if (isset($value['sourcestats'])) { |
|
| 641 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 642 | + } |
|
| 482 | 643 | $SI->add($data); |
| 483 | 644 | unset($data); |
| 484 | 645 | } |
@@ -513,11 +674,20 @@ discard block |
||
| 513 | 674 | $data['format_source'] = 'radarcapejson'; |
| 514 | 675 | $data['id_source'] = $id_source; |
| 515 | 676 | if (isset($value['name']) && $value['name'] != '') { |
| 516 | - if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT'; |
|
| 517 | - else $data['source_name'] = $value['name']; |
|
| 518 | - } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT'; |
|
| 519 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 520 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 677 | + if (isset($line['src']) && !$line['src'] == 'M') { |
|
| 678 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
| 679 | + } else { |
|
| 680 | + $data['source_name'] = $value['name']; |
|
| 681 | + } |
|
| 682 | + } elseif (isset($line['src']) && $line['src'] == 'M') { |
|
| 683 | + $data['source_name'] = 'MLAT'; |
|
| 684 | + } |
|
| 685 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 686 | + $data['noarchive'] = true; |
|
| 687 | + } |
|
| 688 | + if (isset($value['sourcestats'])) { |
|
| 689 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 690 | + } |
|
| 521 | 691 | |
| 522 | 692 | $SI->add($data); |
| 523 | 693 | unset($data); |
@@ -533,7 +703,9 @@ discard block |
||
| 533 | 703 | date_default_timezone_set('CET'); |
| 534 | 704 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 535 | 705 | date_default_timezone_set('UTC'); |
| 536 | - if ($buffer != '') $reset = 0; |
|
| 706 | + if ($buffer != '') { |
|
| 707 | + $reset = 0; |
|
| 708 | + } |
|
| 537 | 709 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 538 | 710 | $buffer = explode('\n',$buffer); |
| 539 | 711 | foreach ($buffer as $line) { |
@@ -542,18 +714,42 @@ discard block |
||
| 542 | 714 | $add = false; |
| 543 | 715 | $ais_data = $AIS->parse_line(trim($line)); |
| 544 | 716 | $data = array(); |
| 545 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 546 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 547 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 548 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 549 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 550 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 551 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 552 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 553 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 554 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 555 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 556 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 717 | + if (isset($ais_data['ident'])) { |
|
| 718 | + $data['ident'] = $ais_data['ident']; |
|
| 719 | + } |
|
| 720 | + if (isset($ais_data['mmsi'])) { |
|
| 721 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 722 | + } |
|
| 723 | + if (isset($ais_data['speed'])) { |
|
| 724 | + $data['speed'] = $ais_data['speed']; |
|
| 725 | + } |
|
| 726 | + if (isset($ais_data['heading'])) { |
|
| 727 | + $data['heading'] = $ais_data['heading']; |
|
| 728 | + } |
|
| 729 | + if (isset($ais_data['latitude'])) { |
|
| 730 | + $data['latitude'] = $ais_data['latitude']; |
|
| 731 | + } |
|
| 732 | + if (isset($ais_data['longitude'])) { |
|
| 733 | + $data['longitude'] = $ais_data['longitude']; |
|
| 734 | + } |
|
| 735 | + if (isset($ais_data['status'])) { |
|
| 736 | + $data['status'] = $ais_data['status']; |
|
| 737 | + } |
|
| 738 | + if (isset($ais_data['statusid'])) { |
|
| 739 | + $data['status_id'] = $ais_data['statusid']; |
|
| 740 | + } |
|
| 741 | + if (isset($ais_data['type'])) { |
|
| 742 | + $data['type'] = $ais_data['type']; |
|
| 743 | + } |
|
| 744 | + if (isset($ais_data['typeid'])) { |
|
| 745 | + $data['type_id'] = $ais_data['typeid']; |
|
| 746 | + } |
|
| 747 | + if (isset($ais_data['imo'])) { |
|
| 748 | + $data['imo'] = $ais_data['imo']; |
|
| 749 | + } |
|
| 750 | + if (isset($ais_data['callsign'])) { |
|
| 751 | + $data['callsign'] = $ais_data['callsign']; |
|
| 752 | + } |
|
| 557 | 753 | if (isset($ais_data['timestamp'])) { |
| 558 | 754 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 559 | 755 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -567,8 +763,12 @@ discard block |
||
| 567 | 763 | $data['format_source'] = 'aisnmeatxt'; |
| 568 | 764 | $data['id_source'] = $id_source; |
| 569 | 765 | //print_r($data); |
| 570 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 571 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 766 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 767 | + $data['noarchive'] = true; |
|
| 768 | + } |
|
| 769 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 770 | + $MI->add($data); |
|
| 771 | + } |
|
| 572 | 772 | unset($data); |
| 573 | 773 | } |
| 574 | 774 | } |
@@ -591,20 +791,48 @@ discard block |
||
| 591 | 791 | if ($line != '') { |
| 592 | 792 | $ais_data = $AIS->parse_line(trim($line)); |
| 593 | 793 | $data = array(); |
| 594 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 595 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 596 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 597 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 598 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 599 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 600 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 601 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 602 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 603 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 604 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 605 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 606 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 607 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 794 | + if (isset($ais_data['ident'])) { |
|
| 795 | + $data['ident'] = $ais_data['ident']; |
|
| 796 | + } |
|
| 797 | + if (isset($ais_data['mmsi'])) { |
|
| 798 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 799 | + } |
|
| 800 | + if (isset($ais_data['speed'])) { |
|
| 801 | + $data['speed'] = $ais_data['speed']; |
|
| 802 | + } |
|
| 803 | + if (isset($ais_data['heading'])) { |
|
| 804 | + $data['heading'] = $ais_data['heading']; |
|
| 805 | + } |
|
| 806 | + if (isset($ais_data['latitude'])) { |
|
| 807 | + $data['latitude'] = $ais_data['latitude']; |
|
| 808 | + } |
|
| 809 | + if (isset($ais_data['longitude'])) { |
|
| 810 | + $data['longitude'] = $ais_data['longitude']; |
|
| 811 | + } |
|
| 812 | + if (isset($ais_data['status'])) { |
|
| 813 | + $data['status'] = $ais_data['status']; |
|
| 814 | + } |
|
| 815 | + if (isset($ais_data['statusid'])) { |
|
| 816 | + $data['status_id'] = $ais_data['statusid']; |
|
| 817 | + } |
|
| 818 | + if (isset($ais_data['type'])) { |
|
| 819 | + $data['type'] = $ais_data['type']; |
|
| 820 | + } |
|
| 821 | + if (isset($ais_data['typeid'])) { |
|
| 822 | + $data['type_id'] = $ais_data['typeid']; |
|
| 823 | + } |
|
| 824 | + if (isset($ais_data['imo'])) { |
|
| 825 | + $data['imo'] = $ais_data['imo']; |
|
| 826 | + } |
|
| 827 | + if (isset($ais_data['callsign'])) { |
|
| 828 | + $data['callsign'] = $ais_data['callsign']; |
|
| 829 | + } |
|
| 830 | + if (isset($ais_data['destination'])) { |
|
| 831 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 832 | + } |
|
| 833 | + if (isset($ais_data['eta_ts'])) { |
|
| 834 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 835 | + } |
|
| 608 | 836 | if (isset($ais_data['timestamp'])) { |
| 609 | 837 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 610 | 838 | } else { |
@@ -612,18 +840,27 @@ discard block |
||
| 612 | 840 | } |
| 613 | 841 | $data['format_source'] = 'aisnmeahttp'; |
| 614 | 842 | $data['id_source'] = $id_source; |
| 615 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 616 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 843 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 844 | + $data['noarchive'] = true; |
|
| 845 | + } |
|
| 846 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 847 | + $MI->add($data); |
|
| 848 | + } |
|
| 617 | 849 | unset($data); |
| 618 | 850 | } |
| 619 | 851 | } |
| 620 | 852 | } |
| 621 | 853 | } else { |
| 622 | 854 | $format = $value['format']; |
| 623 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 624 | - else $tt[$format] = 0; |
|
| 855 | + if (isset($tt[$format])) { |
|
| 856 | + $tt[$format]++; |
|
| 857 | + } else { |
|
| 858 | + $tt[$format] = 0; |
|
| 859 | + } |
|
| 625 | 860 | if ($tt[$format] > 30) { |
| 626 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 861 | + if ($globalDebug) { |
|
| 862 | + echo 'Reconnect...'."\n"; |
|
| 863 | + } |
|
| 627 | 864 | sleep(2); |
| 628 | 865 | //$sourceeen[] = $value; |
| 629 | 866 | //connect_all($sourceeen); |
@@ -659,12 +896,18 @@ discard block |
||
| 659 | 896 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
| 660 | 897 | //$data['type_id'] = $line['TYPE']; |
| 661 | 898 | $data['imo'] = $line['IMO']; |
| 662 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
| 663 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 899 | + if ($line['DEST'] != '') { |
|
| 900 | + $data['arrival_code'] = $line['DEST']; |
|
| 901 | + } |
|
| 902 | + if ($line['ARV'] != '') { |
|
| 903 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 904 | + } |
|
| 664 | 905 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
| 665 | 906 | $data['format_source'] = 'myshiptracking'; |
| 666 | 907 | $data['id_source'] = $id_source; |
| 667 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 908 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 909 | + $data['noarchive'] = true; |
|
| 910 | + } |
|
| 668 | 911 | $MI->add($data); |
| 669 | 912 | unset($data); |
| 670 | 913 | } |
@@ -689,7 +932,9 @@ discard block |
||
| 689 | 932 | $data['callsign'] = $line['callsign']; |
| 690 | 933 | $data['mmsi'] = substr($line['mmsi'],-9); |
| 691 | 934 | $data['speed'] = $line['sog']; |
| 692 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 935 | + if ($line['heading'] != '511') { |
|
| 936 | + $data['heading'] = $line['heading']; |
|
| 937 | + } |
|
| 693 | 938 | $data['latitude'] = $line['latitude']; |
| 694 | 939 | $data['longitude'] = $line['longitude']; |
| 695 | 940 | $data['type_id'] = $line['shiptype']; |
@@ -697,7 +942,9 @@ discard block |
||
| 697 | 942 | $data['datetime'] = $line['time']; |
| 698 | 943 | $data['format_source'] = 'boatbeaconapp'; |
| 699 | 944 | $data['id_source'] = $id_source; |
| 700 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 945 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 946 | + $data['noarchive'] = true; |
|
| 947 | + } |
|
| 701 | 948 | $MI->add($data); |
| 702 | 949 | unset($data); |
| 703 | 950 | } |
@@ -719,22 +966,44 @@ discard block |
||
| 719 | 966 | foreach ($all_data['features'] as $line) { |
| 720 | 967 | print_r($line); |
| 721 | 968 | $data = array(); |
| 722 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
| 723 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
| 724 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 725 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
| 726 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
| 727 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
| 969 | + if (isset($line['properties']['name'])) { |
|
| 970 | + $data['ident'] = $line['properties']['name']; |
|
| 971 | + } |
|
| 972 | + if (isset($line['properties']['callsign'])) { |
|
| 973 | + $data['callsign'] = $line['properties']['callsign']; |
|
| 974 | + } |
|
| 975 | + if (isset($line['properties']['mmsi'])) { |
|
| 976 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 977 | + } |
|
| 978 | + if (isset($line['properties']['imo'])) { |
|
| 979 | + $data['imo'] = $line['properties']['imo']; |
|
| 980 | + } |
|
| 981 | + if (isset($line['properties']['speed'])) { |
|
| 982 | + $data['speed'] = $line['properties']['speed']; |
|
| 983 | + } |
|
| 984 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
| 985 | + $data['heading'] = $line['properties']['heading']; |
|
| 986 | + } |
|
| 728 | 987 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
| 729 | 988 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
| 730 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
| 731 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
| 732 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
| 989 | + if (isset($line['properties']['vesselType'])) { |
|
| 990 | + $data['type'] = $line['properties']['vesselType']; |
|
| 991 | + } |
|
| 992 | + if (isset($line['properties']['destination'])) { |
|
| 993 | + $data['arrival_code'] = $line['properties']['destination']; |
|
| 994 | + } |
|
| 995 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
| 996 | + $data['arrival_date'] = $line['properties']['eta']; |
|
| 997 | + } |
|
| 733 | 998 | $data['format_source'] = 'boatnerd'; |
| 734 | 999 | $data['id_source'] = $id_source; |
| 735 | 1000 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 736 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 737 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
| 1001 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1002 | + $data['noarchive'] = true; |
|
| 1003 | + } |
|
| 1004 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
| 1005 | + $MI->add($data); |
|
| 1006 | + } |
|
| 738 | 1007 | unset($data); |
| 739 | 1008 | } |
| 740 | 1009 | } |
@@ -747,11 +1016,17 @@ discard block |
||
| 747 | 1016 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 748 | 1017 | ) |
| 749 | 1018 | ) { |
| 750 | - if ($globalDebug) echo 'download...'; |
|
| 1019 | + if ($globalDebug) { |
|
| 1020 | + echo 'download...'; |
|
| 1021 | + } |
|
| 751 | 1022 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 752 | - if ($globalDebug) echo 'done !'."\n"; |
|
| 1023 | + if ($globalDebug) { |
|
| 1024 | + echo 'done !'."\n"; |
|
| 1025 | + } |
|
| 753 | 1026 | // FIXME: Need more work |
| 754 | - if ($buffer != '') $reset = 0; |
|
| 1027 | + if ($buffer != '') { |
|
| 1028 | + $reset = 0; |
|
| 1029 | + } |
|
| 755 | 1030 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 756 | 1031 | $buffer = explode('\n',$buffer); |
| 757 | 1032 | foreach ($buffer as $line) { |
@@ -777,7 +1052,9 @@ discard block |
||
| 777 | 1052 | //$data['etaTime'] = substr($line,135,5); |
| 778 | 1053 | $data['format_source'] = 'shipplotter'; |
| 779 | 1054 | $data['id_source'] = $id_source; |
| 780 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1055 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1056 | + $data['noarchive'] = true; |
|
| 1057 | + } |
|
| 781 | 1058 | //print_r($data); |
| 782 | 1059 | //echo 'Add...'."\n"; |
| 783 | 1060 | $MI->add($data); |
@@ -800,11 +1077,17 @@ discard block |
||
| 800 | 1077 | } |
| 801 | 1078 | } |
| 802 | 1079 | |
| 803 | - if ($globalDebug) echo '! Download... '; |
|
| 1080 | + if ($globalDebug) { |
|
| 1081 | + echo '! Download... '; |
|
| 1082 | + } |
|
| 804 | 1083 | for ($i =0; $i <= 1; $i++) { |
| 805 | - if ($globalDebug) echo 'Racetype: '.$i.' '; |
|
| 1084 | + if ($globalDebug) { |
|
| 1085 | + echo 'Racetype: '.$i.' '; |
|
| 1086 | + } |
|
| 806 | 1087 | $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
| 807 | - if ($globalDebug) echo 'done'."\n"; |
|
| 1088 | + if ($globalDebug) { |
|
| 1089 | + echo 'done'."\n"; |
|
| 1090 | + } |
|
| 808 | 1091 | if ($buffer != '') { |
| 809 | 1092 | $all_data = json_decode($buffer,true); |
| 810 | 1093 | if (isset($all_data['missions'])) { |
@@ -812,8 +1095,11 @@ discard block |
||
| 812 | 1095 | $mission_user = $mission['usrname']; |
| 813 | 1096 | $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])); |
| 814 | 1097 | if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { |
| 815 | - if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
|
| 816 | - else $racebuffer = ''; |
|
| 1098 | + if (isset($sailaway_authcookie) && $sailaway_authcookie != '') { |
|
| 1099 | + $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
|
| 1100 | + } else { |
|
| 1101 | + $racebuffer = ''; |
|
| 1102 | + } |
|
| 817 | 1103 | $bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); |
| 818 | 1104 | } else { |
| 819 | 1105 | $bufferm = ''; |
@@ -877,7 +1163,9 @@ discard block |
||
| 877 | 1163 | $data['captain_id'] = $sail['usrnr']; |
| 878 | 1164 | $data['captain_name'] = $sail['usrname']; |
| 879 | 1165 | $data['race_id'] = $sail['misnr']; |
| 880 | - if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank']; |
|
| 1166 | + if ($sail['rank'] != 'DNF') { |
|
| 1167 | + $data['race_rank'] = $sail['rank']; |
|
| 1168 | + } |
|
| 881 | 1169 | $data['race_time'] = $sail['racetime']; |
| 882 | 1170 | if ($mission_user != '') { |
| 883 | 1171 | $data['race_name'] = $mission_name.' ('.$mission_user.')'; |
@@ -887,7 +1175,9 @@ discard block |
||
| 887 | 1175 | //$data['callsign'] = trim(substr($line,100,7); |
| 888 | 1176 | $data['format_source'] = 'sailaway'; |
| 889 | 1177 | $data['id_source'] = $id_source; |
| 890 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1178 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1179 | + $data['noarchive'] = true; |
|
| 1180 | + } |
|
| 891 | 1181 | //print_r($data); |
| 892 | 1182 | //if ($data['race_id'] == '48') print_r($data); |
| 893 | 1183 | //echo 'Add...'."\n"; |
@@ -929,16 +1219,28 @@ discard block |
||
| 929 | 1219 | $line = explode(':', $line); |
| 930 | 1220 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 931 | 1221 | $data = array(); |
| 932 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 933 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1222 | + if (isset($line[37]) && $line[37] != '') { |
|
| 1223 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 1224 | + } else { |
|
| 1225 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1226 | + } |
|
| 934 | 1227 | $data['pilot_id'] = $line[1]; |
| 935 | 1228 | $data['pilot_name'] = $line[2]; |
| 936 | 1229 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 937 | 1230 | $data['ident'] = $line[0]; // ident |
| 938 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 1231 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 1232 | + $data['altitude'] = $line[7]; |
|
| 1233 | + } |
|
| 1234 | + // altitude |
|
| 939 | 1235 | $data['speed'] = $line[8]; // speed |
| 940 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 941 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 1236 | + if (isset($line[45])) { |
|
| 1237 | + $data['heading'] = $line[45]; |
|
| 1238 | + } |
|
| 1239 | + // heading |
|
| 1240 | + elseif (isset($line[38])) { |
|
| 1241 | + $data['heading'] = $line[38]; |
|
| 1242 | + } |
|
| 1243 | + // heading |
|
| 942 | 1244 | $data['latitude'] = $line[5]; // lat |
| 943 | 1245 | $data['longitude'] = $line[6]; // long |
| 944 | 1246 | $data['verticalrate'] = ''; // vertical rate |
@@ -954,7 +1256,9 @@ discard block |
||
| 954 | 1256 | $data['frequency'] = $line[4]; |
| 955 | 1257 | $data['type'] = $line[18]; |
| 956 | 1258 | $data['range'] = $line[19]; |
| 957 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 1259 | + if (isset($line[35])) { |
|
| 1260 | + $data['info'] = $line[35]; |
|
| 1261 | + } |
|
| 958 | 1262 | $data['id_source'] = $id_source; |
| 959 | 1263 | //$data['arrival_airport_time'] = ; |
| 960 | 1264 | if ($line[9] != '') { |
@@ -968,27 +1272,47 @@ discard block |
||
| 968 | 1272 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 969 | 1273 | */ |
| 970 | 1274 | $data['format_source'] = $value['format']; |
| 971 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 972 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 973 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
| 974 | - elseif ($line[3] === 'ATC') { |
|
| 1275 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1276 | + $data['noarchive'] = true; |
|
| 1277 | + } |
|
| 1278 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1279 | + $data['source_name'] = $value['name']; |
|
| 1280 | + } |
|
| 1281 | + if ($line[3] === 'PILOT') { |
|
| 1282 | + $SI->add($data); |
|
| 1283 | + } elseif ($line[3] === 'ATC') { |
|
| 975 | 1284 | //print_r($data); |
| 976 | 1285 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 977 | 1286 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 978 | 1287 | $typec = substr($data['ident'],-3); |
| 979 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 980 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 981 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 982 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 983 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 984 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 985 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 986 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 987 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
| 988 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 1288 | + if ($typec === 'APP') { |
|
| 1289 | + $data['type'] = 'Approach'; |
|
| 1290 | + } elseif ($typec === 'TWR') { |
|
| 1291 | + $data['type'] = 'Tower'; |
|
| 1292 | + } elseif ($typec === 'OBS') { |
|
| 1293 | + $data['type'] = 'Observer'; |
|
| 1294 | + } elseif ($typec === 'GND') { |
|
| 1295 | + $data['type'] = 'Ground'; |
|
| 1296 | + } elseif ($typec === 'DEL') { |
|
| 1297 | + $data['type'] = 'Delivery'; |
|
| 1298 | + } elseif ($typec === 'DEP') { |
|
| 1299 | + $data['type'] = 'Departure'; |
|
| 1300 | + } elseif ($typec === 'FSS') { |
|
| 1301 | + $data['type'] = 'Flight Service Station'; |
|
| 1302 | + } elseif ($typec === 'CTR') { |
|
| 1303 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1304 | + } elseif ($data['type'] === '') { |
|
| 1305 | + $data['type'] = 'Observer'; |
|
| 1306 | + } |
|
| 1307 | + if (!isset($data['source_name'])) { |
|
| 1308 | + $data['source_name'] = ''; |
|
| 1309 | + } |
|
| 989 | 1310 | if (isset($ATC)) { |
| 990 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 991 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 1311 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
| 1312 | + echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 1313 | + } else { |
|
| 1314 | + echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 1315 | + } |
|
| 992 | 1316 | } |
| 993 | 1317 | } |
| 994 | 1318 | unset($data); |
@@ -1015,14 +1339,20 @@ discard block |
||
| 1015 | 1339 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
| 1016 | 1340 | $data['latitude'] = (float)$line['pktLatitude']; |
| 1017 | 1341 | $data['longitude'] = (float)$line['pktLongitude']; |
| 1018 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 1019 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 1342 | + if ((float)$line['pktTrack'] != 0) { |
|
| 1343 | + $data['heading'] = (float)$line['pktTrack']; |
|
| 1344 | + } |
|
| 1345 | + if ((int)$line['pktSpeed'] != 0) { |
|
| 1346 | + $data['speed'] = (int)$line['pktSpeed']; |
|
| 1347 | + } |
|
| 1020 | 1348 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
| 1021 | 1349 | $data['altitude_relative'] = 'AMSL'; |
| 1022 | 1350 | $data['pilot_id'] = (int)$line['pktPilotID']; |
| 1023 | 1351 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 1024 | 1352 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
| 1025 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
| 1353 | + if (isset($pilot_data[4])) { |
|
| 1354 | + $data['pilot_name'] = $pilot_data[4]; |
|
| 1355 | + } |
|
| 1026 | 1356 | $data['format_source'] = $value['format']; |
| 1027 | 1357 | $SI->add($data); |
| 1028 | 1358 | unset($data); |
@@ -1070,25 +1400,59 @@ discard block |
||
| 1070 | 1400 | foreach ($all_data['acList'] as $line) { |
| 1071 | 1401 | $data = array(); |
| 1072 | 1402 | $data['hex'] = $line['Icao']; // hex |
| 1073 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1074 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1075 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1076 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1077 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1078 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1403 | + if (isset($line['Call'])) { |
|
| 1404 | + $data['ident'] = $line['Call']; |
|
| 1405 | + } |
|
| 1406 | + // ident |
|
| 1407 | + if (isset($line['Alt'])) { |
|
| 1408 | + $data['altitude'] = $line['Alt']; |
|
| 1409 | + } |
|
| 1410 | + // altitude |
|
| 1411 | + if (isset($line['Spd'])) { |
|
| 1412 | + $data['speed'] = $line['Spd']; |
|
| 1413 | + } |
|
| 1414 | + // speed |
|
| 1415 | + if (isset($line['Trak'])) { |
|
| 1416 | + $data['heading'] = $line['Trak']; |
|
| 1417 | + } |
|
| 1418 | + // heading |
|
| 1419 | + if (isset($line['Lat'])) { |
|
| 1420 | + $data['latitude'] = $line['Lat']; |
|
| 1421 | + } |
|
| 1422 | + // lat |
|
| 1423 | + if (isset($line['Long'])) { |
|
| 1424 | + $data['longitude'] = $line['Long']; |
|
| 1425 | + } |
|
| 1426 | + // long |
|
| 1079 | 1427 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1080 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1428 | + if (isset($line['Sqk'])) { |
|
| 1429 | + $data['squawk'] = $line['Sqk']; |
|
| 1430 | + } |
|
| 1431 | + // squawk |
|
| 1081 | 1432 | $data['emergency'] = ''; // emergency |
| 1082 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1083 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1084 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1433 | + if (isset($line['Reg'])) { |
|
| 1434 | + $data['registration'] = $line['Reg']; |
|
| 1435 | + } |
|
| 1436 | + if (isset($line['PosTime'])) { |
|
| 1437 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1438 | + } else { |
|
| 1439 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1440 | + } |
|
| 1085 | 1441 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1086 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1442 | + if (isset($line['Type'])) { |
|
| 1443 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1444 | + } |
|
| 1087 | 1445 | $data['format_source'] = 'aircraftlistjson'; |
| 1088 | 1446 | $data['id_source'] = $id_source; |
| 1089 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1090 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1091 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 1447 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1448 | + $data['source_name'] = $value['name']; |
|
| 1449 | + } |
|
| 1450 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1451 | + $data['noarchive'] = true; |
|
| 1452 | + } |
|
| 1453 | + if (isset($data['latitude'])) { |
|
| 1454 | + $SI->add($data); |
|
| 1455 | + } |
|
| 1092 | 1456 | unset($data); |
| 1093 | 1457 | } |
| 1094 | 1458 | } elseif (is_array($all_data)) { |
@@ -1105,17 +1469,26 @@ discard block |
||
| 1105 | 1469 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 1106 | 1470 | $data['squawk'] = $line['squawk']; // squawk |
| 1107 | 1471 | $data['emergency'] = ''; // emergency |
| 1108 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1109 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1472 | + if (isset($line['PosTime'])) { |
|
| 1473 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1474 | + } else { |
|
| 1475 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1476 | + } |
|
| 1110 | 1477 | $data['format_source'] = 'aircraftlistjson'; |
| 1111 | 1478 | $data['id_source'] = $id_source; |
| 1112 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1113 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1479 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1480 | + $data['noarchive'] = true; |
|
| 1481 | + } |
|
| 1482 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1483 | + $data['source_name'] = $value['name']; |
|
| 1484 | + } |
|
| 1114 | 1485 | $SI->add($data); |
| 1115 | 1486 | unset($data); |
| 1116 | 1487 | } |
| 1117 | 1488 | } |
| 1118 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1489 | + } elseif ($globalDebug) { |
|
| 1490 | + echo 'No data'."\n"; |
|
| 1491 | + } |
|
| 1119 | 1492 | //$last_exec['aircraftlistjson'] = time(); |
| 1120 | 1493 | $last_exec[$id]['last'] = time(); |
| 1121 | 1494 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -1151,8 +1524,12 @@ discard block |
||
| 1151 | 1524 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 1152 | 1525 | $data['format_source'] = 'planeupdatefaa'; |
| 1153 | 1526 | $data['id_source'] = $id_source; |
| 1154 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1155 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1527 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1528 | + $data['noarchive'] = true; |
|
| 1529 | + } |
|
| 1530 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1531 | + $data['source_name'] = $value['name']; |
|
| 1532 | + } |
|
| 1156 | 1533 | $SI->add($data); |
| 1157 | 1534 | unset($data); |
| 1158 | 1535 | } |
@@ -1186,7 +1563,9 @@ discard block |
||
| 1186 | 1563 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
| 1187 | 1564 | $data['format_source'] = 'opensky'; |
| 1188 | 1565 | $data['id_source'] = $id_source; |
| 1189 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1566 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1567 | + $data['noarchive'] = true; |
|
| 1568 | + } |
|
| 1190 | 1569 | $SI->add($data); |
| 1191 | 1570 | unset($data); |
| 1192 | 1571 | } |
@@ -1206,15 +1585,42 @@ discard block |
||
| 1206 | 1585 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1207 | 1586 | $data = array(); |
| 1208 | 1587 | // add support for ground vehicule with ~ in front of hex |
| 1209 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1210 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1211 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1212 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1213 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1214 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1215 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1216 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1217 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1588 | + if (isset($line['hex'])) { |
|
| 1589 | + $data['hex'] = $line['hex']; |
|
| 1590 | + } |
|
| 1591 | + // hex |
|
| 1592 | + if (isset($line['flight'])) { |
|
| 1593 | + $data['ident'] = trim($line['flight']); |
|
| 1594 | + } |
|
| 1595 | + // ident |
|
| 1596 | + if (isset($line['altitude'])) { |
|
| 1597 | + $data['altitude'] = $line['altitude']; |
|
| 1598 | + } |
|
| 1599 | + // altitude |
|
| 1600 | + if (isset($line['speed'])) { |
|
| 1601 | + $data['speed'] = $line['speed']; |
|
| 1602 | + } |
|
| 1603 | + // speed |
|
| 1604 | + if (isset($line['track'])) { |
|
| 1605 | + $data['heading'] = $line['track']; |
|
| 1606 | + } |
|
| 1607 | + // heading |
|
| 1608 | + if (isset($line['lat'])) { |
|
| 1609 | + $data['latitude'] = $line['lat']; |
|
| 1610 | + } |
|
| 1611 | + // lat |
|
| 1612 | + if (isset($line['lon'])) { |
|
| 1613 | + $data['longitude'] = $line['lon']; |
|
| 1614 | + } |
|
| 1615 | + // long |
|
| 1616 | + if (isset($line['vert_rate'])) { |
|
| 1617 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1618 | + } |
|
| 1619 | + // verticale rate |
|
| 1620 | + if (isset($line['squawk'])) { |
|
| 1621 | + $data['squawk'] = $line['squawk']; |
|
| 1622 | + } |
|
| 1623 | + // squawk |
|
| 1218 | 1624 | //$data['emergency'] = ''; // emergency |
| 1219 | 1625 | //$data['registration'] = $line[2]; |
| 1220 | 1626 | //$data['aircraft_icao'] = $line[0]; |
@@ -1222,10 +1628,17 @@ discard block |
||
| 1222 | 1628 | $data['format_source'] = 'aircraftjson'; |
| 1223 | 1629 | $data['id_source'] = $id_source; |
| 1224 | 1630 | if (isset($value['name']) && $value['name'] != '') { |
| 1225 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1226 | - else $data['source_name'] = $value['name']; |
|
| 1227 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1228 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1631 | + if (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1632 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1633 | + } else { |
|
| 1634 | + $data['source_name'] = $value['name']; |
|
| 1635 | + } |
|
| 1636 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1637 | + $data['source_name'] = 'MLAT'; |
|
| 1638 | + } |
|
| 1639 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1640 | + $data['noarchive'] = true; |
|
| 1641 | + } |
|
| 1229 | 1642 | $SI->add($data); |
| 1230 | 1643 | unset($data); |
| 1231 | 1644 | } |
@@ -1245,22 +1658,54 @@ discard block |
||
| 1245 | 1658 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1246 | 1659 | $data = array(); |
| 1247 | 1660 | $data['hex'] = $key; // hex |
| 1248 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1249 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1250 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1251 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1252 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1253 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1254 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1255 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1661 | + if (isset($line['callsign'])) { |
|
| 1662 | + $data['ident'] = trim($line['callsign']); |
|
| 1663 | + } |
|
| 1664 | + // ident |
|
| 1665 | + if (isset($line['altitude'])) { |
|
| 1666 | + $data['altitude'] = $line['altitude']; |
|
| 1667 | + } |
|
| 1668 | + // altitude |
|
| 1669 | + if (isset($line['speed'])) { |
|
| 1670 | + $data['speed'] = $line['speed']; |
|
| 1671 | + } |
|
| 1672 | + // speed |
|
| 1673 | + if (isset($line['heading'])) { |
|
| 1674 | + $data['heading'] = $line['heading']; |
|
| 1675 | + } |
|
| 1676 | + // heading |
|
| 1677 | + if (isset($line['lat'])) { |
|
| 1678 | + $data['latitude'] = $line['lat']; |
|
| 1679 | + } |
|
| 1680 | + // lat |
|
| 1681 | + if (isset($line['lon'])) { |
|
| 1682 | + $data['longitude'] = $line['lon']; |
|
| 1683 | + } |
|
| 1684 | + // long |
|
| 1685 | + if (isset($line['vert_rate'])) { |
|
| 1686 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1687 | + } |
|
| 1688 | + // verticale rate |
|
| 1689 | + if (isset($line['squawk'])) { |
|
| 1690 | + $data['squawk'] = $line['squawk']; |
|
| 1691 | + } |
|
| 1692 | + // squawk |
|
| 1256 | 1693 | //$data['emergency'] = ''; // emergency |
| 1257 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1258 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1694 | + if (isset($line['reg'])) { |
|
| 1695 | + $data['registration'] = $line['reg']; |
|
| 1696 | + } |
|
| 1697 | + if (isset($line['type'])) { |
|
| 1698 | + $data['aircraft_icao'] = $line['type']; |
|
| 1699 | + } |
|
| 1259 | 1700 | $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
| 1260 | 1701 | $data['format_source'] = 'planefinderclient'; |
| 1261 | 1702 | $data['id_source'] = $id_source; |
| 1262 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1263 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1703 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1704 | + $data['source_name'] = $value['name']; |
|
| 1705 | + } |
|
| 1706 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1707 | + $data['noarchive'] = true; |
|
| 1708 | + } |
|
| 1264 | 1709 | $SI->add($data); |
| 1265 | 1710 | unset($data); |
| 1266 | 1711 | } |
@@ -1276,7 +1721,9 @@ discard block |
||
| 1276 | 1721 | //$buffer = $Common->getData($hosts[$id]); |
| 1277 | 1722 | $buffer = $Common->getData($value['host']); |
| 1278 | 1723 | $all_data = json_decode($buffer,true); |
| 1279 | - if (!empty($all_data)) $reset = 0; |
|
| 1724 | + if (!empty($all_data)) { |
|
| 1725 | + $reset = 0; |
|
| 1726 | + } |
|
| 1280 | 1727 | foreach ($all_data as $key => $line) { |
| 1281 | 1728 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 1282 | 1729 | $data = array(); |
@@ -1297,8 +1744,12 @@ discard block |
||
| 1297 | 1744 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 1298 | 1745 | $data['format_source'] = 'fr24json'; |
| 1299 | 1746 | $data['id_source'] = $id_source; |
| 1300 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1301 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1747 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1748 | + $data['noarchive'] = true; |
|
| 1749 | + } |
|
| 1750 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1751 | + $data['source_name'] = $value['name']; |
|
| 1752 | + } |
|
| 1302 | 1753 | $SI->add($data); |
| 1303 | 1754 | unset($data); |
| 1304 | 1755 | } |
@@ -1327,24 +1778,42 @@ discard block |
||
| 1327 | 1778 | if (isset($line['inf'])) { |
| 1328 | 1779 | $data = array(); |
| 1329 | 1780 | $data['hex'] = $line['inf']['ia']; |
| 1330 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1781 | + if (isset($line['inf']['cs'])) { |
|
| 1782 | + $data['ident'] = $line['inf']['cs']; |
|
| 1783 | + } |
|
| 1784 | + //$line[13] |
|
| 1331 | 1785 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 1332 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1333 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1786 | + if (isset($line['inf']['gs'])) { |
|
| 1787 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1788 | + } |
|
| 1789 | + // speed |
|
| 1790 | + if (isset($line['inf']['tr'])) { |
|
| 1791 | + $data['heading'] = $line['inf']['tr']; |
|
| 1792 | + } |
|
| 1793 | + // heading |
|
| 1334 | 1794 | $data['latitude'] = $line['pt'][0]; // lat |
| 1335 | 1795 | $data['longitude'] = $line['pt'][1]; // long |
| 1336 | 1796 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 1337 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1797 | + if (isset($line['inf']['sq'])) { |
|
| 1798 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1799 | + } |
|
| 1800 | + // squawk |
|
| 1338 | 1801 | //$data['aircraft_icao'] = $line[8]; |
| 1339 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1802 | + if (isset($line['inf']['rc'])) { |
|
| 1803 | + $data['registration'] = $line['inf']['rc']; |
|
| 1804 | + } |
|
| 1340 | 1805 | //$data['departure_airport_iata'] = $line[11]; |
| 1341 | 1806 | //$data['arrival_airport_iata'] = $line[12]; |
| 1342 | 1807 | //$data['emergency'] = ''; // emergency |
| 1343 | 1808 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1344 | 1809 | $data['format_source'] = 'radarvirtueljson'; |
| 1345 | 1810 | $data['id_source'] = $id_source; |
| 1346 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1347 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1811 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1812 | + $data['noarchive'] = true; |
|
| 1813 | + } |
|
| 1814 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1815 | + $data['source_name'] = $value['name']; |
|
| 1816 | + } |
|
| 1348 | 1817 | $SI->add($data); |
| 1349 | 1818 | unset($data); |
| 1350 | 1819 | } |
@@ -1370,30 +1839,65 @@ discard block |
||
| 1370 | 1839 | $data['id'] = $line['id']; |
| 1371 | 1840 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 1372 | 1841 | $data['ident'] = $line['callsign']; // ident |
| 1373 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1374 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1375 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1376 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1377 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1378 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1842 | + if (isset($line['pilotid'])) { |
|
| 1843 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1844 | + } |
|
| 1845 | + // pilot id |
|
| 1846 | + if (isset($line['name'])) { |
|
| 1847 | + $data['pilot_name'] = $line['name']; |
|
| 1848 | + } |
|
| 1849 | + // pilot name |
|
| 1850 | + if (isset($line['alt'])) { |
|
| 1851 | + $data['altitude'] = $line['alt']; |
|
| 1852 | + } |
|
| 1853 | + // altitude |
|
| 1854 | + if (isset($line['gs'])) { |
|
| 1855 | + $data['speed'] = $line['gs']; |
|
| 1856 | + } |
|
| 1857 | + // speed |
|
| 1858 | + if (isset($line['heading'])) { |
|
| 1859 | + $data['heading'] = $line['heading']; |
|
| 1860 | + } |
|
| 1861 | + // heading |
|
| 1862 | + if (isset($line['route'])) { |
|
| 1863 | + $data['waypoints'] = $line['route']; |
|
| 1864 | + } |
|
| 1865 | + // route |
|
| 1379 | 1866 | $data['latitude'] = $line['lat']; // lat |
| 1380 | 1867 | $data['longitude'] = $line['lon']; // long |
| 1381 | 1868 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 1382 | 1869 | //$data['squawk'] = $line['squawk']; // squawk |
| 1383 | 1870 | //$data['emergency'] = ''; // emergency |
| 1384 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1385 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1386 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1871 | + if (isset($line['depicao'])) { |
|
| 1872 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1873 | + } |
|
| 1874 | + if (isset($line['deptime'])) { |
|
| 1875 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1876 | + } |
|
| 1877 | + if (isset($line['arricao'])) { |
|
| 1878 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1879 | + } |
|
| 1387 | 1880 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 1388 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1389 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1390 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1391 | - else $data['info'] = ''; |
|
| 1881 | + if (isset($line['aircraft'])) { |
|
| 1882 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1883 | + } |
|
| 1884 | + if (isset($line['transponder'])) { |
|
| 1885 | + $data['squawk'] = $line['transponder']; |
|
| 1886 | + } |
|
| 1887 | + if (isset($line['atis'])) { |
|
| 1888 | + $data['info'] = $line['atis']; |
|
| 1889 | + } else { |
|
| 1890 | + $data['info'] = ''; |
|
| 1891 | + } |
|
| 1392 | 1892 | $data['format_source'] = 'pireps'; |
| 1393 | 1893 | $data['id_source'] = $id_source; |
| 1394 | 1894 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1395 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1396 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1895 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1896 | + $data['noarchive'] = true; |
|
| 1897 | + } |
|
| 1898 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1899 | + $data['source_name'] = $value['name']; |
|
| 1900 | + } |
|
| 1397 | 1901 | if ($line['icon'] === 'plane') { |
| 1398 | 1902 | $SI->add($data); |
| 1399 | 1903 | // print_r($data); |
@@ -1402,16 +1906,28 @@ discard block |
||
| 1402 | 1906 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1403 | 1907 | $typec = substr($data['ident'],-3); |
| 1404 | 1908 | $data['type'] = ''; |
| 1405 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 1406 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 1407 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 1408 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 1409 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 1410 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 1411 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 1412 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 1413 | - else $data['type'] = 'Observer'; |
|
| 1414 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
| 1909 | + if ($typec === 'APP') { |
|
| 1910 | + $data['type'] = 'Approach'; |
|
| 1911 | + } elseif ($typec === 'TWR') { |
|
| 1912 | + $data['type'] = 'Tower'; |
|
| 1913 | + } elseif ($typec === 'OBS') { |
|
| 1914 | + $data['type'] = 'Observer'; |
|
| 1915 | + } elseif ($typec === 'GND') { |
|
| 1916 | + $data['type'] = 'Ground'; |
|
| 1917 | + } elseif ($typec === 'DEL') { |
|
| 1918 | + $data['type'] = 'Delivery'; |
|
| 1919 | + } elseif ($typec === 'DEP') { |
|
| 1920 | + $data['type'] = 'Departure'; |
|
| 1921 | + } elseif ($typec === 'FSS') { |
|
| 1922 | + $data['type'] = 'Flight Service Station'; |
|
| 1923 | + } elseif ($typec === 'CTR') { |
|
| 1924 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1925 | + } else { |
|
| 1926 | + $data['type'] = 'Observer'; |
|
| 1927 | + } |
|
| 1928 | + if (isset($ATC)) { |
|
| 1929 | + echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
| 1930 | + } |
|
| 1415 | 1931 | } |
| 1416 | 1932 | unset($data); |
| 1417 | 1933 | } |
@@ -1426,7 +1942,9 @@ discard block |
||
| 1426 | 1942 | ) |
| 1427 | 1943 | ) { |
| 1428 | 1944 | //$buffer = $Common->getData($hosts[$id]); |
| 1429 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1945 | + if ($globalDebug) { |
|
| 1946 | + echo 'Get Data...'."\n"; |
|
| 1947 | + } |
|
| 1430 | 1948 | $buffer = $Common->getData($value['host']); |
| 1431 | 1949 | $all_data = json_decode($buffer,true); |
| 1432 | 1950 | if ($buffer != '' && is_array($all_data)) { |
@@ -1434,10 +1952,16 @@ discard block |
||
| 1434 | 1952 | foreach ($all_data as $line) { |
| 1435 | 1953 | $data = array(); |
| 1436 | 1954 | //$data['id'] = $line['id']; // id not usable |
| 1437 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1955 | + if (isset($line['pilotid'])) { |
|
| 1956 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1957 | + } |
|
| 1438 | 1958 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1439 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1440 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1959 | + if (isset($line['pilotname'])) { |
|
| 1960 | + $data['pilot_name'] = $line['pilotname']; |
|
| 1961 | + } |
|
| 1962 | + if (isset($line['pilotid'])) { |
|
| 1963 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1964 | + } |
|
| 1441 | 1965 | $data['ident'] = $line['flightnum']; // ident |
| 1442 | 1966 | $data['altitude'] = $line['alt']; // altitude |
| 1443 | 1967 | $data['speed'] = $line['gs']; // speed |
@@ -1453,7 +1977,9 @@ discard block |
||
| 1453 | 1977 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
| 1454 | 1978 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1455 | 1979 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1456 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1980 | + } else { |
|
| 1981 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1982 | + } |
|
| 1457 | 1983 | $data['departure_airport_icao'] = $line['depicao']; |
| 1458 | 1984 | $data['departure_airport_time'] = $line['deptime']; |
| 1459 | 1985 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1461,29 +1987,47 @@ discard block |
||
| 1461 | 1987 | if (isset($line['registration'])) { |
| 1462 | 1988 | $data['registration'] = $line['registration']; |
| 1463 | 1989 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
| 1464 | - } else $data['registration'] = $line['aircraft']; |
|
| 1465 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1466 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1990 | + } else { |
|
| 1991 | + $data['registration'] = $line['aircraft']; |
|
| 1992 | + } |
|
| 1993 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1994 | + $data['noarchive'] = true; |
|
| 1995 | + } |
|
| 1996 | + if (isset($line['route'])) { |
|
| 1997 | + $data['waypoints'] = $line['route']; |
|
| 1998 | + } |
|
| 1999 | + // route |
|
| 1467 | 2000 | if (isset($line['aircraftname'])) { |
| 1468 | 2001 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1469 | 2002 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1470 | 2003 | $aircraft_data = explode('-',$line['aircraftname']); |
| 1471 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1472 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1473 | - else { |
|
| 2004 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 2005 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 2006 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 2007 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 2008 | + } else { |
|
| 1474 | 2009 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 1475 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1476 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 2010 | + if (isset($aircraft_data[1])) { |
|
| 2011 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 2012 | + } else { |
|
| 2013 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 2014 | + } |
|
| 1477 | 2015 | } |
| 1478 | 2016 | } |
| 1479 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 2017 | + if (isset($line['route'])) { |
|
| 2018 | + $data['waypoints'] = $line['route']; |
|
| 2019 | + } |
|
| 1480 | 2020 | $data['id_source'] = $id_source; |
| 1481 | 2021 | $data['format_source'] = 'phpvmacars'; |
| 1482 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2022 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2023 | + $data['source_name'] = $value['name']; |
|
| 2024 | + } |
|
| 1483 | 2025 | $SI->add($data); |
| 1484 | 2026 | unset($data); |
| 1485 | 2027 | } |
| 1486 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2028 | + if ($globalDebug) { |
|
| 2029 | + echo 'No more data...'."\n"; |
|
| 2030 | + } |
|
| 1487 | 2031 | unset($buffer); |
| 1488 | 2032 | unset($all_data); |
| 1489 | 2033 | } |
@@ -1496,7 +2040,9 @@ discard block |
||
| 1496 | 2040 | ) |
| 1497 | 2041 | ) { |
| 1498 | 2042 | //$buffer = $Common->getData($hosts[$id]); |
| 1499 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2043 | + if ($globalDebug) { |
|
| 2044 | + echo 'Get Data...'."\n"; |
|
| 2045 | + } |
|
| 1500 | 2046 | $buffer = $Common->getData($value['host']); |
| 1501 | 2047 | $all_data = json_decode($buffer,true); |
| 1502 | 2048 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1507,10 +2053,16 @@ discard block |
||
| 1507 | 2053 | //$data['id'] = $line['id']; // id not usable |
| 1508 | 2054 | $data['id'] = $line['id']; |
| 1509 | 2055 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1510 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1511 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 2056 | + if (isset($line['user']['username'])) { |
|
| 2057 | + $data['pilot_name'] = $line['user']['username']; |
|
| 2058 | + } |
|
| 2059 | + if (isset($line['user_id'])) { |
|
| 2060 | + $data['pilot_id'] = $line['user_id']; |
|
| 2061 | + } |
|
| 1512 | 2062 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
| 1513 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 2063 | + if (is_numeric($data['ident'])) { |
|
| 2064 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 2065 | + } |
|
| 1514 | 2066 | $data['altitude'] = $line['altitude']; // altitude |
| 1515 | 2067 | $data['speed'] = $line['groundspeed']; // speed |
| 1516 | 2068 | $data['heading'] = $line['heading']; // heading |
@@ -1523,7 +2075,9 @@ discard block |
||
| 1523 | 2075 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
| 1524 | 2076 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1525 | 2077 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1526 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2078 | + } else { |
|
| 2079 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2080 | + } |
|
| 1527 | 2081 | |
| 1528 | 2082 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
| 1529 | 2083 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1531,17 +2085,26 @@ discard block |
||
| 1531 | 2085 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
| 1532 | 2086 | $data['registration'] = $line['bid']['aircraft']['registration']; |
| 1533 | 2087 | |
| 1534 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1535 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 2088 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2089 | + $data['noarchive'] = true; |
|
| 2090 | + } |
|
| 2091 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
| 2092 | + $data['waypoints'] = $line['bid']['route']; |
|
| 2093 | + } |
|
| 2094 | + // route |
|
| 1536 | 2095 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
| 1537 | 2096 | |
| 1538 | 2097 | $data['id_source'] = $id_source; |
| 1539 | 2098 | $data['format_source'] = 'vaos'; |
| 1540 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2099 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2100 | + $data['source_name'] = $value['name']; |
|
| 2101 | + } |
|
| 1541 | 2102 | $SI->add($data); |
| 1542 | 2103 | unset($data); |
| 1543 | 2104 | } |
| 1544 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2105 | + if ($globalDebug) { |
|
| 2106 | + echo 'No more data...'."\n"; |
|
| 2107 | + } |
|
| 1545 | 2108 | unset($buffer); |
| 1546 | 2109 | unset($all_data); |
| 1547 | 2110 | } |
@@ -1554,7 +2117,9 @@ discard block |
||
| 1554 | 2117 | ) |
| 1555 | 2118 | ) { |
| 1556 | 2119 | //$buffer = $Common->getData($hosts[$id]); |
| 1557 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2120 | + if ($globalDebug) { |
|
| 2121 | + echo 'Get Data...'."\n"; |
|
| 2122 | + } |
|
| 1558 | 2123 | $buffer = $Common->getData($value['host']); |
| 1559 | 2124 | $all_data = json_decode($buffer,true); |
| 1560 | 2125 | if ($buffer != '' && is_array($all_data)) { |
@@ -1583,16 +2148,25 @@ discard block |
||
| 1583 | 2148 | $data['arrival_airport_icao'] = $line['arrival']; |
| 1584 | 2149 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 1585 | 2150 | //$data['registration'] = $line['aircraft']; |
| 1586 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 2151 | + if (isset($line['route'])) { |
|
| 2152 | + $data['waypoints'] = $line['route']; |
|
| 2153 | + } |
|
| 2154 | + // route |
|
| 1587 | 2155 | $data['aircraft_icao'] = $line['plane_type']; |
| 1588 | 2156 | $data['id_source'] = $id_source; |
| 1589 | 2157 | $data['format_source'] = 'vam'; |
| 1590 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1591 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2158 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2159 | + $data['noarchive'] = true; |
|
| 2160 | + } |
|
| 2161 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2162 | + $data['source_name'] = $value['name']; |
|
| 2163 | + } |
|
| 1592 | 2164 | $SI->add($data); |
| 1593 | 2165 | unset($data); |
| 1594 | 2166 | } |
| 1595 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2167 | + if ($globalDebug) { |
|
| 2168 | + echo 'No more data...'."\n"; |
|
| 2169 | + } |
|
| 1596 | 2170 | unset($buffer); |
| 1597 | 2171 | unset($all_data); |
| 1598 | 2172 | } |
@@ -1605,7 +2179,9 @@ discard block |
||
| 1605 | 2179 | ) |
| 1606 | 2180 | ) { |
| 1607 | 2181 | //$buffer = $Common->getData($hosts[$id]); |
| 1608 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2182 | + if ($globalDebug) { |
|
| 2183 | + echo 'Get Data...'."\n"; |
|
| 2184 | + } |
|
| 1609 | 2185 | $buffer = $Common->getData($value['host']); |
| 1610 | 2186 | $all_data = json_decode($buffer,true); |
| 1611 | 2187 | if ($buffer != '') { |
@@ -1623,12 +2199,16 @@ discard block |
||
| 1623 | 2199 | $data['id_source'] = $id_source; |
| 1624 | 2200 | $data['format_source'] = 'blitzortung'; |
| 1625 | 2201 | $SI->add($data); |
| 1626 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2202 | + if ($globalDebug) { |
|
| 2203 | + echo '☈ Lightning added'."\n"; |
|
| 2204 | + } |
|
| 1627 | 2205 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1628 | 2206 | unset($data); |
| 1629 | 2207 | } |
| 1630 | 2208 | } |
| 1631 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2209 | + if ($globalDebug) { |
|
| 2210 | + echo 'No more data...'."\n"; |
|
| 2211 | + } |
|
| 1632 | 2212 | unset($buffer); |
| 1633 | 2213 | } |
| 1634 | 2214 | $last_exec[$id]['last'] = time(); |
@@ -1657,10 +2237,15 @@ discard block |
||
| 1657 | 2237 | } |
| 1658 | 2238 | } else { |
| 1659 | 2239 | $format = $value['format']; |
| 1660 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1661 | - else $tt[$format] = 0; |
|
| 2240 | + if (isset($tt[$format])) { |
|
| 2241 | + $tt[$format]++; |
|
| 2242 | + } else { |
|
| 2243 | + $tt[$format] = 0; |
|
| 2244 | + } |
|
| 1662 | 2245 | if ($tt[$format] > 30) { |
| 1663 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 2246 | + if ($globalDebug) { |
|
| 2247 | + echo 'Reconnect...'."\n"; |
|
| 2248 | + } |
|
| 1664 | 2249 | sleep(2); |
| 1665 | 2250 | //$sourceeen[] = $value; |
| 1666 | 2251 | //connect_all($sourceeen); |
@@ -1677,7 +2262,9 @@ discard block |
||
| 1677 | 2262 | $write = NULL; |
| 1678 | 2263 | $e = NULL; |
| 1679 | 2264 | $n = socket_select($read, $write, $e, $timeout); |
| 1680 | - if ($e != NULL) var_dump($e); |
|
| 2265 | + if ($e != NULL) { |
|
| 2266 | + var_dump($e); |
|
| 2267 | + } |
|
| 1681 | 2268 | if ($n > 0) { |
| 1682 | 2269 | $reset = 0; |
| 1683 | 2270 | foreach ($read as $nb => $r) { |
@@ -1699,13 +2286,17 @@ discard block |
||
| 1699 | 2286 | if ($buffer !== FALSE) { |
| 1700 | 2287 | if ($format === 'vrstcp') { |
| 1701 | 2288 | $buffer = explode('},{',$buffer); |
| 1702 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2289 | + } else { |
|
| 2290 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2291 | + } |
|
| 1703 | 2292 | } |
| 1704 | 2293 | // SBS format is CSV format |
| 1705 | 2294 | if ($buffer !== FALSE && $buffer !== '') { |
| 1706 | 2295 | $tt[$format] = 0; |
| 1707 | 2296 | if ($format === 'acarssbs3') { |
| 1708 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2297 | + if ($globalDebug) { |
|
| 2298 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2299 | + } |
|
| 1709 | 2300 | $ACARS->add(trim($buffer)); |
| 1710 | 2301 | $ACARS->deleteLiveAcarsData(); |
| 1711 | 2302 | } elseif ($format === 'raw') { |
@@ -1715,9 +2306,15 @@ discard block |
||
| 1715 | 2306 | //if (!empty($data)) print_r($data); |
| 1716 | 2307 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1717 | 2308 | $data['format_source'] = 'raw'; |
| 1718 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1719 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1720 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2309 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2310 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2311 | + } |
|
| 2312 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2313 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2314 | + } |
|
| 2315 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2316 | + $data['noarchive'] = true; |
|
| 2317 | + } |
|
| 1721 | 2318 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1722 | 2319 | $SI->add($data); |
| 1723 | 2320 | unset($data); |
@@ -1725,22 +2322,54 @@ discard block |
||
| 1725 | 2322 | } elseif ($format === 'ais') { |
| 1726 | 2323 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1727 | 2324 | $data = array(); |
| 1728 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1729 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1730 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1731 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1732 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1733 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1734 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1735 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1736 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1737 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1738 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1739 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1740 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1741 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1742 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1743 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2325 | + if (isset($ais_data['ident'])) { |
|
| 2326 | + $data['ident'] = $ais_data['ident']; |
|
| 2327 | + } |
|
| 2328 | + if (isset($ais_data['mmsi'])) { |
|
| 2329 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 2330 | + } |
|
| 2331 | + if (isset($ais_data['speed'])) { |
|
| 2332 | + $data['speed'] = $ais_data['speed']; |
|
| 2333 | + } |
|
| 2334 | + if (isset($ais_data['heading'])) { |
|
| 2335 | + $data['heading'] = $ais_data['heading']; |
|
| 2336 | + } |
|
| 2337 | + if (isset($ais_data['latitude'])) { |
|
| 2338 | + $data['latitude'] = $ais_data['latitude']; |
|
| 2339 | + } |
|
| 2340 | + if (isset($ais_data['longitude'])) { |
|
| 2341 | + $data['longitude'] = $ais_data['longitude']; |
|
| 2342 | + } |
|
| 2343 | + if (isset($ais_data['status'])) { |
|
| 2344 | + $data['status'] = $ais_data['status']; |
|
| 2345 | + } |
|
| 2346 | + if (isset($ais_data['statusid'])) { |
|
| 2347 | + $data['status_id'] = $ais_data['statusid']; |
|
| 2348 | + } |
|
| 2349 | + if (isset($ais_data['type'])) { |
|
| 2350 | + $data['type'] = $ais_data['type']; |
|
| 2351 | + } |
|
| 2352 | + if (isset($ais_data['imo'])) { |
|
| 2353 | + $data['imo'] = $ais_data['imo']; |
|
| 2354 | + } |
|
| 2355 | + if (isset($ais_data['callsign'])) { |
|
| 2356 | + $data['callsign'] = $ais_data['callsign']; |
|
| 2357 | + } |
|
| 2358 | + if (isset($ais_data['destination'])) { |
|
| 2359 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 2360 | + } |
|
| 2361 | + if (isset($ais_data['eta_ts'])) { |
|
| 2362 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 2363 | + } |
|
| 2364 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2365 | + $data['noarchive'] = true; |
|
| 2366 | + } |
|
| 2367 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2368 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2369 | + } |
|
| 2370 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2371 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2372 | + } |
|
| 1744 | 2373 | |
| 1745 | 2374 | if (isset($ais_data['timestamp'])) { |
| 1746 | 2375 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1749,7 +2378,9 @@ discard block |
||
| 1749 | 2378 | } |
| 1750 | 2379 | $data['format_source'] = 'aisnmea'; |
| 1751 | 2380 | $data['id_source'] = $id_source; |
| 1752 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 2381 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 2382 | + $MI->add($data); |
|
| 2383 | + } |
|
| 1753 | 2384 | unset($data); |
| 1754 | 2385 | } elseif ($format === 'flightgearsp') { |
| 1755 | 2386 | //echo $buffer."\n"; |
@@ -1767,17 +2398,25 @@ discard block |
||
| 1767 | 2398 | $data['speed'] = round($line[5]*1.94384); |
| 1768 | 2399 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1769 | 2400 | $data['format_source'] = 'flightgearsp'; |
| 1770 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1771 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2401 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2402 | + $data['noarchive'] = true; |
|
| 2403 | + } |
|
| 2404 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2405 | + $SI->add($data); |
|
| 2406 | + } |
|
| 1772 | 2407 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1773 | 2408 | } |
| 1774 | 2409 | } elseif ($format === 'acars') { |
| 1775 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2410 | + if ($globalDebug) { |
|
| 2411 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2412 | + } |
|
| 1776 | 2413 | $ACARS->add(trim($buffer)); |
| 1777 | 2414 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1778 | 2415 | $ACARS->deleteLiveAcarsData(); |
| 1779 | 2416 | } elseif ($format === 'acarsjsonudp') { |
| 1780 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2417 | + if ($globalDebug) { |
|
| 2418 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2419 | + } |
|
| 1781 | 2420 | $line = json_decode(trim($buffer), true); |
| 1782 | 2421 | if (!empty($line)) { |
| 1783 | 2422 | $line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); |
@@ -1802,8 +2441,12 @@ discard block |
||
| 1802 | 2441 | $aircraft_type = $line[10]; |
| 1803 | 2442 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1804 | 2443 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1805 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1806 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2444 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2445 | + $data['noarchive'] = true; |
|
| 2446 | + } |
|
| 2447 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2448 | + $SI->add($data); |
|
| 2449 | + } |
|
| 1807 | 2450 | } |
| 1808 | 2451 | } |
| 1809 | 2452 | } elseif ($format === 'beast') { |
@@ -1813,28 +2456,62 @@ discard block |
||
| 1813 | 2456 | foreach($buffer as $all_data) { |
| 1814 | 2457 | $line = json_decode('{'.$all_data.'}',true); |
| 1815 | 2458 | $data = array(); |
| 1816 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1817 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1818 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1819 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1820 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1821 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1822 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 2459 | + if (isset($line['Icao'])) { |
|
| 2460 | + $data['hex'] = $line['Icao']; |
|
| 2461 | + } |
|
| 2462 | + // hex |
|
| 2463 | + if (isset($line['Call'])) { |
|
| 2464 | + $data['ident'] = $line['Call']; |
|
| 2465 | + } |
|
| 2466 | + // ident |
|
| 2467 | + if (isset($line['Alt'])) { |
|
| 2468 | + $data['altitude'] = $line['Alt']; |
|
| 2469 | + } |
|
| 2470 | + // altitude |
|
| 2471 | + if (isset($line['Spd'])) { |
|
| 2472 | + $data['speed'] = $line['Spd']; |
|
| 2473 | + } |
|
| 2474 | + // speed |
|
| 2475 | + if (isset($line['Trak'])) { |
|
| 2476 | + $data['heading'] = $line['Trak']; |
|
| 2477 | + } |
|
| 2478 | + // heading |
|
| 2479 | + if (isset($line['Lat'])) { |
|
| 2480 | + $data['latitude'] = $line['Lat']; |
|
| 2481 | + } |
|
| 2482 | + // lat |
|
| 2483 | + if (isset($line['Long'])) { |
|
| 2484 | + $data['longitude'] = $line['Long']; |
|
| 2485 | + } |
|
| 2486 | + // long |
|
| 1823 | 2487 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1824 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 2488 | + if (isset($line['Sqk'])) { |
|
| 2489 | + $data['squawk'] = $line['Sqk']; |
|
| 2490 | + } |
|
| 2491 | + // squawk |
|
| 1825 | 2492 | $data['emergency'] = ''; // emergency |
| 1826 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 2493 | + if (isset($line['Reg'])) { |
|
| 2494 | + $data['registration'] = $line['Reg']; |
|
| 2495 | + } |
|
| 1827 | 2496 | /* |
| 1828 | 2497 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1829 | 2498 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1830 | 2499 | */ |
| 1831 | 2500 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1832 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 2501 | + if (isset($line['Type'])) { |
|
| 2502 | + $data['aircraft_icao'] = $line['Type']; |
|
| 2503 | + } |
|
| 1833 | 2504 | $data['format_source'] = 'vrstcp'; |
| 1834 | 2505 | $data['id_source'] = $id_source; |
| 1835 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1836 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1837 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 2506 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2507 | + $data['noarchive'] = true; |
|
| 2508 | + } |
|
| 2509 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2510 | + $data['source_name'] = $value['name']; |
|
| 2511 | + } |
|
| 2512 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 2513 | + $SI->add($data); |
|
| 2514 | + } |
|
| 1838 | 2515 | unset($data); |
| 1839 | 2516 | } |
| 1840 | 2517 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1847,22 +2524,46 @@ discard block |
||
| 1847 | 2524 | $data['hex'] = $lined['hexid']; |
| 1848 | 2525 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1849 | 2526 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1850 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1851 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1852 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1853 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1854 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1855 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1856 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 2527 | + if (isset($lined['ident'])) { |
|
| 2528 | + $data['ident'] = $lined['ident']; |
|
| 2529 | + } |
|
| 2530 | + if (isset($lined['lat'])) { |
|
| 2531 | + $data['latitude'] = $lined['lat']; |
|
| 2532 | + } |
|
| 2533 | + if (isset($lined['lon'])) { |
|
| 2534 | + $data['longitude'] = $lined['lon']; |
|
| 2535 | + } |
|
| 2536 | + if (isset($lined['speed'])) { |
|
| 2537 | + $data['speed'] = $lined['speed']; |
|
| 2538 | + } |
|
| 2539 | + if (isset($lined['squawk'])) { |
|
| 2540 | + $data['squawk'] = $lined['squawk']; |
|
| 2541 | + } |
|
| 2542 | + if (isset($lined['alt'])) { |
|
| 2543 | + $data['altitude'] = $lined['alt']; |
|
| 2544 | + } |
|
| 2545 | + if (isset($lined['heading'])) { |
|
| 2546 | + $data['heading'] = $lined['heading']; |
|
| 2547 | + } |
|
| 1857 | 2548 | $data['id_source'] = $id_source; |
| 1858 | 2549 | $data['format_source'] = 'tsv'; |
| 1859 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1860 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1861 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1862 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2550 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2551 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2552 | + } |
|
| 2553 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2554 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2555 | + } |
|
| 2556 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2557 | + $data['noarchive'] = true; |
|
| 2558 | + } |
|
| 2559 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2560 | + $SI->add($data); |
|
| 2561 | + } |
|
| 1863 | 2562 | unset($lined); |
| 1864 | 2563 | unset($data); |
| 1865 | - } else $error = true; |
|
| 2564 | + } else { |
|
| 2565 | + $error = true; |
|
| 2566 | + } |
|
| 1866 | 2567 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1867 | 2568 | if ($aprs_connect === 0) { |
| 1868 | 2569 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1888,47 +2589,96 @@ discard block |
||
| 1888 | 2589 | $aprs_last_tx = time(); |
| 1889 | 2590 | $data = array(); |
| 1890 | 2591 | //print_r($line); |
| 1891 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1892 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1893 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1894 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1895 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1896 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1897 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1898 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1899 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1900 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2592 | + if (isset($line['address'])) { |
|
| 2593 | + $data['hex'] = $line['address']; |
|
| 2594 | + } |
|
| 2595 | + if (isset($line['mmsi'])) { |
|
| 2596 | + $data['mmsi'] = $line['mmsi']; |
|
| 2597 | + } |
|
| 2598 | + if (isset($line['imo'])) { |
|
| 2599 | + $data['imo'] = $line['imo']; |
|
| 2600 | + } |
|
| 2601 | + if (isset($line['squawk'])) { |
|
| 2602 | + $data['squawk'] = $line['squawk']; |
|
| 2603 | + } |
|
| 2604 | + if (isset($line['arrival_code'])) { |
|
| 2605 | + $data['arrival_code'] = $line['arrival_code']; |
|
| 2606 | + } |
|
| 2607 | + if (isset($line['arrival_date'])) { |
|
| 2608 | + $data['arrival_date'] = $line['arrival_date']; |
|
| 2609 | + } |
|
| 2610 | + if (isset($line['typeid'])) { |
|
| 2611 | + $data['type_id'] = $line['typeid']; |
|
| 2612 | + } |
|
| 2613 | + if (isset($line['statusid'])) { |
|
| 2614 | + $data['status_id'] = $line['statusid']; |
|
| 2615 | + } |
|
| 2616 | + if (isset($line['timestamp'])) { |
|
| 2617 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 2618 | + } else { |
|
| 2619 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2620 | + } |
|
| 1901 | 2621 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1902 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 2622 | + if (isset($line['ident'])) { |
|
| 2623 | + $data['ident'] = $line['ident']; |
|
| 2624 | + } |
|
| 1903 | 2625 | $data['latitude'] = $line['latitude']; |
| 1904 | 2626 | $data['longitude'] = $line['longitude']; |
| 1905 | 2627 | //$data['verticalrate'] = $line[16]; |
| 1906 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 2628 | + if (isset($line['speed'])) { |
|
| 2629 | + $data['speed'] = $line['speed']; |
|
| 2630 | + } |
|
| 1907 | 2631 | //else $data['speed'] = 0; |
| 1908 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1909 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1910 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 2632 | + if (isset($line['altitude'])) { |
|
| 2633 | + $data['altitude'] = $line['altitude']; |
|
| 2634 | + } |
|
| 2635 | + if (isset($line['comment'])) { |
|
| 2636 | + $data['comment'] = $line['comment']; |
|
| 2637 | + } |
|
| 2638 | + if (isset($line['symbol'])) { |
|
| 2639 | + $data['type'] = $line['symbol']; |
|
| 2640 | + } |
|
| 1911 | 2641 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
| 1912 | 2642 | |
| 1913 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 2643 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
| 2644 | + $data['heading'] = $line['heading']; |
|
| 2645 | + } |
|
| 1914 | 2646 | //else echo 'No heading...'."\n"; |
| 1915 | 2647 | //else $data['heading'] = 0; |
| 1916 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 2648 | + if (isset($line['stealth'])) { |
|
| 2649 | + $data['aircraft_type'] = $line['stealth']; |
|
| 2650 | + } |
|
| 1917 | 2651 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
| 1918 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1919 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1920 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1921 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 2652 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
| 2653 | + $data['noarchive'] = true; |
|
| 2654 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
| 2655 | + $data['noarchive'] = false; |
|
| 2656 | + } |
|
| 2657 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2658 | + $data['noarchive'] = true; |
|
| 2659 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
| 2660 | + $data['noarchive'] = false; |
|
| 2661 | + } |
|
| 1922 | 2662 | $data['id_source'] = $id_source; |
| 1923 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1924 | - else $data['format_source'] = 'aprs'; |
|
| 2663 | + if (isset($line['format_source'])) { |
|
| 2664 | + $data['format_source'] = $line['format_source']; |
|
| 2665 | + } else { |
|
| 2666 | + $data['format_source'] = 'aprs'; |
|
| 2667 | + } |
|
| 1925 | 2668 | $data['source_name'] = $line['source']; |
| 1926 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1927 | - else $data['source_type'] = 'flarm'; |
|
| 1928 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2669 | + if (isset($line['source_type'])) { |
|
| 2670 | + $data['source_type'] = $line['source_type']; |
|
| 2671 | + } else { |
|
| 2672 | + $data['source_type'] = 'flarm'; |
|
| 2673 | + } |
|
| 2674 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2675 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2676 | + } |
|
| 1929 | 2677 | $currentdate = date('Y-m-d H:i:s'); |
| 1930 | 2678 | $aprsdate = strtotime($data['datetime']); |
| 1931 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 2679 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
| 2680 | + $data['altitude_relative'] = 'AMSL'; |
|
| 2681 | + } |
|
| 1932 | 2682 | // Accept data if time <= system time + 20s |
| 1933 | 2683 | //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 1934 | 2684 | if ( |
@@ -1940,7 +2690,9 @@ discard block |
||
| 1940 | 2690 | $send = $SI->add($data); |
| 1941 | 2691 | } elseif ($data['source_type'] === 'ais') { |
| 1942 | 2692 | $data['type'] = ''; |
| 1943 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
| 2693 | + if (isset($globalMarine) && $globalMarine) { |
|
| 2694 | + $send = $MI->add($data); |
|
| 2695 | + } |
|
| 1944 | 2696 | } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
| 1945 | 2697 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1946 | 2698 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
@@ -1948,8 +2700,12 @@ discard block |
||
| 1948 | 2700 | $line['symbol'] === 'Glider' || |
| 1949 | 2701 | $line['symbol'] === 'No. Plane' || |
| 1950 | 2702 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
| 1951 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1952 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2703 | + if ($line['symbol'] === 'Ballon') { |
|
| 2704 | + $data['aircraft_icao'] = 'BALL'; |
|
| 2705 | + } |
|
| 2706 | + if ($line['symbol'] === 'Glider') { |
|
| 2707 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2708 | + } |
|
| 1953 | 2709 | $send = $SI->add($data); |
| 1954 | 2710 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
| 1955 | 2711 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -1980,9 +2736,13 @@ discard block |
||
| 1980 | 2736 | //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
| 1981 | 2737 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
| 1982 | 2738 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1983 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 2739 | + if (isset($globalTracker) && $globalTracker) { |
|
| 2740 | + $send = $TI->add($data); |
|
| 2741 | + } |
|
| 1984 | 2742 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
| 1985 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
| 2743 | + if (!isset($data['altitude'])) { |
|
| 2744 | + $data['altitude'] = 0; |
|
| 2745 | + } |
|
| 1986 | 2746 | $Source->deleteOldLocationByType('gs'); |
| 1987 | 2747 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
| 1988 | 2748 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1991,7 +2751,9 @@ discard block |
||
| 1991 | 2751 | } |
| 1992 | 2752 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
| 1993 | 2753 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1994 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
| 2754 | + if ($globalDebug) { |
|
| 2755 | + echo '# Weather Station added'."\n"; |
|
| 2756 | + } |
|
| 1995 | 2757 | $Source->deleteOldLocationByType('wx'); |
| 1996 | 2758 | $weather_data = json_encode($line); |
| 1997 | 2759 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -2001,7 +2763,9 @@ discard block |
||
| 2001 | 2763 | } |
| 2002 | 2764 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
| 2003 | 2765 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2004 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2766 | + if ($globalDebug) { |
|
| 2767 | + echo '☈ Lightning added'."\n"; |
|
| 2768 | + } |
|
| 2005 | 2769 | $Source->deleteOldLocationByType('lightning'); |
| 2006 | 2770 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
| 2007 | 2771 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -2013,8 +2777,7 @@ discard block |
||
| 2013 | 2777 | print_r($line); |
| 2014 | 2778 | } |
| 2015 | 2779 | unset($data); |
| 2016 | - } |
|
| 2017 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2780 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2018 | 2781 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
| 2019 | 2782 | } |
| 2020 | 2783 | /* |
@@ -2023,7 +2786,9 @@ discard block |
||
| 2023 | 2786 | } |
| 2024 | 2787 | */ |
| 2025 | 2788 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 2026 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
| 2789 | + elseif ($line === true && $globalDebug) { |
|
| 2790 | + echo '!! Failed : '.$buffer."!!\n"; |
|
| 2791 | + } |
|
| 2027 | 2792 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
| 2028 | 2793 | $Source->deleteOldLocationByType('lightning'); |
| 2029 | 2794 | $Source->deleteOldLocationByType('wx'); |
@@ -2060,27 +2825,47 @@ discard block |
||
| 2060 | 2825 | $data['ground'] = $line[21]; |
| 2061 | 2826 | $data['emergency'] = $line[19]; |
| 2062 | 2827 | $data['format_source'] = 'sbs'; |
| 2063 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2064 | - elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
|
| 2065 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2066 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2828 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2829 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2830 | + } elseif ($line[0] == 'MLAT') { |
|
| 2831 | + $data['source_name'] = 'MLAT'; |
|
| 2832 | + } |
|
| 2833 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2834 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2835 | + } |
|
| 2836 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2837 | + $data['noarchive'] = true; |
|
| 2838 | + } |
|
| 2067 | 2839 | $data['id_source'] = $id_source; |
| 2068 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 2069 | - else $error = true; |
|
| 2840 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2841 | + $send = $SI->add($data); |
|
| 2842 | + } else { |
|
| 2843 | + $error = true; |
|
| 2844 | + } |
|
| 2070 | 2845 | unset($data); |
| 2071 | - } else $error = true; |
|
| 2846 | + } else { |
|
| 2847 | + $error = true; |
|
| 2848 | + } |
|
| 2072 | 2849 | if ($error) { |
| 2073 | 2850 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
| 2074 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 2851 | + if ($globalDebug) { |
|
| 2852 | + echo "Not a message. Ignoring... \n"; |
|
| 2853 | + } |
|
| 2075 | 2854 | } else { |
| 2076 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 2855 | + if ($globalDebug) { |
|
| 2856 | + echo "Wrong line format. Ignoring... \n"; |
|
| 2857 | + } |
|
| 2077 | 2858 | if ($globalDebug) { |
| 2078 | 2859 | echo $buffer; |
| 2079 | 2860 | //print_r($line); |
| 2080 | 2861 | } |
| 2081 | 2862 | //socket_close($r); |
| 2082 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 2083 | - if ($format === 'aprs') $aprs_connect = 0; |
|
| 2863 | + if ($globalDebug) { |
|
| 2864 | + echo "Reconnect after an error...\n"; |
|
| 2865 | + } |
|
| 2866 | + if ($format === 'aprs') { |
|
| 2867 | + $aprs_connect = 0; |
|
| 2868 | + } |
|
| 2084 | 2869 | $sourceer[$nb] = $globalSources[$nb]; |
| 2085 | 2870 | connect_all($sourceer); |
| 2086 | 2871 | $sourceer = array(); |
@@ -2088,10 +2873,14 @@ discard block |
||
| 2088 | 2873 | } |
| 2089 | 2874 | } |
| 2090 | 2875 | // Sleep for xxx microseconds |
| 2091 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 2876 | + if (isset($globalSBSSleep)) { |
|
| 2877 | + usleep($globalSBSSleep); |
|
| 2878 | + } |
|
| 2092 | 2879 | } else { |
| 2093 | 2880 | if ($format === 'flightgearmp') { |
| 2094 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2881 | + if ($globalDebug) { |
|
| 2882 | + echo "Reconnect FlightGear MP..."; |
|
| 2883 | + } |
|
| 2095 | 2884 | //@socket_close($r); |
| 2096 | 2885 | sleep($globalMinFetch); |
| 2097 | 2886 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -2100,10 +2889,15 @@ discard block |
||
| 2100 | 2889 | break; |
| 2101 | 2890 | |
| 2102 | 2891 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 2103 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 2104 | - else $tt[$format] = 0; |
|
| 2892 | + if (isset($tt[$format])) { |
|
| 2893 | + $tt[$format]++; |
|
| 2894 | + } else { |
|
| 2895 | + $tt[$format] = 0; |
|
| 2896 | + } |
|
| 2105 | 2897 | if ($tt[$format] > 30 || $buffer === FALSE) { |
| 2106 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 2898 | + if ($globalDebug) { |
|
| 2899 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 2900 | + } |
|
| 2107 | 2901 | //@socket_close($r); |
| 2108 | 2902 | sleep(2); |
| 2109 | 2903 | $aprs_connect = 0; |
@@ -2121,11 +2915,17 @@ discard block |
||
| 2121 | 2915 | } else { |
| 2122 | 2916 | $error = socket_strerror(socket_last_error()); |
| 2123 | 2917 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 2124 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2125 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 2918 | + if ($globalDebug) { |
|
| 2919 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2920 | + } |
|
| 2921 | + if (isset($globalDebug)) { |
|
| 2922 | + echo "Restarting...\n"; |
|
| 2923 | + } |
|
| 2126 | 2924 | // Restart the script if possible |
| 2127 | 2925 | if (is_array($sockets)) { |
| 2128 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2926 | + if ($globalDebug) { |
|
| 2927 | + echo "Shutdown all sockets..."; |
|
| 2928 | + } |
|
| 2129 | 2929 | |
| 2130 | 2930 | foreach ($sockets as $sock) { |
| 2131 | 2931 | @socket_shutdown($sock,2); |
@@ -2133,25 +2933,45 @@ discard block |
||
| 2133 | 2933 | } |
| 2134 | 2934 | |
| 2135 | 2935 | } |
| 2136 | - if ($globalDebug) echo "Waiting..."; |
|
| 2936 | + if ($globalDebug) { |
|
| 2937 | + echo "Waiting..."; |
|
| 2938 | + } |
|
| 2137 | 2939 | sleep(2); |
| 2138 | 2940 | $time = time(); |
| 2139 | 2941 | //connect_all($hosts); |
| 2140 | 2942 | $aprs_connect = 0; |
| 2141 | - if ($reset%5 === 0) sleep(20); |
|
| 2142 | - if ($reset%10 === 0) sleep(100); |
|
| 2143 | - if ($reset%20 === 0) sleep(200); |
|
| 2144 | - if ($reset > 100) exit('Too many attempts...'); |
|
| 2145 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 2943 | + if ($reset%5 === 0) { |
|
| 2944 | + sleep(20); |
|
| 2945 | + } |
|
| 2946 | + if ($reset%10 === 0) { |
|
| 2947 | + sleep(100); |
|
| 2948 | + } |
|
| 2949 | + if ($reset%20 === 0) { |
|
| 2950 | + sleep(200); |
|
| 2951 | + } |
|
| 2952 | + if ($reset > 100) { |
|
| 2953 | + exit('Too many attempts...'); |
|
| 2954 | + } |
|
| 2955 | + if ($globalDebug) { |
|
| 2956 | + echo "Restart all connections..."; |
|
| 2957 | + } |
|
| 2146 | 2958 | connect_all($globalSources); |
| 2147 | 2959 | } |
| 2148 | 2960 | } |
| 2149 | 2961 | } |
| 2150 | 2962 | if ($globalDaemon === false) { |
| 2151 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2152 | - if (isset($SI)) $SI->checkAll(); |
|
| 2153 | - if (isset($TI)) $TI->checkAll(); |
|
| 2154 | - if (isset($MI)) $MI->checkAll(); |
|
| 2963 | + if ($globalDebug) { |
|
| 2964 | + echo 'Check all...'."\n"; |
|
| 2965 | + } |
|
| 2966 | + if (isset($SI)) { |
|
| 2967 | + $SI->checkAll(); |
|
| 2968 | + } |
|
| 2969 | + if (isset($TI)) { |
|
| 2970 | + $TI->checkAll(); |
|
| 2971 | + } |
|
| 2972 | + if (isset($MI)) { |
|
| 2973 | + $MI->checkAll(); |
|
| 2974 | + } |
|
| 2155 | 2975 | } |
| 2156 | 2976 | } |
| 2157 | 2977 | } |