@@ -165,6 +165,10 @@ discard block |
||
| 165 | 165 | '\~' => 'TNC Stream SW'); |
| 166 | 166 | |
| 167 | 167 | |
| 168 | + /** |
|
| 169 | + * @param integer $n |
|
| 170 | + * @param integer $s |
|
| 171 | + */ |
|
| 168 | 172 | private function urshift($n, $s) { |
| 169 | 173 | return ($n >= 0) ? ($n >> $s) : |
| 170 | 174 | (($n & 0x7fffffff) >> $s) | |
@@ -565,6 +569,9 @@ discard block |
||
| 565 | 569 | socket_close($this->socket); |
| 566 | 570 | } |
| 567 | 571 | |
| 572 | + /** |
|
| 573 | + * @param string $data |
|
| 574 | + */ |
|
| 568 | 575 | public function send($data) { |
| 569 | 576 | global $globalDebug; |
| 570 | 577 | if ($this->connected === false) $this->connect(); |
@@ -2,10 +2,10 @@ discard block |
||
| 2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
| 3 | 3 | require_once(dirname(__FILE__).'/class.Common.php'); |
| 4 | 4 | class aprs { |
| 5 | - private $socket; |
|
| 6 | - private $connected = false; |
|
| 5 | + private $socket; |
|
| 6 | + private $connected = false; |
|
| 7 | 7 | |
| 8 | - protected $symbols = array('/!' => 'Police', |
|
| 8 | + protected $symbols = array('/!' => 'Police', |
|
| 9 | 9 | '/#' => 'DIGI', |
| 10 | 10 | '/$' => 'Phone', |
| 11 | 11 | '/%' => 'DX Cluster', |
@@ -165,13 +165,13 @@ discard block |
||
| 165 | 165 | '\~' => 'TNC Stream SW'); |
| 166 | 166 | |
| 167 | 167 | |
| 168 | - private function urshift($n, $s) { |
|
| 168 | + private function urshift($n, $s) { |
|
| 169 | 169 | return ($n >= 0) ? ($n >> $s) : |
| 170 | - (($n & 0x7fffffff) >> $s) | |
|
| 170 | + (($n & 0x7fffffff) >> $s) | |
|
| 171 | 171 | (0x40000000 >> ($s - 1)); |
| 172 | - } |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - public function parse($input) { |
|
| 174 | + public function parse($input) { |
|
| 175 | 175 | global $globalDebug; |
| 176 | 176 | $debug = false; |
| 177 | 177 | $result = array(); |
@@ -183,8 +183,8 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | /* Check that end was found and body has at least one byte. */ |
| 185 | 185 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
| 186 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
| 187 | - return false; |
|
| 186 | + if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
| 187 | + return false; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | if ($debug) echo 'input : '.$input."\n"; |
@@ -198,34 +198,34 @@ discard block |
||
| 198 | 198 | /* Parse source, target and path. */ |
| 199 | 199 | //FLRDF0A52>APRS,qAS,LSTB |
| 200 | 200 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
| 201 | - $ident = $matches[1]; |
|
| 202 | - $all_elements = $matches[2]; |
|
| 203 | - if ($ident == 'AIRCRAFT') { |
|
| 201 | + $ident = $matches[1]; |
|
| 202 | + $all_elements = $matches[2]; |
|
| 203 | + if ($ident == 'AIRCRAFT') { |
|
| 204 | 204 | $result['format_source'] = 'famaprs'; |
| 205 | 205 | $result['source_type'] = 'modes'; |
| 206 | - } elseif ($ident == 'MARINE') { |
|
| 206 | + } elseif ($ident == 'MARINE') { |
|
| 207 | 207 | $result['format_source'] = 'famaprs'; |
| 208 | 208 | $result['source_type'] = 'ais'; |
| 209 | - } else { |
|
| 209 | + } else { |
|
| 210 | 210 | if ($debug) echo 'ident : '.$ident."\n"; |
| 211 | 211 | $result['ident'] = $ident; |
| 212 | - } |
|
| 212 | + } |
|
| 213 | 213 | } else { |
| 214 | - if ($debug) 'No ident'."\n"; |
|
| 215 | - return false; |
|
| 214 | + if ($debug) 'No ident'."\n"; |
|
| 215 | + return false; |
|
| 216 | 216 | } |
| 217 | 217 | $elements = explode(',',$all_elements); |
| 218 | 218 | $source = end($elements); |
| 219 | 219 | $result['source'] = $source; |
| 220 | 220 | foreach ($elements as $element) { |
| 221 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
| 222 | - //echo "ok"; |
|
| 223 | - //if ($element == 'TCPIP*') return false; |
|
| 224 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
| 221 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
| 222 | + //echo "ok"; |
|
| 223 | + //if ($element == 'TCPIP*') return false; |
|
| 224 | + } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
| 225 | 225 | if ($debug) echo 'element : '.$element."\n"; |
| 226 | 226 | return false; |
| 227 | - } |
|
| 228 | - /* |
|
| 227 | + } |
|
| 228 | + /* |
|
| 229 | 229 | } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
| 230 | 230 | //echo "ok"; |
| 231 | 231 | } else { |
@@ -252,49 +252,49 @@ discard block |
||
| 252 | 252 | $body_parse = substr($body,1); |
| 253 | 253 | //echo 'Body : '.$body."\n"; |
| 254 | 254 | if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
| 255 | - $body_parse = substr($body_parse,10); |
|
| 256 | - $find = true; |
|
| 257 | - //echo $body_parse."\n"; |
|
| 255 | + $body_parse = substr($body_parse,10); |
|
| 256 | + $find = true; |
|
| 257 | + //echo $body_parse."\n"; |
|
| 258 | 258 | } |
| 259 | 259 | if (preg_match('/^`(.*)\//',$body,$matches)) { |
| 260 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 261 | - $find = true; |
|
| 262 | - //echo $body_parse."\n"; |
|
| 260 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 261 | + $find = true; |
|
| 262 | + //echo $body_parse."\n"; |
|
| 263 | 263 | } |
| 264 | 264 | if (preg_match("/^'(.*)\//",$body,$matches)) { |
| 265 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 266 | - $find = true; |
|
| 267 | - //echo $body_parse."\n"; |
|
| 265 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 266 | + $find = true; |
|
| 267 | + //echo $body_parse."\n"; |
|
| 268 | 268 | } |
| 269 | 269 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
| 270 | - $find = true; |
|
| 271 | - //print_r($matches); |
|
| 272 | - $timestamp = $matches[0]; |
|
| 273 | - if ($matches[4] == 'h') { |
|
| 270 | + $find = true; |
|
| 271 | + //print_r($matches); |
|
| 272 | + $timestamp = $matches[0]; |
|
| 273 | + if ($matches[4] == 'h') { |
|
| 274 | 274 | $timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]); |
| 275 | 275 | //echo 'timestamp : '.$timestamp.' - now : '.time()."\n"; |
| 276 | 276 | /* |
| 277 | 277 | if (time() + 3900 < $timestamp) $timestamp -= 86400; |
| 278 | 278 | elseif (time() - 82500 > $timestamp) $timestamp += 86400; |
| 279 | 279 | */ |
| 280 | - } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
| 280 | + } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
| 281 | 281 | // This work or not ? |
| 282 | 282 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
| 283 | - } |
|
| 284 | - $body_parse = substr($body_parse,7); |
|
| 285 | - $result['timestamp'] = $timestamp; |
|
| 286 | - //echo date('Ymd H:i:s',$timestamp); |
|
| 283 | + } |
|
| 284 | + $body_parse = substr($body_parse,7); |
|
| 285 | + $result['timestamp'] = $timestamp; |
|
| 286 | + //echo date('Ymd H:i:s',$timestamp); |
|
| 287 | 287 | } |
| 288 | 288 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
| 289 | - $find = true; |
|
| 290 | - $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
| 291 | - $body_parse = substr($body_parse,8); |
|
| 292 | - $result['timestamp'] = $timestamp; |
|
| 293 | - //echo date('Ymd H:i:s',$timestamp); |
|
| 289 | + $find = true; |
|
| 290 | + $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
| 291 | + $body_parse = substr($body_parse,8); |
|
| 292 | + $result['timestamp'] = $timestamp; |
|
| 293 | + //echo date('Ymd H:i:s',$timestamp); |
|
| 294 | 294 | } |
| 295 | 295 | //if (strlen($body_parse) > 19) { |
| 296 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
| 297 | - $find = true; |
|
| 296 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
| 297 | + $find = true; |
|
| 298 | 298 | // 4658.70N/00707.78Ez |
| 299 | 299 | //print_r(str_split($body_parse)); |
| 300 | 300 | |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | $lon = intval($lon_deg); |
| 313 | 313 | if ($lat > 89 || $lon > 179) return false; |
| 314 | 314 | |
| 315 | - /* |
|
| 315 | + /* |
|
| 316 | 316 | $tmp_5b = str_replace('.','',$lat_min); |
| 317 | 317 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
| 318 | 318 | print_r($matches); |
@@ -326,9 +326,9 @@ discard block |
||
| 326 | 326 | $result['longitude'] = $longitude; |
| 327 | 327 | $body_parse = substr($body_parse,18); |
| 328 | 328 | $body_parse_len = strlen($body_parse); |
| 329 | - } |
|
| 330 | - $body_parse_len = strlen($body_parse); |
|
| 331 | - if ($body_parse_len > 0) { |
|
| 329 | + } |
|
| 330 | + $body_parse_len = strlen($body_parse); |
|
| 331 | + if ($body_parse_len > 0) { |
|
| 332 | 332 | /* |
| 333 | 333 | if (!isset($result['timestamp']) && !isset($result['latitude'])) { |
| 334 | 334 | $body_split = str_split($body); |
@@ -360,95 +360,95 @@ discard block |
||
| 360 | 360 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
| 361 | 361 | if ($symbol_code != '_') { |
| 362 | 362 | } |
| 363 | - //$body_parse = substr($body_parse,1); |
|
| 364 | - //$body_parse = trim($body_parse); |
|
| 365 | - //$body_parse_len = strlen($body_parse); |
|
| 366 | - if ($body_parse_len >= 7) { |
|
| 363 | + //$body_parse = substr($body_parse,1); |
|
| 364 | + //$body_parse = trim($body_parse); |
|
| 365 | + //$body_parse_len = strlen($body_parse); |
|
| 366 | + if ($body_parse_len >= 7) { |
|
| 367 | 367 | |
| 368 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
| 369 | - $course = substr($body_parse,0,3); |
|
| 370 | - $tmp_s = intval($course); |
|
| 371 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
| 372 | - $speed = substr($body_parse,4,3); |
|
| 373 | - if ($speed != '...') { |
|
| 374 | - //$result['speed'] = round($speed*1.852); |
|
| 375 | - $result['speed'] = intval($speed); |
|
| 376 | - } |
|
| 377 | - $body_parse = substr($body_parse,7); |
|
| 378 | - } |
|
| 379 | - // Check PHGR, PHG, RNG |
|
| 380 | - } |
|
| 381 | - /* |
|
| 368 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
| 369 | + $course = substr($body_parse,0,3); |
|
| 370 | + $tmp_s = intval($course); |
|
| 371 | + if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
| 372 | + $speed = substr($body_parse,4,3); |
|
| 373 | + if ($speed != '...') { |
|
| 374 | + //$result['speed'] = round($speed*1.852); |
|
| 375 | + $result['speed'] = intval($speed); |
|
| 376 | + } |
|
| 377 | + $body_parse = substr($body_parse,7); |
|
| 378 | + } |
|
| 379 | + // Check PHGR, PHG, RNG |
|
| 380 | + } |
|
| 381 | + /* |
|
| 382 | 382 | else if ($body_parse_len > 0) { |
| 383 | 383 | $rest = $body_parse; |
| 384 | 384 | } |
| 385 | 385 | */ |
| 386 | - if (strlen($body_parse) > 0) { |
|
| 387 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
| 388 | - $altitude = intval($matches[1]); |
|
| 389 | - //$result['altitude'] = round($altitude*0.3048); |
|
| 390 | - $result['altitude'] = $altitude; |
|
| 391 | - //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
| 392 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
| 393 | - } |
|
| 394 | - } |
|
| 386 | + if (strlen($body_parse) > 0) { |
|
| 387 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
| 388 | + $altitude = intval($matches[1]); |
|
| 389 | + //$result['altitude'] = round($altitude*0.3048); |
|
| 390 | + $result['altitude'] = $altitude; |
|
| 391 | + //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
| 392 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | 395 | |
| 396 | - // Telemetry |
|
| 397 | - /* |
|
| 396 | + // Telemetry |
|
| 397 | + /* |
|
| 398 | 398 | if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) { |
| 399 | 399 | // Nothing yet... |
| 400 | 400 | } |
| 401 | 401 | */ |
| 402 | - // DAO |
|
| 402 | + // DAO |
|
| 403 | 403 | |
| 404 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
| 404 | + if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
| 405 | 405 | |
| 406 | - $dao = $matches[1]; |
|
| 407 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
| 406 | + $dao = $matches[1]; |
|
| 407 | + if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
| 408 | 408 | $dao_split = str_split($dao); |
| 409 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
| 410 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
| 409 | + $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
| 410 | + $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
| 411 | 411 | |
| 412 | 412 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
| 413 | 413 | else $result['latitude'] += $lat_off; |
| 414 | 414 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
| 415 | 415 | else $result['longitude'] += $lon_off; |
| 416 | - } |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | - $body_parse = substr($body_parse,6); |
|
| 419 | - } |
|
| 418 | + $body_parse = substr($body_parse,6); |
|
| 419 | + } |
|
| 420 | 420 | |
| 421 | - if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
| 421 | + if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
| 422 | 422 | $result['ident'] = str_replace('_',' ',$matches[1]); |
| 423 | - } |
|
| 424 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
| 423 | + } |
|
| 424 | + if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
| 425 | 425 | $result['squawk'] = $matches[1]; |
| 426 | - } |
|
| 427 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
| 426 | + } |
|
| 427 | + if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
| 428 | 428 | $result['aircraft_icao'] = $matches[1]; |
| 429 | - } |
|
| 430 | - if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
| 429 | + } |
|
| 430 | + if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
| 431 | 431 | $result['verticalrate'] = $matches[1]; |
| 432 | - } |
|
| 433 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
| 432 | + } |
|
| 433 | + if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
| 434 | 434 | $result['typeid'] = $matches[1]; |
| 435 | - } |
|
| 436 | - if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
| 435 | + } |
|
| 436 | + if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
| 437 | 437 | $result['statusid'] = $matches[1]; |
| 438 | - } |
|
| 439 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
| 438 | + } |
|
| 439 | + if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
| 440 | 440 | $result['imo'] = $matches[1]; |
| 441 | - } |
|
| 442 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
| 441 | + } |
|
| 442 | + if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
| 443 | 443 | $result['arrival_date'] = $matches[1]; |
| 444 | - } |
|
| 445 | - if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
| 444 | + } |
|
| 445 | + if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
| 446 | 446 | $result['arrival_code'] = str_replace('_',' ',$matches[1]); |
| 447 | - } |
|
| 448 | - // OGN comment |
|
| 447 | + } |
|
| 448 | + // OGN comment |
|
| 449 | 449 | // echo "Before OGN : ".$body_parse."\n"; |
| 450 | - //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
| 451 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
| 450 | + //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
| 451 | + if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
| 452 | 452 | $id = $matches[1]; |
| 453 | 453 | //$mode = substr($id,0,2); |
| 454 | 454 | $address = substr($id,2); |
@@ -478,53 +478,53 @@ discard block |
||
| 478 | 478 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
| 479 | 479 | $result['stealth'] = $stealth; |
| 480 | 480 | $result['address'] = $address; |
| 481 | - } |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | - //Comment |
|
| 484 | - $result['comment'] = trim($body_parse); |
|
| 483 | + //Comment |
|
| 484 | + $result['comment'] = trim($body_parse); |
|
| 485 | 485 | } else { |
| 486 | - // parse weather |
|
| 487 | - //$body_parse = substr($body_parse,1); |
|
| 488 | - //$body_parse_len = strlen($body_parse); |
|
| 486 | + // parse weather |
|
| 487 | + //$body_parse = substr($body_parse,1); |
|
| 488 | + //$body_parse_len = strlen($body_parse); |
|
| 489 | 489 | |
| 490 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 491 | - $result['wind_dir'] = intval($matches[1]); |
|
| 492 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
| 493 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
| 494 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
| 495 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 496 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 490 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 491 | + $result['wind_dir'] = intval($matches[1]); |
|
| 492 | + $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
| 493 | + $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
| 494 | + $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
| 495 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 496 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 497 | 497 | $result['wind_dir'] = intval($matches[1]); |
| 498 | 498 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
| 499 | 499 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
| 500 | 500 | $result['temp'] = round(5/9*(($matches[4])-32),1); |
| 501 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 502 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 501 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 502 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 503 | 503 | $result['wind_dir'] = intval($matches[1]); |
| 504 | 504 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
| 505 | 505 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
| 506 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 507 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 506 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 507 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 508 | 508 | $result['wind_dir'] = intval($matches[1]); |
| 509 | 509 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
| 510 | 510 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
| 511 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 512 | - } |
|
| 513 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
| 511 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 512 | + } |
|
| 513 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
| 514 | 514 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
| 515 | - } |
|
| 515 | + } |
|
| 516 | 516 | } |
| 517 | 517 | } else $result['comment'] = trim($body_parse); |
| 518 | 518 | |
| 519 | - } |
|
| 519 | + } |
|
| 520 | 520 | //} |
| 521 | 521 | if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
| 522 | 522 | if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
| 523 | 523 | if ($debug) print_r($result); |
| 524 | 524 | return $result; |
| 525 | - } |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | - public function connect() { |
|
| 527 | + public function connect() { |
|
| 528 | 528 | global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
| 529 | 529 | $aprs_connect = 0; |
| 530 | 530 | $aprs_keep = 120; |
@@ -548,24 +548,24 @@ discard block |
||
| 548 | 548 | socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1); |
| 549 | 549 | while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
| 550 | 550 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
| 551 | - echo 'APRS user verified !'."\n"; |
|
| 552 | - $this->connected = true; |
|
| 553 | - return true; |
|
| 554 | - break; |
|
| 551 | + echo 'APRS user verified !'."\n"; |
|
| 552 | + $this->connected = true; |
|
| 553 | + return true; |
|
| 554 | + break; |
|
| 555 | 555 | } |
| 556 | 556 | if (time()-$authstart > 5) { |
| 557 | - echo 'APRS timeout'."\n"; |
|
| 558 | - break; |
|
| 557 | + echo 'APRS timeout'."\n"; |
|
| 558 | + break; |
|
| 559 | 559 | } |
| 560 | 560 | } |
| 561 | 561 | } |
| 562 | - } |
|
| 562 | + } |
|
| 563 | 563 | |
| 564 | - public function disconnect() { |
|
| 564 | + public function disconnect() { |
|
| 565 | 565 | socket_close($this->socket); |
| 566 | - } |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | - public function send($data) { |
|
| 568 | + public function send($data) { |
|
| 569 | 569 | global $globalDebug; |
| 570 | 570 | if ($this->connected === false) $this->connect(); |
| 571 | 571 | $send = socket_send( $this->socket , $data , strlen($data),0); |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | socket_close($this->socket); |
| 575 | 575 | $this->connect(); |
| 576 | 576 | } |
| 577 | - } |
|
| 577 | + } |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | class APRSSpotter extends APRS { |
@@ -183,17 +183,23 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | /* Check that end was found and body has at least one byte. */ |
| 185 | 185 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
| 186 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
| 186 | + if ($globalDebug) { |
|
| 187 | + echo '!!! APRS invalid : '.$input."\n"; |
|
| 188 | + } |
|
| 187 | 189 | return false; |
| 188 | 190 | } |
| 189 | 191 | |
| 190 | - if ($debug) echo 'input : '.$input."\n"; |
|
| 192 | + if ($debug) { |
|
| 193 | + echo 'input : '.$input."\n"; |
|
| 194 | + } |
|
| 191 | 195 | /* Save header and body. */ |
| 192 | 196 | $body = substr($input,$splitpos+1,$input_len); |
| 193 | 197 | $body_len = strlen($body); |
| 194 | 198 | $header = substr($input,0,$splitpos); |
| 195 | 199 | //$header_len = strlen($header); |
| 196 | - if ($debug) echo 'header : '.$header."\n"; |
|
| 200 | + if ($debug) { |
|
| 201 | + echo 'header : '.$header."\n"; |
|
| 202 | + } |
|
| 197 | 203 | |
| 198 | 204 | /* Parse source, target and path. */ |
| 199 | 205 | //FLRDF0A52>APRS,qAS,LSTB |
@@ -207,11 +213,15 @@ discard block |
||
| 207 | 213 | $result['format_source'] = 'famaprs'; |
| 208 | 214 | $result['source_type'] = 'ais'; |
| 209 | 215 | } else { |
| 210 | - if ($debug) echo 'ident : '.$ident."\n"; |
|
| 216 | + if ($debug) { |
|
| 217 | + echo 'ident : '.$ident."\n"; |
|
| 218 | + } |
|
| 211 | 219 | $result['ident'] = $ident; |
| 212 | 220 | } |
| 213 | 221 | } else { |
| 214 | - if ($debug) 'No ident'."\n"; |
|
| 222 | + if ($debug) { |
|
| 223 | + 'No ident'."\n"; |
|
| 224 | + } |
|
| 215 | 225 | return false; |
| 216 | 226 | } |
| 217 | 227 | $elements = explode(',',$all_elements); |
@@ -222,7 +232,9 @@ discard block |
||
| 222 | 232 | //echo "ok"; |
| 223 | 233 | //if ($element == 'TCPIP*') return false; |
| 224 | 234 | } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
| 225 | - if ($debug) echo 'element : '.$element."\n"; |
|
| 235 | + if ($debug) { |
|
| 236 | + echo 'element : '.$element."\n"; |
|
| 237 | + } |
|
| 226 | 238 | return false; |
| 227 | 239 | } |
| 228 | 240 | /* |
@@ -235,13 +247,17 @@ discard block |
||
| 235 | 247 | } |
| 236 | 248 | |
| 237 | 249 | $type = substr($body,0,1); |
| 238 | - if ($debug) echo 'type : '.$type."\n"; |
|
| 250 | + if ($debug) { |
|
| 251 | + echo 'type : '.$type."\n"; |
|
| 252 | + } |
|
| 239 | 253 | if ($type == ';') { |
| 240 | 254 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
| 241 | 255 | $result['address'] = trim(substr($body,1,9)); |
| 242 | 256 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
| 243 | 257 | $result['mmsi'] = trim(substr($body,1,9)); |
| 244 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
| 258 | + } else { |
|
| 259 | + $result['ident'] = trim(substr($body,1,9)); |
|
| 260 | + } |
|
| 245 | 261 | } elseif ($type == ',') { |
| 246 | 262 | // Invalid data or test data |
| 247 | 263 | return false; |
@@ -310,7 +326,9 @@ discard block |
||
| 310 | 326 | //$symbol_table = $matches[4]; |
| 311 | 327 | $lat = intval($lat_deg); |
| 312 | 328 | $lon = intval($lon_deg); |
| 313 | - if ($lat > 89 || $lon > 179) return false; |
|
| 329 | + if ($lat > 89 || $lon > 179) { |
|
| 330 | + return false; |
|
| 331 | + } |
|
| 314 | 332 | |
| 315 | 333 | /* |
| 316 | 334 | $tmp_5b = str_replace('.','',$lat_min); |
@@ -320,8 +338,12 @@ discard block |
||
| 320 | 338 | */ |
| 321 | 339 | $latitude = $lat + floatval($lat_min)/60; |
| 322 | 340 | $longitude = $lon + floatval($lon_min)/60; |
| 323 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
| 324 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
| 341 | + if ($sind == 'S') { |
|
| 342 | + $latitude = 0-$latitude; |
|
| 343 | + } |
|
| 344 | + if ($wind == 'W') { |
|
| 345 | + $longitude = 0-$longitude; |
|
| 346 | + } |
|
| 325 | 347 | $result['latitude'] = $latitude; |
| 326 | 348 | $result['longitude'] = $longitude; |
| 327 | 349 | $body_parse = substr($body_parse,18); |
@@ -348,8 +370,11 @@ discard block |
||
| 348 | 370 | if ($find) { |
| 349 | 371 | $body_split = str_split($body_parse); |
| 350 | 372 | $symbol_code = $body_split[0]; |
| 351 | - if (!isset($symbolll) || $symbolll == '/') $symbol_code = '/'.$symbol_code; |
|
| 352 | - else $symbol_code = '\\'.$symbol_code; |
|
| 373 | + if (!isset($symbolll) || $symbolll == '/') { |
|
| 374 | + $symbol_code = '/'.$symbol_code; |
|
| 375 | + } else { |
|
| 376 | + $symbol_code = '\\'.$symbol_code; |
|
| 377 | + } |
|
| 353 | 378 | //} |
| 354 | 379 | //echo $body_parse; |
| 355 | 380 | //if ($type != ';' && $type != '>') { |
@@ -357,7 +382,9 @@ discard block |
||
| 357 | 382 | $body_parse = substr($body_parse,1); |
| 358 | 383 | $body_parse_len = strlen($body_parse); |
| 359 | 384 | $result['symbol_code'] = $symbol_code; |
| 360 | - if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
|
| 385 | + if (isset($this->symbols[$symbol_code])) { |
|
| 386 | + $result['symbol'] = $this->symbols[$symbol_code]; |
|
| 387 | + } |
|
| 361 | 388 | if ($symbol_code != '_') { |
| 362 | 389 | } |
| 363 | 390 | //$body_parse = substr($body_parse,1); |
@@ -368,7 +395,9 @@ discard block |
||
| 368 | 395 | if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
| 369 | 396 | $course = substr($body_parse,0,3); |
| 370 | 397 | $tmp_s = intval($course); |
| 371 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
| 398 | + if ($tmp_s >= 1 && $tmp_s <= 360) { |
|
| 399 | + $result['heading'] = intval($course); |
|
| 400 | + } |
|
| 372 | 401 | $speed = substr($body_parse,4,3); |
| 373 | 402 | if ($speed != '...') { |
| 374 | 403 | //$result['speed'] = round($speed*1.852); |
@@ -409,10 +438,16 @@ discard block |
||
| 409 | 438 | $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
| 410 | 439 | $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
| 411 | 440 | |
| 412 | - if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
|
| 413 | - else $result['latitude'] += $lat_off; |
|
| 414 | - if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
|
| 415 | - else $result['longitude'] += $lon_off; |
|
| 441 | + if ($result['latitude'] < 0) { |
|
| 442 | + $result['latitude'] -= $lat_off; |
|
| 443 | + } else { |
|
| 444 | + $result['latitude'] += $lat_off; |
|
| 445 | + } |
|
| 446 | + if ($result['longitude'] < 0) { |
|
| 447 | + $result['longitude'] -= $lon_off; |
|
| 448 | + } else { |
|
| 449 | + $result['longitude'] += $lon_off; |
|
| 450 | + } |
|
| 416 | 451 | } |
| 417 | 452 | |
| 418 | 453 | $body_parse = substr($body_parse,6); |
@@ -454,27 +489,48 @@ discard block |
||
| 454 | 489 | $address = substr($id,2); |
| 455 | 490 | //print_r($matches); |
| 456 | 491 | $addressType = (intval(substr($id,0,2),16))&3; |
| 457 | - if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
|
| 458 | - elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
|
| 459 | - elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
|
| 460 | - elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
|
| 492 | + if ($addressType == 0) { |
|
| 493 | + $result['addresstype'] = "RANDOM"; |
|
| 494 | + } elseif ($addressType == 1) { |
|
| 495 | + $result['addresstype'] = "ICAO"; |
|
| 496 | + } elseif ($addressType == 2) { |
|
| 497 | + $result['addresstype'] = "FLARM"; |
|
| 498 | + } elseif ($addressType == 3) { |
|
| 499 | + $result['addresstype'] = "OGN"; |
|
| 500 | + } |
|
| 461 | 501 | $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
| 462 | 502 | $result['aircrafttype_code'] = $aircraftType; |
| 463 | - if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
|
| 464 | - elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
|
| 465 | - elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE"; |
|
| 466 | - elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
| 467 | - elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE"; |
|
| 468 | - elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE"; |
|
| 469 | - elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER"; |
|
| 470 | - elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER"; |
|
| 471 | - elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
| 472 | - elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
| 473 | - elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO"; |
|
| 474 | - elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON"; |
|
| 475 | - elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
|
| 476 | - elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
|
| 477 | - elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
|
| 503 | + if ($aircraftType == 0) { |
|
| 504 | + $result['aircrafttype'] = "UNKNOWN"; |
|
| 505 | + } elseif ($aircraftType == 1) { |
|
| 506 | + $result['aircrafttype'] = "GLIDER"; |
|
| 507 | + } elseif ($aircraftType == 2) { |
|
| 508 | + $result['aircrafttype'] = "TOW_PLANE"; |
|
| 509 | + } elseif ($aircraftType == 3) { |
|
| 510 | + $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
| 511 | + } elseif ($aircraftType == 4) { |
|
| 512 | + $result['aircrafttype'] = "PARACHUTE"; |
|
| 513 | + } elseif ($aircraftType == 5) { |
|
| 514 | + $result['aircrafttype'] = "DROP_PLANE"; |
|
| 515 | + } elseif ($aircraftType == 6) { |
|
| 516 | + $result['aircrafttype'] = "HANG_GLIDER"; |
|
| 517 | + } elseif ($aircraftType == 7) { |
|
| 518 | + $result['aircrafttype'] = "PARA_GLIDER"; |
|
| 519 | + } elseif ($aircraftType == 8) { |
|
| 520 | + $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
| 521 | + } elseif ($aircraftType == 9) { |
|
| 522 | + $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
| 523 | + } elseif ($aircraftType == 10) { |
|
| 524 | + $result['aircrafttype'] = "UFO"; |
|
| 525 | + } elseif ($aircraftType == 11) { |
|
| 526 | + $result['aircrafttype'] = "BALLOON"; |
|
| 527 | + } elseif ($aircraftType == 12) { |
|
| 528 | + $result['aircrafttype'] = "AIRSHIP"; |
|
| 529 | + } elseif ($aircraftType == 13) { |
|
| 530 | + $result['aircrafttype'] = "UAV"; |
|
| 531 | + } elseif ($aircraftType == 15) { |
|
| 532 | + $result['aircrafttype'] = "STATIC_OBJECT"; |
|
| 533 | + } |
|
| 478 | 534 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
| 479 | 535 | $result['stealth'] = $stealth; |
| 480 | 536 | $result['address'] = $address; |
@@ -514,13 +570,21 @@ discard block |
||
| 514 | 570 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
| 515 | 571 | } |
| 516 | 572 | } |
| 517 | - } else $result['comment'] = trim($body_parse); |
|
| 573 | + } else { |
|
| 574 | + $result['comment'] = trim($body_parse); |
|
| 575 | + } |
|
| 518 | 576 | |
| 519 | 577 | } |
| 520 | 578 | //} |
| 521 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
| 522 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
| 523 | - if ($debug) print_r($result); |
|
| 579 | + if (isset($result['latitude'])) { |
|
| 580 | + $result['latitude'] = round($result['latitude'],4); |
|
| 581 | + } |
|
| 582 | + if (isset($result['longitude'])) { |
|
| 583 | + $result['longitude'] = round($result['longitude'],4); |
|
| 584 | + } |
|
| 585 | + if ($debug) { |
|
| 586 | + print_r($result); |
|
| 587 | + } |
|
| 524 | 588 | return $result; |
| 525 | 589 | } |
| 526 | 590 | |
@@ -529,12 +593,21 @@ discard block |
||
| 529 | 593 | $aprs_connect = 0; |
| 530 | 594 | $aprs_keep = 120; |
| 531 | 595 | $aprs_last_tx = time(); |
| 532 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 533 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 534 | - if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
|
| 535 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 536 | - if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
|
| 537 | - else $aprs_pass = '-1'; |
|
| 596 | + if (isset($globalAPRSversion)) { |
|
| 597 | + $aprs_version = $globalAPRSversion; |
|
| 598 | + } else { |
|
| 599 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 600 | + } |
|
| 601 | + if (isset($globalServerAPRSssid)) { |
|
| 602 | + $aprs_ssid = $globalServerAPRSssid; |
|
| 603 | + } else { |
|
| 604 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 605 | + } |
|
| 606 | + if (isset($globalServerAPRSpass)) { |
|
| 607 | + $aprs_pass = $globalServerAPRSpass; |
|
| 608 | + } else { |
|
| 609 | + $aprs_pass = '-1'; |
|
| 610 | + } |
|
| 538 | 611 | |
| 539 | 612 | $aprs_filter = ''; |
| 540 | 613 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
@@ -567,10 +640,14 @@ discard block |
||
| 567 | 640 | |
| 568 | 641 | public function send($data) { |
| 569 | 642 | global $globalDebug; |
| 570 | - if ($this->connected === false) $this->connect(); |
|
| 643 | + if ($this->connected === false) { |
|
| 644 | + $this->connect(); |
|
| 645 | + } |
|
| 571 | 646 | $send = socket_send( $this->socket , $data , strlen($data),0); |
| 572 | 647 | if ($send === FALSE) { |
| 573 | - if ($globalDebug) echo 'Reconnect...'; |
|
| 648 | + if ($globalDebug) { |
|
| 649 | + echo 'Reconnect...'; |
|
| 650 | + } |
|
| 574 | 651 | socket_close($this->socket); |
| 575 | 652 | $this->connect(); |
| 576 | 653 | } |
@@ -590,22 +667,32 @@ discard block |
||
| 590 | 667 | //$w = '00'; |
| 591 | 668 | $custom = ''; |
| 592 | 669 | if ($ident != '') { |
| 593 | - if ($custom != '') $custom .= '/'; |
|
| 670 | + if ($custom != '') { |
|
| 671 | + $custom .= '/'; |
|
| 672 | + } |
|
| 594 | 673 | $custom .= 'CS='.$ident; |
| 595 | 674 | } |
| 596 | 675 | if ($squawk != '') { |
| 597 | - if ($custom != '') $custom .= '/'; |
|
| 676 | + if ($custom != '') { |
|
| 677 | + $custom .= '/'; |
|
| 678 | + } |
|
| 598 | 679 | $custom .= 'SQ='.$squawk; |
| 599 | 680 | } |
| 600 | 681 | if ($verticalrate != '') { |
| 601 | - if ($custom != '') $custom .= '/'; |
|
| 682 | + if ($custom != '') { |
|
| 683 | + $custom .= '/'; |
|
| 684 | + } |
|
| 602 | 685 | $custom .= 'VR='.$verticalrate; |
| 603 | 686 | } |
| 604 | 687 | if ($aircraft_icao != '' && $aircraft_icao != 'NA') { |
| 605 | - if ($custom != '') $custom .= '/'; |
|
| 688 | + if ($custom != '') { |
|
| 689 | + $custom .= '/'; |
|
| 690 | + } |
|
| 606 | 691 | $custom .= 'AI='.$aircraft_icao; |
| 607 | 692 | } |
| 608 | - if ($custom != '') $custom = ' '.$custom; |
|
| 693 | + if ($custom != '') { |
|
| 694 | + $custom = ' '.$custom; |
|
| 695 | + } |
|
| 609 | 696 | $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
| 610 | 697 | } |
| 611 | 698 | } |
@@ -623,30 +710,44 @@ discard block |
||
| 623 | 710 | //$w = '00'; |
| 624 | 711 | $custom = ''; |
| 625 | 712 | if ($ident != '') { |
| 626 | - if ($custom != '') $custom .= '/'; |
|
| 713 | + if ($custom != '') { |
|
| 714 | + $custom .= '/'; |
|
| 715 | + } |
|
| 627 | 716 | $custom .= 'CS='.str_replace(' ','_',$ident); |
| 628 | 717 | } |
| 629 | 718 | if ($typeid != '') { |
| 630 | - if ($custom != '') $custom .= '/'; |
|
| 719 | + if ($custom != '') { |
|
| 720 | + $custom .= '/'; |
|
| 721 | + } |
|
| 631 | 722 | $custom .= 'TI='.$typeid; |
| 632 | 723 | } |
| 633 | 724 | if ($statusid != '') { |
| 634 | - if ($custom != '') $custom .= '/'; |
|
| 725 | + if ($custom != '') { |
|
| 726 | + $custom .= '/'; |
|
| 727 | + } |
|
| 635 | 728 | $custom .= 'SI='.$statusid; |
| 636 | 729 | } |
| 637 | 730 | if ($imo != '') { |
| 638 | - if ($custom != '') $custom .= '/'; |
|
| 731 | + if ($custom != '') { |
|
| 732 | + $custom .= '/'; |
|
| 733 | + } |
|
| 639 | 734 | $custom .= 'IMO='.$imo; |
| 640 | 735 | } |
| 641 | 736 | if ($arrival_date != '') { |
| 642 | - if ($custom != '') $custom .= '/'; |
|
| 737 | + if ($custom != '') { |
|
| 738 | + $custom .= '/'; |
|
| 739 | + } |
|
| 643 | 740 | $custom .= 'AD='.strtotime($arrival_date); |
| 644 | 741 | } |
| 645 | 742 | if ($arrival_code != '') { |
| 646 | - if ($custom != '') $custom .= '/'; |
|
| 743 | + if ($custom != '') { |
|
| 744 | + $custom .= '/'; |
|
| 745 | + } |
|
| 647 | 746 | $custom .= 'AC='.str_replace(' ','_',$arrival_code); |
| 648 | 747 | } |
| 649 | - if ($custom != '') $custom = ' '.$custom; |
|
| 748 | + if ($custom != '') { |
|
| 749 | + $custom = ' '.$custom; |
|
| 750 | + } |
|
| 650 | 751 | $altitude = 0; |
| 651 | 752 | $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
| 652 | 753 | } |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | /** |
| 15 | 15 | * Get SQL query part for filter used |
| 16 | 16 | * @param Array $filter the filter |
| 17 | - * @return Array the SQL part |
|
| 17 | + * @return string the SQL part |
|
| 18 | 18 | */ |
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
@@ -10,10 +10,10 @@ |
||
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * Get SQL query part for filter used |
|
| 14 | - * @param Array $filter the filter |
|
| 15 | - * @return Array the SQL part |
|
| 16 | - */ |
|
| 13 | + * Get SQL query part for filter used |
|
| 14 | + * @param Array $filter the filter |
|
| 15 | + * @return Array the SQL part |
|
| 16 | + */ |
|
| 17 | 17 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
| 19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
@@ -14,22 +14,22 @@ discard block |
||
| 14 | 14 | * @param Array $filter the filter |
| 15 | 15 | * @return Array the SQL part |
| 16 | 16 | */ |
| 17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 17 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
| 19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 20 | 20 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 21 | - foreach($globalStatsFilters[$globalFilterName] as $source) { |
|
| 21 | + foreach ($globalStatsFilters[$globalFilterName] as $source) { |
|
| 22 | 22 | if (isset($source['source'])) $filter['source'][] = $source['source']; |
| 23 | 23 | } |
| 24 | 24 | } else { |
| 25 | 25 | $filter = $globalStatsFilters[$globalFilterName]; |
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 28 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 29 | 29 | $filter_query_join = ''; |
| 30 | 30 | $filter_query_where = ''; |
| 31 | 31 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 32 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 32 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 33 | 33 | } |
| 34 | 34 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 35 | 35 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | try { |
| 45 | 45 | $sth = $this->db->prepare($query); |
| 46 | 46 | $sth->execute($query_values); |
| 47 | - } catch(PDOException $e) { |
|
| 47 | + } catch (PDOException $e) { |
|
| 48 | 48 | return "error : ".$e->getMessage(); |
| 49 | 49 | } |
| 50 | 50 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -52,66 +52,66 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function getById($id) { |
| 55 | - $filter_query = $this->getFilter(array(),true); |
|
| 55 | + $filter_query = $this->getFilter(array(), true); |
|
| 56 | 56 | $query = "SELECT * FROM atc".$filter_query." atc_id = :id"; |
| 57 | 57 | $query_values = array(':id' => $id); |
| 58 | 58 | try { |
| 59 | 59 | $sth = $this->db->prepare($query); |
| 60 | 60 | $sth->execute($query_values); |
| 61 | - } catch(PDOException $e) { |
|
| 61 | + } catch (PDOException $e) { |
|
| 62 | 62 | return "error : ".$e->getMessage(); |
| 63 | 63 | } |
| 64 | 64 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 65 | 65 | return $all; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public function getByIdent($ident,$format_source = '') { |
|
| 69 | - $filter_query = $this->getFilter(array(),true); |
|
| 68 | + public function getByIdent($ident, $format_source = '') { |
|
| 69 | + $filter_query = $this->getFilter(array(), true); |
|
| 70 | 70 | if ($format_source == '') { |
| 71 | 71 | $query = "SELECT * FROM atc".$filter_query." ident = :ident"; |
| 72 | 72 | $query_values = array(':ident' => $ident); |
| 73 | 73 | } else { |
| 74 | 74 | $query = "SELECT * FROM atc".$filter_query." ident = :ident AND format_source = :format_source"; |
| 75 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
| 75 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
| 76 | 76 | } |
| 77 | 77 | try { |
| 78 | 78 | $sth = $this->db->prepare($query); |
| 79 | 79 | $sth->execute($query_values); |
| 80 | - } catch(PDOException $e) { |
|
| 80 | + } catch (PDOException $e) { |
|
| 81 | 81 | return "error : ".$e->getMessage(); |
| 82 | 82 | } |
| 83 | 83 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 84 | 84 | return $all; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
| 88 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
| 89 | - $info = str_replace('^','<br />',$info); |
|
| 90 | - $info = str_replace('&sect;','',$info); |
|
| 91 | - $info = str_replace('"','',$info); |
|
| 87 | + public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
| 88 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
| 89 | + $info = str_replace('^', '<br />', $info); |
|
| 90 | + $info = str_replace('&sect;', '', $info); |
|
| 91 | + $info = str_replace('"', '', $info); |
|
| 92 | 92 | if ($type == '') $type = NULL; |
| 93 | 93 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
| 94 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
| 94 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
| 95 | 95 | try { |
| 96 | 96 | $sth = $this->db->prepare($query); |
| 97 | 97 | $sth->execute($query_values); |
| 98 | - } catch(PDOException $e) { |
|
| 98 | + } catch (PDOException $e) { |
|
| 99 | 99 | return "error : ".$e->getMessage(); |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - public function update($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
| 104 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
| 105 | - $info = str_replace('^','<br />',$info); |
|
| 106 | - $info = str_replace('&sect;','',$info); |
|
| 107 | - $info = str_replace('"','',$info); |
|
| 103 | + public function update($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
| 104 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
| 105 | + $info = str_replace('^', '<br />', $info); |
|
| 106 | + $info = str_replace('&sect;', '', $info); |
|
| 107 | + $info = str_replace('"', '', $info); |
|
| 108 | 108 | if ($type == '') $type = NULL; |
| 109 | 109 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
| 110 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
| 110 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
| 111 | 111 | try { |
| 112 | 112 | $sth = $this->db->prepare($query); |
| 113 | 113 | $sth->execute($query_values); |
| 114 | - } catch(PDOException $e) { |
|
| 114 | + } catch (PDOException $e) { |
|
| 115 | 115 | return "error : ".$e->getMessage(); |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -122,18 +122,18 @@ discard block |
||
| 122 | 122 | try { |
| 123 | 123 | $sth = $this->db->prepare($query); |
| 124 | 124 | $sth->execute($query_values); |
| 125 | - } catch(PDOException $e) { |
|
| 125 | + } catch (PDOException $e) { |
|
| 126 | 126 | return "error : ".$e->getMessage(); |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public function deleteByIdent($ident,$format_source) { |
|
| 130 | + public function deleteByIdent($ident, $format_source) { |
|
| 131 | 131 | $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source"; |
| 132 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
| 132 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
| 133 | 133 | try { |
| 134 | 134 | $sth = $this->db->prepare($query); |
| 135 | 135 | $sth->execute($query_values); |
| 136 | - } catch(PDOException $e) { |
|
| 136 | + } catch (PDOException $e) { |
|
| 137 | 137 | return "error : ".$e->getMessage(); |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | try { |
| 145 | 145 | $sth = $this->db->prepare($query); |
| 146 | 146 | $sth->execute($query_values); |
| 147 | - } catch(PDOException $e) { |
|
| 147 | + } catch (PDOException $e) { |
|
| 148 | 148 | return "error : ".$e->getMessage(); |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | try { |
| 160 | 160 | $sth = $this->db->prepare($query); |
| 161 | 161 | $sth->execute(); |
| 162 | - } catch(PDOException $e) { |
|
| 162 | + } catch (PDOException $e) { |
|
| 163 | 163 | return "error"; |
| 164 | 164 | } |
| 165 | 165 | return "success"; |
@@ -19,20 +19,27 @@ discard block |
||
| 19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 20 | 20 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 21 | 21 | foreach($globalStatsFilters[$globalFilterName] as $source) { |
| 22 | - if (isset($source['source'])) $filter['source'][] = $source['source']; |
|
| 22 | + if (isset($source['source'])) { |
|
| 23 | + $filter['source'][] = $source['source']; |
|
| 24 | + } |
|
| 23 | 25 | } |
| 24 | 26 | } else { |
| 25 | 27 | $filter = $globalStatsFilters[$globalFilterName]; |
| 26 | 28 | } |
| 27 | 29 | } |
| 28 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 30 | + if (is_array($globalFilter)) { |
|
| 31 | + $filter = array_merge($filter,$globalFilter); |
|
| 32 | + } |
|
| 29 | 33 | $filter_query_join = ''; |
| 30 | 34 | $filter_query_where = ''; |
| 31 | 35 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 32 | 36 | $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
| 33 | 37 | } |
| 34 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 35 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 38 | + if ($filter_query_where == '' && $where) { |
|
| 39 | + $filter_query_where = ' WHERE'; |
|
| 40 | + } elseif ($filter_query_where != '' && $and) { |
|
| 41 | + $filter_query_where .= ' AND'; |
|
| 42 | + } |
|
| 36 | 43 | $filter_query = $filter_query_join.$filter_query_where; |
| 37 | 44 | return $filter_query; |
| 38 | 45 | } |
@@ -89,7 +96,9 @@ discard block |
||
| 89 | 96 | $info = str_replace('^','<br />',$info); |
| 90 | 97 | $info = str_replace('&sect;','',$info); |
| 91 | 98 | $info = str_replace('"','',$info); |
| 92 | - if ($type == '') $type = NULL; |
|
| 99 | + if ($type == '') { |
|
| 100 | + $type = NULL; |
|
| 101 | + } |
|
| 93 | 102 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
| 94 | 103 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
| 95 | 104 | try { |
@@ -105,7 +114,9 @@ discard block |
||
| 105 | 114 | $info = str_replace('^','<br />',$info); |
| 106 | 115 | $info = str_replace('&sect;','',$info); |
| 107 | 116 | $info = str_replace('"','',$info); |
| 108 | - if ($type == '') $type = NULL; |
|
| 117 | + if ($type == '') { |
|
| 118 | + $type = NULL; |
|
| 119 | + } |
|
| 109 | 120 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
| 110 | 121 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
| 111 | 122 | try { |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | try { |
| 6 | 6 | $GeoidHeight = new GeoidHeight(); |
| 7 | 7 | } catch (Exception $e) { |
| 8 | - echo $e; |
|
| 8 | + echo $e; |
|
| 9 | 9 | } |
| 10 | 10 | $title = _("Geoid Height Calculator"); |
| 11 | 11 | require_once('header.php'); |
@@ -12,9 +12,9 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | $page_url = $globalURL.'/tools-geoid'; |
| 14 | 14 | |
| 15 | -$latitude = filter_input(INPUT_POST,'latitude',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 16 | -$longitude = filter_input(INPUT_POST,'longitude',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 17 | -$altitude = filter_input(INPUT_POST,'altitude',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 15 | +$latitude = filter_input(INPUT_POST, 'latitude', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 16 | +$longitude = filter_input(INPUT_POST, 'longitude', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 17 | +$altitude = filter_input(INPUT_POST, 'altitude', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 18 | 18 | |
| 19 | 19 | print '<div class="info column">'; |
| 20 | 20 | print '<h1>'._("Geoid Height Calculator").'</h1>'; |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | if ($latitude != '' && $longitude != '') { |
| 53 | 53 | $globalDebug = FALSE; |
| 54 | - $geoid = $GeoidHeight->get($latitude,$longitude); |
|
| 54 | + $geoid = $GeoidHeight->get($latitude, $longitude); |
|
| 55 | 55 | print '<div class="row">'; |
| 56 | 56 | print '<div class="col-md-3 col-md-offset-5">'; |
| 57 | 57 | print '<div class="col-sm-6"><b>Geoid</b></div>'; |
| 58 | 58 | print '<div class="col-sm-6">'.$geoid.'</div>'; |
| 59 | 59 | if ($altitude != '') { |
| 60 | 60 | print '<div class="col-sm-6"><b>AMSL Elevation</b></div>'; |
| 61 | - print '<div class="col-sm-6">'.round($altitude-$geoid,3).'</div>'; |
|
| 61 | + print '<div class="col-sm-6">'.round($altitude - $geoid, 3).'</div>'; |
|
| 62 | 62 | } |
| 63 | 63 | print '<div class="col-sm-6"><b>Earth Gravity Model</b></div>'; |
| 64 | 64 | if (isset($globalGeoidSource) && $globalGeoidSource != '') $geoidsource = $globalGeoidSource; |
@@ -61,8 +61,11 @@ |
||
| 61 | 61 | print '<div class="col-sm-6">'.round($altitude-$geoid,3).'</div>'; |
| 62 | 62 | } |
| 63 | 63 | print '<div class="col-sm-6"><b>Earth Gravity Model</b></div>'; |
| 64 | - if (isset($globalGeoidSource) && $globalGeoidSource != '') $geoidsource = $globalGeoidSource; |
|
| 65 | - else $geoidsource = 'EGM96-15'; |
|
| 64 | + if (isset($globalGeoidSource) && $globalGeoidSource != '') { |
|
| 65 | + $geoidsource = $globalGeoidSource; |
|
| 66 | + } else { |
|
| 67 | + $geoidsource = 'EGM96-15'; |
|
| 68 | + } |
|
| 66 | 69 | print '<div class="col-sm-6">'.$geoidsource.'</div>'; |
| 67 | 70 | print '</div>'; |
| 68 | 71 | } |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
| 18 | 18 | if (isset($globalMarine) && $globalMarine) { |
| 19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,42 +25,42 @@ discard block |
||
| 25 | 25 | // Check if schema is at latest version |
| 26 | 26 | $Connection = new Connection(); |
| 27 | 27 | if ($Connection->latest() === false) { |
| 28 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
| 29 | - exit(); |
|
| 28 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
| 29 | + exit(); |
|
| 30 | 30 | } |
| 31 | 31 | if (PHP_SAPI != 'cli') { |
| 32 | - echo "This script MUST be called from console, not a web browser."; |
|
| 32 | + echo "This script MUST be called from console, not a web browser."; |
|
| 33 | 33 | // exit(); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | // This is to be compatible with old version of settings.php |
| 37 | 37 | if (!isset($globalSources)) { |
| 38 | - if (isset($globalSBS1Hosts)) { |
|
| 39 | - //$hosts = $globalSBS1Hosts; |
|
| 40 | - foreach ($globalSBS1Hosts as $host) { |
|
| 41 | - $globalSources[] = array('host' => $host); |
|
| 42 | - } |
|
| 43 | - } else { |
|
| 44 | - if (!isset($globalSBS1Host)) { |
|
| 45 | - echo '$globalSources MUST be defined !'; |
|
| 46 | - die; |
|
| 38 | + if (isset($globalSBS1Hosts)) { |
|
| 39 | + //$hosts = $globalSBS1Hosts; |
|
| 40 | + foreach ($globalSBS1Hosts as $host) { |
|
| 41 | + $globalSources[] = array('host' => $host); |
|
| 42 | + } |
|
| 43 | + } else { |
|
| 44 | + if (!isset($globalSBS1Host)) { |
|
| 45 | + echo '$globalSources MUST be defined !'; |
|
| 46 | + die; |
|
| 47 | 47 | } |
| 48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 49 | 49 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
| 50 | - } |
|
| 50 | + } |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
| 54 | 54 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 55 | 55 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 56 | 56 | if (isset($options['s'])) { |
| 57 | - $globalSources = array(); |
|
| 58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 59 | - else $globalSources[] = array('host' => $options['s']); |
|
| 57 | + $globalSources = array(); |
|
| 58 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 59 | + else $globalSources[] = array('host' => $options['s']); |
|
| 60 | 60 | } elseif (isset($options['source'])) { |
| 61 | - $globalSources = array(); |
|
| 62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 63 | - else $globalSources[] = array('host' => $options['source']); |
|
| 61 | + $globalSources = array(); |
|
| 62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 63 | + else $globalSources[] = array('host' => $options['source']); |
|
| 64 | 64 | } |
| 65 | 65 | if (isset($options['aprsserverhost'])) { |
| 66 | 66 | $globalServerAPRS = TRUE; |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 76 | 76 | else $id_source = 1; |
| 77 | 77 | if (isset($globalServer) && $globalServer) { |
| 78 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 79 | - $SI=new SpotterServer(); |
|
| 78 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 79 | + $SI=new SpotterServer(); |
|
| 80 | 80 | /* |
| 81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 82 | 82 | $SI = new adsb2aprs(); |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | } else $SI=new SpotterImport($Connection->db); |
| 86 | 86 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
| 87 | 87 | if (isset($globalMarine) && $globalMarine) { |
| 88 | - $AIS = new AIS(); |
|
| 89 | - $MI = new MarineImport($Connection->db); |
|
| 88 | + $AIS = new AIS(); |
|
| 89 | + $MI = new MarineImport($Connection->db); |
|
| 90 | 90 | } |
| 91 | 91 | //$APRS=new APRS($Connection->db); |
| 92 | 92 | $SBS=new SBS(); |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | //$servertz = system('date +%Z'); |
| 98 | 98 | // signal handler - playing nice with sockets and dump1090 |
| 99 | 99 | if (function_exists('pcntl_fork')) { |
| 100 | - pcntl_signal(SIGINT, function() { |
|
| 101 | - global $sockets; |
|
| 102 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 103 | - die("Bye!\n"); |
|
| 104 | - }); |
|
| 105 | - pcntl_signal_dispatch(); |
|
| 100 | + pcntl_signal(SIGINT, function() { |
|
| 101 | + global $sockets; |
|
| 102 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 103 | + die("Bye!\n"); |
|
| 104 | + }); |
|
| 105 | + pcntl_signal_dispatch(); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // let's try and connect |
@@ -112,36 +112,36 @@ discard block |
||
| 112 | 112 | $reset = 0; |
| 113 | 113 | |
| 114 | 114 | function connect_all($hosts) { |
| 115 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 116 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 117 | - $reset++; |
|
| 118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 119 | - foreach ($hosts as $id => $value) { |
|
| 115 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 116 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 117 | + $reset++; |
|
| 118 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 119 | + foreach ($hosts as $id => $value) { |
|
| 120 | 120 | $host = $value['host']; |
| 121 | 121 | $globalSources[$id]['last_exec'] = 0; |
| 122 | 122 | // Here we check type of source(s) |
| 123 | 123 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 125 | - //$formats[$id] = 'deltadbtxt'; |
|
| 126 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 127 | - //$last_exec['deltadbtxt'] = 0; |
|
| 128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 130 | - //$formats[$id] = 'vatsimtxt'; |
|
| 131 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 132 | - //$last_exec['vatsimtxt'] = 0; |
|
| 133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 135 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 136 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 137 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 139 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 140 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 141 | - $globalSources[$id]['format'] = 'opensky'; |
|
| 142 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 144 | - /* |
|
| 124 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 125 | + //$formats[$id] = 'deltadbtxt'; |
|
| 126 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 127 | + //$last_exec['deltadbtxt'] = 0; |
|
| 128 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 129 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 130 | + //$formats[$id] = 'vatsimtxt'; |
|
| 131 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 132 | + //$last_exec['vatsimtxt'] = 0; |
|
| 133 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 134 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 135 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 136 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 137 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 138 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 139 | + } else if (preg_match('/opensky/i',$host)) { |
|
| 140 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 141 | + $globalSources[$id]['format'] = 'opensky'; |
|
| 142 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 143 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 144 | + /* |
|
| 145 | 145 | // Disabled for now, site change source format |
| 146 | 146 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
| 147 | 147 | //$formats[$id] = 'radarvirtueljson'; |
@@ -153,118 +153,118 @@ discard block |
||
| 153 | 153 | exit(0); |
| 154 | 154 | } |
| 155 | 155 | */ |
| 156 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 157 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 158 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 159 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 160 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 161 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 162 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 163 | - exit(0); |
|
| 164 | - } |
|
| 165 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 166 | - //$formats[$id] = 'phpvmacars'; |
|
| 167 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 168 | - //$last_exec['phpvmacars'] = 0; |
|
| 169 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 170 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 171 | - //$formats[$id] = 'phpvmacars'; |
|
| 172 | - $globalSources[$id]['format'] = 'vam'; |
|
| 173 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 174 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 175 | - //$formats[$id] = 'whazzup'; |
|
| 176 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 177 | - //$last_exec['whazzup'] = 0; |
|
| 178 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 179 | - } else if (preg_match('/airwhere/i',$host)) { |
|
| 180 | - $globalSources[$id]['format'] = 'airwhere'; |
|
| 181 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 182 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 183 | - //$formats[$id] = 'pirepsjson'; |
|
| 184 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 185 | - //$last_exec['pirepsjson'] = 0; |
|
| 186 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 187 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 188 | - //$formats[$id] = 'fr24json'; |
|
| 189 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 190 | - //$last_exec['fr24json'] = 0; |
|
| 191 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 192 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 193 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 194 | - exit(0); |
|
| 195 | - } |
|
| 196 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 197 | - //$formats[$id] = 'fr24json'; |
|
| 198 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 199 | - //$last_exec['fr24json'] = 0; |
|
| 200 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 201 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 202 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 203 | - exit(0); |
|
| 204 | - } |
|
| 205 | - //} else if (preg_match('/10001/',$host)) { |
|
| 206 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 207 | - //$formats[$id] = 'tsv'; |
|
| 208 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 209 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 210 | - } |
|
| 211 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 212 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 213 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 214 | - if ($idf !== false) { |
|
| 215 | - $httpfeeds[$id] = $idf; |
|
| 216 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 217 | - } |
|
| 218 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 219 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 220 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 221 | - $hostport = explode(':',$host); |
|
| 222 | - if (isset($hostport[1])) { |
|
| 156 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 157 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 158 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 159 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 160 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 161 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 162 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 163 | + exit(0); |
|
| 164 | + } |
|
| 165 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 166 | + //$formats[$id] = 'phpvmacars'; |
|
| 167 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 168 | + //$last_exec['phpvmacars'] = 0; |
|
| 169 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 170 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 171 | + //$formats[$id] = 'phpvmacars'; |
|
| 172 | + $globalSources[$id]['format'] = 'vam'; |
|
| 173 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 174 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 175 | + //$formats[$id] = 'whazzup'; |
|
| 176 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 177 | + //$last_exec['whazzup'] = 0; |
|
| 178 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 179 | + } else if (preg_match('/airwhere/i',$host)) { |
|
| 180 | + $globalSources[$id]['format'] = 'airwhere'; |
|
| 181 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 182 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 183 | + //$formats[$id] = 'pirepsjson'; |
|
| 184 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 185 | + //$last_exec['pirepsjson'] = 0; |
|
| 186 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 187 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 188 | + //$formats[$id] = 'fr24json'; |
|
| 189 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 190 | + //$last_exec['fr24json'] = 0; |
|
| 191 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 192 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 193 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 194 | + exit(0); |
|
| 195 | + } |
|
| 196 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 197 | + //$formats[$id] = 'fr24json'; |
|
| 198 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 199 | + //$last_exec['fr24json'] = 0; |
|
| 200 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 201 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 202 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 203 | + exit(0); |
|
| 204 | + } |
|
| 205 | + //} else if (preg_match('/10001/',$host)) { |
|
| 206 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 207 | + //$formats[$id] = 'tsv'; |
|
| 208 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 209 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 210 | + } |
|
| 211 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 212 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 213 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 214 | + if ($idf !== false) { |
|
| 215 | + $httpfeeds[$id] = $idf; |
|
| 216 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 217 | + } |
|
| 218 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 219 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 220 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 221 | + $hostport = explode(':',$host); |
|
| 222 | + if (isset($hostport[1])) { |
|
| 223 | 223 | $port = $hostport[1]; |
| 224 | 224 | $hostn = $hostport[0]; |
| 225 | - } else { |
|
| 225 | + } else { |
|
| 226 | 226 | $port = $globalSources[$id]['port']; |
| 227 | 227 | $hostn = $globalSources[$id]['host']; |
| 228 | - } |
|
| 229 | - $Common = new Common(); |
|
| 230 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 231 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 232 | - } else { |
|
| 233 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 234 | - } |
|
| 235 | - if ($s) { |
|
| 236 | - $sockets[$id] = $s; |
|
| 237 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 238 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 228 | + } |
|
| 229 | + $Common = new Common(); |
|
| 230 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 231 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 232 | + } else { |
|
| 233 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 234 | + } |
|
| 235 | + if ($s) { |
|
| 236 | + $sockets[$id] = $s; |
|
| 237 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 238 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 239 | 239 | //$formats[$id] = 'aprs'; |
| 240 | 240 | $globalSources[$id]['format'] = 'aprs'; |
| 241 | 241 | //$aprs_connect = 0; |
| 242 | 242 | //$use_aprs = true; |
| 243 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 243 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 244 | 244 | $globalSources[$id]['format'] = 'vrstcp'; |
| 245 | - } elseif ($port == '10001') { |
|
| 246 | - //$formats[$id] = 'tsv'; |
|
| 247 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 248 | - } elseif ($port == '30002') { |
|
| 249 | - //$formats[$id] = 'raw'; |
|
| 250 | - $globalSources[$id]['format'] = 'raw'; |
|
| 251 | - } elseif ($port == '5001') { |
|
| 252 | - //$formats[$id] = 'raw'; |
|
| 253 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 254 | - } elseif ($port == '30005') { |
|
| 245 | + } elseif ($port == '10001') { |
|
| 246 | + //$formats[$id] = 'tsv'; |
|
| 247 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 248 | + } elseif ($port == '30002') { |
|
| 249 | + //$formats[$id] = 'raw'; |
|
| 250 | + $globalSources[$id]['format'] = 'raw'; |
|
| 251 | + } elseif ($port == '5001') { |
|
| 252 | + //$formats[$id] = 'raw'; |
|
| 253 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 254 | + } elseif ($port == '30005') { |
|
| 255 | 255 | // Not yet supported |
| 256 | - //$formats[$id] = 'beast'; |
|
| 257 | - $globalSources[$id]['format'] = 'beast'; |
|
| 258 | - //} else $formats[$id] = 'sbs'; |
|
| 259 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 260 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 256 | + //$formats[$id] = 'beast'; |
|
| 257 | + $globalSources[$id]['format'] = 'beast'; |
|
| 258 | + //} else $formats[$id] = 'sbs'; |
|
| 259 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 260 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 261 | 261 | } |
| 262 | 262 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 263 | - } else { |
|
| 263 | + } else { |
|
| 264 | 264 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 265 | - } |
|
| 266 | - } |
|
| 267 | - } |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | 268 | } |
| 269 | 269 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
| 270 | 270 | |
@@ -287,9 +287,9 @@ discard block |
||
| 287 | 287 | //connect_all($globalSources); |
| 288 | 288 | |
| 289 | 289 | if (isset($globalProxy) && $globalProxy) { |
| 290 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 290 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 291 | 291 | } else { |
| 292 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 292 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // APRS Configuration |
@@ -298,21 +298,21 @@ discard block |
||
| 298 | 298 | die; |
| 299 | 299 | } |
| 300 | 300 | foreach ($globalSources as $key => $source) { |
| 301 | - if (!isset($source['format'])) { |
|
| 302 | - $globalSources[$key]['format'] = 'auto'; |
|
| 303 | - } |
|
| 304 | - if (isset($source['callback'])) { |
|
| 305 | - unset($globalSources[$key]); |
|
| 306 | - } |
|
| 301 | + if (!isset($source['format'])) { |
|
| 302 | + $globalSources[$key]['format'] = 'auto'; |
|
| 303 | + } |
|
| 304 | + if (isset($source['callback'])) { |
|
| 305 | + unset($globalSources[$key]); |
|
| 306 | + } |
|
| 307 | 307 | } |
| 308 | 308 | connect_all($globalSources); |
| 309 | 309 | foreach ($globalSources as $key => $source) { |
| 310 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 310 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 311 | 311 | $aprs_connect = 0; |
| 312 | 312 | $use_aprs = true; |
| 313 | 313 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
| 314 | 314 | break; |
| 315 | - } |
|
| 315 | + } |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | if ($use_aprs) { |
@@ -353,115 +353,115 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 355 | 355 | while ($i > 0) { |
| 356 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 357 | - // Delete old ATC |
|
| 358 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 356 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 357 | + // Delete old ATC |
|
| 358 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 359 | 359 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
| 360 | - $ATC->deleteOldATC(); |
|
| 361 | - } |
|
| 360 | + $ATC->deleteOldATC(); |
|
| 361 | + } |
|
| 362 | 362 | |
| 363 | - if (count($last_exec) == count($globalSources)) { |
|
| 363 | + if (count($last_exec) == count($globalSources)) { |
|
| 364 | 364 | $max = $globalMinFetch; |
| 365 | 365 | foreach ($last_exec as $last) { |
| 366 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 366 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 367 | 367 | } |
| 368 | 368 | if ($max != $globalMinFetch) { |
| 369 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 370 | - sleep($globalMinFetch-$max+2); |
|
| 369 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 370 | + sleep($globalMinFetch-$max+2); |
|
| 371 | + } |
|
| 371 | 372 | } |
| 372 | - } |
|
| 373 | 373 | |
| 374 | 374 | |
| 375 | - //foreach ($formats as $id => $value) { |
|
| 376 | - foreach ($globalSources as $id => $value) { |
|
| 375 | + //foreach ($formats as $id => $value) { |
|
| 376 | + foreach ($globalSources as $id => $value) { |
|
| 377 | 377 | date_default_timezone_set('UTC'); |
| 378 | 378 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
| 379 | 379 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 380 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 381 | - $buffer = $Common->getData($value['host']); |
|
| 382 | - if ($buffer != '') $reset = 0; |
|
| 383 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 384 | - $buffer = explode('\n',$buffer); |
|
| 385 | - foreach ($buffer as $line) { |
|
| 386 | - if ($line != '' && count($line) > 7) { |
|
| 387 | - $line = explode(',', $line); |
|
| 388 | - $data = array(); |
|
| 389 | - $data['hex'] = $line[1]; // hex |
|
| 390 | - $data['ident'] = $line[2]; // ident |
|
| 391 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 392 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 393 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 394 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 395 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 396 | - $data['verticalrate'] = ''; // vertical rate |
|
| 397 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 398 | - $data['emergency'] = ''; // emergency |
|
| 399 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 400 | - $data['format_source'] = 'deltadbtxt'; |
|
| 401 | - $data['id_source'] = $id_source; |
|
| 402 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 403 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 404 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 405 | - $SI->add($data); |
|
| 406 | - unset($data); |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - $last_exec[$id]['last'] = time(); |
|
| 380 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 381 | + $buffer = $Common->getData($value['host']); |
|
| 382 | + if ($buffer != '') $reset = 0; |
|
| 383 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 384 | + $buffer = explode('\n',$buffer); |
|
| 385 | + foreach ($buffer as $line) { |
|
| 386 | + if ($line != '' && count($line) > 7) { |
|
| 387 | + $line = explode(',', $line); |
|
| 388 | + $data = array(); |
|
| 389 | + $data['hex'] = $line[1]; // hex |
|
| 390 | + $data['ident'] = $line[2]; // ident |
|
| 391 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 392 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 393 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 394 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 395 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 396 | + $data['verticalrate'] = ''; // vertical rate |
|
| 397 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 398 | + $data['emergency'] = ''; // emergency |
|
| 399 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 400 | + $data['format_source'] = 'deltadbtxt'; |
|
| 401 | + $data['id_source'] = $id_source; |
|
| 402 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 403 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 404 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 405 | + $SI->add($data); |
|
| 406 | + unset($data); |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + $last_exec[$id]['last'] = time(); |
|
| 410 | 410 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 411 | - date_default_timezone_set('CET'); |
|
| 412 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 413 | - date_default_timezone_set('UTC'); |
|
| 414 | - if ($buffer != '') $reset = 0; |
|
| 415 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 416 | - $buffer = explode('\n',$buffer); |
|
| 417 | - foreach ($buffer as $line) { |
|
| 411 | + date_default_timezone_set('CET'); |
|
| 412 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 413 | + date_default_timezone_set('UTC'); |
|
| 414 | + if ($buffer != '') $reset = 0; |
|
| 415 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 416 | + $buffer = explode('\n',$buffer); |
|
| 417 | + foreach ($buffer as $line) { |
|
| 418 | 418 | if ($line != '') { |
| 419 | - //echo "'".$line."'\n"; |
|
| 420 | - $add = false; |
|
| 421 | - $ais_data = $AIS->parse_line(trim($line)); |
|
| 422 | - $data = array(); |
|
| 423 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 424 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 425 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 426 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 427 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 428 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 429 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 430 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 431 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 432 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 433 | - if (isset($ais_data['timestamp'])) { |
|
| 419 | + //echo "'".$line."'\n"; |
|
| 420 | + $add = false; |
|
| 421 | + $ais_data = $AIS->parse_line(trim($line)); |
|
| 422 | + $data = array(); |
|
| 423 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 424 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 425 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 426 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 427 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 428 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 429 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 430 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 431 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 432 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 433 | + if (isset($ais_data['timestamp'])) { |
|
| 434 | 434 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 435 | 435 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 436 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 437 | - $add = true; |
|
| 436 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 437 | + $add = true; |
|
| 438 | 438 | } |
| 439 | - } else { |
|
| 439 | + } else { |
|
| 440 | 440 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 441 | 441 | $add = true; |
| 442 | - } |
|
| 443 | - $data['format_source'] = 'aisnmeatxt'; |
|
| 444 | - $data['id_source'] = $id_source; |
|
| 445 | - //print_r($data); |
|
| 446 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 447 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 448 | - unset($data); |
|
| 442 | + } |
|
| 443 | + $data['format_source'] = 'aisnmeatxt'; |
|
| 444 | + $data['id_source'] = $id_source; |
|
| 445 | + //print_r($data); |
|
| 446 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 447 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 448 | + unset($data); |
|
| 449 | 449 | } |
| 450 | - } |
|
| 451 | - $last_exec[$id]['last'] = time(); |
|
| 450 | + } |
|
| 451 | + $last_exec[$id]['last'] = time(); |
|
| 452 | 452 | } elseif ($value['format'] == 'aisnmeahttp') { |
| 453 | - $arr = $httpfeeds; |
|
| 454 | - $w = $e = null; |
|
| 453 | + $arr = $httpfeeds; |
|
| 454 | + $w = $e = null; |
|
| 455 | 455 | |
| 456 | - if (isset($arr[$id])) { |
|
| 456 | + if (isset($arr[$id])) { |
|
| 457 | 457 | $nn = stream_select($arr,$w,$e,$timeout); |
| 458 | 458 | if ($nn > 0) { |
| 459 | - foreach ($httpfeeds as $feed) { |
|
| 459 | + foreach ($httpfeeds as $feed) { |
|
| 460 | 460 | $buffer = stream_get_line($feed,2000,"\n"); |
| 461 | 461 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 462 | 462 | $buffer = explode('\n',$buffer); |
| 463 | 463 | foreach ($buffer as $line) { |
| 464 | - if ($line != '') { |
|
| 464 | + if ($line != '') { |
|
| 465 | 465 | $ais_data = $AIS->parse_line(trim($line)); |
| 466 | 466 | $data = array(); |
| 467 | 467 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -479,96 +479,96 @@ discard block |
||
| 479 | 479 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 480 | 480 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
| 481 | 481 | if (isset($ais_data['timestamp'])) { |
| 482 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 482 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 483 | 483 | } else { |
| 484 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 484 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 485 | 485 | } |
| 486 | 486 | $data['format_source'] = 'aisnmeahttp'; |
| 487 | 487 | $data['id_source'] = $id_source; |
| 488 | 488 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 489 | 489 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
| 490 | 490 | unset($data); |
| 491 | - } |
|
| 491 | + } |
|
| 492 | + } |
|
| 492 | 493 | } |
| 493 | - } |
|
| 494 | 494 | } else { |
| 495 | - $format = $value['format']; |
|
| 496 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 497 | - else $tt[$format] = 0; |
|
| 498 | - if ($tt[$format] > 30) { |
|
| 495 | + $format = $value['format']; |
|
| 496 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 497 | + else $tt[$format] = 0; |
|
| 498 | + if ($tt[$format] > 30) { |
|
| 499 | 499 | if ($globalDebug) echo 'Reconnect...'."\n"; |
| 500 | 500 | sleep(2); |
| 501 | 501 | $sourceeen[] = $value; |
| 502 | 502 | connect_all($sourceeen); |
| 503 | 503 | $sourceeen = array(); |
| 504 | - } |
|
| 504 | + } |
|
| 505 | + } |
|
| 505 | 506 | } |
| 506 | - } |
|
| 507 | 507 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 508 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 509 | - if ($buffer != '') { |
|
| 508 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 509 | + if ($buffer != '') { |
|
| 510 | 510 | //echo $buffer; |
| 511 | 511 | $all_data = json_decode($buffer,true); |
| 512 | 512 | //print_r($all_data); |
| 513 | 513 | if (isset($all_data[0]['DATA'])) { |
| 514 | - foreach ($all_data[0]['DATA'] as $line) { |
|
| 514 | + foreach ($all_data[0]['DATA'] as $line) { |
|
| 515 | 515 | if ($line != '') { |
| 516 | - $data = array(); |
|
| 517 | - $data['ident'] = $line['NAME']; |
|
| 518 | - $data['mmsi'] = $line['MMSI']; |
|
| 519 | - $data['speed'] = $line['SOG']; |
|
| 520 | - $data['heading'] = $line['COG']; |
|
| 521 | - $data['latitude'] = $line['LAT']; |
|
| 522 | - $data['longitude'] = $line['LNG']; |
|
| 523 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 524 | - $data['imo'] = $line['IMO']; |
|
| 525 | - //$data['arrival_code'] = $ais_data['destination']; |
|
| 526 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 527 | - $data['format_source'] = 'myshiptracking'; |
|
| 528 | - $data['id_source'] = $id_source; |
|
| 529 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 530 | - $MI->add($data); |
|
| 531 | - unset($data); |
|
| 516 | + $data = array(); |
|
| 517 | + $data['ident'] = $line['NAME']; |
|
| 518 | + $data['mmsi'] = $line['MMSI']; |
|
| 519 | + $data['speed'] = $line['SOG']; |
|
| 520 | + $data['heading'] = $line['COG']; |
|
| 521 | + $data['latitude'] = $line['LAT']; |
|
| 522 | + $data['longitude'] = $line['LNG']; |
|
| 523 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 524 | + $data['imo'] = $line['IMO']; |
|
| 525 | + //$data['arrival_code'] = $ais_data['destination']; |
|
| 526 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 527 | + $data['format_source'] = 'myshiptracking'; |
|
| 528 | + $data['id_source'] = $id_source; |
|
| 529 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 530 | + $MI->add($data); |
|
| 531 | + unset($data); |
|
| 532 | + } |
|
| 532 | 533 | } |
| 533 | - } |
|
| 534 | 534 | } |
| 535 | - } |
|
| 536 | - $last_exec[$id]['last'] = time(); |
|
| 535 | + } |
|
| 536 | + $last_exec[$id]['last'] = time(); |
|
| 537 | 537 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 538 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 539 | - if ($buffer != '') { |
|
| 538 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 539 | + if ($buffer != '') { |
|
| 540 | 540 | $all_data = json_decode($buffer,true); |
| 541 | 541 | if (isset($all_data[0]['mmsi'])) { |
| 542 | - foreach ($all_data as $line) { |
|
| 542 | + foreach ($all_data as $line) { |
|
| 543 | 543 | if ($line != '') { |
| 544 | - $data = array(); |
|
| 545 | - $data['ident'] = $line['shipname']; |
|
| 546 | - $data['callsign'] = $line['callsign']; |
|
| 547 | - $data['mmsi'] = $line['mmsi']; |
|
| 548 | - $data['speed'] = $line['sog']; |
|
| 549 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 550 | - $data['latitude'] = $line['latitude']; |
|
| 551 | - $data['longitude'] = $line['longitude']; |
|
| 552 | - $data['type_id'] = $line['shiptype']; |
|
| 553 | - $data['arrival_code'] = $line['destination']; |
|
| 554 | - $data['datetime'] = $line['time']; |
|
| 555 | - $data['format_source'] = 'boatbeaconapp'; |
|
| 556 | - $data['id_source'] = $id_source; |
|
| 557 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 558 | - $MI->add($data); |
|
| 559 | - unset($data); |
|
| 544 | + $data = array(); |
|
| 545 | + $data['ident'] = $line['shipname']; |
|
| 546 | + $data['callsign'] = $line['callsign']; |
|
| 547 | + $data['mmsi'] = $line['mmsi']; |
|
| 548 | + $data['speed'] = $line['sog']; |
|
| 549 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 550 | + $data['latitude'] = $line['latitude']; |
|
| 551 | + $data['longitude'] = $line['longitude']; |
|
| 552 | + $data['type_id'] = $line['shiptype']; |
|
| 553 | + $data['arrival_code'] = $line['destination']; |
|
| 554 | + $data['datetime'] = $line['time']; |
|
| 555 | + $data['format_source'] = 'boatbeaconapp'; |
|
| 556 | + $data['id_source'] = $id_source; |
|
| 557 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 558 | + $MI->add($data); |
|
| 559 | + unset($data); |
|
| 560 | + } |
|
| 560 | 561 | } |
| 561 | - } |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | - } |
|
| 565 | - $last_exec[$id]['last'] = time(); |
|
| 564 | + } |
|
| 565 | + $last_exec[$id]['last'] = time(); |
|
| 566 | 566 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 567 | - $buffer = $Common->getData($value['host']); |
|
| 568 | - if ($buffer != '') { |
|
| 567 | + $buffer = $Common->getData($value['host']); |
|
| 568 | + if ($buffer != '') { |
|
| 569 | 569 | $all_data = json_decode($buffer,true); |
| 570 | 570 | if (isset($all_data['features'][0]['id'])) { |
| 571 | - foreach ($all_data['features'] as $line) { |
|
| 571 | + foreach ($all_data['features'] as $line) { |
|
| 572 | 572 | $data = array(); |
| 573 | 573 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
| 574 | 574 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -587,59 +587,59 @@ discard block |
||
| 587 | 587 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 588 | 588 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
| 589 | 589 | unset($data); |
| 590 | - } |
|
| 590 | + } |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | - } |
|
| 594 | - $last_exec[$id]['last'] = time(); |
|
| 593 | + } |
|
| 594 | + $last_exec[$id]['last'] = time(); |
|
| 595 | 595 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 596 | - echo 'download...'; |
|
| 597 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 598 | - echo 'done !'."\n"; |
|
| 599 | - if ($buffer != '') $reset = 0; |
|
| 600 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 601 | - $buffer = explode('\n',$buffer); |
|
| 602 | - foreach ($buffer as $line) { |
|
| 596 | + echo 'download...'; |
|
| 597 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 598 | + echo 'done !'."\n"; |
|
| 599 | + if ($buffer != '') $reset = 0; |
|
| 600 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 601 | + $buffer = explode('\n',$buffer); |
|
| 602 | + foreach ($buffer as $line) { |
|
| 603 | 603 | if ($line != '') { |
| 604 | - $data = array(); |
|
| 605 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 606 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 607 | - //$data['status'] = substr($line,21,2); |
|
| 608 | - //$data['type'] = substr($line,24,3); |
|
| 609 | - $data['latitude'] = substr($line,29,9); |
|
| 610 | - $data['longitude'] = substr($line,41,9); |
|
| 611 | - $data['speed'] = round(substr($line,51,5)); |
|
| 612 | - //$data['course'] = substr($line,57,5); |
|
| 613 | - $data['heading'] = round(substr($line,63,3)); |
|
| 614 | - //$data['draft'] = substr($line,67,4); |
|
| 615 | - //$data['length'] = substr($line,72,3); |
|
| 616 | - //$data['beam'] = substr($line,76,2); |
|
| 617 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 618 | - //$data['callsign'] = trim(substr($line,100,7); |
|
| 619 | - //$data['dest'] = substr($line,108,20); |
|
| 620 | - //$data['etaDate'] = substr($line,129,5); |
|
| 621 | - //$data['etaTime'] = substr($line,135,5); |
|
| 622 | - $data['format_source'] = 'shipplotter'; |
|
| 623 | - $data['id_source'] = $id_source; |
|
| 624 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 625 | - //print_r($data); |
|
| 626 | - echo 'Add...'."\n"; |
|
| 627 | - $MI->add($data); |
|
| 628 | - unset($data); |
|
| 604 | + $data = array(); |
|
| 605 | + $data['mmsi'] = (int)substr($line,0,9); |
|
| 606 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 607 | + //$data['status'] = substr($line,21,2); |
|
| 608 | + //$data['type'] = substr($line,24,3); |
|
| 609 | + $data['latitude'] = substr($line,29,9); |
|
| 610 | + $data['longitude'] = substr($line,41,9); |
|
| 611 | + $data['speed'] = round(substr($line,51,5)); |
|
| 612 | + //$data['course'] = substr($line,57,5); |
|
| 613 | + $data['heading'] = round(substr($line,63,3)); |
|
| 614 | + //$data['draft'] = substr($line,67,4); |
|
| 615 | + //$data['length'] = substr($line,72,3); |
|
| 616 | + //$data['beam'] = substr($line,76,2); |
|
| 617 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 618 | + //$data['callsign'] = trim(substr($line,100,7); |
|
| 619 | + //$data['dest'] = substr($line,108,20); |
|
| 620 | + //$data['etaDate'] = substr($line,129,5); |
|
| 621 | + //$data['etaTime'] = substr($line,135,5); |
|
| 622 | + $data['format_source'] = 'shipplotter'; |
|
| 623 | + $data['id_source'] = $id_source; |
|
| 624 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 625 | + //print_r($data); |
|
| 626 | + echo 'Add...'."\n"; |
|
| 627 | + $MI->add($data); |
|
| 628 | + unset($data); |
|
| 629 | 629 | } |
| 630 | - } |
|
| 631 | - $last_exec[$id]['last'] = time(); |
|
| 630 | + } |
|
| 631 | + $last_exec[$id]['last'] = time(); |
|
| 632 | 632 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 633 | 633 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
| 634 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 635 | - $buffer = $Common->getData($value['host']); |
|
| 636 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 637 | - $buffer = explode('\n',$buffer); |
|
| 638 | - $reset = 0; |
|
| 639 | - foreach ($buffer as $line) { |
|
| 640 | - if ($line != '') { |
|
| 641 | - $line = explode(':', $line); |
|
| 642 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 634 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 635 | + $buffer = $Common->getData($value['host']); |
|
| 636 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 637 | + $buffer = explode('\n',$buffer); |
|
| 638 | + $reset = 0; |
|
| 639 | + foreach ($buffer as $line) { |
|
| 640 | + if ($line != '') { |
|
| 641 | + $line = explode(':', $line); |
|
| 642 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 643 | 643 | $data = array(); |
| 644 | 644 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
| 645 | 645 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -652,37 +652,37 @@ discard block |
||
| 652 | 652 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 653 | 653 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 654 | 654 | $data['latitude'] = $line[5]; // lat |
| 655 | - $data['longitude'] = $line[6]; // long |
|
| 656 | - $data['verticalrate'] = ''; // vertical rate |
|
| 657 | - $data['squawk'] = ''; // squawk |
|
| 658 | - $data['emergency'] = ''; // emergency |
|
| 659 | - $data['waypoints'] = $line[30]; |
|
| 655 | + $data['longitude'] = $line[6]; // long |
|
| 656 | + $data['verticalrate'] = ''; // vertical rate |
|
| 657 | + $data['squawk'] = ''; // squawk |
|
| 658 | + $data['emergency'] = ''; // emergency |
|
| 659 | + $data['waypoints'] = $line[30]; |
|
| 660 | 660 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 661 | 661 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 662 | 662 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 663 | - $data['departure_airport_icao'] = $line[11]; |
|
| 664 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 665 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 663 | + $data['departure_airport_icao'] = $line[11]; |
|
| 664 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 665 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 666 | 666 | $data['frequency'] = $line[4]; |
| 667 | 667 | $data['type'] = $line[18]; |
| 668 | 668 | $data['range'] = $line[19]; |
| 669 | 669 | if (isset($line[35])) $data['info'] = $line[35]; |
| 670 | - $data['id_source'] = $id_source; |
|
| 671 | - //$data['arrival_airport_time'] = ; |
|
| 672 | - if ($line[9] != '') { |
|
| 673 | - $aircraft_data = explode('/',$line[9]); |
|
| 674 | - if (isset($aircraft_data[1])) { |
|
| 675 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 676 | - } |
|
| 677 | - } |
|
| 678 | - /* |
|
| 670 | + $data['id_source'] = $id_source; |
|
| 671 | + //$data['arrival_airport_time'] = ; |
|
| 672 | + if ($line[9] != '') { |
|
| 673 | + $aircraft_data = explode('/',$line[9]); |
|
| 674 | + if (isset($aircraft_data[1])) { |
|
| 675 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 676 | + } |
|
| 677 | + } |
|
| 678 | + /* |
|
| 679 | 679 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
| 680 | 680 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 681 | 681 | */ |
| 682 | - $data['format_source'] = $value['format']; |
|
| 682 | + $data['format_source'] = $value['format']; |
|
| 683 | 683 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 684 | 684 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 685 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 685 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
| 686 | 686 | elseif ($line[3] == 'ATC') { |
| 687 | 687 | //print_r($data); |
| 688 | 688 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -703,16 +703,16 @@ discard block |
||
| 703 | 703 | 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']); |
| 704 | 704 | } |
| 705 | 705 | } |
| 706 | - unset($data); |
|
| 707 | - } |
|
| 708 | - } |
|
| 709 | - } |
|
| 710 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 711 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 712 | - $last_exec[$id]['last'] = time(); |
|
| 713 | - } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 714 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 715 | - if ($buffer != '') { |
|
| 706 | + unset($data); |
|
| 707 | + } |
|
| 708 | + } |
|
| 709 | + } |
|
| 710 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 711 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 712 | + $last_exec[$id]['last'] = time(); |
|
| 713 | + } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 714 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 715 | + if ($buffer != '') { |
|
| 716 | 716 | $all_data = simplexml_load_string($buffer); |
| 717 | 717 | foreach($all_data->children() as $childdata) { |
| 718 | 718 | $data = array(); |
@@ -734,10 +734,10 @@ discard block |
||
| 734 | 734 | $SI->add($data); |
| 735 | 735 | unset($data); |
| 736 | 736 | } |
| 737 | - } |
|
| 738 | - $Source->deleteOldLocationByType('gs'); |
|
| 739 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 740 | - if ($buffer != '') { |
|
| 737 | + } |
|
| 738 | + $Source->deleteOldLocationByType('gs'); |
|
| 739 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 740 | + if ($buffer != '') { |
|
| 741 | 741 | $all_data = simplexml_load_string($buffer); |
| 742 | 742 | foreach($all_data->children() as $childdata) { |
| 743 | 743 | $data = array(); |
@@ -755,249 +755,249 @@ discard block |
||
| 755 | 755 | } |
| 756 | 756 | unset($data); |
| 757 | 757 | } |
| 758 | - } |
|
| 759 | - $last_exec[$id]['last'] = time(); |
|
| 758 | + } |
|
| 759 | + $last_exec[$id]['last'] = time(); |
|
| 760 | 760 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 761 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 762 | - if ($buffer != '') { |
|
| 763 | - $all_data = json_decode($buffer,true); |
|
| 764 | - if (isset($all_data['acList'])) { |
|
| 761 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 762 | + if ($buffer != '') { |
|
| 763 | + $all_data = json_decode($buffer,true); |
|
| 764 | + if (isset($all_data['acList'])) { |
|
| 765 | 765 | $reset = 0; |
| 766 | 766 | foreach ($all_data['acList'] as $line) { |
| 767 | - $data = array(); |
|
| 768 | - $data['hex'] = $line['Icao']; // hex |
|
| 769 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 770 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 771 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 772 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 773 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 774 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 775 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
| 776 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 777 | - $data['emergency'] = ''; // emergency |
|
| 778 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 767 | + $data = array(); |
|
| 768 | + $data['hex'] = $line['Icao']; // hex |
|
| 769 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 770 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 771 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 772 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 773 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 774 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 775 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
| 776 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 777 | + $data['emergency'] = ''; // emergency |
|
| 778 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 779 | 779 | |
| 780 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 781 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 780 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 781 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 782 | 782 | |
| 783 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 784 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 785 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 786 | - $data['id_source'] = $id_source; |
|
| 787 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 788 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 789 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 790 | - unset($data); |
|
| 783 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 784 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 785 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 786 | + $data['id_source'] = $id_source; |
|
| 787 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 788 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 789 | + if (isset($data['latitude'])) $SI->add($data); |
|
| 790 | + unset($data); |
|
| 791 | 791 | } |
| 792 | - } elseif (is_array($all_data)) { |
|
| 792 | + } elseif (is_array($all_data)) { |
|
| 793 | 793 | $reset = 0; |
| 794 | 794 | foreach ($all_data as $line) { |
| 795 | - $data = array(); |
|
| 796 | - $data['hex'] = $line['hex']; // hex |
|
| 797 | - $data['ident'] = $line['flight']; // ident |
|
| 798 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 799 | - $data['speed'] = $line['speed']; // speed |
|
| 800 | - $data['heading'] = $line['track']; // heading |
|
| 801 | - $data['latitude'] = $line['lat']; // lat |
|
| 802 | - $data['longitude'] = $line['lon']; // long |
|
| 803 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 804 | - $data['squawk'] = $line['squawk']; // squawk |
|
| 805 | - $data['emergency'] = ''; // emergency |
|
| 806 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 807 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 808 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 809 | - $data['id_source'] = $id_source; |
|
| 810 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 811 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 812 | - $SI->add($data); |
|
| 813 | - unset($data); |
|
| 795 | + $data = array(); |
|
| 796 | + $data['hex'] = $line['hex']; // hex |
|
| 797 | + $data['ident'] = $line['flight']; // ident |
|
| 798 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 799 | + $data['speed'] = $line['speed']; // speed |
|
| 800 | + $data['heading'] = $line['track']; // heading |
|
| 801 | + $data['latitude'] = $line['lat']; // lat |
|
| 802 | + $data['longitude'] = $line['lon']; // long |
|
| 803 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 804 | + $data['squawk'] = $line['squawk']; // squawk |
|
| 805 | + $data['emergency'] = ''; // emergency |
|
| 806 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 807 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 808 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 809 | + $data['id_source'] = $id_source; |
|
| 810 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 811 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 812 | + $SI->add($data); |
|
| 813 | + unset($data); |
|
| 814 | + } |
|
| 814 | 815 | } |
| 815 | - } |
|
| 816 | - } |
|
| 817 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 818 | - $last_exec[$id]['last'] = time(); |
|
| 819 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 820 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 821 | - $buffer = $Common->getData($value['host']); |
|
| 822 | - $all_data = json_decode($buffer,true); |
|
| 823 | - if (isset($all_data['planes'])) { |
|
| 816 | + } |
|
| 817 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 818 | + $last_exec[$id]['last'] = time(); |
|
| 819 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 820 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 821 | + $buffer = $Common->getData($value['host']); |
|
| 822 | + $all_data = json_decode($buffer,true); |
|
| 823 | + if (isset($all_data['planes'])) { |
|
| 824 | 824 | $reset = 0; |
| 825 | 825 | foreach ($all_data['planes'] as $key => $line) { |
| 826 | - $data = array(); |
|
| 827 | - $data['hex'] = $key; // hex |
|
| 828 | - $data['ident'] = $line[3]; // ident |
|
| 829 | - $data['altitude'] = $line[6]; // altitude |
|
| 830 | - $data['speed'] = $line[8]; // speed |
|
| 831 | - $data['heading'] = $line[7]; // heading |
|
| 832 | - $data['latitude'] = $line[4]; // lat |
|
| 833 | - $data['longitude'] = $line[5]; // long |
|
| 834 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 835 | - $data['squawk'] = $line[10]; // squawk |
|
| 836 | - $data['emergency'] = ''; // emergency |
|
| 837 | - $data['registration'] = $line[2]; |
|
| 838 | - $data['aircraft_icao'] = $line[0]; |
|
| 839 | - $deparr = explode('-',$line[1]); |
|
| 840 | - if (count($deparr) == 2) { |
|
| 826 | + $data = array(); |
|
| 827 | + $data['hex'] = $key; // hex |
|
| 828 | + $data['ident'] = $line[3]; // ident |
|
| 829 | + $data['altitude'] = $line[6]; // altitude |
|
| 830 | + $data['speed'] = $line[8]; // speed |
|
| 831 | + $data['heading'] = $line[7]; // heading |
|
| 832 | + $data['latitude'] = $line[4]; // lat |
|
| 833 | + $data['longitude'] = $line[5]; // long |
|
| 834 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 835 | + $data['squawk'] = $line[10]; // squawk |
|
| 836 | + $data['emergency'] = ''; // emergency |
|
| 837 | + $data['registration'] = $line[2]; |
|
| 838 | + $data['aircraft_icao'] = $line[0]; |
|
| 839 | + $deparr = explode('-',$line[1]); |
|
| 840 | + if (count($deparr) == 2) { |
|
| 841 | 841 | $data['departure_airport_icao'] = $deparr[0]; |
| 842 | 842 | $data['arrival_airport_icao'] = $deparr[1]; |
| 843 | - } |
|
| 844 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 845 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 846 | - $data['id_source'] = $id_source; |
|
| 847 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 848 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 849 | - $SI->add($data); |
|
| 850 | - unset($data); |
|
| 843 | + } |
|
| 844 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 845 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 846 | + $data['id_source'] = $id_source; |
|
| 847 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 848 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 849 | + $SI->add($data); |
|
| 850 | + unset($data); |
|
| 851 | 851 | } |
| 852 | - } |
|
| 853 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 854 | - $last_exec[$id]['last'] = time(); |
|
| 855 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 856 | - $buffer = $Common->getData($value['host']); |
|
| 857 | - $all_data = json_decode($buffer,true); |
|
| 858 | - if (isset($all_data['states'])) { |
|
| 852 | + } |
|
| 853 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 854 | + $last_exec[$id]['last'] = time(); |
|
| 855 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 856 | + $buffer = $Common->getData($value['host']); |
|
| 857 | + $all_data = json_decode($buffer,true); |
|
| 858 | + if (isset($all_data['states'])) { |
|
| 859 | 859 | $reset = 0; |
| 860 | 860 | foreach ($all_data['states'] as $key => $line) { |
| 861 | - $data = array(); |
|
| 862 | - $data['hex'] = $line[0]; // hex |
|
| 863 | - $data['ident'] = trim($line[1]); // ident |
|
| 864 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 865 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 866 | - $data['heading'] = round($line[10]); // heading |
|
| 867 | - $data['latitude'] = $line[6]; // lat |
|
| 868 | - $data['longitude'] = $line[5]; // long |
|
| 869 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 870 | - //$data['squawk'] = $line[10]; // squawk |
|
| 871 | - //$data['emergency'] = ''; // emergency |
|
| 872 | - //$data['registration'] = $line[2]; |
|
| 873 | - //$data['aircraft_icao'] = $line[0]; |
|
| 874 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 875 | - $data['format_source'] = 'opensky'; |
|
| 876 | - $data['id_source'] = $id_source; |
|
| 877 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 878 | - $SI->add($data); |
|
| 879 | - unset($data); |
|
| 861 | + $data = array(); |
|
| 862 | + $data['hex'] = $line[0]; // hex |
|
| 863 | + $data['ident'] = trim($line[1]); // ident |
|
| 864 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 865 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 866 | + $data['heading'] = round($line[10]); // heading |
|
| 867 | + $data['latitude'] = $line[6]; // lat |
|
| 868 | + $data['longitude'] = $line[5]; // long |
|
| 869 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 870 | + //$data['squawk'] = $line[10]; // squawk |
|
| 871 | + //$data['emergency'] = ''; // emergency |
|
| 872 | + //$data['registration'] = $line[2]; |
|
| 873 | + //$data['aircraft_icao'] = $line[0]; |
|
| 874 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 875 | + $data['format_source'] = 'opensky'; |
|
| 876 | + $data['id_source'] = $id_source; |
|
| 877 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 878 | + $SI->add($data); |
|
| 879 | + unset($data); |
|
| 880 | + } |
|
| 880 | 881 | } |
| 881 | - } |
|
| 882 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 883 | - $last_exec[$id]['last'] = time(); |
|
| 884 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 885 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 886 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 887 | - $buffer = $Common->getData($value['host']); |
|
| 888 | - $all_data = json_decode($buffer,true); |
|
| 889 | - if (!empty($all_data)) $reset = 0; |
|
| 890 | - foreach ($all_data as $key => $line) { |
|
| 882 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 883 | + $last_exec[$id]['last'] = time(); |
|
| 884 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 885 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 886 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 887 | + $buffer = $Common->getData($value['host']); |
|
| 888 | + $all_data = json_decode($buffer,true); |
|
| 889 | + if (!empty($all_data)) $reset = 0; |
|
| 890 | + foreach ($all_data as $key => $line) { |
|
| 891 | 891 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 892 | - $data = array(); |
|
| 893 | - $data['hex'] = $line[0]; |
|
| 894 | - $data['ident'] = $line[16]; //$line[13] |
|
| 895 | - $data['altitude'] = $line[4]; // altitude |
|
| 896 | - $data['speed'] = $line[5]; // speed |
|
| 897 | - $data['heading'] = $line[3]; // heading |
|
| 898 | - $data['latitude'] = $line[1]; // lat |
|
| 899 | - $data['longitude'] = $line[2]; // long |
|
| 900 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 901 | - $data['squawk'] = $line[6]; // squawk |
|
| 902 | - $data['aircraft_icao'] = $line[8]; |
|
| 903 | - $data['registration'] = $line[9]; |
|
| 904 | - $data['departure_airport_iata'] = $line[11]; |
|
| 905 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 906 | - $data['emergency'] = ''; // emergency |
|
| 907 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 908 | - $data['format_source'] = 'fr24json'; |
|
| 909 | - $data['id_source'] = $id_source; |
|
| 910 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 911 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 912 | - $SI->add($data); |
|
| 913 | - unset($data); |
|
| 892 | + $data = array(); |
|
| 893 | + $data['hex'] = $line[0]; |
|
| 894 | + $data['ident'] = $line[16]; //$line[13] |
|
| 895 | + $data['altitude'] = $line[4]; // altitude |
|
| 896 | + $data['speed'] = $line[5]; // speed |
|
| 897 | + $data['heading'] = $line[3]; // heading |
|
| 898 | + $data['latitude'] = $line[1]; // lat |
|
| 899 | + $data['longitude'] = $line[2]; // long |
|
| 900 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 901 | + $data['squawk'] = $line[6]; // squawk |
|
| 902 | + $data['aircraft_icao'] = $line[8]; |
|
| 903 | + $data['registration'] = $line[9]; |
|
| 904 | + $data['departure_airport_iata'] = $line[11]; |
|
| 905 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 906 | + $data['emergency'] = ''; // emergency |
|
| 907 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 908 | + $data['format_source'] = 'fr24json'; |
|
| 909 | + $data['id_source'] = $id_source; |
|
| 910 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 911 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 912 | + $SI->add($data); |
|
| 913 | + unset($data); |
|
| 914 | 914 | } |
| 915 | - } |
|
| 916 | - //$last_exec['fr24json'] = time(); |
|
| 917 | - $last_exec[$id]['last'] = time(); |
|
| 918 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 919 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 920 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 921 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 922 | - //echo $buffer; |
|
| 923 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 924 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 925 | - $all_data = json_decode($buffer,true); |
|
| 926 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 915 | + } |
|
| 916 | + //$last_exec['fr24json'] = time(); |
|
| 917 | + $last_exec[$id]['last'] = time(); |
|
| 918 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 919 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 920 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 921 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 922 | + //echo $buffer; |
|
| 923 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 924 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 925 | + $all_data = json_decode($buffer,true); |
|
| 926 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 927 | 927 | die(json_last_error_msg()); |
| 928 | - } |
|
| 929 | - if (isset($all_data['mrkrs'])) { |
|
| 928 | + } |
|
| 929 | + if (isset($all_data['mrkrs'])) { |
|
| 930 | 930 | $reset = 0; |
| 931 | 931 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 932 | - if (isset($line['inf'])) { |
|
| 932 | + if (isset($line['inf'])) { |
|
| 933 | 933 | $data = array(); |
| 934 | 934 | $data['hex'] = $line['inf']['ia']; |
| 935 | 935 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 936 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 937 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 938 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 939 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 940 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 941 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 942 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 943 | - //$data['aircraft_icao'] = $line[8]; |
|
| 944 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 936 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 937 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 938 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 939 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 940 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 941 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 942 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 943 | + //$data['aircraft_icao'] = $line[8]; |
|
| 944 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 945 | 945 | //$data['departure_airport_iata'] = $line[11]; |
| 946 | 946 | //$data['arrival_airport_iata'] = $line[12]; |
| 947 | - //$data['emergency'] = ''; // emergency |
|
| 947 | + //$data['emergency'] = ''; // emergency |
|
| 948 | 948 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 949 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 950 | - $data['id_source'] = $id_source; |
|
| 949 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 950 | + $data['id_source'] = $id_source; |
|
| 951 | 951 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 952 | 952 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 953 | 953 | $SI->add($data); |
| 954 | 954 | unset($data); |
| 955 | - } |
|
| 955 | + } |
|
| 956 | + } |
|
| 956 | 957 | } |
| 957 | - } |
|
| 958 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 959 | - $last_exec[$id]['last'] = time(); |
|
| 960 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 961 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 962 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 963 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 964 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 958 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 959 | + $last_exec[$id]['last'] = time(); |
|
| 960 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 961 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 962 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 963 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 964 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 965 | 965 | |
| 966 | - if (isset($all_data['pireps'])) { |
|
| 966 | + if (isset($all_data['pireps'])) { |
|
| 967 | 967 | $reset = 0; |
| 968 | - foreach ($all_data['pireps'] as $line) { |
|
| 969 | - $data = array(); |
|
| 970 | - $data['id'] = $line['id']; |
|
| 971 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 972 | - $data['ident'] = $line['callsign']; // ident |
|
| 973 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 974 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 975 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 976 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 977 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 978 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 979 | - $data['latitude'] = $line['lat']; // lat |
|
| 980 | - $data['longitude'] = $line['lon']; // long |
|
| 981 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 982 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 983 | - //$data['emergency'] = ''; // emergency |
|
| 984 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 985 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 986 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 987 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 988 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 989 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 990 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 991 | - else $data['info'] = ''; |
|
| 992 | - $data['format_source'] = 'pireps'; |
|
| 993 | - $data['id_source'] = $id_source; |
|
| 994 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 995 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 996 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 997 | - if ($line['icon'] == 'plane') { |
|
| 968 | + foreach ($all_data['pireps'] as $line) { |
|
| 969 | + $data = array(); |
|
| 970 | + $data['id'] = $line['id']; |
|
| 971 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 972 | + $data['ident'] = $line['callsign']; // ident |
|
| 973 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 974 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 975 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 976 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 977 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 978 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 979 | + $data['latitude'] = $line['lat']; // lat |
|
| 980 | + $data['longitude'] = $line['lon']; // long |
|
| 981 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 982 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 983 | + //$data['emergency'] = ''; // emergency |
|
| 984 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 985 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 986 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 987 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 988 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 989 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 990 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 991 | + else $data['info'] = ''; |
|
| 992 | + $data['format_source'] = 'pireps'; |
|
| 993 | + $data['id_source'] = $id_source; |
|
| 994 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 995 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 996 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 997 | + if ($line['icon'] == 'plane') { |
|
| 998 | 998 | $SI->add($data); |
| 999 | - // print_r($data); |
|
| 1000 | - } elseif ($line['icon'] == 'ct') { |
|
| 999 | + // print_r($data); |
|
| 1000 | + } elseif ($line['icon'] == 'ct') { |
|
| 1001 | 1001 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 1002 | 1002 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1003 | 1003 | $typec = substr($data['ident'],-3); |
@@ -1012,203 +1012,203 @@ discard block |
||
| 1012 | 1012 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 1013 | 1013 | else $data['type'] = 'Observer'; |
| 1014 | 1014 | 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']); |
| 1015 | - } |
|
| 1016 | - unset($data); |
|
| 1015 | + } |
|
| 1016 | + unset($data); |
|
| 1017 | + } |
|
| 1017 | 1018 | } |
| 1018 | - } |
|
| 1019 | - //$last_exec['pirepsjson'] = time(); |
|
| 1020 | - $last_exec[$id]['last'] = time(); |
|
| 1021 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 1022 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 1023 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1024 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1025 | - $buffer = $Common->getData($value['host']); |
|
| 1026 | - $all_data = json_decode($buffer,true); |
|
| 1027 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1019 | + //$last_exec['pirepsjson'] = time(); |
|
| 1020 | + $last_exec[$id]['last'] = time(); |
|
| 1021 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 1022 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 1023 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1024 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1025 | + $buffer = $Common->getData($value['host']); |
|
| 1026 | + $all_data = json_decode($buffer,true); |
|
| 1027 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1028 | 1028 | $reset = 0; |
| 1029 | 1029 | foreach ($all_data as $line) { |
| 1030 | - $data = array(); |
|
| 1031 | - //$data['id'] = $line['id']; // id not usable |
|
| 1032 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1033 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1034 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1035 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1036 | - $data['ident'] = $line['flightnum']; // ident |
|
| 1037 | - $data['altitude'] = $line['alt']; // altitude |
|
| 1038 | - $data['speed'] = $line['gs']; // speed |
|
| 1039 | - $data['heading'] = $line['heading']; // heading |
|
| 1040 | - $data['latitude'] = $line['lat']; // lat |
|
| 1041 | - $data['longitude'] = $line['lng']; // long |
|
| 1042 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1043 | - $data['squawk'] = ''; // squawk |
|
| 1044 | - $data['emergency'] = ''; // emergency |
|
| 1045 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1046 | - //$data['last_update'] = $line['lastupdate']; |
|
| 1047 | - if (isset($value['timezone'])) { |
|
| 1048 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1049 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1050 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1051 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1052 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 1053 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 1054 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1055 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1056 | - $data['registration'] = $line['aircraft']; |
|
| 1057 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1058 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1059 | - if (isset($line['aircraftname'])) { |
|
| 1030 | + $data = array(); |
|
| 1031 | + //$data['id'] = $line['id']; // id not usable |
|
| 1032 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1033 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1034 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1035 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1036 | + $data['ident'] = $line['flightnum']; // ident |
|
| 1037 | + $data['altitude'] = $line['alt']; // altitude |
|
| 1038 | + $data['speed'] = $line['gs']; // speed |
|
| 1039 | + $data['heading'] = $line['heading']; // heading |
|
| 1040 | + $data['latitude'] = $line['lat']; // lat |
|
| 1041 | + $data['longitude'] = $line['lng']; // long |
|
| 1042 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1043 | + $data['squawk'] = ''; // squawk |
|
| 1044 | + $data['emergency'] = ''; // emergency |
|
| 1045 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1046 | + //$data['last_update'] = $line['lastupdate']; |
|
| 1047 | + if (isset($value['timezone'])) { |
|
| 1048 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1049 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1050 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1051 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1052 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1053 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1054 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1055 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1056 | + $data['registration'] = $line['aircraft']; |
|
| 1057 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1058 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1059 | + if (isset($line['aircraftname'])) { |
|
| 1060 | 1060 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1061 | 1061 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1062 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1063 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1064 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1065 | - else { |
|
| 1066 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1067 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1068 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1069 | - } |
|
| 1070 | - } |
|
| 1071 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1072 | - $data['id_source'] = $id_source; |
|
| 1073 | - $data['format_source'] = 'phpvmacars'; |
|
| 1074 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1075 | - $SI->add($data); |
|
| 1076 | - unset($data); |
|
| 1062 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1063 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1064 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1065 | + else { |
|
| 1066 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1067 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1068 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1069 | + } |
|
| 1070 | + } |
|
| 1071 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1072 | + $data['id_source'] = $id_source; |
|
| 1073 | + $data['format_source'] = 'phpvmacars'; |
|
| 1074 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1075 | + $SI->add($data); |
|
| 1076 | + unset($data); |
|
| 1077 | 1077 | } |
| 1078 | 1078 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1079 | 1079 | unset($buffer); |
| 1080 | 1080 | unset($all_data); |
| 1081 | - } |
|
| 1082 | - //$last_exec['phpvmacars'] = time(); |
|
| 1083 | - $last_exec[$id]['last'] = time(); |
|
| 1084 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 1085 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1086 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1087 | - $buffer = $Common->getData($value['host']); |
|
| 1088 | - $all_data = json_decode($buffer,true); |
|
| 1089 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1081 | + } |
|
| 1082 | + //$last_exec['phpvmacars'] = time(); |
|
| 1083 | + $last_exec[$id]['last'] = time(); |
|
| 1084 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 1085 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1086 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1087 | + $buffer = $Common->getData($value['host']); |
|
| 1088 | + $all_data = json_decode($buffer,true); |
|
| 1089 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1090 | 1090 | $reset = 0; |
| 1091 | 1091 | foreach ($all_data as $line) { |
| 1092 | - $data = array(); |
|
| 1093 | - //$data['id'] = $line['id']; // id not usable |
|
| 1094 | - $data['id'] = trim($line['flight_id']); |
|
| 1095 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1096 | - $data['pilot_name'] = $line['pilot_name']; |
|
| 1097 | - $data['pilot_id'] = $line['pilot_id']; |
|
| 1098 | - $data['ident'] = trim($line['callsign']); // ident |
|
| 1099 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 1100 | - $data['speed'] = $line['gs']; // speed |
|
| 1101 | - $data['heading'] = $line['heading']; // heading |
|
| 1102 | - $data['latitude'] = $line['latitude']; // lat |
|
| 1103 | - $data['longitude'] = $line['longitude']; // long |
|
| 1104 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1105 | - $data['squawk'] = ''; // squawk |
|
| 1106 | - $data['emergency'] = ''; // emergency |
|
| 1107 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1108 | - $data['last_update'] = $line['last_update']; |
|
| 1109 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1110 | - $data['departure_airport_icao'] = $line['departure']; |
|
| 1111 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1112 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1113 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1114 | - //$data['registration'] = $line['aircraft']; |
|
| 1115 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1116 | - $data['aircraft_icao'] = $line['plane_type']; |
|
| 1117 | - $data['id_source'] = $id_source; |
|
| 1118 | - $data['format_source'] = 'vam'; |
|
| 1119 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1120 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1121 | - $SI->add($data); |
|
| 1122 | - unset($data); |
|
| 1092 | + $data = array(); |
|
| 1093 | + //$data['id'] = $line['id']; // id not usable |
|
| 1094 | + $data['id'] = trim($line['flight_id']); |
|
| 1095 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1096 | + $data['pilot_name'] = $line['pilot_name']; |
|
| 1097 | + $data['pilot_id'] = $line['pilot_id']; |
|
| 1098 | + $data['ident'] = trim($line['callsign']); // ident |
|
| 1099 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 1100 | + $data['speed'] = $line['gs']; // speed |
|
| 1101 | + $data['heading'] = $line['heading']; // heading |
|
| 1102 | + $data['latitude'] = $line['latitude']; // lat |
|
| 1103 | + $data['longitude'] = $line['longitude']; // long |
|
| 1104 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1105 | + $data['squawk'] = ''; // squawk |
|
| 1106 | + $data['emergency'] = ''; // emergency |
|
| 1107 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1108 | + $data['last_update'] = $line['last_update']; |
|
| 1109 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1110 | + $data['departure_airport_icao'] = $line['departure']; |
|
| 1111 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1112 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1113 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1114 | + //$data['registration'] = $line['aircraft']; |
|
| 1115 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1116 | + $data['aircraft_icao'] = $line['plane_type']; |
|
| 1117 | + $data['id_source'] = $id_source; |
|
| 1118 | + $data['format_source'] = 'vam'; |
|
| 1119 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1120 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1121 | + $SI->add($data); |
|
| 1122 | + unset($data); |
|
| 1123 | 1123 | } |
| 1124 | 1124 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1125 | 1125 | unset($buffer); |
| 1126 | 1126 | unset($all_data); |
| 1127 | - } |
|
| 1128 | - //$last_exec['phpvmacars'] = time(); |
|
| 1129 | - $last_exec[$id]['last'] = time(); |
|
| 1127 | + } |
|
| 1128 | + //$last_exec['phpvmacars'] = time(); |
|
| 1129 | + $last_exec[$id]['last'] = time(); |
|
| 1130 | 1130 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 1131 | 1131 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
| 1132 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1133 | - //$last_exec[$id]['last'] = time(); |
|
| 1132 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1133 | + //$last_exec[$id]['last'] = time(); |
|
| 1134 | 1134 | |
| 1135 | - //$read = array( $sockets[$id] ); |
|
| 1136 | - $read = $sockets; |
|
| 1137 | - $write = NULL; |
|
| 1138 | - $e = NULL; |
|
| 1139 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 1140 | - if ($e != NULL) var_dump($e); |
|
| 1141 | - if ($n > 0) { |
|
| 1135 | + //$read = array( $sockets[$id] ); |
|
| 1136 | + $read = $sockets; |
|
| 1137 | + $write = NULL; |
|
| 1138 | + $e = NULL; |
|
| 1139 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 1140 | + if ($e != NULL) var_dump($e); |
|
| 1141 | + if ($n > 0) { |
|
| 1142 | 1142 | $reset = 0; |
| 1143 | 1143 | foreach ($read as $nb => $r) { |
| 1144 | - //$value = $formats[$nb]; |
|
| 1145 | - $format = $globalSources[$nb]['format']; |
|
| 1146 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 1144 | + //$value = $formats[$nb]; |
|
| 1145 | + $format = $globalSources[$nb]['format']; |
|
| 1146 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 1147 | 1147 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
| 1148 | - } elseif ($format == 'vrstcp') { |
|
| 1148 | + } elseif ($format == 'vrstcp') { |
|
| 1149 | 1149 | $buffer = @socket_read($r, 6000); |
| 1150 | - } else { |
|
| 1150 | + } else { |
|
| 1151 | 1151 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
| 1152 | - } |
|
| 1153 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1154 | - //echo $buffer."\n"; |
|
| 1155 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1156 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1157 | - $error = false; |
|
| 1158 | - //$SI::del(); |
|
| 1159 | - if ($format == 'vrstcp') { |
|
| 1152 | + } |
|
| 1153 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1154 | + //echo $buffer."\n"; |
|
| 1155 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1156 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1157 | + $error = false; |
|
| 1158 | + //$SI::del(); |
|
| 1159 | + if ($format == 'vrstcp') { |
|
| 1160 | 1160 | $buffer = explode('},{',$buffer); |
| 1161 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1162 | - // SBS format is CSV format |
|
| 1163 | - if ($buffer !== FALSE && $buffer != '') { |
|
| 1161 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1162 | + // SBS format is CSV format |
|
| 1163 | + if ($buffer !== FALSE && $buffer != '') { |
|
| 1164 | 1164 | $tt[$format] = 0; |
| 1165 | 1165 | if ($format == 'acarssbs3') { |
| 1166 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1167 | - $ACARS->add(trim($buffer)); |
|
| 1168 | - $ACARS->deleteLiveAcarsData(); |
|
| 1166 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1167 | + $ACARS->add(trim($buffer)); |
|
| 1168 | + $ACARS->deleteLiveAcarsData(); |
|
| 1169 | 1169 | } elseif ($format == 'raw') { |
| 1170 | - // AVR format |
|
| 1171 | - $data = $SBS->parse($buffer); |
|
| 1172 | - if (is_array($data)) { |
|
| 1170 | + // AVR format |
|
| 1171 | + $data = $SBS->parse($buffer); |
|
| 1172 | + if (is_array($data)) { |
|
| 1173 | 1173 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1174 | 1174 | $data['format_source'] = 'raw'; |
| 1175 | 1175 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1176 | 1176 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
| 1177 | 1177 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1178 | 1178 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1179 | - } |
|
| 1179 | + } |
|
| 1180 | 1180 | } elseif ($format == 'ais') { |
| 1181 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1182 | - $data = array(); |
|
| 1183 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1184 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1185 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1186 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1187 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1188 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1189 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1190 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1191 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1192 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1193 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1194 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1195 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1196 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1197 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1198 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1181 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1182 | + $data = array(); |
|
| 1183 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1184 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1185 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1186 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1187 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1188 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1189 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1190 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1191 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1192 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1193 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1194 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1195 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1196 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1197 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1198 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1199 | 1199 | |
| 1200 | - if (isset($ais_data['timestamp'])) { |
|
| 1200 | + if (isset($ais_data['timestamp'])) { |
|
| 1201 | 1201 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 1202 | - } else { |
|
| 1202 | + } else { |
|
| 1203 | 1203 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1204 | - } |
|
| 1205 | - $data['format_source'] = 'aisnmea'; |
|
| 1206 | - $data['id_source'] = $id_source; |
|
| 1207 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1208 | - unset($data); |
|
| 1209 | - } elseif ($format == 'flightgearsp') { |
|
| 1210 | - //echo $buffer."\n"; |
|
| 1211 | - if (strlen($buffer) > 5) { |
|
| 1204 | + } |
|
| 1205 | + $data['format_source'] = 'aisnmea'; |
|
| 1206 | + $data['id_source'] = $id_source; |
|
| 1207 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1208 | + unset($data); |
|
| 1209 | + } elseif ($format == 'flightgearsp') { |
|
| 1210 | + //echo $buffer."\n"; |
|
| 1211 | + if (strlen($buffer) > 5) { |
|
| 1212 | 1212 | $line = explode(',',$buffer); |
| 1213 | 1213 | $data = array(); |
| 1214 | 1214 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1225,38 +1225,38 @@ discard block |
||
| 1225 | 1225 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1226 | 1226 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1227 | 1227 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1228 | - } |
|
| 1229 | - } elseif ($format == 'acars') { |
|
| 1230 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1231 | - $ACARS->add(trim($buffer)); |
|
| 1232 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1233 | - $ACARS->deleteLiveAcarsData(); |
|
| 1228 | + } |
|
| 1229 | + } elseif ($format == 'acars') { |
|
| 1230 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1231 | + $ACARS->add(trim($buffer)); |
|
| 1232 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1233 | + $ACARS->deleteLiveAcarsData(); |
|
| 1234 | 1234 | } elseif ($format == 'flightgearmp') { |
| 1235 | - if (substr($buffer,0,1) != '#') { |
|
| 1235 | + if (substr($buffer,0,1) != '#') { |
|
| 1236 | 1236 | $data = array(); |
| 1237 | 1237 | //echo $buffer."\n"; |
| 1238 | 1238 | $line = explode(' ',$buffer); |
| 1239 | 1239 | if (count($line) == 11) { |
| 1240 | - $userserver = explode('@',$line[0]); |
|
| 1241 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1242 | - $data['ident'] = $userserver[0]; |
|
| 1243 | - $data['registration'] = $userserver[0]; |
|
| 1244 | - $data['latitude'] = $line[4]; |
|
| 1245 | - $data['longitude'] = $line[5]; |
|
| 1246 | - $data['altitude'] = $line[6]; |
|
| 1247 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1248 | - $aircraft_type = $line[10]; |
|
| 1249 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1250 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1251 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1252 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1240 | + $userserver = explode('@',$line[0]); |
|
| 1241 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1242 | + $data['ident'] = $userserver[0]; |
|
| 1243 | + $data['registration'] = $userserver[0]; |
|
| 1244 | + $data['latitude'] = $line[4]; |
|
| 1245 | + $data['longitude'] = $line[5]; |
|
| 1246 | + $data['altitude'] = $line[6]; |
|
| 1247 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1248 | + $aircraft_type = $line[10]; |
|
| 1249 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1250 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1251 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1252 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1253 | + } |
|
| 1253 | 1254 | } |
| 1254 | - } |
|
| 1255 | 1255 | } elseif ($format == 'beast') { |
| 1256 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1257 | - die; |
|
| 1256 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1257 | + die; |
|
| 1258 | 1258 | } elseif ($format == 'vrstcp') { |
| 1259 | - foreach($buffer as $all_data) { |
|
| 1259 | + foreach($buffer as $all_data) { |
|
| 1260 | 1260 | $line = json_decode('{'.$all_data.'}',true); |
| 1261 | 1261 | $data = array(); |
| 1262 | 1262 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1276,145 +1276,145 @@ discard block |
||
| 1276 | 1276 | */ |
| 1277 | 1277 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1278 | 1278 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
| 1279 | - $data['format_source'] = 'vrstcp'; |
|
| 1279 | + $data['format_source'] = 'vrstcp'; |
|
| 1280 | 1280 | $data['id_source'] = $id_source; |
| 1281 | 1281 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1282 | 1282 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1283 | 1283 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1284 | 1284 | unset($data); |
| 1285 | - } |
|
| 1285 | + } |
|
| 1286 | 1286 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
| 1287 | - $line = explode("\t", $buffer); |
|
| 1288 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1287 | + $line = explode("\t", $buffer); |
|
| 1288 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1289 | 1289 | $key = $line[$k]; |
| 1290 | - $lined[$key] = $line[$k+1]; |
|
| 1291 | - } |
|
| 1292 | - if (count($lined) > 3) { |
|
| 1293 | - $data['hex'] = $lined['hexid']; |
|
| 1294 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1295 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1296 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1297 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1298 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1299 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1300 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1301 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1302 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1303 | - $data['id_source'] = $id_source; |
|
| 1304 | - $data['format_source'] = 'tsv'; |
|
| 1305 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1306 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1290 | + $lined[$key] = $line[$k+1]; |
|
| 1291 | + } |
|
| 1292 | + if (count($lined) > 3) { |
|
| 1293 | + $data['hex'] = $lined['hexid']; |
|
| 1294 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1295 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1296 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1297 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1298 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1299 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1300 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1301 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1302 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1303 | + $data['id_source'] = $id_source; |
|
| 1304 | + $data['format_source'] = 'tsv'; |
|
| 1305 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1306 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1307 | 1307 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1308 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1309 | - unset($lined); |
|
| 1310 | - unset($data); |
|
| 1311 | - } else $error = true; |
|
| 1308 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1309 | + unset($lined); |
|
| 1310 | + unset($data); |
|
| 1311 | + } else $error = true; |
|
| 1312 | 1312 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1313 | - if ($aprs_connect == 0) { |
|
| 1313 | + if ($aprs_connect == 0) { |
|
| 1314 | 1314 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 1315 | 1315 | $aprs_connect = 1; |
| 1316 | - } |
|
| 1316 | + } |
|
| 1317 | 1317 | |
| 1318 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1318 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1319 | 1319 | $aprs_last_tx = time(); |
| 1320 | 1320 | $data_aprs = "# Keep alive"; |
| 1321 | 1321 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1322 | - } |
|
| 1322 | + } |
|
| 1323 | 1323 | |
| 1324 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1325 | - //echo 'APRS data : '.$buffer."\n"; |
|
| 1326 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1327 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1328 | - //echo $buffer."\n"; |
|
| 1329 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1324 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1325 | + //echo 'APRS data : '.$buffer."\n"; |
|
| 1326 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1327 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1328 | + //echo $buffer."\n"; |
|
| 1329 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1330 | 1330 | $line = $APRS->parse($buffer); |
| 1331 | 1331 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1332 | 1332 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
| 1333 | - $aprs_last_tx = time(); |
|
| 1334 | - $data = array(); |
|
| 1335 | - //print_r($line); |
|
| 1336 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1337 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1338 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1339 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1340 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
| 1341 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
| 1342 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
| 1343 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
| 1344 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1345 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1346 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1347 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1348 | - $data['latitude'] = $line['latitude']; |
|
| 1349 | - $data['longitude'] = $line['longitude']; |
|
| 1350 | - //$data['verticalrate'] = $line[16]; |
|
| 1351 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1352 | - //else $data['speed'] = 0; |
|
| 1353 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1354 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1355 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1356 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1357 | - //else $data['heading'] = 0; |
|
| 1358 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1359 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1360 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1361 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1362 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1363 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1364 | - $data['id_source'] = $id_source; |
|
| 1365 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1366 | - else $data['format_source'] = 'aprs'; |
|
| 1367 | - $data['source_name'] = $line['source']; |
|
| 1368 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1369 | - else $data['source_type'] = 'flarm'; |
|
| 1370 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1371 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 1372 | - $aprsdate = strtotime($data['datetime']); |
|
| 1373 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1374 | - // Accept data if time <= system time + 20s |
|
| 1375 | - //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'])))) { |
|
| 1376 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1333 | + $aprs_last_tx = time(); |
|
| 1334 | + $data = array(); |
|
| 1335 | + //print_r($line); |
|
| 1336 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1337 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1338 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1339 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1340 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
| 1341 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
| 1342 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
| 1343 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
| 1344 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1345 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1346 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1347 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1348 | + $data['latitude'] = $line['latitude']; |
|
| 1349 | + $data['longitude'] = $line['longitude']; |
|
| 1350 | + //$data['verticalrate'] = $line[16]; |
|
| 1351 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1352 | + //else $data['speed'] = 0; |
|
| 1353 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1354 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1355 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1356 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1357 | + //else $data['heading'] = 0; |
|
| 1358 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1359 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1360 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1361 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1362 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1363 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1364 | + $data['id_source'] = $id_source; |
|
| 1365 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1366 | + else $data['format_source'] = 'aprs'; |
|
| 1367 | + $data['source_name'] = $line['source']; |
|
| 1368 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1369 | + else $data['source_type'] = 'flarm'; |
|
| 1370 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1371 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 1372 | + $aprsdate = strtotime($data['datetime']); |
|
| 1373 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1374 | + // Accept data if time <= system time + 20s |
|
| 1375 | + //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'])))) { |
|
| 1376 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1377 | 1377 | $send = $SI->add($data); |
| 1378 | - } elseif ($data['source_type'] == 'ais') { |
|
| 1378 | + } elseif ($data['source_type'] == 'ais') { |
|
| 1379 | 1379 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
| 1380 | - } elseif (isset($line['stealth'])) { |
|
| 1380 | + } elseif (isset($line['stealth'])) { |
|
| 1381 | 1381 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1382 | 1382 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
| 1383 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1384 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
| 1385 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
| 1386 | - $send = $SI->add($data); |
|
| 1387 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1388 | - $line['symbol'] == 'Yacht (Sail)' || |
|
| 1389 | - $line['symbol'] == 'Ship (Power Boat)')) { |
|
| 1390 | - $send = $MI->add($data); |
|
| 1391 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1392 | - $line['symbol'] == 'Car' || |
|
| 1393 | - $line['symbol'] == 'Ambulance' || |
|
| 1394 | - $line['symbol'] == 'Van' || |
|
| 1395 | - $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
| 1396 | - $line['symbol'] == 'Motorcycle' || |
|
| 1397 | - $line['symbol'] == 'Tractor' || |
|
| 1398 | - $line['symbol'] == 'Police' || |
|
| 1399 | - $line['symbol'] == 'Bike' || |
|
| 1400 | - $line['symbol'] == 'Jogger' || |
|
| 1401 | - $line['symbol'] == 'Horse' || |
|
| 1402 | - $line['symbol'] == 'Bus' || |
|
| 1403 | - $line['symbol'] == 'Jeep' || |
|
| 1404 | - $line['symbol'] == 'Recreational Vehicle' || |
|
| 1405 | - $line['symbol'] == 'Yacht (Sail)' || |
|
| 1406 | - $line['symbol'] == 'Ship (Power Boat)' || |
|
| 1407 | - $line['symbol'] == 'Firetruck' || |
|
| 1408 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
| 1409 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
| 1410 | - $line['symbol'] == 'SUV' || |
|
| 1411 | - $line['symbol'] == 'Snowmobile' || |
|
| 1412 | - $line['symbol'] == 'Mobile Satellite Station')) { |
|
| 1413 | - //} 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') { |
|
| 1383 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1384 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
| 1385 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
| 1386 | + $send = $SI->add($data); |
|
| 1387 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1388 | + $line['symbol'] == 'Yacht (Sail)' || |
|
| 1389 | + $line['symbol'] == 'Ship (Power Boat)')) { |
|
| 1390 | + $send = $MI->add($data); |
|
| 1391 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1392 | + $line['symbol'] == 'Car' || |
|
| 1393 | + $line['symbol'] == 'Ambulance' || |
|
| 1394 | + $line['symbol'] == 'Van' || |
|
| 1395 | + $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
| 1396 | + $line['symbol'] == 'Motorcycle' || |
|
| 1397 | + $line['symbol'] == 'Tractor' || |
|
| 1398 | + $line['symbol'] == 'Police' || |
|
| 1399 | + $line['symbol'] == 'Bike' || |
|
| 1400 | + $line['symbol'] == 'Jogger' || |
|
| 1401 | + $line['symbol'] == 'Horse' || |
|
| 1402 | + $line['symbol'] == 'Bus' || |
|
| 1403 | + $line['symbol'] == 'Jeep' || |
|
| 1404 | + $line['symbol'] == 'Recreational Vehicle' || |
|
| 1405 | + $line['symbol'] == 'Yacht (Sail)' || |
|
| 1406 | + $line['symbol'] == 'Ship (Power Boat)' || |
|
| 1407 | + $line['symbol'] == 'Firetruck' || |
|
| 1408 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
| 1409 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
| 1410 | + $line['symbol'] == 'SUV' || |
|
| 1411 | + $line['symbol'] == 'Snowmobile' || |
|
| 1412 | + $line['symbol'] == 'Mobile Satellite Station')) { |
|
| 1413 | + //} 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') { |
|
| 1414 | 1414 | // } 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') { |
| 1415 | 1415 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1416 | 1416 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
| 1417 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 1417 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 1418 | 1418 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
| 1419 | 1419 | $Source->deleteOldLocationByType('gs'); |
| 1420 | 1420 | if (count($Source->getLocationInfoByName($data['ident'])) > 0) { |
@@ -1422,11 +1422,11 @@ discard block |
||
| 1422 | 1422 | } else { |
| 1423 | 1423 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
| 1424 | 1424 | } |
| 1425 | - } else { |
|
| 1426 | - echo '/!\ Not added: '.$buffer."\n"; |
|
| 1427 | - print_r($line); |
|
| 1428 | - } |
|
| 1429 | - unset($data); |
|
| 1425 | + } else { |
|
| 1426 | + echo '/!\ Not added: '.$buffer."\n"; |
|
| 1427 | + print_r($line); |
|
| 1428 | + } |
|
| 1429 | + unset($data); |
|
| 1430 | 1430 | } |
| 1431 | 1431 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
| 1432 | 1432 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1442,12 +1442,12 @@ discard block |
||
| 1442 | 1442 | */ |
| 1443 | 1443 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 1444 | 1444 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
| 1445 | - } |
|
| 1445 | + } |
|
| 1446 | 1446 | } else { |
| 1447 | - $line = explode(',', $buffer); |
|
| 1448 | - if (count($line) > 20) { |
|
| 1449 | - $data['hex'] = $line[4]; |
|
| 1450 | - /* |
|
| 1447 | + $line = explode(',', $buffer); |
|
| 1448 | + if (count($line) > 20) { |
|
| 1449 | + $data['hex'] = $line[4]; |
|
| 1450 | + /* |
|
| 1451 | 1451 | $data['datetime'] = $line[6].' '.$line[7]; |
| 1452 | 1452 | date_default_timezone_set($globalTimezone); |
| 1453 | 1453 | $datetime = new DateTime($data['datetime']); |
@@ -1455,30 +1455,30 @@ discard block |
||
| 1455 | 1455 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1456 | 1456 | date_default_timezone_set('UTC'); |
| 1457 | 1457 | */ |
| 1458 | - // Force datetime to current UTC datetime |
|
| 1459 | - date_default_timezone_set('UTC'); |
|
| 1460 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1461 | - $data['ident'] = trim($line[10]); |
|
| 1462 | - $data['latitude'] = $line[14]; |
|
| 1463 | - $data['longitude'] = $line[15]; |
|
| 1464 | - $data['verticalrate'] = $line[16]; |
|
| 1465 | - $data['emergency'] = $line[20]; |
|
| 1466 | - $data['speed'] = $line[12]; |
|
| 1467 | - $data['squawk'] = $line[17]; |
|
| 1468 | - $data['altitude'] = $line[11]; |
|
| 1469 | - $data['heading'] = $line[13]; |
|
| 1470 | - $data['ground'] = $line[21]; |
|
| 1471 | - $data['emergency'] = $line[19]; |
|
| 1472 | - $data['format_source'] = 'sbs'; |
|
| 1458 | + // Force datetime to current UTC datetime |
|
| 1459 | + date_default_timezone_set('UTC'); |
|
| 1460 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1461 | + $data['ident'] = trim($line[10]); |
|
| 1462 | + $data['latitude'] = $line[14]; |
|
| 1463 | + $data['longitude'] = $line[15]; |
|
| 1464 | + $data['verticalrate'] = $line[16]; |
|
| 1465 | + $data['emergency'] = $line[20]; |
|
| 1466 | + $data['speed'] = $line[12]; |
|
| 1467 | + $data['squawk'] = $line[17]; |
|
| 1468 | + $data['altitude'] = $line[11]; |
|
| 1469 | + $data['heading'] = $line[13]; |
|
| 1470 | + $data['ground'] = $line[21]; |
|
| 1471 | + $data['emergency'] = $line[19]; |
|
| 1472 | + $data['format_source'] = 'sbs'; |
|
| 1473 | 1473 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1474 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1474 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1475 | 1475 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1476 | - $data['id_source'] = $id_source; |
|
| 1477 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1478 | - else $error = true; |
|
| 1479 | - unset($data); |
|
| 1480 | - } else $error = true; |
|
| 1481 | - if ($error) { |
|
| 1476 | + $data['id_source'] = $id_source; |
|
| 1477 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1478 | + else $error = true; |
|
| 1479 | + unset($data); |
|
| 1480 | + } else $error = true; |
|
| 1481 | + if ($error) { |
|
| 1482 | 1482 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1483 | 1483 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 1484 | 1484 | } else { |
@@ -1494,13 +1494,13 @@ discard block |
||
| 1494 | 1494 | connect_all($sourceer); |
| 1495 | 1495 | $sourceer = array(); |
| 1496 | 1496 | } |
| 1497 | - } |
|
| 1497 | + } |
|
| 1498 | 1498 | } |
| 1499 | 1499 | // Sleep for xxx microseconds |
| 1500 | 1500 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 1501 | - } else { |
|
| 1501 | + } else { |
|
| 1502 | 1502 | if ($format == 'flightgearmp') { |
| 1503 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1503 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1504 | 1504 | //@socket_close($r); |
| 1505 | 1505 | sleep($globalMinFetch); |
| 1506 | 1506 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1509,9 +1509,9 @@ discard block |
||
| 1509 | 1509 | break; |
| 1510 | 1510 | |
| 1511 | 1511 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1512 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1513 | - else $tt[$format] = 0; |
|
| 1514 | - if ($tt[$format] > 30) { |
|
| 1512 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 1513 | + else $tt[$format] = 0; |
|
| 1514 | + if ($tt[$format] > 30) { |
|
| 1515 | 1515 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
| 1516 | 1516 | //@socket_close($r); |
| 1517 | 1517 | sleep(2); |
@@ -1522,23 +1522,23 @@ discard block |
||
| 1522 | 1522 | //connect_all($globalSources); |
| 1523 | 1523 | $tt[$format]=0; |
| 1524 | 1524 | break; |
| 1525 | - } |
|
| 1525 | + } |
|
| 1526 | + } |
|
| 1526 | 1527 | } |
| 1527 | - } |
|
| 1528 | 1528 | } |
| 1529 | - } else { |
|
| 1529 | + } else { |
|
| 1530 | 1530 | $error = socket_strerror(socket_last_error()); |
| 1531 | 1531 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1532 | 1532 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 1533 | 1533 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1534 | 1534 | // Restart the script if possible |
| 1535 | 1535 | if (is_array($sockets)) { |
| 1536 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1536 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1537 | 1537 | |
| 1538 | - foreach ($sockets as $sock) { |
|
| 1538 | + foreach ($sockets as $sock) { |
|
| 1539 | 1539 | @socket_shutdown($sock,2); |
| 1540 | 1540 | @socket_close($sock); |
| 1541 | - } |
|
| 1541 | + } |
|
| 1542 | 1542 | |
| 1543 | 1543 | } |
| 1544 | 1544 | if ($globalDebug) echo "Waiting..."; |
@@ -1553,15 +1553,15 @@ discard block |
||
| 1553 | 1553 | if ($globalDebug) echo "Restart all connections..."; |
| 1554 | 1554 | connect_all($globalSources); |
| 1555 | 1555 | } |
| 1556 | - } |
|
| 1556 | + } |
|
| 1557 | 1557 | } |
| 1558 | 1558 | if ($globalDaemon === false) { |
| 1559 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1560 | - if (isset($SI)) $SI->checkAll(); |
|
| 1561 | - if (isset($TI)) $TI->checkAll(); |
|
| 1562 | - if (isset($MI)) $MI->checkAll(); |
|
| 1559 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1560 | + if (isset($SI)) $SI->checkAll(); |
|
| 1561 | + if (isset($TI)) $TI->checkAll(); |
|
| 1562 | + if (isset($MI)) $MI->checkAll(); |
|
| 1563 | + } |
|
| 1563 | 1564 | } |
| 1564 | - } |
|
| 1565 | 1565 | } |
| 1566 | 1566 | |
| 1567 | 1567 | ?> |
@@ -14,13 +14,17 @@ discard block |
||
| 14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 17 | +if (isset($globalTracker) && $globalTracker) { |
|
| 18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 19 | +} |
|
| 18 | 20 | if (isset($globalMarine) && $globalMarine) { |
| 19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 21 | 23 | } |
| 22 | 24 | |
| 23 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 25 | +if (!isset($globalDebug)) { |
|
| 26 | + $globalDebug = FALSE; |
|
| 27 | +} |
|
| 24 | 28 | |
| 25 | 29 | // Check if schema is at latest version |
| 26 | 30 | $Connection = new Connection(); |
@@ -55,35 +59,62 @@ discard block |
||
| 55 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 56 | 60 | if (isset($options['s'])) { |
| 57 | 61 | $globalSources = array(); |
| 58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 59 | - else $globalSources[] = array('host' => $options['s']); |
|
| 60 | -} elseif (isset($options['source'])) { |
|
| 62 | + if (isset($options['format'])) { |
|
| 63 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 64 | + } else { |
|
| 65 | + $globalSources[] = array('host' => $options['s']); |
|
| 66 | + } |
|
| 67 | + } elseif (isset($options['source'])) { |
|
| 61 | 68 | $globalSources = array(); |
| 62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 63 | - else $globalSources[] = array('host' => $options['source']); |
|
| 64 | -} |
|
| 69 | + if (isset($options['format'])) { |
|
| 70 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 71 | + } else { |
|
| 72 | + $globalSources[] = array('host' => $options['source']); |
|
| 73 | + } |
|
| 74 | + } |
|
| 65 | 75 | if (isset($options['aprsserverhost'])) { |
| 66 | 76 | $globalServerAPRS = TRUE; |
| 67 | 77 | $globalServerAPRShost = $options['aprsserverhost']; |
| 68 | 78 | } |
| 69 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
| 70 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 71 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 72 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
| 73 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 74 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 75 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 76 | -else $id_source = 1; |
|
| 79 | +if (isset($options['aprsserverport'])) { |
|
| 80 | + $globalServerAPRSport = $options['aprsserverport']; |
|
| 81 | +} |
|
| 82 | +if (isset($options['aprsserverssid'])) { |
|
| 83 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 84 | +} |
|
| 85 | +if (isset($options['aprsserverpass'])) { |
|
| 86 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 87 | +} |
|
| 88 | +if (isset($options['noaprsserver'])) { |
|
| 89 | + $globalServerAPRS = FALSE; |
|
| 90 | +} |
|
| 91 | +if (isset($options['nodaemon'])) { |
|
| 92 | + $globalDaemon = FALSE; |
|
| 93 | +} |
|
| 94 | +if (isset($options['server'])) { |
|
| 95 | + $globalServer = TRUE; |
|
| 96 | +} |
|
| 97 | +if (isset($options['idsource'])) { |
|
| 98 | + $id_source = $options['idsource']; |
|
| 99 | +} else { |
|
| 100 | + $id_source = 1; |
|
| 101 | +} |
|
| 77 | 102 | if (isset($globalServer) && $globalServer) { |
| 78 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 103 | + if ($globalDebug) { |
|
| 104 | + echo "Using Server Mode\n"; |
|
| 105 | + } |
|
| 79 | 106 | $SI=new SpotterServer(); |
| 80 | 107 | /* |
| 81 | 108 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 82 | 109 | $SI = new adsb2aprs(); |
| 83 | 110 | $SI->connect(); |
| 84 | 111 | */ |
| 85 | -} else $SI=new SpotterImport($Connection->db); |
|
| 86 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 112 | +} else { |
|
| 113 | + $SI=new SpotterImport($Connection->db); |
|
| 114 | +} |
|
| 115 | +if (isset($globalTracker) && $globalTracker) { |
|
| 116 | + $TI = new TrackerImport($Connection->db); |
|
| 117 | +} |
|
| 87 | 118 | if (isset($globalMarine) && $globalMarine) { |
| 88 | 119 | $AIS = new AIS(); |
| 89 | 120 | $MI = new MarineImport($Connection->db); |
@@ -106,7 +137,9 @@ discard block |
||
| 106 | 137 | } |
| 107 | 138 | |
| 108 | 139 | // let's try and connect |
| 109 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 140 | +if ($globalDebug) { |
|
| 141 | + echo "Connecting...\n"; |
|
| 142 | +} |
|
| 110 | 143 | $use_aprs = false; |
| 111 | 144 | $aprs_full = false; |
| 112 | 145 | $reset = 0; |
@@ -115,7 +148,9 @@ discard block |
||
| 115 | 148 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 116 | 149 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 117 | 150 | $reset++; |
| 118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 151 | + if ($globalDebug) { |
|
| 152 | + echo 'Connect to all...'."\n"; |
|
| 153 | + } |
|
| 119 | 154 | foreach ($hosts as $id => $value) { |
| 120 | 155 | $host = $value['host']; |
| 121 | 156 | $globalSources[$id]['last_exec'] = 0; |
@@ -125,22 +160,30 @@ discard block |
||
| 125 | 160 | //$formats[$id] = 'deltadbtxt'; |
| 126 | 161 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 127 | 162 | //$last_exec['deltadbtxt'] = 0; |
| 128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 163 | + if ($globalDebug) { |
|
| 164 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 165 | + } |
|
| 129 | 166 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 130 | 167 | //$formats[$id] = 'vatsimtxt'; |
| 131 | 168 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 132 | 169 | //$last_exec['vatsimtxt'] = 0; |
| 133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 170 | + if ($globalDebug) { |
|
| 171 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 172 | + } |
|
| 134 | 173 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 135 | 174 | //$formats[$id] = 'aircraftlistjson'; |
| 136 | 175 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 137 | 176 | //$last_exec['aircraftlistjson'] = 0; |
| 138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 177 | + if ($globalDebug) { |
|
| 178 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 179 | + } |
|
| 139 | 180 | } else if (preg_match('/opensky/i',$host)) { |
| 140 | 181 | //$formats[$id] = 'aircraftlistjson'; |
| 141 | 182 | $globalSources[$id]['format'] = 'opensky'; |
| 142 | 183 | //$last_exec['aircraftlistjson'] = 0; |
| 143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 184 | + if ($globalDebug) { |
|
| 185 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 186 | + } |
|
| 144 | 187 | /* |
| 145 | 188 | // Disabled for now, site change source format |
| 146 | 189 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -157,7 +200,9 @@ discard block |
||
| 157 | 200 | //$formats[$id] = 'planeupdatefaa'; |
| 158 | 201 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 159 | 202 | //$last_exec['planeupdatefaa'] = 0; |
| 160 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 203 | + if ($globalDebug) { |
|
| 204 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 205 | + } |
|
| 161 | 206 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 162 | 207 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 163 | 208 | exit(0); |
@@ -166,29 +211,41 @@ discard block |
||
| 166 | 211 | //$formats[$id] = 'phpvmacars'; |
| 167 | 212 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 168 | 213 | //$last_exec['phpvmacars'] = 0; |
| 169 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 214 | + if ($globalDebug) { |
|
| 215 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 216 | + } |
|
| 170 | 217 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 171 | 218 | //$formats[$id] = 'phpvmacars'; |
| 172 | 219 | $globalSources[$id]['format'] = 'vam'; |
| 173 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 220 | + if ($globalDebug) { |
|
| 221 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 222 | + } |
|
| 174 | 223 | } else if (preg_match('/whazzup/i',$host)) { |
| 175 | 224 | //$formats[$id] = 'whazzup'; |
| 176 | 225 | $globalSources[$id]['format'] = 'whazzup'; |
| 177 | 226 | //$last_exec['whazzup'] = 0; |
| 178 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 227 | + if ($globalDebug) { |
|
| 228 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 229 | + } |
|
| 179 | 230 | } else if (preg_match('/airwhere/i',$host)) { |
| 180 | 231 | $globalSources[$id]['format'] = 'airwhere'; |
| 181 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 232 | + if ($globalDebug) { |
|
| 233 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
| 234 | + } |
|
| 182 | 235 | } else if (preg_match('/recentpireps/i',$host)) { |
| 183 | 236 | //$formats[$id] = 'pirepsjson'; |
| 184 | 237 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 185 | 238 | //$last_exec['pirepsjson'] = 0; |
| 186 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 239 | + if ($globalDebug) { |
|
| 240 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 241 | + } |
|
| 187 | 242 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 188 | 243 | //$formats[$id] = 'fr24json'; |
| 189 | 244 | $globalSources[$id]['format'] = 'fr24json'; |
| 190 | 245 | //$last_exec['fr24json'] = 0; |
| 191 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 246 | + if ($globalDebug) { |
|
| 247 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 248 | + } |
|
| 192 | 249 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 193 | 250 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 194 | 251 | exit(0); |
@@ -197,7 +254,9 @@ discard block |
||
| 197 | 254 | //$formats[$id] = 'fr24json'; |
| 198 | 255 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 199 | 256 | //$last_exec['fr24json'] = 0; |
| 200 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 257 | + if ($globalDebug) { |
|
| 258 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 259 | + } |
|
| 201 | 260 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 202 | 261 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 203 | 262 | exit(0); |
@@ -206,17 +265,24 @@ discard block |
||
| 206 | 265 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 207 | 266 | //$formats[$id] = 'tsv'; |
| 208 | 267 | $globalSources[$id]['format'] = 'tsv'; |
| 209 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 268 | + if ($globalDebug) { |
|
| 269 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 270 | + } |
|
| 210 | 271 | } |
| 211 | 272 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
| 212 | 273 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 213 | 274 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 214 | 275 | if ($idf !== false) { |
| 215 | 276 | $httpfeeds[$id] = $idf; |
| 216 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 277 | + if ($globalDebug) { |
|
| 278 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 279 | + } |
|
| 280 | + } elseif ($globalDebug) { |
|
| 281 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 217 | 282 | } |
| 218 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 219 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 283 | + } elseif ($globalDebug) { |
|
| 284 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 285 | + } |
|
| 220 | 286 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 221 | 287 | $hostport = explode(':',$host); |
| 222 | 288 | if (isset($hostport[1])) { |
@@ -256,17 +322,25 @@ discard block |
||
| 256 | 322 | //$formats[$id] = 'beast'; |
| 257 | 323 | $globalSources[$id]['format'] = 'beast'; |
| 258 | 324 | //} else $formats[$id] = 'sbs'; |
| 259 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 325 | + } else { |
|
| 326 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 327 | + } |
|
| 260 | 328 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 261 | 329 | } |
| 262 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 330 | + if ($globalDebug) { |
|
| 331 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 332 | + } |
|
| 263 | 333 | } else { |
| 264 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 334 | + if ($globalDebug) { |
|
| 335 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 336 | + } |
|
| 265 | 337 | } |
| 266 | 338 | } |
| 267 | 339 | } |
| 268 | 340 | } |
| 269 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 341 | +if (!isset($globalMinFetch)) { |
|
| 342 | + $globalMinFetch = 15; |
|
| 343 | +} |
|
| 270 | 344 | |
| 271 | 345 | // Initialize all |
| 272 | 346 | $status = array(); |
@@ -275,13 +349,19 @@ discard block |
||
| 275 | 349 | $formats = array(); |
| 276 | 350 | $last_exec = array(); |
| 277 | 351 | $time = time(); |
| 278 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 279 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 280 | -else $timeout = 20; |
|
| 352 | +if (isset($globalSourcesTimeout)) { |
|
| 353 | + $timeout = $globalSourcesTimeOut; |
|
| 354 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 355 | + $timeout = $globalSBS1TimeOut; |
|
| 356 | +} else { |
|
| 357 | + $timeout = 20; |
|
| 358 | +} |
|
| 281 | 359 | $errno = ''; |
| 282 | 360 | $errstr=''; |
| 283 | 361 | |
| 284 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 362 | +if (!isset($globalDaemon)) { |
|
| 363 | + $globalDaemon = TRUE; |
|
| 364 | +} |
|
| 285 | 365 | /* Initiate connections to all the hosts simultaneously */ |
| 286 | 366 | //connect_all($hosts); |
| 287 | 367 | //connect_all($globalSources); |
@@ -310,7 +390,9 @@ discard block |
||
| 310 | 390 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 311 | 391 | $aprs_connect = 0; |
| 312 | 392 | $use_aprs = true; |
| 313 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 393 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 394 | + $aprs_full = true; |
|
| 395 | + } |
|
| 314 | 396 | break; |
| 315 | 397 | } |
| 316 | 398 | } |
@@ -321,25 +403,48 @@ discard block |
||
| 321 | 403 | $aprs_connect = 0; |
| 322 | 404 | $aprs_keep = 120; |
| 323 | 405 | $aprs_last_tx = time(); |
| 324 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 325 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 326 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 327 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 328 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 329 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 330 | - if ($aprs_full) $aprs_filter = ''; |
|
| 331 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 332 | - else $aprs_pass = '-1'; |
|
| 406 | + if (isset($globalAPRSversion)) { |
|
| 407 | + $aprs_version = $globalAPRSversion; |
|
| 408 | + } else { |
|
| 409 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 410 | + } |
|
| 411 | + if (isset($globalAPRSssid)) { |
|
| 412 | + $aprs_ssid = $globalAPRSssid; |
|
| 413 | + } else { |
|
| 414 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 415 | + } |
|
| 416 | + if (isset($globalAPRSfilter)) { |
|
| 417 | + $aprs_filter = $globalAPRSfilter; |
|
| 418 | + } else { |
|
| 419 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 420 | + } |
|
| 421 | + if ($aprs_full) { |
|
| 422 | + $aprs_filter = ''; |
|
| 423 | + } |
|
| 424 | + if (isset($globalAPRSpass)) { |
|
| 425 | + $aprs_pass = $globalAPRSpass; |
|
| 426 | + } else { |
|
| 427 | + $aprs_pass = '-1'; |
|
| 428 | + } |
|
| 333 | 429 | |
| 334 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 335 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 336 | -} |
|
| 430 | + if ($aprs_filter != '') { |
|
| 431 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 432 | + } else { |
|
| 433 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 434 | + } |
|
| 435 | + } |
|
| 337 | 436 | |
| 338 | 437 | // connected - lets do some work |
| 339 | -if ($globalDebug) echo "Connected!\n"; |
|
| 438 | +if ($globalDebug) { |
|
| 439 | + echo "Connected!\n"; |
|
| 440 | +} |
|
| 340 | 441 | sleep(1); |
| 341 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 342 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 442 | +if ($globalDebug) { |
|
| 443 | + echo "SCAN MODE \n\n"; |
|
| 444 | +} |
|
| 445 | +if (!isset($globalCronEnd)) { |
|
| 446 | + $globalCronEnd = 60; |
|
| 447 | +} |
|
| 343 | 448 | $endtime = time()+$globalCronEnd; |
| 344 | 449 | $i = 1; |
| 345 | 450 | $tt = array(); |
@@ -353,20 +458,28 @@ discard block |
||
| 353 | 458 | |
| 354 | 459 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 355 | 460 | while ($i > 0) { |
| 356 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 461 | + if (!$globalDaemon) { |
|
| 462 | + $i = $endtime-time(); |
|
| 463 | + } |
|
| 357 | 464 | // Delete old ATC |
| 358 | 465 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 359 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 466 | + if ($globalDebug) { |
|
| 467 | + echo 'Delete old ATC...'."\n"; |
|
| 468 | + } |
|
| 360 | 469 | $ATC->deleteOldATC(); |
| 361 | 470 | } |
| 362 | 471 | |
| 363 | 472 | if (count($last_exec) == count($globalSources)) { |
| 364 | 473 | $max = $globalMinFetch; |
| 365 | 474 | foreach ($last_exec as $last) { |
| 366 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 475 | + if ((time() - $last['last']) < $max) { |
|
| 476 | + $max = time() - $last['last']; |
|
| 477 | + } |
|
| 367 | 478 | } |
| 368 | 479 | if ($max != $globalMinFetch) { |
| 369 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 480 | + if ($globalDebug) { |
|
| 481 | + echo 'Sleeping...'."\n"; |
|
| 482 | + } |
|
| 370 | 483 | sleep($globalMinFetch-$max+2); |
| 371 | 484 | } |
| 372 | 485 | } |
@@ -375,11 +488,15 @@ discard block |
||
| 375 | 488 | //foreach ($formats as $id => $value) { |
| 376 | 489 | foreach ($globalSources as $id => $value) { |
| 377 | 490 | date_default_timezone_set('UTC'); |
| 378 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 491 | + if (!isset($last_exec[$id]['last'])) { |
|
| 492 | + $last_exec[$id]['last'] = 0; |
|
| 493 | + } |
|
| 379 | 494 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 380 | 495 | //$buffer = $Common->getData($hosts[$id]); |
| 381 | 496 | $buffer = $Common->getData($value['host']); |
| 382 | - if ($buffer != '') $reset = 0; |
|
| 497 | + if ($buffer != '') { |
|
| 498 | + $reset = 0; |
|
| 499 | + } |
|
| 383 | 500 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 384 | 501 | $buffer = explode('\n',$buffer); |
| 385 | 502 | foreach ($buffer as $line) { |
@@ -388,20 +505,41 @@ discard block |
||
| 388 | 505 | $data = array(); |
| 389 | 506 | $data['hex'] = $line[1]; // hex |
| 390 | 507 | $data['ident'] = $line[2]; // ident |
| 391 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 392 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 393 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 394 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 395 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 508 | + if (isset($line[3])) { |
|
| 509 | + $data['altitude'] = $line[3]; |
|
| 510 | + } |
|
| 511 | + // altitude |
|
| 512 | + if (isset($line[4])) { |
|
| 513 | + $data['speed'] = $line[4]; |
|
| 514 | + } |
|
| 515 | + // speed |
|
| 516 | + if (isset($line[5])) { |
|
| 517 | + $data['heading'] = $line[5]; |
|
| 518 | + } |
|
| 519 | + // heading |
|
| 520 | + if (isset($line[6])) { |
|
| 521 | + $data['latitude'] = $line[6]; |
|
| 522 | + } |
|
| 523 | + // lat |
|
| 524 | + if (isset($line[7])) { |
|
| 525 | + $data['longitude'] = $line[7]; |
|
| 526 | + } |
|
| 527 | + // long |
|
| 396 | 528 | $data['verticalrate'] = ''; // vertical rate |
| 397 | 529 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 398 | 530 | $data['emergency'] = ''; // emergency |
| 399 | 531 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 400 | 532 | $data['format_source'] = 'deltadbtxt'; |
| 401 | 533 | $data['id_source'] = $id_source; |
| 402 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 403 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 404 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 534 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 535 | + $data['source_name'] = $value['name']; |
|
| 536 | + } |
|
| 537 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 538 | + $data['noarchive'] = true; |
|
| 539 | + } |
|
| 540 | + if (isset($value['sourcestats'])) { |
|
| 541 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 542 | + } |
|
| 405 | 543 | $SI->add($data); |
| 406 | 544 | unset($data); |
| 407 | 545 | } |
@@ -411,7 +549,9 @@ discard block |
||
| 411 | 549 | date_default_timezone_set('CET'); |
| 412 | 550 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 413 | 551 | date_default_timezone_set('UTC'); |
| 414 | - if ($buffer != '') $reset = 0; |
|
| 552 | + if ($buffer != '') { |
|
| 553 | + $reset = 0; |
|
| 554 | + } |
|
| 415 | 555 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 416 | 556 | $buffer = explode('\n',$buffer); |
| 417 | 557 | foreach ($buffer as $line) { |
@@ -420,16 +560,36 @@ discard block |
||
| 420 | 560 | $add = false; |
| 421 | 561 | $ais_data = $AIS->parse_line(trim($line)); |
| 422 | 562 | $data = array(); |
| 423 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 424 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 425 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 426 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 427 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 428 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 429 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 430 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 431 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 432 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 563 | + if (isset($ais_data['ident'])) { |
|
| 564 | + $data['ident'] = $ais_data['ident']; |
|
| 565 | + } |
|
| 566 | + if (isset($ais_data['mmsi'])) { |
|
| 567 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 568 | + } |
|
| 569 | + if (isset($ais_data['speed'])) { |
|
| 570 | + $data['speed'] = $ais_data['speed']; |
|
| 571 | + } |
|
| 572 | + if (isset($ais_data['heading'])) { |
|
| 573 | + $data['heading'] = $ais_data['heading']; |
|
| 574 | + } |
|
| 575 | + if (isset($ais_data['latitude'])) { |
|
| 576 | + $data['latitude'] = $ais_data['latitude']; |
|
| 577 | + } |
|
| 578 | + if (isset($ais_data['longitude'])) { |
|
| 579 | + $data['longitude'] = $ais_data['longitude']; |
|
| 580 | + } |
|
| 581 | + if (isset($ais_data['status'])) { |
|
| 582 | + $data['status'] = $ais_data['status']; |
|
| 583 | + } |
|
| 584 | + if (isset($ais_data['type'])) { |
|
| 585 | + $data['type'] = $ais_data['type']; |
|
| 586 | + } |
|
| 587 | + if (isset($ais_data['imo'])) { |
|
| 588 | + $data['imo'] = $ais_data['imo']; |
|
| 589 | + } |
|
| 590 | + if (isset($ais_data['callsign'])) { |
|
| 591 | + $data['callsign'] = $ais_data['callsign']; |
|
| 592 | + } |
|
| 433 | 593 | if (isset($ais_data['timestamp'])) { |
| 434 | 594 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 435 | 595 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -443,8 +603,12 @@ discard block |
||
| 443 | 603 | $data['format_source'] = 'aisnmeatxt'; |
| 444 | 604 | $data['id_source'] = $id_source; |
| 445 | 605 | //print_r($data); |
| 446 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 447 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 606 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 607 | + $data['noarchive'] = true; |
|
| 608 | + } |
|
| 609 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 610 | + $MI->add($data); |
|
| 611 | + } |
|
| 448 | 612 | unset($data); |
| 449 | 613 | } |
| 450 | 614 | } |
@@ -464,20 +628,48 @@ discard block |
||
| 464 | 628 | if ($line != '') { |
| 465 | 629 | $ais_data = $AIS->parse_line(trim($line)); |
| 466 | 630 | $data = array(); |
| 467 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 468 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 469 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 470 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 471 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 472 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 473 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 474 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 475 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 476 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 477 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 478 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 479 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 480 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 631 | + if (isset($ais_data['ident'])) { |
|
| 632 | + $data['ident'] = $ais_data['ident']; |
|
| 633 | + } |
|
| 634 | + if (isset($ais_data['mmsi'])) { |
|
| 635 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 636 | + } |
|
| 637 | + if (isset($ais_data['speed'])) { |
|
| 638 | + $data['speed'] = $ais_data['speed']; |
|
| 639 | + } |
|
| 640 | + if (isset($ais_data['heading'])) { |
|
| 641 | + $data['heading'] = $ais_data['heading']; |
|
| 642 | + } |
|
| 643 | + if (isset($ais_data['latitude'])) { |
|
| 644 | + $data['latitude'] = $ais_data['latitude']; |
|
| 645 | + } |
|
| 646 | + if (isset($ais_data['longitude'])) { |
|
| 647 | + $data['longitude'] = $ais_data['longitude']; |
|
| 648 | + } |
|
| 649 | + if (isset($ais_data['status'])) { |
|
| 650 | + $data['status'] = $ais_data['status']; |
|
| 651 | + } |
|
| 652 | + if (isset($ais_data['statusid'])) { |
|
| 653 | + $data['status_id'] = $ais_data['statusid']; |
|
| 654 | + } |
|
| 655 | + if (isset($ais_data['type'])) { |
|
| 656 | + $data['type'] = $ais_data['type']; |
|
| 657 | + } |
|
| 658 | + if (isset($ais_data['typeid'])) { |
|
| 659 | + $data['type_id'] = $ais_data['typeid']; |
|
| 660 | + } |
|
| 661 | + if (isset($ais_data['imo'])) { |
|
| 662 | + $data['imo'] = $ais_data['imo']; |
|
| 663 | + } |
|
| 664 | + if (isset($ais_data['callsign'])) { |
|
| 665 | + $data['callsign'] = $ais_data['callsign']; |
|
| 666 | + } |
|
| 667 | + if (isset($ais_data['destination'])) { |
|
| 668 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 669 | + } |
|
| 670 | + if (isset($ais_data['eta_ts'])) { |
|
| 671 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 672 | + } |
|
| 481 | 673 | if (isset($ais_data['timestamp'])) { |
| 482 | 674 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 483 | 675 | } else { |
@@ -485,18 +677,27 @@ discard block |
||
| 485 | 677 | } |
| 486 | 678 | $data['format_source'] = 'aisnmeahttp'; |
| 487 | 679 | $data['id_source'] = $id_source; |
| 488 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 489 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 680 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 681 | + $data['noarchive'] = true; |
|
| 682 | + } |
|
| 683 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 684 | + $MI->add($data); |
|
| 685 | + } |
|
| 490 | 686 | unset($data); |
| 491 | 687 | } |
| 492 | 688 | } |
| 493 | 689 | } |
| 494 | 690 | } else { |
| 495 | 691 | $format = $value['format']; |
| 496 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 497 | - else $tt[$format] = 0; |
|
| 692 | + if (isset($tt[$format])) { |
|
| 693 | + $tt[$format]++; |
|
| 694 | + } else { |
|
| 695 | + $tt[$format] = 0; |
|
| 696 | + } |
|
| 498 | 697 | if ($tt[$format] > 30) { |
| 499 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 698 | + if ($globalDebug) { |
|
| 699 | + echo 'Reconnect...'."\n"; |
|
| 700 | + } |
|
| 500 | 701 | sleep(2); |
| 501 | 702 | $sourceeen[] = $value; |
| 502 | 703 | connect_all($sourceeen); |
@@ -526,7 +727,9 @@ discard block |
||
| 526 | 727 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
| 527 | 728 | $data['format_source'] = 'myshiptracking'; |
| 528 | 729 | $data['id_source'] = $id_source; |
| 529 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 730 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 731 | + $data['noarchive'] = true; |
|
| 732 | + } |
|
| 530 | 733 | $MI->add($data); |
| 531 | 734 | unset($data); |
| 532 | 735 | } |
@@ -546,7 +749,9 @@ discard block |
||
| 546 | 749 | $data['callsign'] = $line['callsign']; |
| 547 | 750 | $data['mmsi'] = $line['mmsi']; |
| 548 | 751 | $data['speed'] = $line['sog']; |
| 549 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 752 | + if ($line['heading'] != '511') { |
|
| 753 | + $data['heading'] = $line['heading']; |
|
| 754 | + } |
|
| 550 | 755 | $data['latitude'] = $line['latitude']; |
| 551 | 756 | $data['longitude'] = $line['longitude']; |
| 552 | 757 | $data['type_id'] = $line['shiptype']; |
@@ -554,7 +759,9 @@ discard block |
||
| 554 | 759 | $data['datetime'] = $line['time']; |
| 555 | 760 | $data['format_source'] = 'boatbeaconapp'; |
| 556 | 761 | $data['id_source'] = $id_source; |
| 557 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 762 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 763 | + $data['noarchive'] = true; |
|
| 764 | + } |
|
| 558 | 765 | $MI->add($data); |
| 559 | 766 | unset($data); |
| 560 | 767 | } |
@@ -570,22 +777,44 @@ discard block |
||
| 570 | 777 | if (isset($all_data['features'][0]['id'])) { |
| 571 | 778 | foreach ($all_data['features'] as $line) { |
| 572 | 779 | $data = array(); |
| 573 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
| 574 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
| 575 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi']; |
|
| 576 | - if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo']; |
|
| 577 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
| 578 | - if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading']; |
|
| 780 | + if (isset($line['properties']['name'])) { |
|
| 781 | + $data['ident'] = $line['properties']['name']; |
|
| 782 | + } |
|
| 783 | + if (isset($line['properties']['callsign'])) { |
|
| 784 | + $data['callsign'] = $line['properties']['callsign']; |
|
| 785 | + } |
|
| 786 | + if (isset($line['properties']['mmsi'])) { |
|
| 787 | + $data['mmsi'] = $line['properties']['mmsi']; |
|
| 788 | + } |
|
| 789 | + if (isset($line['properties']['imo'])) { |
|
| 790 | + $data['mmsi'] = $line['properties']['imo']; |
|
| 791 | + } |
|
| 792 | + if (isset($line['properties']['speed'])) { |
|
| 793 | + $data['speed'] = $line['properties']['speed']; |
|
| 794 | + } |
|
| 795 | + if (isset($line['properties']['heading'])) { |
|
| 796 | + $data['heading'] = $line['properties']['heading']; |
|
| 797 | + } |
|
| 579 | 798 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
| 580 | 799 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
| 581 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
| 582 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
| 583 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
| 800 | + if (isset($line['properties']['vesselType'])) { |
|
| 801 | + $data['type'] = $line['properties']['vesselType']; |
|
| 802 | + } |
|
| 803 | + if (isset($line['properties']['destination'])) { |
|
| 804 | + $data['arrival_code'] = $line['properties']['destination']; |
|
| 805 | + } |
|
| 806 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
| 807 | + $data['arrival_date'] = $line['properties']['eta']; |
|
| 808 | + } |
|
| 584 | 809 | $data['format_source'] = 'boatnerd'; |
| 585 | 810 | $data['id_source'] = $id_source; |
| 586 | 811 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 587 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 588 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
| 812 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 813 | + $data['noarchive'] = true; |
|
| 814 | + } |
|
| 815 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
| 816 | + $MI->add($data); |
|
| 817 | + } |
|
| 589 | 818 | unset($data); |
| 590 | 819 | } |
| 591 | 820 | } |
@@ -596,7 +825,9 @@ discard block |
||
| 596 | 825 | echo 'download...'; |
| 597 | 826 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 598 | 827 | echo 'done !'."\n"; |
| 599 | - if ($buffer != '') $reset = 0; |
|
| 828 | + if ($buffer != '') { |
|
| 829 | + $reset = 0; |
|
| 830 | + } |
|
| 600 | 831 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 601 | 832 | $buffer = explode('\n',$buffer); |
| 602 | 833 | foreach ($buffer as $line) { |
@@ -621,7 +852,9 @@ discard block |
||
| 621 | 852 | //$data['etaTime'] = substr($line,135,5); |
| 622 | 853 | $data['format_source'] = 'shipplotter'; |
| 623 | 854 | $data['id_source'] = $id_source; |
| 624 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 855 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 856 | + $data['noarchive'] = true; |
|
| 857 | + } |
|
| 625 | 858 | //print_r($data); |
| 626 | 859 | echo 'Add...'."\n"; |
| 627 | 860 | $MI->add($data); |
@@ -641,16 +874,28 @@ discard block |
||
| 641 | 874 | $line = explode(':', $line); |
| 642 | 875 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 643 | 876 | $data = array(); |
| 644 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 645 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 877 | + if (isset($line[37]) && $line[37] != '') { |
|
| 878 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 879 | + } else { |
|
| 880 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 881 | + } |
|
| 646 | 882 | $data['pilot_id'] = $line[1]; |
| 647 | 883 | $data['pilot_name'] = $line[2]; |
| 648 | 884 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 649 | 885 | $data['ident'] = $line[0]; // ident |
| 650 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 886 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 887 | + $data['altitude'] = $line[7]; |
|
| 888 | + } |
|
| 889 | + // altitude |
|
| 651 | 890 | $data['speed'] = $line[8]; // speed |
| 652 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 653 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 891 | + if (isset($line[45])) { |
|
| 892 | + $data['heading'] = $line[45]; |
|
| 893 | + } |
|
| 894 | + // heading |
|
| 895 | + elseif (isset($line[38])) { |
|
| 896 | + $data['heading'] = $line[38]; |
|
| 897 | + } |
|
| 898 | + // heading |
|
| 654 | 899 | $data['latitude'] = $line[5]; // lat |
| 655 | 900 | $data['longitude'] = $line[6]; // long |
| 656 | 901 | $data['verticalrate'] = ''; // vertical rate |
@@ -666,7 +911,9 @@ discard block |
||
| 666 | 911 | $data['frequency'] = $line[4]; |
| 667 | 912 | $data['type'] = $line[18]; |
| 668 | 913 | $data['range'] = $line[19]; |
| 669 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 914 | + if (isset($line[35])) { |
|
| 915 | + $data['info'] = $line[35]; |
|
| 916 | + } |
|
| 670 | 917 | $data['id_source'] = $id_source; |
| 671 | 918 | //$data['arrival_airport_time'] = ; |
| 672 | 919 | if ($line[9] != '') { |
@@ -680,27 +927,47 @@ discard block |
||
| 680 | 927 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 681 | 928 | */ |
| 682 | 929 | $data['format_source'] = $value['format']; |
| 683 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 684 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 685 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 686 | - elseif ($line[3] == 'ATC') { |
|
| 930 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 931 | + $data['noarchive'] = true; |
|
| 932 | + } |
|
| 933 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 934 | + $data['source_name'] = $value['name']; |
|
| 935 | + } |
|
| 936 | + if ($line[3] == 'PILOT') { |
|
| 937 | + $SI->add($data); |
|
| 938 | + } elseif ($line[3] == 'ATC') { |
|
| 687 | 939 | //print_r($data); |
| 688 | 940 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 689 | 941 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 690 | 942 | $typec = substr($data['ident'],-3); |
| 691 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 692 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 693 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 694 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 695 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 696 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 697 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 698 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 699 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
| 700 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 943 | + if ($typec == 'APP') { |
|
| 944 | + $data['type'] = 'Approach'; |
|
| 945 | + } elseif ($typec == 'TWR') { |
|
| 946 | + $data['type'] = 'Tower'; |
|
| 947 | + } elseif ($typec == 'OBS') { |
|
| 948 | + $data['type'] = 'Observer'; |
|
| 949 | + } elseif ($typec == 'GND') { |
|
| 950 | + $data['type'] = 'Ground'; |
|
| 951 | + } elseif ($typec == 'DEL') { |
|
| 952 | + $data['type'] = 'Delivery'; |
|
| 953 | + } elseif ($typec == 'DEP') { |
|
| 954 | + $data['type'] = 'Departure'; |
|
| 955 | + } elseif ($typec == 'FSS') { |
|
| 956 | + $data['type'] = 'Flight Service Station'; |
|
| 957 | + } elseif ($typec == 'CTR') { |
|
| 958 | + $data['type'] = 'Control Radar or Centre'; |
|
| 959 | + } elseif ($data['type'] == '') { |
|
| 960 | + $data['type'] = 'Observer'; |
|
| 961 | + } |
|
| 962 | + if (!isset($data['source_name'])) { |
|
| 963 | + $data['source_name'] = ''; |
|
| 964 | + } |
|
| 701 | 965 | if (isset($ATC)) { |
| 702 | - 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']); |
|
| 703 | - 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']); |
|
| 966 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
| 967 | + 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']); |
|
| 968 | + } else { |
|
| 969 | + 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']); |
|
| 970 | + } |
|
| 704 | 971 | } |
| 705 | 972 | } |
| 706 | 973 | unset($data); |
@@ -722,14 +989,20 @@ discard block |
||
| 722 | 989 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
| 723 | 990 | $data['latitude'] = (float)$line['pktLatitude']; |
| 724 | 991 | $data['longitude'] = (float)$line['pktLongitude']; |
| 725 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 726 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 992 | + if ((float)$line['pktTrack'] != 0) { |
|
| 993 | + $data['heading'] = (float)$line['pktTrack']; |
|
| 994 | + } |
|
| 995 | + if ((int)$line['pktSpeed'] != 0) { |
|
| 996 | + $data['speed'] = (int)$line['pktSpeed']; |
|
| 997 | + } |
|
| 727 | 998 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
| 728 | 999 | $data['altitude_relative'] = 'AMSL'; |
| 729 | 1000 | $data['pilot_id'] = (int)$line['pktPilotID']; |
| 730 | 1001 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 731 | 1002 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
| 732 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
| 1003 | + if (isset($pilot_data[4])) { |
|
| 1004 | + $data['pilot_name'] = $pilot_data[4]; |
|
| 1005 | + } |
|
| 733 | 1006 | $data['format_source'] = $value['format']; |
| 734 | 1007 | $SI->add($data); |
| 735 | 1008 | unset($data); |
@@ -766,27 +1039,61 @@ discard block |
||
| 766 | 1039 | foreach ($all_data['acList'] as $line) { |
| 767 | 1040 | $data = array(); |
| 768 | 1041 | $data['hex'] = $line['Icao']; // hex |
| 769 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 770 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 771 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 772 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 773 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 774 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1042 | + if (isset($line['Call'])) { |
|
| 1043 | + $data['ident'] = $line['Call']; |
|
| 1044 | + } |
|
| 1045 | + // ident |
|
| 1046 | + if (isset($line['Alt'])) { |
|
| 1047 | + $data['altitude'] = $line['Alt']; |
|
| 1048 | + } |
|
| 1049 | + // altitude |
|
| 1050 | + if (isset($line['Spd'])) { |
|
| 1051 | + $data['speed'] = $line['Spd']; |
|
| 1052 | + } |
|
| 1053 | + // speed |
|
| 1054 | + if (isset($line['Trak'])) { |
|
| 1055 | + $data['heading'] = $line['Trak']; |
|
| 1056 | + } |
|
| 1057 | + // heading |
|
| 1058 | + if (isset($line['Lat'])) { |
|
| 1059 | + $data['latitude'] = $line['Lat']; |
|
| 1060 | + } |
|
| 1061 | + // lat |
|
| 1062 | + if (isset($line['Long'])) { |
|
| 1063 | + $data['longitude'] = $line['Long']; |
|
| 1064 | + } |
|
| 1065 | + // long |
|
| 775 | 1066 | //$data['verticalrate'] = $line['']; // verticale rate |
| 776 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1067 | + if (isset($line['Sqk'])) { |
|
| 1068 | + $data['squawk'] = $line['Sqk']; |
|
| 1069 | + } |
|
| 1070 | + // squawk |
|
| 777 | 1071 | $data['emergency'] = ''; // emergency |
| 778 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1072 | + if (isset($line['Reg'])) { |
|
| 1073 | + $data['registration'] = $line['Reg']; |
|
| 1074 | + } |
|
| 779 | 1075 | |
| 780 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 781 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1076 | + if (isset($line['PosTime'])) { |
|
| 1077 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1078 | + } else { |
|
| 1079 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1080 | + } |
|
| 782 | 1081 | |
| 783 | 1082 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 784 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1083 | + if (isset($line['Type'])) { |
|
| 1084 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1085 | + } |
|
| 785 | 1086 | $data['format_source'] = 'aircraftlistjson'; |
| 786 | 1087 | $data['id_source'] = $id_source; |
| 787 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 788 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 789 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 1088 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1089 | + $data['source_name'] = $value['name']; |
|
| 1090 | + } |
|
| 1091 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1092 | + $data['noarchive'] = true; |
|
| 1093 | + } |
|
| 1094 | + if (isset($data['latitude'])) { |
|
| 1095 | + $SI->add($data); |
|
| 1096 | + } |
|
| 790 | 1097 | unset($data); |
| 791 | 1098 | } |
| 792 | 1099 | } elseif (is_array($all_data)) { |
@@ -803,12 +1110,19 @@ discard block |
||
| 803 | 1110 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 804 | 1111 | $data['squawk'] = $line['squawk']; // squawk |
| 805 | 1112 | $data['emergency'] = ''; // emergency |
| 806 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 807 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1113 | + if (isset($line['PosTime'])) { |
|
| 1114 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1115 | + } else { |
|
| 1116 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1117 | + } |
|
| 808 | 1118 | $data['format_source'] = 'aircraftlistjson'; |
| 809 | 1119 | $data['id_source'] = $id_source; |
| 810 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 811 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1120 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1121 | + $data['noarchive'] = true; |
|
| 1122 | + } |
|
| 1123 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1124 | + $data['source_name'] = $value['name']; |
|
| 1125 | + } |
|
| 812 | 1126 | $SI->add($data); |
| 813 | 1127 | unset($data); |
| 814 | 1128 | } |
@@ -844,8 +1158,12 @@ discard block |
||
| 844 | 1158 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 845 | 1159 | $data['format_source'] = 'planeupdatefaa'; |
| 846 | 1160 | $data['id_source'] = $id_source; |
| 847 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 848 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1161 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1162 | + $data['noarchive'] = true; |
|
| 1163 | + } |
|
| 1164 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1165 | + $data['source_name'] = $value['name']; |
|
| 1166 | + } |
|
| 849 | 1167 | $SI->add($data); |
| 850 | 1168 | unset($data); |
| 851 | 1169 | } |
@@ -874,7 +1192,9 @@ discard block |
||
| 874 | 1192 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
| 875 | 1193 | $data['format_source'] = 'opensky'; |
| 876 | 1194 | $data['id_source'] = $id_source; |
| 877 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1195 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1196 | + $data['noarchive'] = true; |
|
| 1197 | + } |
|
| 878 | 1198 | $SI->add($data); |
| 879 | 1199 | unset($data); |
| 880 | 1200 | } |
@@ -886,7 +1206,9 @@ discard block |
||
| 886 | 1206 | //$buffer = $Common->getData($hosts[$id]); |
| 887 | 1207 | $buffer = $Common->getData($value['host']); |
| 888 | 1208 | $all_data = json_decode($buffer,true); |
| 889 | - if (!empty($all_data)) $reset = 0; |
|
| 1209 | + if (!empty($all_data)) { |
|
| 1210 | + $reset = 0; |
|
| 1211 | + } |
|
| 890 | 1212 | foreach ($all_data as $key => $line) { |
| 891 | 1213 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 892 | 1214 | $data = array(); |
@@ -907,8 +1229,12 @@ discard block |
||
| 907 | 1229 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 908 | 1230 | $data['format_source'] = 'fr24json'; |
| 909 | 1231 | $data['id_source'] = $id_source; |
| 910 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 911 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1232 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1233 | + $data['noarchive'] = true; |
|
| 1234 | + } |
|
| 1235 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1236 | + $data['source_name'] = $value['name']; |
|
| 1237 | + } |
|
| 912 | 1238 | $SI->add($data); |
| 913 | 1239 | unset($data); |
| 914 | 1240 | } |
@@ -932,24 +1258,42 @@ discard block |
||
| 932 | 1258 | if (isset($line['inf'])) { |
| 933 | 1259 | $data = array(); |
| 934 | 1260 | $data['hex'] = $line['inf']['ia']; |
| 935 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1261 | + if (isset($line['inf']['cs'])) { |
|
| 1262 | + $data['ident'] = $line['inf']['cs']; |
|
| 1263 | + } |
|
| 1264 | + //$line[13] |
|
| 936 | 1265 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 937 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 938 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1266 | + if (isset($line['inf']['gs'])) { |
|
| 1267 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1268 | + } |
|
| 1269 | + // speed |
|
| 1270 | + if (isset($line['inf']['tr'])) { |
|
| 1271 | + $data['heading'] = $line['inf']['tr']; |
|
| 1272 | + } |
|
| 1273 | + // heading |
|
| 939 | 1274 | $data['latitude'] = $line['pt'][0]; // lat |
| 940 | 1275 | $data['longitude'] = $line['pt'][1]; // long |
| 941 | 1276 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 942 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1277 | + if (isset($line['inf']['sq'])) { |
|
| 1278 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1279 | + } |
|
| 1280 | + // squawk |
|
| 943 | 1281 | //$data['aircraft_icao'] = $line[8]; |
| 944 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1282 | + if (isset($line['inf']['rc'])) { |
|
| 1283 | + $data['registration'] = $line['inf']['rc']; |
|
| 1284 | + } |
|
| 945 | 1285 | //$data['departure_airport_iata'] = $line[11]; |
| 946 | 1286 | //$data['arrival_airport_iata'] = $line[12]; |
| 947 | 1287 | //$data['emergency'] = ''; // emergency |
| 948 | 1288 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 949 | 1289 | $data['format_source'] = 'radarvirtueljson'; |
| 950 | 1290 | $data['id_source'] = $id_source; |
| 951 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 952 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1291 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1292 | + $data['noarchive'] = true; |
|
| 1293 | + } |
|
| 1294 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1295 | + $data['source_name'] = $value['name']; |
|
| 1296 | + } |
|
| 953 | 1297 | $SI->add($data); |
| 954 | 1298 | unset($data); |
| 955 | 1299 | } |
@@ -970,30 +1314,65 @@ discard block |
||
| 970 | 1314 | $data['id'] = $line['id']; |
| 971 | 1315 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 972 | 1316 | $data['ident'] = $line['callsign']; // ident |
| 973 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 974 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 975 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 976 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 977 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 978 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1317 | + if (isset($line['pilotid'])) { |
|
| 1318 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1319 | + } |
|
| 1320 | + // pilot id |
|
| 1321 | + if (isset($line['name'])) { |
|
| 1322 | + $data['pilot_name'] = $line['name']; |
|
| 1323 | + } |
|
| 1324 | + // pilot name |
|
| 1325 | + if (isset($line['alt'])) { |
|
| 1326 | + $data['altitude'] = $line['alt']; |
|
| 1327 | + } |
|
| 1328 | + // altitude |
|
| 1329 | + if (isset($line['gs'])) { |
|
| 1330 | + $data['speed'] = $line['gs']; |
|
| 1331 | + } |
|
| 1332 | + // speed |
|
| 1333 | + if (isset($line['heading'])) { |
|
| 1334 | + $data['heading'] = $line['heading']; |
|
| 1335 | + } |
|
| 1336 | + // heading |
|
| 1337 | + if (isset($line['route'])) { |
|
| 1338 | + $data['waypoints'] = $line['route']; |
|
| 1339 | + } |
|
| 1340 | + // route |
|
| 979 | 1341 | $data['latitude'] = $line['lat']; // lat |
| 980 | 1342 | $data['longitude'] = $line['lon']; // long |
| 981 | 1343 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 982 | 1344 | //$data['squawk'] = $line['squawk']; // squawk |
| 983 | 1345 | //$data['emergency'] = ''; // emergency |
| 984 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 985 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 986 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1346 | + if (isset($line['depicao'])) { |
|
| 1347 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1348 | + } |
|
| 1349 | + if (isset($line['deptime'])) { |
|
| 1350 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1351 | + } |
|
| 1352 | + if (isset($line['arricao'])) { |
|
| 1353 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1354 | + } |
|
| 987 | 1355 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 988 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 989 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 990 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 991 | - else $data['info'] = ''; |
|
| 1356 | + if (isset($line['aircraft'])) { |
|
| 1357 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1358 | + } |
|
| 1359 | + if (isset($line['transponder'])) { |
|
| 1360 | + $data['squawk'] = $line['transponder']; |
|
| 1361 | + } |
|
| 1362 | + if (isset($line['atis'])) { |
|
| 1363 | + $data['info'] = $line['atis']; |
|
| 1364 | + } else { |
|
| 1365 | + $data['info'] = ''; |
|
| 1366 | + } |
|
| 992 | 1367 | $data['format_source'] = 'pireps'; |
| 993 | 1368 | $data['id_source'] = $id_source; |
| 994 | 1369 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 995 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 996 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1370 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1371 | + $data['noarchive'] = true; |
|
| 1372 | + } |
|
| 1373 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1374 | + $data['source_name'] = $value['name']; |
|
| 1375 | + } |
|
| 997 | 1376 | if ($line['icon'] == 'plane') { |
| 998 | 1377 | $SI->add($data); |
| 999 | 1378 | // print_r($data); |
@@ -1002,16 +1381,28 @@ discard block |
||
| 1002 | 1381 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1003 | 1382 | $typec = substr($data['ident'],-3); |
| 1004 | 1383 | $data['type'] = ''; |
| 1005 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 1006 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 1007 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 1008 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 1009 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 1010 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 1011 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 1012 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 1013 | - else $data['type'] = 'Observer'; |
|
| 1014 | - 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']); |
|
| 1384 | + if ($typec == 'APP') { |
|
| 1385 | + $data['type'] = 'Approach'; |
|
| 1386 | + } elseif ($typec == 'TWR') { |
|
| 1387 | + $data['type'] = 'Tower'; |
|
| 1388 | + } elseif ($typec == 'OBS') { |
|
| 1389 | + $data['type'] = 'Observer'; |
|
| 1390 | + } elseif ($typec == 'GND') { |
|
| 1391 | + $data['type'] = 'Ground'; |
|
| 1392 | + } elseif ($typec == 'DEL') { |
|
| 1393 | + $data['type'] = 'Delivery'; |
|
| 1394 | + } elseif ($typec == 'DEP') { |
|
| 1395 | + $data['type'] = 'Departure'; |
|
| 1396 | + } elseif ($typec == 'FSS') { |
|
| 1397 | + $data['type'] = 'Flight Service Station'; |
|
| 1398 | + } elseif ($typec == 'CTR') { |
|
| 1399 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1400 | + } else { |
|
| 1401 | + $data['type'] = 'Observer'; |
|
| 1402 | + } |
|
| 1403 | + if (isset($ATC)) { |
|
| 1404 | + 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']); |
|
| 1405 | + } |
|
| 1015 | 1406 | } |
| 1016 | 1407 | unset($data); |
| 1017 | 1408 | } |
@@ -1021,7 +1412,9 @@ discard block |
||
| 1021 | 1412 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 1022 | 1413 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 1023 | 1414 | //$buffer = $Common->getData($hosts[$id]); |
| 1024 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1415 | + if ($globalDebug) { |
|
| 1416 | + echo 'Get Data...'."\n"; |
|
| 1417 | + } |
|
| 1025 | 1418 | $buffer = $Common->getData($value['host']); |
| 1026 | 1419 | $all_data = json_decode($buffer,true); |
| 1027 | 1420 | if ($buffer != '' && is_array($all_data)) { |
@@ -1029,10 +1422,16 @@ discard block |
||
| 1029 | 1422 | foreach ($all_data as $line) { |
| 1030 | 1423 | $data = array(); |
| 1031 | 1424 | //$data['id'] = $line['id']; // id not usable |
| 1032 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1425 | + if (isset($line['pilotid'])) { |
|
| 1426 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1427 | + } |
|
| 1033 | 1428 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1034 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1035 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1429 | + if (isset($line['pilotname'])) { |
|
| 1430 | + $data['pilot_name'] = $line['pilotname']; |
|
| 1431 | + } |
|
| 1432 | + if (isset($line['pilotid'])) { |
|
| 1433 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1434 | + } |
|
| 1036 | 1435 | $data['ident'] = $line['flightnum']; // ident |
| 1037 | 1436 | $data['altitude'] = $line['alt']; // altitude |
| 1038 | 1437 | $data['speed'] = $line['gs']; // speed |
@@ -1048,34 +1447,52 @@ discard block |
||
| 1048 | 1447 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
| 1049 | 1448 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1050 | 1449 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1051 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1450 | + } else { |
|
| 1451 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1452 | + } |
|
| 1052 | 1453 | $data['departure_airport_icao'] = $line['depicao']; |
| 1053 | 1454 | $data['departure_airport_time'] = $line['deptime']; |
| 1054 | 1455 | $data['arrival_airport_icao'] = $line['arricao']; |
| 1055 | 1456 | $data['arrival_airport_time'] = $line['arrtime']; |
| 1056 | 1457 | $data['registration'] = $line['aircraft']; |
| 1057 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1058 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1458 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1459 | + $data['noarchive'] = true; |
|
| 1460 | + } |
|
| 1461 | + if (isset($line['route'])) { |
|
| 1462 | + $data['waypoints'] = $line['route']; |
|
| 1463 | + } |
|
| 1464 | + // route |
|
| 1059 | 1465 | if (isset($line['aircraftname'])) { |
| 1060 | 1466 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1061 | 1467 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1062 | 1468 | $aircraft_data = explode('-',$line['aircraftname']); |
| 1063 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1064 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1065 | - else { |
|
| 1469 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 1470 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1471 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 1472 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1473 | + } else { |
|
| 1066 | 1474 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 1067 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1068 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1475 | + if (isset($aircraft_data[1])) { |
|
| 1476 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1477 | + } else { |
|
| 1478 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1479 | + } |
|
| 1069 | 1480 | } |
| 1070 | 1481 | } |
| 1071 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1482 | + if (isset($line['route'])) { |
|
| 1483 | + $data['waypoints'] = $line['route']; |
|
| 1484 | + } |
|
| 1072 | 1485 | $data['id_source'] = $id_source; |
| 1073 | 1486 | $data['format_source'] = 'phpvmacars'; |
| 1074 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1487 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1488 | + $data['source_name'] = $value['name']; |
|
| 1489 | + } |
|
| 1075 | 1490 | $SI->add($data); |
| 1076 | 1491 | unset($data); |
| 1077 | 1492 | } |
| 1078 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1493 | + if ($globalDebug) { |
|
| 1494 | + echo 'No more data...'."\n"; |
|
| 1495 | + } |
|
| 1079 | 1496 | unset($buffer); |
| 1080 | 1497 | unset($all_data); |
| 1081 | 1498 | } |
@@ -1083,7 +1500,9 @@ discard block |
||
| 1083 | 1500 | $last_exec[$id]['last'] = time(); |
| 1084 | 1501 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 1085 | 1502 | //$buffer = $Common->getData($hosts[$id]); |
| 1086 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1503 | + if ($globalDebug) { |
|
| 1504 | + echo 'Get Data...'."\n"; |
|
| 1505 | + } |
|
| 1087 | 1506 | $buffer = $Common->getData($value['host']); |
| 1088 | 1507 | $all_data = json_decode($buffer,true); |
| 1089 | 1508 | if ($buffer != '' && is_array($all_data)) { |
@@ -1112,16 +1531,25 @@ discard block |
||
| 1112 | 1531 | $data['arrival_airport_icao'] = $line['arrival']; |
| 1113 | 1532 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 1114 | 1533 | //$data['registration'] = $line['aircraft']; |
| 1115 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1534 | + if (isset($line['route'])) { |
|
| 1535 | + $data['waypoints'] = $line['route']; |
|
| 1536 | + } |
|
| 1537 | + // route |
|
| 1116 | 1538 | $data['aircraft_icao'] = $line['plane_type']; |
| 1117 | 1539 | $data['id_source'] = $id_source; |
| 1118 | 1540 | $data['format_source'] = 'vam'; |
| 1119 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1120 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1541 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1542 | + $data['noarchive'] = true; |
|
| 1543 | + } |
|
| 1544 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1545 | + $data['source_name'] = $value['name']; |
|
| 1546 | + } |
|
| 1121 | 1547 | $SI->add($data); |
| 1122 | 1548 | unset($data); |
| 1123 | 1549 | } |
| 1124 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1550 | + if ($globalDebug) { |
|
| 1551 | + echo 'No more data...'."\n"; |
|
| 1552 | + } |
|
| 1125 | 1553 | unset($buffer); |
| 1126 | 1554 | unset($all_data); |
| 1127 | 1555 | } |
@@ -1129,7 +1557,9 @@ discard block |
||
| 1129 | 1557 | $last_exec[$id]['last'] = time(); |
| 1130 | 1558 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 1131 | 1559 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
| 1132 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1560 | + if (function_exists('pcntl_fork')) { |
|
| 1561 | + pcntl_signal_dispatch(); |
|
| 1562 | + } |
|
| 1133 | 1563 | //$last_exec[$id]['last'] = time(); |
| 1134 | 1564 | |
| 1135 | 1565 | //$read = array( $sockets[$id] ); |
@@ -1137,7 +1567,9 @@ discard block |
||
| 1137 | 1567 | $write = NULL; |
| 1138 | 1568 | $e = NULL; |
| 1139 | 1569 | $n = socket_select($read, $write, $e, $timeout); |
| 1140 | - if ($e != NULL) var_dump($e); |
|
| 1570 | + if ($e != NULL) { |
|
| 1571 | + var_dump($e); |
|
| 1572 | + } |
|
| 1141 | 1573 | if ($n > 0) { |
| 1142 | 1574 | $reset = 0; |
| 1143 | 1575 | foreach ($read as $nb => $r) { |
@@ -1158,12 +1590,16 @@ discard block |
||
| 1158 | 1590 | //$SI::del(); |
| 1159 | 1591 | if ($format == 'vrstcp') { |
| 1160 | 1592 | $buffer = explode('},{',$buffer); |
| 1161 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1593 | + } else { |
|
| 1594 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1595 | + } |
|
| 1162 | 1596 | // SBS format is CSV format |
| 1163 | 1597 | if ($buffer !== FALSE && $buffer != '') { |
| 1164 | 1598 | $tt[$format] = 0; |
| 1165 | 1599 | if ($format == 'acarssbs3') { |
| 1166 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1600 | + if ($globalDebug) { |
|
| 1601 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1602 | + } |
|
| 1167 | 1603 | $ACARS->add(trim($buffer)); |
| 1168 | 1604 | $ACARS->deleteLiveAcarsData(); |
| 1169 | 1605 | } elseif ($format == 'raw') { |
@@ -1172,30 +1608,70 @@ discard block |
||
| 1172 | 1608 | if (is_array($data)) { |
| 1173 | 1609 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1174 | 1610 | $data['format_source'] = 'raw'; |
| 1175 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1176 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1177 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1178 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1611 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1612 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1613 | + } |
|
| 1614 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1615 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1616 | + } |
|
| 1617 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1618 | + $data['noarchive'] = true; |
|
| 1619 | + } |
|
| 1620 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1621 | + $SI->add($data); |
|
| 1622 | + } |
|
| 1179 | 1623 | } |
| 1180 | 1624 | } elseif ($format == 'ais') { |
| 1181 | 1625 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1182 | 1626 | $data = array(); |
| 1183 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1184 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1185 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1186 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1187 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1188 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1189 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1190 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1191 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1192 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1193 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1194 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1195 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1196 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1197 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1198 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1627 | + if (isset($ais_data['ident'])) { |
|
| 1628 | + $data['ident'] = $ais_data['ident']; |
|
| 1629 | + } |
|
| 1630 | + if (isset($ais_data['mmsi'])) { |
|
| 1631 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 1632 | + } |
|
| 1633 | + if (isset($ais_data['speed'])) { |
|
| 1634 | + $data['speed'] = $ais_data['speed']; |
|
| 1635 | + } |
|
| 1636 | + if (isset($ais_data['heading'])) { |
|
| 1637 | + $data['heading'] = $ais_data['heading']; |
|
| 1638 | + } |
|
| 1639 | + if (isset($ais_data['latitude'])) { |
|
| 1640 | + $data['latitude'] = $ais_data['latitude']; |
|
| 1641 | + } |
|
| 1642 | + if (isset($ais_data['longitude'])) { |
|
| 1643 | + $data['longitude'] = $ais_data['longitude']; |
|
| 1644 | + } |
|
| 1645 | + if (isset($ais_data['status'])) { |
|
| 1646 | + $data['status'] = $ais_data['status']; |
|
| 1647 | + } |
|
| 1648 | + if (isset($ais_data['statusid'])) { |
|
| 1649 | + $data['status_id'] = $ais_data['statusid']; |
|
| 1650 | + } |
|
| 1651 | + if (isset($ais_data['type'])) { |
|
| 1652 | + $data['type'] = $ais_data['type']; |
|
| 1653 | + } |
|
| 1654 | + if (isset($ais_data['imo'])) { |
|
| 1655 | + $data['imo'] = $ais_data['imo']; |
|
| 1656 | + } |
|
| 1657 | + if (isset($ais_data['callsign'])) { |
|
| 1658 | + $data['callsign'] = $ais_data['callsign']; |
|
| 1659 | + } |
|
| 1660 | + if (isset($ais_data['destination'])) { |
|
| 1661 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 1662 | + } |
|
| 1663 | + if (isset($ais_data['eta_ts'])) { |
|
| 1664 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1665 | + } |
|
| 1666 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1667 | + $data['noarchive'] = true; |
|
| 1668 | + } |
|
| 1669 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1670 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1671 | + } |
|
| 1672 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1673 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1674 | + } |
|
| 1199 | 1675 | |
| 1200 | 1676 | if (isset($ais_data['timestamp'])) { |
| 1201 | 1677 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1204,7 +1680,9 @@ discard block |
||
| 1204 | 1680 | } |
| 1205 | 1681 | $data['format_source'] = 'aisnmea'; |
| 1206 | 1682 | $data['id_source'] = $id_source; |
| 1207 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1683 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 1684 | + $MI->add($data); |
|
| 1685 | + } |
|
| 1208 | 1686 | unset($data); |
| 1209 | 1687 | } elseif ($format == 'flightgearsp') { |
| 1210 | 1688 | //echo $buffer."\n"; |
@@ -1222,12 +1700,18 @@ discard block |
||
| 1222 | 1700 | $data['speed'] = round($line[5]*1.94384); |
| 1223 | 1701 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1224 | 1702 | $data['format_source'] = 'flightgearsp'; |
| 1225 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1226 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1703 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1704 | + $data['noarchive'] = true; |
|
| 1705 | + } |
|
| 1706 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1707 | + $SI->add($data); |
|
| 1708 | + } |
|
| 1227 | 1709 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1228 | 1710 | } |
| 1229 | 1711 | } elseif ($format == 'acars') { |
| 1230 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1712 | + if ($globalDebug) { |
|
| 1713 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1714 | + } |
|
| 1231 | 1715 | $ACARS->add(trim($buffer)); |
| 1232 | 1716 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1233 | 1717 | $ACARS->deleteLiveAcarsData(); |
@@ -1248,8 +1732,12 @@ discard block |
||
| 1248 | 1732 | $aircraft_type = $line[10]; |
| 1249 | 1733 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1250 | 1734 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1251 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1252 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1735 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1736 | + $data['noarchive'] = true; |
|
| 1737 | + } |
|
| 1738 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1739 | + $SI->add($data); |
|
| 1740 | + } |
|
| 1253 | 1741 | } |
| 1254 | 1742 | } |
| 1255 | 1743 | } elseif ($format == 'beast') { |
@@ -1259,28 +1747,62 @@ discard block |
||
| 1259 | 1747 | foreach($buffer as $all_data) { |
| 1260 | 1748 | $line = json_decode('{'.$all_data.'}',true); |
| 1261 | 1749 | $data = array(); |
| 1262 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1263 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1264 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1265 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1266 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1267 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1268 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1750 | + if (isset($line['Icao'])) { |
|
| 1751 | + $data['hex'] = $line['Icao']; |
|
| 1752 | + } |
|
| 1753 | + // hex |
|
| 1754 | + if (isset($line['Call'])) { |
|
| 1755 | + $data['ident'] = $line['Call']; |
|
| 1756 | + } |
|
| 1757 | + // ident |
|
| 1758 | + if (isset($line['Alt'])) { |
|
| 1759 | + $data['altitude'] = $line['Alt']; |
|
| 1760 | + } |
|
| 1761 | + // altitude |
|
| 1762 | + if (isset($line['Spd'])) { |
|
| 1763 | + $data['speed'] = $line['Spd']; |
|
| 1764 | + } |
|
| 1765 | + // speed |
|
| 1766 | + if (isset($line['Trak'])) { |
|
| 1767 | + $data['heading'] = $line['Trak']; |
|
| 1768 | + } |
|
| 1769 | + // heading |
|
| 1770 | + if (isset($line['Lat'])) { |
|
| 1771 | + $data['latitude'] = $line['Lat']; |
|
| 1772 | + } |
|
| 1773 | + // lat |
|
| 1774 | + if (isset($line['Long'])) { |
|
| 1775 | + $data['longitude'] = $line['Long']; |
|
| 1776 | + } |
|
| 1777 | + // long |
|
| 1269 | 1778 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1270 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1779 | + if (isset($line['Sqk'])) { |
|
| 1780 | + $data['squawk'] = $line['Sqk']; |
|
| 1781 | + } |
|
| 1782 | + // squawk |
|
| 1271 | 1783 | $data['emergency'] = ''; // emergency |
| 1272 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1784 | + if (isset($line['Reg'])) { |
|
| 1785 | + $data['registration'] = $line['Reg']; |
|
| 1786 | + } |
|
| 1273 | 1787 | /* |
| 1274 | 1788 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1275 | 1789 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1276 | 1790 | */ |
| 1277 | 1791 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1278 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1792 | + if (isset($line['Type'])) { |
|
| 1793 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1794 | + } |
|
| 1279 | 1795 | $data['format_source'] = 'vrstcp'; |
| 1280 | 1796 | $data['id_source'] = $id_source; |
| 1281 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1282 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1283 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 1797 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1798 | + $data['noarchive'] = true; |
|
| 1799 | + } |
|
| 1800 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1801 | + $data['source_name'] = $value['name']; |
|
| 1802 | + } |
|
| 1803 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 1804 | + $SI->add($data); |
|
| 1805 | + } |
|
| 1284 | 1806 | unset($data); |
| 1285 | 1807 | } |
| 1286 | 1808 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1293,22 +1815,46 @@ discard block |
||
| 1293 | 1815 | $data['hex'] = $lined['hexid']; |
| 1294 | 1816 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1295 | 1817 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1296 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1297 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1298 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1299 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1300 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1301 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1302 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1818 | + if (isset($lined['ident'])) { |
|
| 1819 | + $data['ident'] = $lined['ident']; |
|
| 1820 | + } |
|
| 1821 | + if (isset($lined['lat'])) { |
|
| 1822 | + $data['latitude'] = $lined['lat']; |
|
| 1823 | + } |
|
| 1824 | + if (isset($lined['lon'])) { |
|
| 1825 | + $data['longitude'] = $lined['lon']; |
|
| 1826 | + } |
|
| 1827 | + if (isset($lined['speed'])) { |
|
| 1828 | + $data['speed'] = $lined['speed']; |
|
| 1829 | + } |
|
| 1830 | + if (isset($lined['squawk'])) { |
|
| 1831 | + $data['squawk'] = $lined['squawk']; |
|
| 1832 | + } |
|
| 1833 | + if (isset($lined['alt'])) { |
|
| 1834 | + $data['altitude'] = $lined['alt']; |
|
| 1835 | + } |
|
| 1836 | + if (isset($lined['heading'])) { |
|
| 1837 | + $data['heading'] = $lined['heading']; |
|
| 1838 | + } |
|
| 1303 | 1839 | $data['id_source'] = $id_source; |
| 1304 | 1840 | $data['format_source'] = 'tsv'; |
| 1305 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1306 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1307 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1308 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1841 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1842 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1843 | + } |
|
| 1844 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1845 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1846 | + } |
|
| 1847 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1848 | + $data['noarchive'] = true; |
|
| 1849 | + } |
|
| 1850 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1851 | + $SI->add($data); |
|
| 1852 | + } |
|
| 1309 | 1853 | unset($lined); |
| 1310 | 1854 | unset($data); |
| 1311 | - } else $error = true; |
|
| 1855 | + } else { |
|
| 1856 | + $error = true; |
|
| 1857 | + } |
|
| 1312 | 1858 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1313 | 1859 | if ($aprs_connect == 0) { |
| 1314 | 1860 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1333,53 +1879,107 @@ discard block |
||
| 1333 | 1879 | $aprs_last_tx = time(); |
| 1334 | 1880 | $data = array(); |
| 1335 | 1881 | //print_r($line); |
| 1336 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1337 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1338 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1339 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1340 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
| 1341 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
| 1342 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
| 1343 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
| 1344 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1345 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1882 | + if (isset($line['address'])) { |
|
| 1883 | + $data['hex'] = $line['address']; |
|
| 1884 | + } |
|
| 1885 | + if (isset($line['mmsi'])) { |
|
| 1886 | + $data['mmsi'] = $line['mmsi']; |
|
| 1887 | + } |
|
| 1888 | + if (isset($line['imo'])) { |
|
| 1889 | + $data['imo'] = $line['imo']; |
|
| 1890 | + } |
|
| 1891 | + if (isset($line['squawk'])) { |
|
| 1892 | + $data['squawk'] = $line['squawk']; |
|
| 1893 | + } |
|
| 1894 | + if (isset($line['arrival_code'])) { |
|
| 1895 | + $data['arrical_code'] = $line['arrival_code']; |
|
| 1896 | + } |
|
| 1897 | + if (isset($line['arrival_date'])) { |
|
| 1898 | + $data['arrical_date'] = $line['arrival_date']; |
|
| 1899 | + } |
|
| 1900 | + if (isset($line['type_id'])) { |
|
| 1901 | + $data['type_id'] = $line['typeid']; |
|
| 1902 | + } |
|
| 1903 | + if (isset($line['status_id'])) { |
|
| 1904 | + $data['status_id'] = $line['statusid']; |
|
| 1905 | + } |
|
| 1906 | + if (isset($line['timestamp'])) { |
|
| 1907 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1908 | + } else { |
|
| 1909 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1910 | + } |
|
| 1346 | 1911 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1347 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1912 | + if (isset($line['ident'])) { |
|
| 1913 | + $data['ident'] = $line['ident']; |
|
| 1914 | + } |
|
| 1348 | 1915 | $data['latitude'] = $line['latitude']; |
| 1349 | 1916 | $data['longitude'] = $line['longitude']; |
| 1350 | 1917 | //$data['verticalrate'] = $line[16]; |
| 1351 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1918 | + if (isset($line['speed'])) { |
|
| 1919 | + $data['speed'] = $line['speed']; |
|
| 1920 | + } |
|
| 1352 | 1921 | //else $data['speed'] = 0; |
| 1353 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1354 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1355 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1356 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1922 | + if (isset($line['altitude'])) { |
|
| 1923 | + $data['altitude'] = $line['altitude']; |
|
| 1924 | + } |
|
| 1925 | + if (isset($line['comment'])) { |
|
| 1926 | + $data['comment'] = $line['comment']; |
|
| 1927 | + } |
|
| 1928 | + if (isset($line['symbol'])) { |
|
| 1929 | + $data['type'] = $line['symbol']; |
|
| 1930 | + } |
|
| 1931 | + if (isset($line['heading'])) { |
|
| 1932 | + $data['heading'] = $line['heading']; |
|
| 1933 | + } |
|
| 1357 | 1934 | //else $data['heading'] = 0; |
| 1358 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1935 | + if (isset($line['stealth'])) { |
|
| 1936 | + $data['aircraft_type'] = $line['stealth']; |
|
| 1937 | + } |
|
| 1359 | 1938 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
| 1360 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1361 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1362 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1363 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1939 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
| 1940 | + $data['noarchive'] = true; |
|
| 1941 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
| 1942 | + $data['noarchive'] = false; |
|
| 1943 | + } |
|
| 1944 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1945 | + $data['noarchive'] = true; |
|
| 1946 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
| 1947 | + $data['noarchive'] = false; |
|
| 1948 | + } |
|
| 1364 | 1949 | $data['id_source'] = $id_source; |
| 1365 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1366 | - else $data['format_source'] = 'aprs'; |
|
| 1950 | + if (isset($line['format_source'])) { |
|
| 1951 | + $data['format_source'] = $line['format_source']; |
|
| 1952 | + } else { |
|
| 1953 | + $data['format_source'] = 'aprs'; |
|
| 1954 | + } |
|
| 1367 | 1955 | $data['source_name'] = $line['source']; |
| 1368 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1369 | - else $data['source_type'] = 'flarm'; |
|
| 1370 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1956 | + if (isset($line['source_type'])) { |
|
| 1957 | + $data['source_type'] = $line['source_type']; |
|
| 1958 | + } else { |
|
| 1959 | + $data['source_type'] = 'flarm'; |
|
| 1960 | + } |
|
| 1961 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1962 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1963 | + } |
|
| 1371 | 1964 | $currentdate = date('Y-m-d H:i:s'); |
| 1372 | 1965 | $aprsdate = strtotime($data['datetime']); |
| 1373 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1966 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
| 1967 | + $data['altitude_relative'] = 'AMSL'; |
|
| 1968 | + } |
|
| 1374 | 1969 | // Accept data if time <= system time + 20s |
| 1375 | 1970 | //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'])))) { |
| 1376 | 1971 | if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 1377 | 1972 | $send = $SI->add($data); |
| 1378 | 1973 | } elseif ($data['source_type'] == 'ais') { |
| 1379 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
| 1974 | + if (isset($globalMarine) && $globalMarine) { |
|
| 1975 | + $send = $MI->add($data); |
|
| 1976 | + } |
|
| 1380 | 1977 | } elseif (isset($line['stealth'])) { |
| 1381 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1382 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1978 | + if ($line['stealth'] != 0) { |
|
| 1979 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1980 | + } else { |
|
| 1981 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1982 | + } |
|
| 1383 | 1983 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
| 1384 | 1984 | $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
| 1385 | 1985 | $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
@@ -1413,9 +2013,13 @@ discard block |
||
| 1413 | 2013 | //} 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') { |
| 1414 | 2014 | // } 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') { |
| 1415 | 2015 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1416 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 2016 | + if (isset($globalTracker) && $globalTracker) { |
|
| 2017 | + $send = $TI->add($data); |
|
| 2018 | + } |
|
| 1417 | 2019 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
| 1418 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
| 2020 | + if (!isset($data['altitude'])) { |
|
| 2021 | + $data['altitude'] = 0; |
|
| 2022 | + } |
|
| 1419 | 2023 | $Source->deleteOldLocationByType('gs'); |
| 1420 | 2024 | if (count($Source->getLocationInfoByName($data['ident'])) > 0) { |
| 1421 | 2025 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1427,12 +2031,9 @@ discard block |
||
| 1427 | 2031 | print_r($line); |
| 1428 | 2032 | } |
| 1429 | 2033 | unset($data); |
| 1430 | - } |
|
| 1431 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 2034 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1432 | 2035 | echo '!! Weather Station not yet supported'."\n"; |
| 1433 | - } |
|
| 1434 | - |
|
| 1435 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2036 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 1436 | 2037 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
| 1437 | 2038 | } |
| 1438 | 2039 | /* |
@@ -1441,7 +2042,9 @@ discard block |
||
| 1441 | 2042 | } |
| 1442 | 2043 | */ |
| 1443 | 2044 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 1444 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
| 2045 | + elseif ($line == true && $globalDebug) { |
|
| 2046 | + echo '!! Failed : '.$buffer."!!\n"; |
|
| 2047 | + } |
|
| 1445 | 2048 | } |
| 1446 | 2049 | } else { |
| 1447 | 2050 | $line = explode(',', $buffer); |
@@ -1470,26 +2073,45 @@ discard block |
||
| 1470 | 2073 | $data['ground'] = $line[21]; |
| 1471 | 2074 | $data['emergency'] = $line[19]; |
| 1472 | 2075 | $data['format_source'] = 'sbs'; |
| 1473 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1474 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1475 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2076 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2077 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2078 | + } |
|
| 2079 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2080 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2081 | + } |
|
| 2082 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2083 | + $data['noarchive'] = true; |
|
| 2084 | + } |
|
| 1476 | 2085 | $data['id_source'] = $id_source; |
| 1477 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1478 | - else $error = true; |
|
| 2086 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2087 | + $send = $SI->add($data); |
|
| 2088 | + } else { |
|
| 2089 | + $error = true; |
|
| 2090 | + } |
|
| 1479 | 2091 | unset($data); |
| 1480 | - } else $error = true; |
|
| 2092 | + } else { |
|
| 2093 | + $error = true; |
|
| 2094 | + } |
|
| 1481 | 2095 | if ($error) { |
| 1482 | 2096 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1483 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 2097 | + if ($globalDebug) { |
|
| 2098 | + echo "Not a message. Ignoring... \n"; |
|
| 2099 | + } |
|
| 1484 | 2100 | } else { |
| 1485 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 2101 | + if ($globalDebug) { |
|
| 2102 | + echo "Wrong line format. Ignoring... \n"; |
|
| 2103 | + } |
|
| 1486 | 2104 | if ($globalDebug) { |
| 1487 | 2105 | echo $buffer; |
| 1488 | 2106 | //print_r($line); |
| 1489 | 2107 | } |
| 1490 | 2108 | //socket_close($r); |
| 1491 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 1492 | - if ($format == 'aprs') $aprs_connect = 0; |
|
| 2109 | + if ($globalDebug) { |
|
| 2110 | + echo "Reconnect after an error...\n"; |
|
| 2111 | + } |
|
| 2112 | + if ($format == 'aprs') { |
|
| 2113 | + $aprs_connect = 0; |
|
| 2114 | + } |
|
| 1493 | 2115 | $sourceer[$nb] = $globalSources[$nb]; |
| 1494 | 2116 | connect_all($sourceer); |
| 1495 | 2117 | $sourceer = array(); |
@@ -1497,10 +2119,14 @@ discard block |
||
| 1497 | 2119 | } |
| 1498 | 2120 | } |
| 1499 | 2121 | // Sleep for xxx microseconds |
| 1500 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 2122 | + if (isset($globalSBSSleep)) { |
|
| 2123 | + usleep($globalSBSSleep); |
|
| 2124 | + } |
|
| 1501 | 2125 | } else { |
| 1502 | 2126 | if ($format == 'flightgearmp') { |
| 1503 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2127 | + if ($globalDebug) { |
|
| 2128 | + echo "Reconnect FlightGear MP..."; |
|
| 2129 | + } |
|
| 1504 | 2130 | //@socket_close($r); |
| 1505 | 2131 | sleep($globalMinFetch); |
| 1506 | 2132 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1509,10 +2135,15 @@ discard block |
||
| 1509 | 2135 | break; |
| 1510 | 2136 | |
| 1511 | 2137 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1512 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1513 | - else $tt[$format] = 0; |
|
| 2138 | + if (isset($tt[$format])) { |
|
| 2139 | + $tt[$format]++; |
|
| 2140 | + } else { |
|
| 2141 | + $tt[$format] = 0; |
|
| 2142 | + } |
|
| 1514 | 2143 | if ($tt[$format] > 30) { |
| 1515 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 2144 | + if ($globalDebug) { |
|
| 2145 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 2146 | + } |
|
| 1516 | 2147 | //@socket_close($r); |
| 1517 | 2148 | sleep(2); |
| 1518 | 2149 | $aprs_connect = 0; |
@@ -1529,11 +2160,17 @@ discard block |
||
| 1529 | 2160 | } else { |
| 1530 | 2161 | $error = socket_strerror(socket_last_error()); |
| 1531 | 2162 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1532 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1533 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 2163 | + if ($globalDebug) { |
|
| 2164 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2165 | + } |
|
| 2166 | + if (isset($globalDebug)) { |
|
| 2167 | + echo "Restarting...\n"; |
|
| 2168 | + } |
|
| 1534 | 2169 | // Restart the script if possible |
| 1535 | 2170 | if (is_array($sockets)) { |
| 1536 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2171 | + if ($globalDebug) { |
|
| 2172 | + echo "Shutdown all sockets..."; |
|
| 2173 | + } |
|
| 1537 | 2174 | |
| 1538 | 2175 | foreach ($sockets as $sock) { |
| 1539 | 2176 | @socket_shutdown($sock,2); |
@@ -1541,25 +2178,45 @@ discard block |
||
| 1541 | 2178 | } |
| 1542 | 2179 | |
| 1543 | 2180 | } |
| 1544 | - if ($globalDebug) echo "Waiting..."; |
|
| 2181 | + if ($globalDebug) { |
|
| 2182 | + echo "Waiting..."; |
|
| 2183 | + } |
|
| 1545 | 2184 | sleep(2); |
| 1546 | 2185 | $time = time(); |
| 1547 | 2186 | //connect_all($hosts); |
| 1548 | 2187 | $aprs_connect = 0; |
| 1549 | - if ($reset%5 == 0) sleep(20); |
|
| 1550 | - if ($reset%10 == 0) sleep(100); |
|
| 1551 | - if ($reset%20 == 0) sleep(200); |
|
| 1552 | - if ($reset > 100) exit('Too many attempts...'); |
|
| 1553 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 2188 | + if ($reset%5 == 0) { |
|
| 2189 | + sleep(20); |
|
| 2190 | + } |
|
| 2191 | + if ($reset%10 == 0) { |
|
| 2192 | + sleep(100); |
|
| 2193 | + } |
|
| 2194 | + if ($reset%20 == 0) { |
|
| 2195 | + sleep(200); |
|
| 2196 | + } |
|
| 2197 | + if ($reset > 100) { |
|
| 2198 | + exit('Too many attempts...'); |
|
| 2199 | + } |
|
| 2200 | + if ($globalDebug) { |
|
| 2201 | + echo "Restart all connections..."; |
|
| 2202 | + } |
|
| 1554 | 2203 | connect_all($globalSources); |
| 1555 | 2204 | } |
| 1556 | 2205 | } |
| 1557 | 2206 | } |
| 1558 | 2207 | if ($globalDaemon === false) { |
| 1559 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1560 | - if (isset($SI)) $SI->checkAll(); |
|
| 1561 | - if (isset($TI)) $TI->checkAll(); |
|
| 1562 | - if (isset($MI)) $MI->checkAll(); |
|
| 2208 | + if ($globalDebug) { |
|
| 2209 | + echo 'Check all...'."\n"; |
|
| 2210 | + } |
|
| 2211 | + if (isset($SI)) { |
|
| 2212 | + $SI->checkAll(); |
|
| 2213 | + } |
|
| 2214 | + if (isset($TI)) { |
|
| 2215 | + $TI->checkAll(); |
|
| 2216 | + } |
|
| 2217 | + if (isset($MI)) { |
|
| 2218 | + $MI->checkAll(); |
|
| 2219 | + } |
|
| 1563 | 2220 | } |
| 1564 | 2221 | } |
| 1565 | 2222 | } |
@@ -76,38 +76,38 @@ discard block |
||
| 76 | 76 | try { |
| 77 | 77 | //$Connection = new Connection(); |
| 78 | 78 | $sth = $Connection->db->prepare($query); |
| 79 | - $sth->execute(array(':source' => $database_file)); |
|
| 80 | - } catch(PDOException $e) { |
|
| 81 | - return "error : ".$e->getMessage(); |
|
| 82 | - } |
|
| 79 | + $sth->execute(array(':source' => $database_file)); |
|
| 80 | + } catch(PDOException $e) { |
|
| 81 | + return "error : ".$e->getMessage(); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 85 | - update_db::connect_sqlite($database_file); |
|
| 84 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 85 | + update_db::connect_sqlite($database_file); |
|
| 86 | 86 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
| 87 | 87 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
| 88 | 88 | try { |
| 89 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 90 | - $sth->execute(); |
|
| 91 | - } catch(PDOException $e) { |
|
| 92 | - return "error : ".$e->getMessage(); |
|
| 93 | - } |
|
| 89 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 90 | + $sth->execute(); |
|
| 91 | + } catch(PDOException $e) { |
|
| 92 | + return "error : ".$e->getMessage(); |
|
| 93 | + } |
|
| 94 | 94 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
| 95 | 95 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
| 96 | 96 | $Connection = new Connection(); |
| 97 | 97 | $sth_dest = $Connection->db->prepare($query_dest); |
| 98 | 98 | try { |
| 99 | 99 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 100 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 100 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 101 | 101 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 102 | 102 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 103 | 103 | $sth_dest->execute($query_dest_values); |
| 104 | - } |
|
| 104 | + } |
|
| 105 | 105 | if ($globalTransaction) $Connection->db->commit(); |
| 106 | 106 | } catch(PDOException $e) { |
| 107 | 107 | if ($globalTransaction) $Connection->db->rollBack(); |
| 108 | 108 | return "error : ".$e->getMessage(); |
| 109 | 109 | } |
| 110 | - return ''; |
|
| 110 | + return ''; |
|
| 111 | 111 | } |
| 112 | 112 | public static function retrieve_route_oneworld($database_file) { |
| 113 | 113 | global $globalDebug, $globalTransaction; |
@@ -118,12 +118,12 @@ discard block |
||
| 118 | 118 | try { |
| 119 | 119 | //$Connection = new Connection(); |
| 120 | 120 | $sth = $Connection->db->prepare($query); |
| 121 | - $sth->execute(array(':source' => 'oneworld')); |
|
| 122 | - } catch(PDOException $e) { |
|
| 123 | - return "error : ".$e->getMessage(); |
|
| 124 | - } |
|
| 121 | + $sth->execute(array(':source' => 'oneworld')); |
|
| 122 | + } catch(PDOException $e) { |
|
| 123 | + return "error : ".$e->getMessage(); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 126 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 127 | 127 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 128 | 128 | $Spotter = new Spotter(); |
| 129 | 129 | if ($fh = fopen($database_file,"r")) { |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | if ($globalTransaction) $Connection->db->commit(); |
| 149 | 149 | } |
| 150 | - return ''; |
|
| 150 | + return ''; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | public static function retrieve_route_skyteam($database_file) { |
@@ -159,12 +159,12 @@ discard block |
||
| 159 | 159 | try { |
| 160 | 160 | //$Connection = new Connection(); |
| 161 | 161 | $sth = $Connection->db->prepare($query); |
| 162 | - $sth->execute(array(':source' => 'skyteam')); |
|
| 163 | - } catch(PDOException $e) { |
|
| 164 | - return "error : ".$e->getMessage(); |
|
| 165 | - } |
|
| 162 | + $sth->execute(array(':source' => 'skyteam')); |
|
| 163 | + } catch(PDOException $e) { |
|
| 164 | + return "error : ".$e->getMessage(); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 167 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 168 | 168 | |
| 169 | 169 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 170 | 170 | $Spotter = new Spotter(); |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | return "error : ".$e->getMessage(); |
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | - return ''; |
|
| 193 | + return ''; |
|
| 194 | 194 | } |
| 195 | 195 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
| 196 | 196 | global $globalTransaction; |
@@ -199,27 +199,27 @@ discard block |
||
| 199 | 199 | try { |
| 200 | 200 | $Connection = new Connection(); |
| 201 | 201 | $sth = $Connection->db->prepare($query); |
| 202 | - $sth->execute(array(':source' => $database_file)); |
|
| 203 | - } catch(PDOException $e) { |
|
| 204 | - return "error : ".$e->getMessage(); |
|
| 205 | - } |
|
| 202 | + $sth->execute(array(':source' => $database_file)); |
|
| 203 | + } catch(PDOException $e) { |
|
| 204 | + return "error : ".$e->getMessage(); |
|
| 205 | + } |
|
| 206 | 206 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
| 207 | 207 | try { |
| 208 | 208 | $Connection = new Connection(); |
| 209 | 209 | $sth = $Connection->db->prepare($query); |
| 210 | - $sth->execute(array(':source' => $database_file)); |
|
| 211 | - } catch(PDOException $e) { |
|
| 212 | - return "error : ".$e->getMessage(); |
|
| 213 | - } |
|
| 210 | + $sth->execute(array(':source' => $database_file)); |
|
| 211 | + } catch(PDOException $e) { |
|
| 212 | + return "error : ".$e->getMessage(); |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - update_db::connect_sqlite($database_file); |
|
| 215 | + update_db::connect_sqlite($database_file); |
|
| 216 | 216 | $query = 'select * from Aircraft'; |
| 217 | 217 | try { |
| 218 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 219 | - $sth->execute(); |
|
| 220 | - } catch(PDOException $e) { |
|
| 221 | - return "error : ".$e->getMessage(); |
|
| 222 | - } |
|
| 218 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 219 | + $sth->execute(); |
|
| 220 | + } catch(PDOException $e) { |
|
| 221 | + return "error : ".$e->getMessage(); |
|
| 222 | + } |
|
| 223 | 223 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 224 | 224 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
| 225 | 225 | |
@@ -230,17 +230,17 @@ discard block |
||
| 230 | 230 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 231 | 231 | try { |
| 232 | 232 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 233 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 233 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 234 | 234 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 235 | 235 | if ($values['UserString4'] == 'M') $type = 'military'; |
| 236 | 236 | else $type = null; |
| 237 | 237 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 238 | 238 | $sth_dest->execute($query_dest_values); |
| 239 | 239 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
| 240 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 241 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
| 240 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 241 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
| 242 | 242 | } |
| 243 | - } |
|
| 243 | + } |
|
| 244 | 244 | if ($globalTransaction) $Connection->db->commit(); |
| 245 | 245 | } catch(PDOException $e) { |
| 246 | 246 | return "error : ".$e->getMessage(); |
@@ -251,10 +251,10 @@ discard block |
||
| 251 | 251 | try { |
| 252 | 252 | $Connection = new Connection(); |
| 253 | 253 | $sth = $Connection->db->prepare($query); |
| 254 | - $sth->execute(array(':source' => $database_file)); |
|
| 255 | - } catch(PDOException $e) { |
|
| 256 | - return "error : ".$e->getMessage(); |
|
| 257 | - } |
|
| 254 | + $sth->execute(array(':source' => $database_file)); |
|
| 255 | + } catch(PDOException $e) { |
|
| 256 | + return "error : ".$e->getMessage(); |
|
| 257 | + } |
|
| 258 | 258 | return ''; |
| 259 | 259 | } |
| 260 | 260 | |
@@ -266,10 +266,10 @@ discard block |
||
| 266 | 266 | try { |
| 267 | 267 | $Connection = new Connection(); |
| 268 | 268 | $sth = $Connection->db->prepare($query); |
| 269 | - $sth->execute(array(':source' => $database_file)); |
|
| 270 | - } catch(PDOException $e) { |
|
| 271 | - return "error : ".$e->getMessage(); |
|
| 272 | - } |
|
| 269 | + $sth->execute(array(':source' => $database_file)); |
|
| 270 | + } catch(PDOException $e) { |
|
| 271 | + return "error : ".$e->getMessage(); |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | 274 | if ($fh = fopen($database_file,"r")) { |
| 275 | 275 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -279,26 +279,26 @@ discard block |
||
| 279 | 279 | $sth_dest = $Connection->db->prepare($query_dest); |
| 280 | 280 | try { |
| 281 | 281 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 282 | - while (!feof($fh)) { |
|
| 283 | - $values = array(); |
|
| 284 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
| 282 | + while (!feof($fh)) { |
|
| 283 | + $values = array(); |
|
| 284 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
| 285 | 285 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 286 | - $values['ModeS'] = substr($line,0,6); |
|
| 287 | - $values['Registration'] = trim(substr($line,69,6)); |
|
| 288 | - $aircraft_name = trim(substr($line,48,6)); |
|
| 289 | - // Check if we can find ICAO, else set it to GLID |
|
| 290 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 291 | - $search_more = ''; |
|
| 292 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 293 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 294 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 286 | + $values['ModeS'] = substr($line,0,6); |
|
| 287 | + $values['Registration'] = trim(substr($line,69,6)); |
|
| 288 | + $aircraft_name = trim(substr($line,48,6)); |
|
| 289 | + // Check if we can find ICAO, else set it to GLID |
|
| 290 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 291 | + $search_more = ''; |
|
| 292 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 293 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 294 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 295 | 295 | try { |
| 296 | - $sth_search->execute(); |
|
| 297 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 298 | - //if (count($result) > 0) { |
|
| 299 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
| 300 | - $values['ICAOTypeCode'] = $result['icao']; |
|
| 301 | - } |
|
| 296 | + $sth_search->execute(); |
|
| 297 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 298 | + //if (count($result) > 0) { |
|
| 299 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 300 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 301 | + } |
|
| 302 | 302 | } catch(PDOException $e) { |
| 303 | 303 | return "error : ".$e->getMessage(); |
| 304 | 304 | } |
@@ -321,10 +321,10 @@ discard block |
||
| 321 | 321 | try { |
| 322 | 322 | $Connection = new Connection(); |
| 323 | 323 | $sth = $Connection->db->prepare($query); |
| 324 | - $sth->execute(array(':source' => $database_file)); |
|
| 325 | - } catch(PDOException $e) { |
|
| 326 | - return "error : ".$e->getMessage(); |
|
| 327 | - } |
|
| 324 | + $sth->execute(array(':source' => $database_file)); |
|
| 325 | + } catch(PDOException $e) { |
|
| 326 | + return "error : ".$e->getMessage(); |
|
| 327 | + } |
|
| 328 | 328 | return ''; |
| 329 | 329 | } |
| 330 | 330 | |
@@ -335,10 +335,10 @@ discard block |
||
| 335 | 335 | try { |
| 336 | 336 | $Connection = new Connection(); |
| 337 | 337 | $sth = $Connection->db->prepare($query); |
| 338 | - $sth->execute(array(':source' => $database_file)); |
|
| 339 | - } catch(PDOException $e) { |
|
| 340 | - return "error : ".$e->getMessage(); |
|
| 341 | - } |
|
| 338 | + $sth->execute(array(':source' => $database_file)); |
|
| 339 | + } catch(PDOException $e) { |
|
| 340 | + return "error : ".$e->getMessage(); |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | 343 | if ($fh = fopen($database_file,"r")) { |
| 344 | 344 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -349,25 +349,25 @@ discard block |
||
| 349 | 349 | try { |
| 350 | 350 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 351 | 351 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 352 | - while (!feof($fh)) { |
|
| 353 | - $line = fgetcsv($fh,9999,',',"'"); |
|
| 352 | + while (!feof($fh)) { |
|
| 353 | + $line = fgetcsv($fh,9999,',',"'"); |
|
| 354 | 354 | |
| 355 | 355 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 356 | 356 | //print_r($line); |
| 357 | - $values['ModeS'] = $line[1]; |
|
| 358 | - $values['Registration'] = $line[3]; |
|
| 359 | - $values['ICAOTypeCode'] = ''; |
|
| 360 | - $aircraft_name = $line[2]; |
|
| 361 | - // Check if we can find ICAO, else set it to GLID |
|
| 362 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 363 | - $search_more = ''; |
|
| 364 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 365 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 366 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 357 | + $values['ModeS'] = $line[1]; |
|
| 358 | + $values['Registration'] = $line[3]; |
|
| 359 | + $values['ICAOTypeCode'] = ''; |
|
| 360 | + $aircraft_name = $line[2]; |
|
| 361 | + // Check if we can find ICAO, else set it to GLID |
|
| 362 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 363 | + $search_more = ''; |
|
| 364 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 365 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 366 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 367 | 367 | try { |
| 368 | - $sth_search->execute(); |
|
| 369 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 370 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 368 | + $sth_search->execute(); |
|
| 369 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 370 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 371 | 371 | } catch(PDOException $e) { |
| 372 | 372 | return "error : ".$e->getMessage(); |
| 373 | 373 | } |
@@ -390,10 +390,10 @@ discard block |
||
| 390 | 390 | try { |
| 391 | 391 | $Connection = new Connection(); |
| 392 | 392 | $sth = $Connection->db->prepare($query); |
| 393 | - $sth->execute(array(':source' => $database_file)); |
|
| 394 | - } catch(PDOException $e) { |
|
| 395 | - return "error : ".$e->getMessage(); |
|
| 396 | - } |
|
| 393 | + $sth->execute(array(':source' => $database_file)); |
|
| 394 | + } catch(PDOException $e) { |
|
| 395 | + return "error : ".$e->getMessage(); |
|
| 396 | + } |
|
| 397 | 397 | return ''; |
| 398 | 398 | } |
| 399 | 399 | |
@@ -404,16 +404,16 @@ discard block |
||
| 404 | 404 | try { |
| 405 | 405 | $Connection = new Connection(); |
| 406 | 406 | $sth = $Connection->db->prepare($query); |
| 407 | - $sth->execute(array(':source' => $database_file)); |
|
| 408 | - } catch(PDOException $e) { |
|
| 409 | - return "error : ".$e->getMessage(); |
|
| 410 | - } |
|
| 407 | + $sth->execute(array(':source' => $database_file)); |
|
| 408 | + } catch(PDOException $e) { |
|
| 409 | + return "error : ".$e->getMessage(); |
|
| 410 | + } |
|
| 411 | 411 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 412 | 412 | $Spotter = new Spotter(); |
| 413 | 413 | if ($fh = fopen($database_file,"r")) { |
| 414 | 414 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 415 | 415 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 416 | - $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
| 416 | + $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
| 417 | 417 | |
| 418 | 418 | $Connection = new Connection(); |
| 419 | 419 | $sth_dest = $Connection->db->prepare($query_dest); |
@@ -421,126 +421,126 @@ discard block |
||
| 421 | 421 | try { |
| 422 | 422 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 423 | 423 | $tmp = fgetcsv($fh,9999,',','"'); |
| 424 | - while (!feof($fh)) { |
|
| 425 | - $line = fgetcsv($fh,9999,',','"'); |
|
| 426 | - $values = array(); |
|
| 427 | - //print_r($line); |
|
| 428 | - if ($country == 'F') { |
|
| 429 | - $values['registration'] = $line[0]; |
|
| 430 | - $values['base'] = $line[4]; |
|
| 431 | - $values['owner'] = $line[5]; |
|
| 432 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 433 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 434 | - $values['cancel'] = $line[7]; |
|
| 424 | + while (!feof($fh)) { |
|
| 425 | + $line = fgetcsv($fh,9999,',','"'); |
|
| 426 | + $values = array(); |
|
| 427 | + //print_r($line); |
|
| 428 | + if ($country == 'F') { |
|
| 429 | + $values['registration'] = $line[0]; |
|
| 430 | + $values['base'] = $line[4]; |
|
| 431 | + $values['owner'] = $line[5]; |
|
| 432 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 433 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 434 | + $values['cancel'] = $line[7]; |
|
| 435 | 435 | } elseif ($country == 'EI') { |
| 436 | - // TODO : add modeS & reg to aircraft_modes |
|
| 437 | - $values['registration'] = $line[0]; |
|
| 438 | - $values['base'] = $line[3]; |
|
| 439 | - $values['owner'] = $line[2]; |
|
| 440 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 441 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 442 | - $values['cancel'] = ''; |
|
| 443 | - $values['modes'] = $line[7]; |
|
| 444 | - $values['icao'] = $line[8]; |
|
| 436 | + // TODO : add modeS & reg to aircraft_modes |
|
| 437 | + $values['registration'] = $line[0]; |
|
| 438 | + $values['base'] = $line[3]; |
|
| 439 | + $values['owner'] = $line[2]; |
|
| 440 | + if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 441 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 442 | + $values['cancel'] = ''; |
|
| 443 | + $values['modes'] = $line[7]; |
|
| 444 | + $values['icao'] = $line[8]; |
|
| 445 | 445 | |
| 446 | 446 | } elseif ($country == 'HB') { |
| 447 | - // TODO : add modeS & reg to aircraft_modes |
|
| 448 | - $values['registration'] = $line[0]; |
|
| 449 | - $values['base'] = null; |
|
| 450 | - $values['owner'] = $line[5]; |
|
| 451 | - $values['date_first_reg'] = null; |
|
| 452 | - $values['cancel'] = ''; |
|
| 453 | - $values['modes'] = $line[4]; |
|
| 454 | - $values['icao'] = $line[7]; |
|
| 447 | + // TODO : add modeS & reg to aircraft_modes |
|
| 448 | + $values['registration'] = $line[0]; |
|
| 449 | + $values['base'] = null; |
|
| 450 | + $values['owner'] = $line[5]; |
|
| 451 | + $values['date_first_reg'] = null; |
|
| 452 | + $values['cancel'] = ''; |
|
| 453 | + $values['modes'] = $line[4]; |
|
| 454 | + $values['icao'] = $line[7]; |
|
| 455 | 455 | } elseif ($country == 'OK') { |
| 456 | - // TODO : add modeS & reg to aircraft_modes |
|
| 457 | - $values['registration'] = $line[3]; |
|
| 458 | - $values['base'] = null; |
|
| 459 | - $values['owner'] = $line[5]; |
|
| 460 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 461 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 462 | - $values['cancel'] = ''; |
|
| 456 | + // TODO : add modeS & reg to aircraft_modes |
|
| 457 | + $values['registration'] = $line[3]; |
|
| 458 | + $values['base'] = null; |
|
| 459 | + $values['owner'] = $line[5]; |
|
| 460 | + if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 461 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 462 | + $values['cancel'] = ''; |
|
| 463 | 463 | } elseif ($country == 'VH') { |
| 464 | - // TODO : add modeS & reg to aircraft_modes |
|
| 465 | - $values['registration'] = $line[0]; |
|
| 466 | - $values['base'] = null; |
|
| 467 | - $values['owner'] = $line[12]; |
|
| 468 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 469 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 470 | - |
|
| 471 | - $values['cancel'] = $line[39]; |
|
| 464 | + // TODO : add modeS & reg to aircraft_modes |
|
| 465 | + $values['registration'] = $line[0]; |
|
| 466 | + $values['base'] = null; |
|
| 467 | + $values['owner'] = $line[12]; |
|
| 468 | + if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 469 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 470 | + |
|
| 471 | + $values['cancel'] = $line[39]; |
|
| 472 | 472 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
| 473 | - $values['registration'] = $line[0]; |
|
| 474 | - $values['base'] = null; |
|
| 475 | - $values['owner'] = $line[4]; |
|
| 476 | - $values['date_first_reg'] = null; |
|
| 477 | - $values['cancel'] = ''; |
|
| 473 | + $values['registration'] = $line[0]; |
|
| 474 | + $values['base'] = null; |
|
| 475 | + $values['owner'] = $line[4]; |
|
| 476 | + $values['date_first_reg'] = null; |
|
| 477 | + $values['cancel'] = ''; |
|
| 478 | 478 | } elseif ($country == 'CC') { |
| 479 | - $values['registration'] = $line[0]; |
|
| 480 | - $values['base'] = null; |
|
| 481 | - $values['owner'] = $line[6]; |
|
| 482 | - $values['date_first_reg'] = null; |
|
| 483 | - $values['cancel'] = ''; |
|
| 479 | + $values['registration'] = $line[0]; |
|
| 480 | + $values['base'] = null; |
|
| 481 | + $values['owner'] = $line[6]; |
|
| 482 | + $values['date_first_reg'] = null; |
|
| 483 | + $values['cancel'] = ''; |
|
| 484 | 484 | } elseif ($country == 'HJ') { |
| 485 | - $values['registration'] = $line[0]; |
|
| 486 | - $values['base'] = null; |
|
| 487 | - $values['owner'] = $line[8]; |
|
| 488 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 489 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 490 | - $values['cancel'] = ''; |
|
| 485 | + $values['registration'] = $line[0]; |
|
| 486 | + $values['base'] = null; |
|
| 487 | + $values['owner'] = $line[8]; |
|
| 488 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 489 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 490 | + $values['cancel'] = ''; |
|
| 491 | 491 | } elseif ($country == 'PP') { |
| 492 | - $values['registration'] = $line[0]; |
|
| 493 | - $values['base'] = null; |
|
| 494 | - $values['owner'] = $line[4]; |
|
| 495 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 496 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 497 | - $values['cancel'] = $line[7]; |
|
| 492 | + $values['registration'] = $line[0]; |
|
| 493 | + $values['base'] = null; |
|
| 494 | + $values['owner'] = $line[4]; |
|
| 495 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 496 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 497 | + $values['cancel'] = $line[7]; |
|
| 498 | 498 | } elseif ($country == 'E7') { |
| 499 | - $values['registration'] = $line[0]; |
|
| 500 | - $values['base'] = null; |
|
| 501 | - $values['owner'] = $line[4]; |
|
| 502 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 503 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 504 | - $values['cancel'] = ''; |
|
| 499 | + $values['registration'] = $line[0]; |
|
| 500 | + $values['base'] = null; |
|
| 501 | + $values['owner'] = $line[4]; |
|
| 502 | + if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 503 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 504 | + $values['cancel'] = ''; |
|
| 505 | 505 | } elseif ($country == '8Q') { |
| 506 | - $values['registration'] = $line[0]; |
|
| 507 | - $values['base'] = null; |
|
| 508 | - $values['owner'] = $line[3]; |
|
| 509 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 510 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 511 | - $values['cancel'] = ''; |
|
| 506 | + $values['registration'] = $line[0]; |
|
| 507 | + $values['base'] = null; |
|
| 508 | + $values['owner'] = $line[3]; |
|
| 509 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 510 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 511 | + $values['cancel'] = ''; |
|
| 512 | 512 | } elseif ($country == 'ZK') { |
| 513 | - $values['registration'] = $line[0]; |
|
| 514 | - $values['base'] = null; |
|
| 515 | - $values['owner'] = $line[3]; |
|
| 516 | - $values['date_first_reg'] = null; |
|
| 517 | - $values['cancel'] = ''; |
|
| 518 | - $values['modes'] = $line[5]; |
|
| 519 | - $values['icao'] = $line[9]; |
|
| 513 | + $values['registration'] = $line[0]; |
|
| 514 | + $values['base'] = null; |
|
| 515 | + $values['owner'] = $line[3]; |
|
| 516 | + $values['date_first_reg'] = null; |
|
| 517 | + $values['cancel'] = ''; |
|
| 518 | + $values['modes'] = $line[5]; |
|
| 519 | + $values['icao'] = $line[9]; |
|
| 520 | 520 | } elseif ($country == 'M') { |
| 521 | - $values['registration'] = $line[0]; |
|
| 522 | - $values['base'] = null; |
|
| 523 | - $values['owner'] = $line[6]; |
|
| 524 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 525 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
| 526 | - $values['modes'] = $line[4]; |
|
| 527 | - $values['icao'] = $line[10]; |
|
| 521 | + $values['registration'] = $line[0]; |
|
| 522 | + $values['base'] = null; |
|
| 523 | + $values['owner'] = $line[6]; |
|
| 524 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 525 | + $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
| 526 | + $values['modes'] = $line[4]; |
|
| 527 | + $values['icao'] = $line[10]; |
|
| 528 | 528 | } elseif ($country == 'OY') { |
| 529 | - $values['registration'] = $line[0]; |
|
| 530 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
| 531 | - $values['modes'] = $line[5]; |
|
| 532 | - $values['icao'] = $line[6]; |
|
| 529 | + $values['registration'] = $line[0]; |
|
| 530 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
| 531 | + $values['modes'] = $line[5]; |
|
| 532 | + $values['icao'] = $line[6]; |
|
| 533 | 533 | } elseif ($country == 'PH') { |
| 534 | - $values['registration'] = $line[0]; |
|
| 535 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
| 536 | - $values['modes'] = $line[4]; |
|
| 537 | - $values['icao'] = $line[5]; |
|
| 534 | + $values['registration'] = $line[0]; |
|
| 535 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
| 536 | + $values['modes'] = $line[4]; |
|
| 537 | + $values['icao'] = $line[5]; |
|
| 538 | 538 | } elseif ($country == 'OM' || $country == 'TF') { |
| 539 | - $values['registration'] = $line[0]; |
|
| 540 | - $values['base'] = null; |
|
| 541 | - $values['owner'] = $line[3]; |
|
| 542 | - $values['date_first_reg'] = null; |
|
| 543 | - $values['cancel'] = ''; |
|
| 539 | + $values['registration'] = $line[0]; |
|
| 540 | + $values['base'] = null; |
|
| 541 | + $values['owner'] = $line[3]; |
|
| 542 | + $values['date_first_reg'] = null; |
|
| 543 | + $values['cancel'] = ''; |
|
| 544 | 544 | } |
| 545 | 545 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
| 546 | 546 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | return "error : ".$e->getMessage(); |
| 674 | 674 | } |
| 675 | 675 | */ |
| 676 | - /* |
|
| 676 | + /* |
|
| 677 | 677 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
| 678 | 678 | try { |
| 679 | 679 | $Connection = new Connection(); |
@@ -918,10 +918,10 @@ discard block |
||
| 918 | 918 | try { |
| 919 | 919 | $Connection = new Connection(); |
| 920 | 920 | $sth = $Connection->db->prepare($query); |
| 921 | - $sth->execute(array(':source' => 'translation.csv')); |
|
| 922 | - } catch(PDOException $e) { |
|
| 923 | - return "error : ".$e->getMessage(); |
|
| 924 | - } |
|
| 921 | + $sth->execute(array(':source' => 'translation.csv')); |
|
| 922 | + } catch(PDOException $e) { |
|
| 923 | + return "error : ".$e->getMessage(); |
|
| 924 | + } |
|
| 925 | 925 | |
| 926 | 926 | |
| 927 | 927 | //update_db::unzip($out_file); |
@@ -940,21 +940,21 @@ discard block |
||
| 940 | 940 | $data = $row; |
| 941 | 941 | $operator = $data[2]; |
| 942 | 942 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
| 943 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 944 | - //echo substr($operator, 0, 2)."\n";; |
|
| 945 | - if (count($airline_array) > 0) { |
|
| 943 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 944 | + //echo substr($operator, 0, 2)."\n";; |
|
| 945 | + if (count($airline_array) > 0) { |
|
| 946 | 946 | //print_r($airline_array); |
| 947 | 947 | $operator = $airline_array[0]['icao'].substr($operator,2); |
| 948 | - } |
|
| 949 | - } |
|
| 948 | + } |
|
| 949 | + } |
|
| 950 | 950 | |
| 951 | 951 | $operator_correct = $data[3]; |
| 952 | 952 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
| 953 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 954 | - if (count($airline_array) > 0) { |
|
| 955 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 956 | - } |
|
| 957 | - } |
|
| 953 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 954 | + if (count($airline_array) > 0) { |
|
| 955 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 956 | + } |
|
| 957 | + } |
|
| 958 | 958 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 959 | 959 | try { |
| 960 | 960 | $sth = $Connection->db->prepare($query); |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | //$Connection->db->commit(); |
| 969 | 969 | } |
| 970 | 970 | return ''; |
| 971 | - } |
|
| 971 | + } |
|
| 972 | 972 | |
| 973 | 973 | public static function translation_fam() { |
| 974 | 974 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -978,10 +978,10 @@ discard block |
||
| 978 | 978 | try { |
| 979 | 979 | $Connection = new Connection(); |
| 980 | 980 | $sth = $Connection->db->prepare($query); |
| 981 | - $sth->execute(array(':source' => 'website_fam')); |
|
| 982 | - } catch(PDOException $e) { |
|
| 983 | - return "error : ".$e->getMessage(); |
|
| 984 | - } |
|
| 981 | + $sth->execute(array(':source' => 'website_fam')); |
|
| 982 | + } catch(PDOException $e) { |
|
| 983 | + return "error : ".$e->getMessage(); |
|
| 984 | + } |
|
| 985 | 985 | |
| 986 | 986 | |
| 987 | 987 | //update_db::unzip($out_file); |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | //$Connection->db->commit(); |
| 1011 | 1011 | } |
| 1012 | 1012 | return ''; |
| 1013 | - } |
|
| 1013 | + } |
|
| 1014 | 1014 | |
| 1015 | 1015 | /* |
| 1016 | 1016 | * This function use FAA public data. |
@@ -1022,19 +1022,19 @@ discard block |
||
| 1022 | 1022 | try { |
| 1023 | 1023 | $Connection = new Connection(); |
| 1024 | 1024 | $sth = $Connection->db->prepare($query); |
| 1025 | - $sth->execute(array(':source' => 'website_faa')); |
|
| 1026 | - } catch(PDOException $e) { |
|
| 1027 | - return "error : ".$e->getMessage(); |
|
| 1028 | - } |
|
| 1025 | + $sth->execute(array(':source' => 'website_faa')); |
|
| 1026 | + } catch(PDOException $e) { |
|
| 1027 | + return "error : ".$e->getMessage(); |
|
| 1028 | + } |
|
| 1029 | 1029 | |
| 1030 | 1030 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; |
| 1031 | 1031 | try { |
| 1032 | 1032 | $Connection = new Connection(); |
| 1033 | 1033 | $sth = $Connection->db->prepare($query); |
| 1034 | - $sth->execute(array(':source' => 'website_faa')); |
|
| 1035 | - } catch(PDOException $e) { |
|
| 1036 | - return "error : ".$e->getMessage(); |
|
| 1037 | - } |
|
| 1034 | + $sth->execute(array(':source' => 'website_faa')); |
|
| 1035 | + } catch(PDOException $e) { |
|
| 1036 | + return "error : ".$e->getMessage(); |
|
| 1037 | + } |
|
| 1038 | 1038 | |
| 1039 | 1039 | $delimiter = ","; |
| 1040 | 1040 | $mfr = array(); |
@@ -1110,17 +1110,17 @@ discard block |
||
| 1110 | 1110 | } |
| 1111 | 1111 | print_r($mfr); |
| 1112 | 1112 | return ''; |
| 1113 | - } |
|
| 1113 | + } |
|
| 1114 | 1114 | public static function modes_fam() { |
| 1115 | 1115 | global $tmp_dir, $globalTransaction; |
| 1116 | 1116 | $query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source"; |
| 1117 | 1117 | try { |
| 1118 | 1118 | $Connection = new Connection(); |
| 1119 | 1119 | $sth = $Connection->db->prepare($query); |
| 1120 | - $sth->execute(array(':source' => 'website_fam')); |
|
| 1121 | - } catch(PDOException $e) { |
|
| 1122 | - return "error : ".$e->getMessage(); |
|
| 1123 | - } |
|
| 1120 | + $sth->execute(array(':source' => 'website_fam')); |
|
| 1121 | + } catch(PDOException $e) { |
|
| 1122 | + return "error : ".$e->getMessage(); |
|
| 1123 | + } |
|
| 1124 | 1124 | |
| 1125 | 1125 | |
| 1126 | 1126 | //update_db::unzip($out_file); |
@@ -1150,7 +1150,7 @@ discard block |
||
| 1150 | 1150 | if ($globalTransaction) $Connection->db->commit(); |
| 1151 | 1151 | } |
| 1152 | 1152 | return ''; |
| 1153 | - } |
|
| 1153 | + } |
|
| 1154 | 1154 | |
| 1155 | 1155 | public static function owner_fam() { |
| 1156 | 1156 | global $tmp_dir, $globalTransaction; |
@@ -1158,10 +1158,10 @@ discard block |
||
| 1158 | 1158 | try { |
| 1159 | 1159 | $Connection = new Connection(); |
| 1160 | 1160 | $sth = $Connection->db->prepare($query); |
| 1161 | - $sth->execute(array(':source' => 'website_fam')); |
|
| 1162 | - } catch(PDOException $e) { |
|
| 1163 | - return "error : ".$e->getMessage(); |
|
| 1164 | - } |
|
| 1161 | + $sth->execute(array(':source' => 'website_fam')); |
|
| 1162 | + } catch(PDOException $e) { |
|
| 1163 | + return "error : ".$e->getMessage(); |
|
| 1164 | + } |
|
| 1165 | 1165 | |
| 1166 | 1166 | $delimiter = "\t"; |
| 1167 | 1167 | $Connection = new Connection(); |
@@ -1187,7 +1187,7 @@ discard block |
||
| 1187 | 1187 | if ($globalTransaction) $Connection->db->commit(); |
| 1188 | 1188 | } |
| 1189 | 1189 | return ''; |
| 1190 | - } |
|
| 1190 | + } |
|
| 1191 | 1191 | |
| 1192 | 1192 | public static function routes_fam() { |
| 1193 | 1193 | global $tmp_dir, $globalTransaction, $globalDebug; |
@@ -1222,7 +1222,7 @@ discard block |
||
| 1222 | 1222 | if ($globalTransaction) $Connection->db->commit(); |
| 1223 | 1223 | } |
| 1224 | 1224 | return ''; |
| 1225 | - } |
|
| 1225 | + } |
|
| 1226 | 1226 | |
| 1227 | 1227 | public static function marine_identity_fam() { |
| 1228 | 1228 | global $tmp_dir, $globalTransaction; |
@@ -1230,10 +1230,10 @@ discard block |
||
| 1230 | 1230 | try { |
| 1231 | 1231 | $Connection = new Connection(); |
| 1232 | 1232 | $sth = $Connection->db->prepare($query); |
| 1233 | - $sth->execute(); |
|
| 1234 | - } catch(PDOException $e) { |
|
| 1235 | - return "error : ".$e->getMessage(); |
|
| 1236 | - } |
|
| 1233 | + $sth->execute(); |
|
| 1234 | + } catch(PDOException $e) { |
|
| 1235 | + return "error : ".$e->getMessage(); |
|
| 1236 | + } |
|
| 1237 | 1237 | |
| 1238 | 1238 | |
| 1239 | 1239 | //update_db::unzip($out_file); |
@@ -1263,7 +1263,7 @@ discard block |
||
| 1263 | 1263 | if ($globalTransaction) $Connection->db->commit(); |
| 1264 | 1264 | } |
| 1265 | 1265 | return ''; |
| 1266 | - } |
|
| 1266 | + } |
|
| 1267 | 1267 | |
| 1268 | 1268 | public static function banned_fam() { |
| 1269 | 1269 | global $tmp_dir, $globalTransaction; |
@@ -1297,7 +1297,7 @@ discard block |
||
| 1297 | 1297 | if ($globalTransaction) $Connection->db->commit(); |
| 1298 | 1298 | } |
| 1299 | 1299 | return ''; |
| 1300 | - } |
|
| 1300 | + } |
|
| 1301 | 1301 | |
| 1302 | 1302 | public static function tle($filename,$tletype) { |
| 1303 | 1303 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1308,10 +1308,10 @@ discard block |
||
| 1308 | 1308 | try { |
| 1309 | 1309 | $Connection = new Connection(); |
| 1310 | 1310 | $sth = $Connection->db->prepare($query); |
| 1311 | - $sth->execute(array(':source' => $filename)); |
|
| 1312 | - } catch(PDOException $e) { |
|
| 1313 | - return "error : ".$e->getMessage(); |
|
| 1314 | - } |
|
| 1311 | + $sth->execute(array(':source' => $filename)); |
|
| 1312 | + } catch(PDOException $e) { |
|
| 1313 | + return "error : ".$e->getMessage(); |
|
| 1314 | + } |
|
| 1315 | 1315 | |
| 1316 | 1316 | $Connection = new Connection(); |
| 1317 | 1317 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -1346,54 +1346,54 @@ discard block |
||
| 1346 | 1346 | //$Connection->db->commit(); |
| 1347 | 1347 | } |
| 1348 | 1348 | return ''; |
| 1349 | - } |
|
| 1349 | + } |
|
| 1350 | 1350 | |
| 1351 | 1351 | /** |
| 1352 | - * Convert a HTML table to an array |
|
| 1353 | - * @param String $data HTML page |
|
| 1354 | - * @return Array array of the tables in HTML page |
|
| 1355 | - */ |
|
| 1356 | - private static function table2array($data) { |
|
| 1357 | - $html = str_get_html($data); |
|
| 1358 | - $tabledata=array(); |
|
| 1359 | - foreach($html->find('tr') as $element) |
|
| 1360 | - { |
|
| 1361 | - $td = array(); |
|
| 1362 | - foreach( $element->find('th') as $row) |
|
| 1363 | - { |
|
| 1364 | - $td [] = trim($row->plaintext); |
|
| 1365 | - } |
|
| 1366 | - $td=array_filter($td); |
|
| 1367 | - $tabledata[] = $td; |
|
| 1368 | - |
|
| 1369 | - $td = array(); |
|
| 1370 | - $tdi = array(); |
|
| 1371 | - foreach( $element->find('td') as $row) |
|
| 1372 | - { |
|
| 1373 | - $td [] = trim($row->plaintext); |
|
| 1374 | - $tdi [] = trim($row->innertext); |
|
| 1375 | - } |
|
| 1376 | - $td=array_filter($td); |
|
| 1377 | - $tdi=array_filter($tdi); |
|
| 1378 | - // $tabledata[]=array_merge($td,$tdi); |
|
| 1379 | - $tabledata[]=$td; |
|
| 1380 | - } |
|
| 1381 | - return(array_filter($tabledata)); |
|
| 1382 | - } |
|
| 1383 | - |
|
| 1384 | - /** |
|
| 1385 | - * Get data from form result |
|
| 1386 | - * @param String $url form URL |
|
| 1387 | - * @return String the result |
|
| 1388 | - */ |
|
| 1389 | - private static function getData($url) { |
|
| 1390 | - $ch = curl_init(); |
|
| 1391 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
| 1392 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 1393 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 1394 | - curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
|
| 1395 | - return curl_exec($ch); |
|
| 1396 | - } |
|
| 1352 | + * Convert a HTML table to an array |
|
| 1353 | + * @param String $data HTML page |
|
| 1354 | + * @return Array array of the tables in HTML page |
|
| 1355 | + */ |
|
| 1356 | + private static function table2array($data) { |
|
| 1357 | + $html = str_get_html($data); |
|
| 1358 | + $tabledata=array(); |
|
| 1359 | + foreach($html->find('tr') as $element) |
|
| 1360 | + { |
|
| 1361 | + $td = array(); |
|
| 1362 | + foreach( $element->find('th') as $row) |
|
| 1363 | + { |
|
| 1364 | + $td [] = trim($row->plaintext); |
|
| 1365 | + } |
|
| 1366 | + $td=array_filter($td); |
|
| 1367 | + $tabledata[] = $td; |
|
| 1368 | + |
|
| 1369 | + $td = array(); |
|
| 1370 | + $tdi = array(); |
|
| 1371 | + foreach( $element->find('td') as $row) |
|
| 1372 | + { |
|
| 1373 | + $td [] = trim($row->plaintext); |
|
| 1374 | + $tdi [] = trim($row->innertext); |
|
| 1375 | + } |
|
| 1376 | + $td=array_filter($td); |
|
| 1377 | + $tdi=array_filter($tdi); |
|
| 1378 | + // $tabledata[]=array_merge($td,$tdi); |
|
| 1379 | + $tabledata[]=$td; |
|
| 1380 | + } |
|
| 1381 | + return(array_filter($tabledata)); |
|
| 1382 | + } |
|
| 1383 | + |
|
| 1384 | + /** |
|
| 1385 | + * Get data from form result |
|
| 1386 | + * @param String $url form URL |
|
| 1387 | + * @return String the result |
|
| 1388 | + */ |
|
| 1389 | + private static function getData($url) { |
|
| 1390 | + $ch = curl_init(); |
|
| 1391 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 1392 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 1393 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 1394 | + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
|
| 1395 | + return curl_exec($ch); |
|
| 1396 | + } |
|
| 1397 | 1397 | /* |
| 1398 | 1398 | public static function waypoints() { |
| 1399 | 1399 | $data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); |
@@ -1476,7 +1476,7 @@ discard block |
||
| 1476 | 1476 | if ($globalTransaction) $Connection->db->commit(); |
| 1477 | 1477 | } |
| 1478 | 1478 | return ''; |
| 1479 | - } |
|
| 1479 | + } |
|
| 1480 | 1480 | |
| 1481 | 1481 | public static function ivao_airlines($filename) { |
| 1482 | 1482 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1486,10 +1486,10 @@ discard block |
||
| 1486 | 1486 | try { |
| 1487 | 1487 | $Connection = new Connection(); |
| 1488 | 1488 | $sth = $Connection->db->prepare($query); |
| 1489 | - $sth->execute(); |
|
| 1490 | - } catch(PDOException $e) { |
|
| 1491 | - return "error : ".$e->getMessage(); |
|
| 1492 | - } |
|
| 1489 | + $sth->execute(); |
|
| 1490 | + } catch(PDOException $e) { |
|
| 1491 | + return "error : ".$e->getMessage(); |
|
| 1492 | + } |
|
| 1493 | 1493 | |
| 1494 | 1494 | $header = NULL; |
| 1495 | 1495 | $delimiter = ':'; |
@@ -1513,7 +1513,7 @@ discard block |
||
| 1513 | 1513 | if ($globalTransaction) $Connection->db->commit(); |
| 1514 | 1514 | } |
| 1515 | 1515 | return ''; |
| 1516 | - } |
|
| 1516 | + } |
|
| 1517 | 1517 | |
| 1518 | 1518 | public static function update_airspace() { |
| 1519 | 1519 | global $tmp_dir, $globalDBdriver; |
@@ -1523,11 +1523,11 @@ discard block |
||
| 1523 | 1523 | $query = 'DROP TABLE airspace'; |
| 1524 | 1524 | try { |
| 1525 | 1525 | $sth = $Connection->db->prepare($query); |
| 1526 | - $sth->execute(); |
|
| 1527 | - } catch(PDOException $e) { |
|
| 1526 | + $sth->execute(); |
|
| 1527 | + } catch(PDOException $e) { |
|
| 1528 | 1528 | return "error : ".$e->getMessage(); |
| 1529 | - } |
|
| 1530 | - } |
|
| 1529 | + } |
|
| 1530 | + } |
|
| 1531 | 1531 | |
| 1532 | 1532 | |
| 1533 | 1533 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -1582,10 +1582,10 @@ discard block |
||
| 1582 | 1582 | $query = 'DROP TABLE countries'; |
| 1583 | 1583 | try { |
| 1584 | 1584 | $sth = $Connection->db->prepare($query); |
| 1585 | - $sth->execute(); |
|
| 1586 | - } catch(PDOException $e) { |
|
| 1587 | - echo "error : ".$e->getMessage(); |
|
| 1588 | - } |
|
| 1585 | + $sth->execute(); |
|
| 1586 | + } catch(PDOException $e) { |
|
| 1587 | + echo "error : ".$e->getMessage(); |
|
| 1588 | + } |
|
| 1589 | 1589 | } |
| 1590 | 1590 | if ($globalDBdriver == 'mysql') { |
| 1591 | 1591 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -2114,11 +2114,11 @@ discard block |
||
| 2114 | 2114 | $query = 'DROP TABLE airspace'; |
| 2115 | 2115 | try { |
| 2116 | 2116 | $sth = $Connection->db->prepare($query); |
| 2117 | - $sth->execute(); |
|
| 2118 | - } catch(PDOException $e) { |
|
| 2117 | + $sth->execute(); |
|
| 2118 | + } catch(PDOException $e) { |
|
| 2119 | 2119 | return "error : ".$e->getMessage(); |
| 2120 | - } |
|
| 2121 | - } |
|
| 2120 | + } |
|
| 2121 | + } |
|
| 2122 | 2122 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 2123 | 2123 | update_db::insert_airspace_version($airspace_md5); |
| 2124 | 2124 | } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
@@ -2300,12 +2300,12 @@ discard block |
||
| 2300 | 2300 | echo $data; |
| 2301 | 2301 | */ |
| 2302 | 2302 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 2303 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 2304 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 2305 | - $result = fread($fh,100000000); |
|
| 2306 | - //echo $result; |
|
| 2307 | - //var_dump(str_get_html($result)); |
|
| 2308 | - //print_r(self::table2array($result)); |
|
| 2303 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 2304 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 2305 | + $result = fread($fh,100000000); |
|
| 2306 | + //echo $result; |
|
| 2307 | + //var_dump(str_get_html($result)); |
|
| 2308 | + //print_r(self::table2array($result)); |
|
| 2309 | 2309 | } |
| 2310 | 2310 | |
| 2311 | 2311 | } |
@@ -2319,10 +2319,10 @@ discard block |
||
| 2319 | 2319 | try { |
| 2320 | 2320 | $Connection = new Connection(); |
| 2321 | 2321 | $sth = $Connection->db->prepare($query); |
| 2322 | - $sth->execute(); |
|
| 2323 | - } catch(PDOException $e) { |
|
| 2324 | - return "error : ".$e->getMessage(); |
|
| 2325 | - } |
|
| 2322 | + $sth->execute(); |
|
| 2323 | + } catch(PDOException $e) { |
|
| 2324 | + return "error : ".$e->getMessage(); |
|
| 2325 | + } |
|
| 2326 | 2326 | |
| 2327 | 2327 | $error = ''; |
| 2328 | 2328 | if ($globalDebug) echo "Notam : Download..."; |
@@ -2378,8 +2378,8 @@ discard block |
||
| 2378 | 2378 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
| 2379 | 2379 | $data['permanent'] = 0; |
| 2380 | 2380 | } else { |
| 2381 | - $data['date_end'] = NULL; |
|
| 2382 | - $data['permanent'] = 1; |
|
| 2381 | + $data['date_end'] = NULL; |
|
| 2382 | + $data['permanent'] = 1; |
|
| 2383 | 2383 | } |
| 2384 | 2384 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 2385 | 2385 | $NOTAM = new NOTAM(); |
@@ -2453,13 +2453,13 @@ discard block |
||
| 2453 | 2453 | try { |
| 2454 | 2454 | $Connection = new Connection(); |
| 2455 | 2455 | $sth = $Connection->db->prepare($query); |
| 2456 | - $sth->execute(); |
|
| 2457 | - } catch(PDOException $e) { |
|
| 2458 | - return "error : ".$e->getMessage(); |
|
| 2459 | - } |
|
| 2460 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2461 | - if ($row['nb'] > 0) return false; |
|
| 2462 | - else return true; |
|
| 2456 | + $sth->execute(); |
|
| 2457 | + } catch(PDOException $e) { |
|
| 2458 | + return "error : ".$e->getMessage(); |
|
| 2459 | + } |
|
| 2460 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2461 | + if ($row['nb'] > 0) return false; |
|
| 2462 | + else return true; |
|
| 2463 | 2463 | } |
| 2464 | 2464 | |
| 2465 | 2465 | public static function insert_last_update() { |
@@ -2468,10 +2468,10 @@ discard block |
||
| 2468 | 2468 | try { |
| 2469 | 2469 | $Connection = new Connection(); |
| 2470 | 2470 | $sth = $Connection->db->prepare($query); |
| 2471 | - $sth->execute(); |
|
| 2472 | - } catch(PDOException $e) { |
|
| 2473 | - return "error : ".$e->getMessage(); |
|
| 2474 | - } |
|
| 2471 | + $sth->execute(); |
|
| 2472 | + } catch(PDOException $e) { |
|
| 2473 | + return "error : ".$e->getMessage(); |
|
| 2474 | + } |
|
| 2475 | 2475 | } |
| 2476 | 2476 | |
| 2477 | 2477 | public static function check_airspace_version($version) { |
@@ -2479,13 +2479,13 @@ discard block |
||
| 2479 | 2479 | try { |
| 2480 | 2480 | $Connection = new Connection(); |
| 2481 | 2481 | $sth = $Connection->db->prepare($query); |
| 2482 | - $sth->execute(array(':version' => $version)); |
|
| 2483 | - } catch(PDOException $e) { |
|
| 2484 | - return "error : ".$e->getMessage(); |
|
| 2485 | - } |
|
| 2486 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2487 | - if ($row['nb'] > 0) return true; |
|
| 2488 | - else return false; |
|
| 2482 | + $sth->execute(array(':version' => $version)); |
|
| 2483 | + } catch(PDOException $e) { |
|
| 2484 | + return "error : ".$e->getMessage(); |
|
| 2485 | + } |
|
| 2486 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2487 | + if ($row['nb'] > 0) return true; |
|
| 2488 | + else return false; |
|
| 2489 | 2489 | } |
| 2490 | 2490 | |
| 2491 | 2491 | public static function check_geoid_version($version) { |
@@ -2493,13 +2493,13 @@ discard block |
||
| 2493 | 2493 | try { |
| 2494 | 2494 | $Connection = new Connection(); |
| 2495 | 2495 | $sth = $Connection->db->prepare($query); |
| 2496 | - $sth->execute(array(':version' => $version)); |
|
| 2497 | - } catch(PDOException $e) { |
|
| 2498 | - return "error : ".$e->getMessage(); |
|
| 2499 | - } |
|
| 2500 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2501 | - if ($row['nb'] > 0) return true; |
|
| 2502 | - else return false; |
|
| 2496 | + $sth->execute(array(':version' => $version)); |
|
| 2497 | + } catch(PDOException $e) { |
|
| 2498 | + return "error : ".$e->getMessage(); |
|
| 2499 | + } |
|
| 2500 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2501 | + if ($row['nb'] > 0) return true; |
|
| 2502 | + else return false; |
|
| 2503 | 2503 | } |
| 2504 | 2504 | |
| 2505 | 2505 | public static function check_marine_identity_version($version) { |
@@ -2507,13 +2507,13 @@ discard block |
||
| 2507 | 2507 | try { |
| 2508 | 2508 | $Connection = new Connection(); |
| 2509 | 2509 | $sth = $Connection->db->prepare($query); |
| 2510 | - $sth->execute(array(':version' => $version)); |
|
| 2511 | - } catch(PDOException $e) { |
|
| 2512 | - return "error : ".$e->getMessage(); |
|
| 2513 | - } |
|
| 2514 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2515 | - if ($row['nb'] > 0) return true; |
|
| 2516 | - else return false; |
|
| 2510 | + $sth->execute(array(':version' => $version)); |
|
| 2511 | + } catch(PDOException $e) { |
|
| 2512 | + return "error : ".$e->getMessage(); |
|
| 2513 | + } |
|
| 2514 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2515 | + if ($row['nb'] > 0) return true; |
|
| 2516 | + else return false; |
|
| 2517 | 2517 | } |
| 2518 | 2518 | |
| 2519 | 2519 | |
@@ -2535,10 +2535,10 @@ discard block |
||
| 2535 | 2535 | try { |
| 2536 | 2536 | $Connection = new Connection(); |
| 2537 | 2537 | $sth = $Connection->db->prepare($query); |
| 2538 | - $sth->execute(array(':version' => $version)); |
|
| 2539 | - } catch(PDOException $e) { |
|
| 2540 | - return "error : ".$e->getMessage(); |
|
| 2541 | - } |
|
| 2538 | + $sth->execute(array(':version' => $version)); |
|
| 2539 | + } catch(PDOException $e) { |
|
| 2540 | + return "error : ".$e->getMessage(); |
|
| 2541 | + } |
|
| 2542 | 2542 | } |
| 2543 | 2543 | |
| 2544 | 2544 | public static function insert_marine_identity_version($version) { |
@@ -2547,10 +2547,10 @@ discard block |
||
| 2547 | 2547 | try { |
| 2548 | 2548 | $Connection = new Connection(); |
| 2549 | 2549 | $sth = $Connection->db->prepare($query); |
| 2550 | - $sth->execute(array(':version' => $version)); |
|
| 2551 | - } catch(PDOException $e) { |
|
| 2552 | - return "error : ".$e->getMessage(); |
|
| 2553 | - } |
|
| 2550 | + $sth->execute(array(':version' => $version)); |
|
| 2551 | + } catch(PDOException $e) { |
|
| 2552 | + return "error : ".$e->getMessage(); |
|
| 2553 | + } |
|
| 2554 | 2554 | } |
| 2555 | 2555 | |
| 2556 | 2556 | public static function check_last_notam_update() { |
@@ -2563,13 +2563,13 @@ discard block |
||
| 2563 | 2563 | try { |
| 2564 | 2564 | $Connection = new Connection(); |
| 2565 | 2565 | $sth = $Connection->db->prepare($query); |
| 2566 | - $sth->execute(); |
|
| 2567 | - } catch(PDOException $e) { |
|
| 2568 | - return "error : ".$e->getMessage(); |
|
| 2569 | - } |
|
| 2570 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2571 | - if ($row['nb'] > 0) return false; |
|
| 2572 | - else return true; |
|
| 2566 | + $sth->execute(); |
|
| 2567 | + } catch(PDOException $e) { |
|
| 2568 | + return "error : ".$e->getMessage(); |
|
| 2569 | + } |
|
| 2570 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2571 | + if ($row['nb'] > 0) return false; |
|
| 2572 | + else return true; |
|
| 2573 | 2573 | } |
| 2574 | 2574 | |
| 2575 | 2575 | public static function insert_last_notam_update() { |
@@ -2578,10 +2578,10 @@ discard block |
||
| 2578 | 2578 | try { |
| 2579 | 2579 | $Connection = new Connection(); |
| 2580 | 2580 | $sth = $Connection->db->prepare($query); |
| 2581 | - $sth->execute(); |
|
| 2582 | - } catch(PDOException $e) { |
|
| 2583 | - return "error : ".$e->getMessage(); |
|
| 2584 | - } |
|
| 2581 | + $sth->execute(); |
|
| 2582 | + } catch(PDOException $e) { |
|
| 2583 | + return "error : ".$e->getMessage(); |
|
| 2584 | + } |
|
| 2585 | 2585 | } |
| 2586 | 2586 | |
| 2587 | 2587 | public static function check_last_airspace_update() { |
@@ -2594,13 +2594,13 @@ discard block |
||
| 2594 | 2594 | try { |
| 2595 | 2595 | $Connection = new Connection(); |
| 2596 | 2596 | $sth = $Connection->db->prepare($query); |
| 2597 | - $sth->execute(); |
|
| 2598 | - } catch(PDOException $e) { |
|
| 2599 | - return "error : ".$e->getMessage(); |
|
| 2600 | - } |
|
| 2601 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2602 | - if ($row['nb'] > 0) return false; |
|
| 2603 | - else return true; |
|
| 2597 | + $sth->execute(); |
|
| 2598 | + } catch(PDOException $e) { |
|
| 2599 | + return "error : ".$e->getMessage(); |
|
| 2600 | + } |
|
| 2601 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2602 | + if ($row['nb'] > 0) return false; |
|
| 2603 | + else return true; |
|
| 2604 | 2604 | } |
| 2605 | 2605 | |
| 2606 | 2606 | public static function insert_last_airspace_update() { |
@@ -2609,10 +2609,10 @@ discard block |
||
| 2609 | 2609 | try { |
| 2610 | 2610 | $Connection = new Connection(); |
| 2611 | 2611 | $sth = $Connection->db->prepare($query); |
| 2612 | - $sth->execute(); |
|
| 2613 | - } catch(PDOException $e) { |
|
| 2614 | - return "error : ".$e->getMessage(); |
|
| 2615 | - } |
|
| 2612 | + $sth->execute(); |
|
| 2613 | + } catch(PDOException $e) { |
|
| 2614 | + return "error : ".$e->getMessage(); |
|
| 2615 | + } |
|
| 2616 | 2616 | } |
| 2617 | 2617 | |
| 2618 | 2618 | public static function check_last_geoid_update() { |
@@ -2625,13 +2625,13 @@ discard block |
||
| 2625 | 2625 | try { |
| 2626 | 2626 | $Connection = new Connection(); |
| 2627 | 2627 | $sth = $Connection->db->prepare($query); |
| 2628 | - $sth->execute(); |
|
| 2629 | - } catch(PDOException $e) { |
|
| 2630 | - return "error : ".$e->getMessage(); |
|
| 2631 | - } |
|
| 2632 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2633 | - if ($row['nb'] > 0) return false; |
|
| 2634 | - else return true; |
|
| 2628 | + $sth->execute(); |
|
| 2629 | + } catch(PDOException $e) { |
|
| 2630 | + return "error : ".$e->getMessage(); |
|
| 2631 | + } |
|
| 2632 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2633 | + if ($row['nb'] > 0) return false; |
|
| 2634 | + else return true; |
|
| 2635 | 2635 | } |
| 2636 | 2636 | |
| 2637 | 2637 | public static function insert_last_geoid_update() { |
@@ -2640,10 +2640,10 @@ discard block |
||
| 2640 | 2640 | try { |
| 2641 | 2641 | $Connection = new Connection(); |
| 2642 | 2642 | $sth = $Connection->db->prepare($query); |
| 2643 | - $sth->execute(); |
|
| 2644 | - } catch(PDOException $e) { |
|
| 2645 | - return "error : ".$e->getMessage(); |
|
| 2646 | - } |
|
| 2643 | + $sth->execute(); |
|
| 2644 | + } catch(PDOException $e) { |
|
| 2645 | + return "error : ".$e->getMessage(); |
|
| 2646 | + } |
|
| 2647 | 2647 | } |
| 2648 | 2648 | |
| 2649 | 2649 | public static function check_last_owner_update() { |
@@ -2656,13 +2656,13 @@ discard block |
||
| 2656 | 2656 | try { |
| 2657 | 2657 | $Connection = new Connection(); |
| 2658 | 2658 | $sth = $Connection->db->prepare($query); |
| 2659 | - $sth->execute(); |
|
| 2660 | - } catch(PDOException $e) { |
|
| 2661 | - return "error : ".$e->getMessage(); |
|
| 2662 | - } |
|
| 2663 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2664 | - if ($row['nb'] > 0) return false; |
|
| 2665 | - else return true; |
|
| 2659 | + $sth->execute(); |
|
| 2660 | + } catch(PDOException $e) { |
|
| 2661 | + return "error : ".$e->getMessage(); |
|
| 2662 | + } |
|
| 2663 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2664 | + if ($row['nb'] > 0) return false; |
|
| 2665 | + else return true; |
|
| 2666 | 2666 | } |
| 2667 | 2667 | |
| 2668 | 2668 | public static function insert_last_owner_update() { |
@@ -2671,10 +2671,10 @@ discard block |
||
| 2671 | 2671 | try { |
| 2672 | 2672 | $Connection = new Connection(); |
| 2673 | 2673 | $sth = $Connection->db->prepare($query); |
| 2674 | - $sth->execute(); |
|
| 2675 | - } catch(PDOException $e) { |
|
| 2676 | - return "error : ".$e->getMessage(); |
|
| 2677 | - } |
|
| 2674 | + $sth->execute(); |
|
| 2675 | + } catch(PDOException $e) { |
|
| 2676 | + return "error : ".$e->getMessage(); |
|
| 2677 | + } |
|
| 2678 | 2678 | } |
| 2679 | 2679 | public static function check_last_schedules_update() { |
| 2680 | 2680 | global $globalDBdriver; |
@@ -2686,13 +2686,13 @@ discard block |
||
| 2686 | 2686 | try { |
| 2687 | 2687 | $Connection = new Connection(); |
| 2688 | 2688 | $sth = $Connection->db->prepare($query); |
| 2689 | - $sth->execute(); |
|
| 2690 | - } catch(PDOException $e) { |
|
| 2691 | - return "error : ".$e->getMessage(); |
|
| 2692 | - } |
|
| 2693 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2694 | - if ($row['nb'] > 0) return false; |
|
| 2695 | - else return true; |
|
| 2689 | + $sth->execute(); |
|
| 2690 | + } catch(PDOException $e) { |
|
| 2691 | + return "error : ".$e->getMessage(); |
|
| 2692 | + } |
|
| 2693 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2694 | + if ($row['nb'] > 0) return false; |
|
| 2695 | + else return true; |
|
| 2696 | 2696 | } |
| 2697 | 2697 | |
| 2698 | 2698 | public static function insert_last_schedules_update() { |
@@ -2701,10 +2701,10 @@ discard block |
||
| 2701 | 2701 | try { |
| 2702 | 2702 | $Connection = new Connection(); |
| 2703 | 2703 | $sth = $Connection->db->prepare($query); |
| 2704 | - $sth->execute(); |
|
| 2705 | - } catch(PDOException $e) { |
|
| 2706 | - return "error : ".$e->getMessage(); |
|
| 2707 | - } |
|
| 2704 | + $sth->execute(); |
|
| 2705 | + } catch(PDOException $e) { |
|
| 2706 | + return "error : ".$e->getMessage(); |
|
| 2707 | + } |
|
| 2708 | 2708 | } |
| 2709 | 2709 | public static function check_last_tle_update() { |
| 2710 | 2710 | global $globalDBdriver; |
@@ -2716,13 +2716,13 @@ discard block |
||
| 2716 | 2716 | try { |
| 2717 | 2717 | $Connection = new Connection(); |
| 2718 | 2718 | $sth = $Connection->db->prepare($query); |
| 2719 | - $sth->execute(); |
|
| 2720 | - } catch(PDOException $e) { |
|
| 2721 | - return "error : ".$e->getMessage(); |
|
| 2722 | - } |
|
| 2723 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2724 | - if ($row['nb'] > 0) return false; |
|
| 2725 | - else return true; |
|
| 2719 | + $sth->execute(); |
|
| 2720 | + } catch(PDOException $e) { |
|
| 2721 | + return "error : ".$e->getMessage(); |
|
| 2722 | + } |
|
| 2723 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2724 | + if ($row['nb'] > 0) return false; |
|
| 2725 | + else return true; |
|
| 2726 | 2726 | } |
| 2727 | 2727 | |
| 2728 | 2728 | public static function insert_last_tle_update() { |
@@ -2731,10 +2731,10 @@ discard block |
||
| 2731 | 2731 | try { |
| 2732 | 2732 | $Connection = new Connection(); |
| 2733 | 2733 | $sth = $Connection->db->prepare($query); |
| 2734 | - $sth->execute(); |
|
| 2735 | - } catch(PDOException $e) { |
|
| 2736 | - return "error : ".$e->getMessage(); |
|
| 2737 | - } |
|
| 2734 | + $sth->execute(); |
|
| 2735 | + } catch(PDOException $e) { |
|
| 2736 | + return "error : ".$e->getMessage(); |
|
| 2737 | + } |
|
| 2738 | 2738 | } |
| 2739 | 2739 | public static function check_last_marine_identity_update() { |
| 2740 | 2740 | global $globalDBdriver; |
@@ -2746,13 +2746,13 @@ discard block |
||
| 2746 | 2746 | try { |
| 2747 | 2747 | $Connection = new Connection(); |
| 2748 | 2748 | $sth = $Connection->db->prepare($query); |
| 2749 | - $sth->execute(); |
|
| 2750 | - } catch(PDOException $e) { |
|
| 2751 | - return "error : ".$e->getMessage(); |
|
| 2752 | - } |
|
| 2753 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2754 | - if ($row['nb'] > 0) return false; |
|
| 2755 | - else return true; |
|
| 2749 | + $sth->execute(); |
|
| 2750 | + } catch(PDOException $e) { |
|
| 2751 | + return "error : ".$e->getMessage(); |
|
| 2752 | + } |
|
| 2753 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2754 | + if ($row['nb'] > 0) return false; |
|
| 2755 | + else return true; |
|
| 2756 | 2756 | } |
| 2757 | 2757 | |
| 2758 | 2758 | public static function insert_last_marine_identity_update() { |
@@ -2761,10 +2761,10 @@ discard block |
||
| 2761 | 2761 | try { |
| 2762 | 2762 | $Connection = new Connection(); |
| 2763 | 2763 | $sth = $Connection->db->prepare($query); |
| 2764 | - $sth->execute(); |
|
| 2765 | - } catch(PDOException $e) { |
|
| 2766 | - return "error : ".$e->getMessage(); |
|
| 2767 | - } |
|
| 2764 | + $sth->execute(); |
|
| 2765 | + } catch(PDOException $e) { |
|
| 2766 | + return "error : ".$e->getMessage(); |
|
| 2767 | + } |
|
| 2768 | 2768 | } |
| 2769 | 2769 | public static function delete_duplicatemodes() { |
| 2770 | 2770 | global $globalDBdriver; |
@@ -2776,10 +2776,10 @@ discard block |
||
| 2776 | 2776 | try { |
| 2777 | 2777 | $Connection = new Connection(); |
| 2778 | 2778 | $sth = $Connection->db->prepare($query); |
| 2779 | - $sth->execute(); |
|
| 2780 | - } catch(PDOException $e) { |
|
| 2781 | - return "error : ".$e->getMessage(); |
|
| 2782 | - } |
|
| 2779 | + $sth->execute(); |
|
| 2780 | + } catch(PDOException $e) { |
|
| 2781 | + return "error : ".$e->getMessage(); |
|
| 2782 | + } |
|
| 2783 | 2783 | } |
| 2784 | 2784 | public static function delete_duplicateowner() { |
| 2785 | 2785 | global $globalDBdriver; |
@@ -2791,10 +2791,10 @@ discard block |
||
| 2791 | 2791 | try { |
| 2792 | 2792 | $Connection = new Connection(); |
| 2793 | 2793 | $sth = $Connection->db->prepare($query); |
| 2794 | - $sth->execute(); |
|
| 2795 | - } catch(PDOException $e) { |
|
| 2796 | - return "error : ".$e->getMessage(); |
|
| 2797 | - } |
|
| 2794 | + $sth->execute(); |
|
| 2795 | + } catch(PDOException $e) { |
|
| 2796 | + return "error : ".$e->getMessage(); |
|
| 2797 | + } |
|
| 2798 | 2798 | } |
| 2799 | 2799 | |
| 2800 | 2800 | public static function update_all() { |
@@ -25,20 +25,20 @@ discard block |
||
| 25 | 25 | fclose($fp); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public static function gunzip($in_file,$out_file_name = '') { |
|
| 28 | + public static function gunzip($in_file, $out_file_name = '') { |
|
| 29 | 29 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 30 | 30 | $buffer_size = 4096; // read 4kb at a time |
| 31 | 31 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
| 32 | 32 | if ($in_file != '' && file_exists($in_file)) { |
| 33 | 33 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 34 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 35 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 34 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
| 35 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
| 36 | 36 | else { |
| 37 | 37 | echo 'gzopen not available'; |
| 38 | 38 | die; |
| 39 | 39 | } |
| 40 | 40 | $out_file = fopen($out_file_name, 'wb'); |
| 41 | - while(!gzeof($file)) { |
|
| 41 | + while (!gzeof($file)) { |
|
| 42 | 42 | fwrite($out_file, gzread($file, $buffer_size)); |
| 43 | 43 | } |
| 44 | 44 | fclose($out_file); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | try { |
| 63 | 63 | self::$db_sqlite = new PDO('sqlite:'.$database); |
| 64 | 64 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 65 | - } catch(PDOException $e) { |
|
| 65 | + } catch (PDOException $e) { |
|
| 66 | 66 | return "error : ".$e->getMessage(); |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | //$Connection = new Connection(); |
| 78 | 78 | $sth = $Connection->db->prepare($query); |
| 79 | 79 | $sth->execute(array(':source' => $database_file)); |
| 80 | - } catch(PDOException $e) { |
|
| 80 | + } catch (PDOException $e) { |
|
| 81 | 81 | return "error : ".$e->getMessage(); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | try { |
| 89 | 89 | $sth = update_db::$db_sqlite->prepare($query); |
| 90 | 90 | $sth->execute(); |
| 91 | - } catch(PDOException $e) { |
|
| 91 | + } catch (PDOException $e) { |
|
| 92 | 92 | return "error : ".$e->getMessage(); |
| 93 | 93 | } |
| 94 | 94 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 100 | 100 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 101 | 101 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 102 | - $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
|
| 102 | + $query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file); |
|
| 103 | 103 | $sth_dest->execute($query_dest_values); |
| 104 | 104 | } |
| 105 | 105 | if ($globalTransaction) $Connection->db->commit(); |
| 106 | - } catch(PDOException $e) { |
|
| 106 | + } catch (PDOException $e) { |
|
| 107 | 107 | if ($globalTransaction) $Connection->db->rollBack(); |
| 108 | 108 | return "error : ".$e->getMessage(); |
| 109 | 109 | } |
@@ -119,26 +119,26 @@ discard block |
||
| 119 | 119 | //$Connection = new Connection(); |
| 120 | 120 | $sth = $Connection->db->prepare($query); |
| 121 | 121 | $sth->execute(array(':source' => 'oneworld')); |
| 122 | - } catch(PDOException $e) { |
|
| 122 | + } catch (PDOException $e) { |
|
| 123 | 123 | return "error : ".$e->getMessage(); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | if ($globalDebug) echo " - Add routes to DB -"; |
| 127 | 127 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 128 | 128 | $Spotter = new Spotter(); |
| 129 | - if ($fh = fopen($database_file,"r")) { |
|
| 129 | + if ($fh = fopen($database_file, "r")) { |
|
| 130 | 130 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 131 | 131 | $Connection = new Connection(); |
| 132 | 132 | $sth_dest = $Connection->db->prepare($query_dest); |
| 133 | 133 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 134 | 134 | while (!feof($fh)) { |
| 135 | - $line = fgetcsv($fh,9999,','); |
|
| 135 | + $line = fgetcsv($fh, 9999, ','); |
|
| 136 | 136 | if ($line[0] != '') { |
| 137 | 137 | if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { |
| 138 | 138 | try { |
| 139 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
|
| 139 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld'); |
|
| 140 | 140 | $sth_dest->execute($query_dest_values); |
| 141 | - } catch(PDOException $e) { |
|
| 141 | + } catch (PDOException $e) { |
|
| 142 | 142 | if ($globalTransaction) $Connection->db->rollBack(); |
| 143 | 143 | return "error : ".$e->getMessage(); |
| 144 | 144 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | //$Connection = new Connection(); |
| 161 | 161 | $sth = $Connection->db->prepare($query); |
| 162 | 162 | $sth->execute(array(':source' => 'skyteam')); |
| 163 | - } catch(PDOException $e) { |
|
| 163 | + } catch (PDOException $e) { |
|
| 164 | 164 | return "error : ".$e->getMessage(); |
| 165 | 165 | } |
| 166 | 166 | |
@@ -168,24 +168,24 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 170 | 170 | $Spotter = new Spotter(); |
| 171 | - if ($fh = fopen($database_file,"r")) { |
|
| 171 | + if ($fh = fopen($database_file, "r")) { |
|
| 172 | 172 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 173 | 173 | $Connection = new Connection(); |
| 174 | 174 | $sth_dest = $Connection->db->prepare($query_dest); |
| 175 | 175 | try { |
| 176 | 176 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 177 | 177 | while (!feof($fh)) { |
| 178 | - $line = fgetcsv($fh,9999,','); |
|
| 178 | + $line = fgetcsv($fh, 9999, ','); |
|
| 179 | 179 | if ($line[0] != '') { |
| 180 | - $datebe = explode(' - ',$line[2]); |
|
| 180 | + $datebe = explode(' - ', $line[2]); |
|
| 181 | 181 | if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { |
| 182 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam'); |
|
| 182 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam'); |
|
| 183 | 183 | $sth_dest->execute($query_dest_values); |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | if ($globalTransaction) $Connection->db->commit(); |
| 188 | - } catch(PDOException $e) { |
|
| 188 | + } catch (PDOException $e) { |
|
| 189 | 189 | if ($globalTransaction) $Connection->db->rollBack(); |
| 190 | 190 | return "error : ".$e->getMessage(); |
| 191 | 191 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | $Connection = new Connection(); |
| 201 | 201 | $sth = $Connection->db->prepare($query); |
| 202 | 202 | $sth->execute(array(':source' => $database_file)); |
| 203 | - } catch(PDOException $e) { |
|
| 203 | + } catch (PDOException $e) { |
|
| 204 | 204 | return "error : ".$e->getMessage(); |
| 205 | 205 | } |
| 206 | 206 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $Connection = new Connection(); |
| 209 | 209 | $sth = $Connection->db->prepare($query); |
| 210 | 210 | $sth->execute(array(':source' => $database_file)); |
| 211 | - } catch(PDOException $e) { |
|
| 211 | + } catch (PDOException $e) { |
|
| 212 | 212 | return "error : ".$e->getMessage(); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | try { |
| 218 | 218 | $sth = update_db::$db_sqlite->prepare($query); |
| 219 | 219 | $sth->execute(); |
| 220 | - } catch(PDOException $e) { |
|
| 220 | + } catch (PDOException $e) { |
|
| 221 | 221 | return "error : ".$e->getMessage(); |
| 222 | 222 | } |
| 223 | 223 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -234,15 +234,15 @@ discard block |
||
| 234 | 234 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 235 | 235 | if ($values['UserString4'] == 'M') $type = 'military'; |
| 236 | 236 | else $type = null; |
| 237 | - $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
|
| 237 | + $query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type); |
|
| 238 | 238 | $sth_dest->execute($query_dest_values); |
| 239 | 239 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
| 240 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 240 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
| 241 | 241 | $sth_dest_owner->execute($query_dest_owner_values); |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | if ($globalTransaction) $Connection->db->commit(); |
| 245 | - } catch(PDOException $e) { |
|
| 245 | + } catch (PDOException $e) { |
|
| 246 | 246 | return "error : ".$e->getMessage(); |
| 247 | 247 | } |
| 248 | 248 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $Connection = new Connection(); |
| 253 | 253 | $sth = $Connection->db->prepare($query); |
| 254 | 254 | $sth->execute(array(':source' => $database_file)); |
| 255 | - } catch(PDOException $e) { |
|
| 255 | + } catch (PDOException $e) { |
|
| 256 | 256 | return "error : ".$e->getMessage(); |
| 257 | 257 | } |
| 258 | 258 | return ''; |
@@ -267,11 +267,11 @@ discard block |
||
| 267 | 267 | $Connection = new Connection(); |
| 268 | 268 | $sth = $Connection->db->prepare($query); |
| 269 | 269 | $sth->execute(array(':source' => $database_file)); |
| 270 | - } catch(PDOException $e) { |
|
| 270 | + } catch (PDOException $e) { |
|
| 271 | 271 | return "error : ".$e->getMessage(); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if ($fh = fopen($database_file,"r")) { |
|
| 274 | + if ($fh = fopen($database_file, "r")) { |
|
| 275 | 275 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 276 | 276 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
| 277 | 277 | |
@@ -281,13 +281,13 @@ discard block |
||
| 281 | 281 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 282 | 282 | while (!feof($fh)) { |
| 283 | 283 | $values = array(); |
| 284 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
| 284 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
| 285 | 285 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 286 | - $values['ModeS'] = substr($line,0,6); |
|
| 287 | - $values['Registration'] = trim(substr($line,69,6)); |
|
| 288 | - $aircraft_name = trim(substr($line,48,6)); |
|
| 286 | + $values['ModeS'] = substr($line, 0, 6); |
|
| 287 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
| 288 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
| 289 | 289 | // Check if we can find ICAO, else set it to GLID |
| 290 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 290 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
| 291 | 291 | $search_more = ''; |
| 292 | 292 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
| 293 | 293 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -299,20 +299,20 @@ discard block |
||
| 299 | 299 | if (isset($result['icao']) && $result['icao'] != '') { |
| 300 | 300 | $values['ICAOTypeCode'] = $result['icao']; |
| 301 | 301 | } |
| 302 | - } catch(PDOException $e) { |
|
| 302 | + } catch (PDOException $e) { |
|
| 303 | 303 | return "error : ".$e->getMessage(); |
| 304 | 304 | } |
| 305 | 305 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
| 306 | 306 | // Add data to db |
| 307 | 307 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
| 308 | 308 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 309 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); |
|
| 309 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); |
|
| 310 | 310 | //print_r($query_dest_values); |
| 311 | 311 | $sth_dest->execute($query_dest_values); |
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | if ($globalTransaction) $Connection->db->commit(); |
| 315 | - } catch(PDOException $e) { |
|
| 315 | + } catch (PDOException $e) { |
|
| 316 | 316 | return "error : ".$e->getMessage(); |
| 317 | 317 | } |
| 318 | 318 | } |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | $Connection = new Connection(); |
| 323 | 323 | $sth = $Connection->db->prepare($query); |
| 324 | 324 | $sth->execute(array(':source' => $database_file)); |
| 325 | - } catch(PDOException $e) { |
|
| 325 | + } catch (PDOException $e) { |
|
| 326 | 326 | return "error : ".$e->getMessage(); |
| 327 | 327 | } |
| 328 | 328 | return ''; |
@@ -336,11 +336,11 @@ discard block |
||
| 336 | 336 | $Connection = new Connection(); |
| 337 | 337 | $sth = $Connection->db->prepare($query); |
| 338 | 338 | $sth->execute(array(':source' => $database_file)); |
| 339 | - } catch(PDOException $e) { |
|
| 339 | + } catch (PDOException $e) { |
|
| 340 | 340 | return "error : ".$e->getMessage(); |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - if ($fh = fopen($database_file,"r")) { |
|
| 343 | + if ($fh = fopen($database_file, "r")) { |
|
| 344 | 344 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 345 | 345 | $query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
| 346 | 346 | |
@@ -348,9 +348,9 @@ discard block |
||
| 348 | 348 | $sth_dest = $Connection->db->prepare($query_dest); |
| 349 | 349 | try { |
| 350 | 350 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 351 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
| 351 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
| 352 | 352 | while (!feof($fh)) { |
| 353 | - $line = fgetcsv($fh,9999,',',"'"); |
|
| 353 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
| 354 | 354 | |
| 355 | 355 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 356 | 356 | //print_r($line); |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | $values['ICAOTypeCode'] = ''; |
| 360 | 360 | $aircraft_name = $line[2]; |
| 361 | 361 | // Check if we can find ICAO, else set it to GLID |
| 362 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 362 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
| 363 | 363 | $search_more = ''; |
| 364 | 364 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
| 365 | 365 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -368,20 +368,20 @@ discard block |
||
| 368 | 368 | $sth_search->execute(); |
| 369 | 369 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 370 | 370 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
| 371 | - } catch(PDOException $e) { |
|
| 371 | + } catch (PDOException $e) { |
|
| 372 | 372 | return "error : ".$e->getMessage(); |
| 373 | 373 | } |
| 374 | 374 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
| 375 | 375 | // Add data to db |
| 376 | 376 | if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
| 377 | 377 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 378 | - $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); |
|
| 378 | + $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); |
|
| 379 | 379 | //print_r($query_dest_values); |
| 380 | 380 | $sth_dest->execute($query_dest_values); |
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | if ($globalTransaction) $Connection->db->commit(); |
| 384 | - } catch(PDOException $e) { |
|
| 384 | + } catch (PDOException $e) { |
|
| 385 | 385 | return "error : ".$e->getMessage(); |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -391,13 +391,13 @@ discard block |
||
| 391 | 391 | $Connection = new Connection(); |
| 392 | 392 | $sth = $Connection->db->prepare($query); |
| 393 | 393 | $sth->execute(array(':source' => $database_file)); |
| 394 | - } catch(PDOException $e) { |
|
| 394 | + } catch (PDOException $e) { |
|
| 395 | 395 | return "error : ".$e->getMessage(); |
| 396 | 396 | } |
| 397 | 397 | return ''; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
| 400 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
| 401 | 401 | global $globalTransaction, $globalMasterSource; |
| 402 | 402 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
| 403 | 403 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;"; |
@@ -405,12 +405,12 @@ discard block |
||
| 405 | 405 | $Connection = new Connection(); |
| 406 | 406 | $sth = $Connection->db->prepare($query); |
| 407 | 407 | $sth->execute(array(':source' => $database_file)); |
| 408 | - } catch(PDOException $e) { |
|
| 408 | + } catch (PDOException $e) { |
|
| 409 | 409 | return "error : ".$e->getMessage(); |
| 410 | 410 | } |
| 411 | 411 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 412 | 412 | $Spotter = new Spotter(); |
| 413 | - if ($fh = fopen($database_file,"r")) { |
|
| 413 | + if ($fh = fopen($database_file, "r")) { |
|
| 414 | 414 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 415 | 415 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 416 | 416 | $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
@@ -420,9 +420,9 @@ discard block |
||
| 420 | 420 | $sth_modes = $Connection->db->prepare($query_modes); |
| 421 | 421 | try { |
| 422 | 422 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 423 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
| 423 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
| 424 | 424 | while (!feof($fh)) { |
| 425 | - $line = fgetcsv($fh,9999,',','"'); |
|
| 425 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
| 426 | 426 | $values = array(); |
| 427 | 427 | //print_r($line); |
| 428 | 428 | if ($country == 'F') { |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | $values['base'] = $line[4]; |
| 431 | 431 | $values['owner'] = $line[5]; |
| 432 | 432 | if ($line[6] == '') $values['date_first_reg'] = null; |
| 433 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 433 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
| 434 | 434 | $values['cancel'] = $line[7]; |
| 435 | 435 | } elseif ($country == 'EI') { |
| 436 | 436 | // TODO : add modeS & reg to aircraft_modes |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | $values['base'] = $line[3]; |
| 439 | 439 | $values['owner'] = $line[2]; |
| 440 | 440 | if ($line[1] == '') $values['date_first_reg'] = null; |
| 441 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 441 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
| 442 | 442 | $values['cancel'] = ''; |
| 443 | 443 | $values['modes'] = $line[7]; |
| 444 | 444 | $values['icao'] = $line[8]; |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | $values['base'] = null; |
| 459 | 459 | $values['owner'] = $line[5]; |
| 460 | 460 | if ($line[18] == '') $values['date_first_reg'] = null; |
| 461 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 461 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
| 462 | 462 | $values['cancel'] = ''; |
| 463 | 463 | } elseif ($country == 'VH') { |
| 464 | 464 | // TODO : add modeS & reg to aircraft_modes |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | $values['base'] = null; |
| 467 | 467 | $values['owner'] = $line[12]; |
| 468 | 468 | if ($line[28] == '') $values['date_first_reg'] = null; |
| 469 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 469 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
| 470 | 470 | |
| 471 | 471 | $values['cancel'] = $line[39]; |
| 472 | 472 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -486,28 +486,28 @@ discard block |
||
| 486 | 486 | $values['base'] = null; |
| 487 | 487 | $values['owner'] = $line[8]; |
| 488 | 488 | if ($line[7] == '') $values['date_first_reg'] = null; |
| 489 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 489 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
| 490 | 490 | $values['cancel'] = ''; |
| 491 | 491 | } elseif ($country == 'PP') { |
| 492 | 492 | $values['registration'] = $line[0]; |
| 493 | 493 | $values['base'] = null; |
| 494 | 494 | $values['owner'] = $line[4]; |
| 495 | 495 | if ($line[6] == '') $values['date_first_reg'] = null; |
| 496 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 496 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
| 497 | 497 | $values['cancel'] = $line[7]; |
| 498 | 498 | } elseif ($country == 'E7') { |
| 499 | 499 | $values['registration'] = $line[0]; |
| 500 | 500 | $values['base'] = null; |
| 501 | 501 | $values['owner'] = $line[4]; |
| 502 | 502 | if ($line[5] == '') $values['date_first_reg'] = null; |
| 503 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 503 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
| 504 | 504 | $values['cancel'] = ''; |
| 505 | 505 | } elseif ($country == '8Q') { |
| 506 | 506 | $values['registration'] = $line[0]; |
| 507 | 507 | $values['base'] = null; |
| 508 | 508 | $values['owner'] = $line[3]; |
| 509 | 509 | if ($line[7] == '') $values['date_first_reg'] = null; |
| 510 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 510 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
| 511 | 511 | $values['cancel'] = ''; |
| 512 | 512 | } elseif ($country == 'ZK') { |
| 513 | 513 | $values['registration'] = $line[0]; |
@@ -521,18 +521,18 @@ discard block |
||
| 521 | 521 | $values['registration'] = $line[0]; |
| 522 | 522 | $values['base'] = null; |
| 523 | 523 | $values['owner'] = $line[6]; |
| 524 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 525 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
| 524 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
| 525 | + $values['cancel'] = date("Y-m-d", strtotime($line[8])); |
|
| 526 | 526 | $values['modes'] = $line[4]; |
| 527 | 527 | $values['icao'] = $line[10]; |
| 528 | 528 | } elseif ($country == 'OY') { |
| 529 | 529 | $values['registration'] = $line[0]; |
| 530 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
| 530 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[4])); |
|
| 531 | 531 | $values['modes'] = $line[5]; |
| 532 | 532 | $values['icao'] = $line[6]; |
| 533 | 533 | } elseif ($country == 'PH') { |
| 534 | 534 | $values['registration'] = $line[0]; |
| 535 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
| 535 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[3])); |
|
| 536 | 536 | $values['modes'] = $line[4]; |
| 537 | 537 | $values['icao'] = $line[5]; |
| 538 | 538 | } elseif ($country == 'OM' || $country == 'TF') { |
@@ -543,17 +543,17 @@ discard block |
||
| 543 | 543 | $values['cancel'] = ''; |
| 544 | 544 | } |
| 545 | 545 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
| 546 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
| 546 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
| 547 | 547 | $sth_dest->execute($query_dest_values); |
| 548 | 548 | } |
| 549 | 549 | if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') { |
| 550 | 550 | $modescountry = $Spotter->countryFromAircraftRegistration($values['registration']); |
| 551 | - $query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file); |
|
| 551 | + $query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file); |
|
| 552 | 552 | $sth_modes->execute($query_modes_values); |
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | 555 | if ($globalTransaction) $Connection->db->commit(); |
| 556 | - } catch(PDOException $e) { |
|
| 556 | + } catch (PDOException $e) { |
|
| 557 | 557 | return "error : ".$e->getMessage(); |
| 558 | 558 | } |
| 559 | 559 | } |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 692 | 692 | |
| 693 | 693 | $i = 0; |
| 694 | - while($row = sparql_fetch_array($result)) |
|
| 694 | + while ($row = sparql_fetch_array($result)) |
|
| 695 | 695 | { |
| 696 | 696 | if ($i >= 1) { |
| 697 | 697 | //print_r($row); |
@@ -711,33 +711,33 @@ discard block |
||
| 711 | 711 | $row['image'] = ''; |
| 712 | 712 | $row['image_thumb'] = ''; |
| 713 | 713 | } else { |
| 714 | - $image = str_replace(' ','_',$row['image']); |
|
| 714 | + $image = str_replace(' ', '_', $row['image']); |
|
| 715 | 715 | $digest = md5($image); |
| 716 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
| 717 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
| 718 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
| 719 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
| 716 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
| 717 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
| 718 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
| 719 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | - $country = explode('-',$row['country']); |
|
| 722 | + $country = explode('-', $row['country']); |
|
| 723 | 723 | $row['country'] = $country[0]; |
| 724 | 724 | |
| 725 | 725 | $row['type'] = trim($row['type']); |
| 726 | - if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { |
|
| 726 | + if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) { |
|
| 727 | 727 | $row['type'] = 'military'; |
| 728 | 728 | } elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { |
| 729 | 729 | $row['type'] = 'small_airport'; |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
| 733 | - $query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($row['altitude']),':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); |
|
| 732 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
| 733 | + $query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($row['altitude']), ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']); |
|
| 734 | 734 | //print_r($query_dest_values); |
| 735 | 735 | |
| 736 | 736 | if ($row['icao'] != '') { |
| 737 | 737 | try { |
| 738 | 738 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao'); |
| 739 | 739 | $sth->execute(array(':icao' => $row['icao'])); |
| 740 | - } catch(PDOException $e) { |
|
| 740 | + } catch (PDOException $e) { |
|
| 741 | 741 | return "error : ".$e->getMessage(); |
| 742 | 742 | } |
| 743 | 743 | if ($sth->fetchColumn() > 0) { |
@@ -745,15 +745,15 @@ discard block |
||
| 745 | 745 | $query = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
| 746 | 746 | try { |
| 747 | 747 | $sth = $Connection->db->prepare($query); |
| 748 | - $sth->execute(array(':icao' => $row['icao'],':type' => $row['type'])); |
|
| 749 | - } catch(PDOException $e) { |
|
| 748 | + $sth->execute(array(':icao' => $row['icao'], ':type' => $row['type'])); |
|
| 749 | + } catch (PDOException $e) { |
|
| 750 | 750 | return "error : ".$e->getMessage(); |
| 751 | 751 | } |
| 752 | 752 | echo $row['icao'].' : '.$row['type']."\n"; |
| 753 | 753 | } else { |
| 754 | 754 | try { |
| 755 | 755 | $sth_dest->execute($query_dest_values); |
| 756 | - } catch(PDOException $e) { |
|
| 756 | + } catch (PDOException $e) { |
|
| 757 | 757 | return "error : ".$e->getMessage(); |
| 758 | 758 | } |
| 759 | 759 | } |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | echo "Download data from ourairports.com...\n"; |
| 805 | 805 | $delimiter = ','; |
| 806 | 806 | $out_file = $tmp_dir.'airports.csv'; |
| 807 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
| 807 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
| 808 | 808 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
| 809 | 809 | echo "Add data from ourairports.com...\n"; |
| 810 | 810 | |
@@ -815,33 +815,33 @@ discard block |
||
| 815 | 815 | //$Connection->db->beginTransaction(); |
| 816 | 816 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 817 | 817 | { |
| 818 | - if(!$header) $header = $row; |
|
| 818 | + if (!$header) $header = $row; |
|
| 819 | 819 | else { |
| 820 | 820 | $data = array(); |
| 821 | 821 | $data = array_combine($header, $row); |
| 822 | 822 | try { |
| 823 | 823 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao'); |
| 824 | 824 | $sth->execute(array(':icao' => $data['ident'])); |
| 825 | - } catch(PDOException $e) { |
|
| 825 | + } catch (PDOException $e) { |
|
| 826 | 826 | return "error : ".$e->getMessage(); |
| 827 | 827 | } |
| 828 | 828 | if ($sth->fetchColumn() > 0) { |
| 829 | 829 | $query = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
| 830 | 830 | try { |
| 831 | 831 | $sth = $Connection->db->prepare($query); |
| 832 | - $sth->execute(array(':icao' => $data['ident'],':type' => $data['type'])); |
|
| 833 | - } catch(PDOException $e) { |
|
| 832 | + $sth->execute(array(':icao' => $data['ident'], ':type' => $data['type'])); |
|
| 833 | + } catch (PDOException $e) { |
|
| 834 | 834 | return "error : ".$e->getMessage(); |
| 835 | 835 | } |
| 836 | 836 | } else { |
| 837 | 837 | if ($data['gps_code'] == $data['ident']) { |
| 838 | 838 | $query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link) |
| 839 | 839 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
| 840 | - $query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
| 840 | + $query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
| 841 | 841 | try { |
| 842 | 842 | $sth = $Connection->db->prepare($query); |
| 843 | 843 | $sth->execute($query_values); |
| 844 | - } catch(PDOException $e) { |
|
| 844 | + } catch (PDOException $e) { |
|
| 845 | 845 | return "error : ".$e->getMessage(); |
| 846 | 846 | } |
| 847 | 847 | $i++; |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | |
| 857 | 857 | echo "Download data from another free database...\n"; |
| 858 | 858 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 859 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
| 859 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
| 860 | 860 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
| 861 | 861 | update_db::unzip($out_file); |
| 862 | 862 | $header = NULL; |
@@ -868,15 +868,15 @@ discard block |
||
| 868 | 868 | //$Connection->db->beginTransaction(); |
| 869 | 869 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 870 | 870 | { |
| 871 | - if(!$header) $header = $row; |
|
| 871 | + if (!$header) $header = $row; |
|
| 872 | 872 | else { |
| 873 | 873 | $data = $row; |
| 874 | 874 | |
| 875 | 875 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
| 876 | 876 | try { |
| 877 | 877 | $sth = $Connection->db->prepare($query); |
| 878 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
| 879 | - } catch(PDOException $e) { |
|
| 878 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
| 879 | + } catch (PDOException $e) { |
|
| 880 | 880 | return "error : ".$e->getMessage(); |
| 881 | 881 | } |
| 882 | 882 | } |
@@ -890,15 +890,15 @@ discard block |
||
| 890 | 890 | try { |
| 891 | 891 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'"); |
| 892 | 892 | $sth->execute(); |
| 893 | - } catch(PDOException $e) { |
|
| 893 | + } catch (PDOException $e) { |
|
| 894 | 894 | return "error : ".$e->getMessage(); |
| 895 | 895 | } |
| 896 | 896 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 897 | 897 | $query2 = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
| 898 | 898 | try { |
| 899 | 899 | $sth2 = $Connection->db->prepare($query2); |
| 900 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
| 901 | - } catch(PDOException $e) { |
|
| 900 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
| 901 | + } catch (PDOException $e) { |
|
| 902 | 902 | return "error : ".$e->getMessage(); |
| 903 | 903 | } |
| 904 | 904 | } |
@@ -919,7 +919,7 @@ discard block |
||
| 919 | 919 | $Connection = new Connection(); |
| 920 | 920 | $sth = $Connection->db->prepare($query); |
| 921 | 921 | $sth->execute(array(':source' => 'translation.csv')); |
| 922 | - } catch(PDOException $e) { |
|
| 922 | + } catch (PDOException $e) { |
|
| 923 | 923 | return "error : ".$e->getMessage(); |
| 924 | 924 | } |
| 925 | 925 | |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 937 | 937 | { |
| 938 | 938 | $i++; |
| 939 | - if($i > 12) { |
|
| 939 | + if ($i > 12) { |
|
| 940 | 940 | $data = $row; |
| 941 | 941 | $operator = $data[2]; |
| 942 | 942 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | //echo substr($operator, 0, 2)."\n";; |
| 945 | 945 | if (count($airline_array) > 0) { |
| 946 | 946 | //print_r($airline_array); |
| 947 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
| 947 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
| 948 | 948 | } |
| 949 | 949 | } |
| 950 | 950 | |
@@ -952,14 +952,14 @@ discard block |
||
| 952 | 952 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
| 953 | 953 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
| 954 | 954 | if (count($airline_array) > 0) { |
| 955 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 955 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
| 956 | 956 | } |
| 957 | 957 | } |
| 958 | 958 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 959 | 959 | try { |
| 960 | 960 | $sth = $Connection->db->prepare($query); |
| 961 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
| 962 | - } catch(PDOException $e) { |
|
| 961 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
| 962 | + } catch (PDOException $e) { |
|
| 963 | 963 | return "error : ".$e->getMessage(); |
| 964 | 964 | } |
| 965 | 965 | } |
@@ -979,7 +979,7 @@ discard block |
||
| 979 | 979 | $Connection = new Connection(); |
| 980 | 980 | $sth = $Connection->db->prepare($query); |
| 981 | 981 | $sth->execute(array(':source' => 'website_fam')); |
| 982 | - } catch(PDOException $e) { |
|
| 982 | + } catch (PDOException $e) { |
|
| 983 | 983 | return "error : ".$e->getMessage(); |
| 984 | 984 | } |
| 985 | 985 | |
@@ -999,8 +999,8 @@ discard block |
||
| 999 | 999 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 1000 | 1000 | try { |
| 1001 | 1001 | $sth = $Connection->db->prepare($query); |
| 1002 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
| 1003 | - } catch(PDOException $e) { |
|
| 1002 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
| 1003 | + } catch (PDOException $e) { |
|
| 1004 | 1004 | return "error : ".$e->getMessage(); |
| 1005 | 1005 | } |
| 1006 | 1006 | } |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | $Connection = new Connection(); |
| 1024 | 1024 | $sth = $Connection->db->prepare($query); |
| 1025 | 1025 | $sth->execute(array(':source' => 'website_faa')); |
| 1026 | - } catch(PDOException $e) { |
|
| 1026 | + } catch (PDOException $e) { |
|
| 1027 | 1027 | return "error : ".$e->getMessage(); |
| 1028 | 1028 | } |
| 1029 | 1029 | |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | $Connection = new Connection(); |
| 1033 | 1033 | $sth = $Connection->db->prepare($query); |
| 1034 | 1034 | $sth->execute(array(':source' => 'website_faa')); |
| 1035 | - } catch(PDOException $e) { |
|
| 1035 | + } catch (PDOException $e) { |
|
| 1036 | 1036 | return "error : ".$e->getMessage(); |
| 1037 | 1037 | } |
| 1038 | 1038 | |
@@ -1049,8 +1049,8 @@ discard block |
||
| 1049 | 1049 | $query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1'; |
| 1050 | 1050 | try { |
| 1051 | 1051 | $sths = $Connection->db->prepare($query_search); |
| 1052 | - $sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa')); |
|
| 1053 | - } catch(PDOException $e) { |
|
| 1052 | + $sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa')); |
|
| 1053 | + } catch (PDOException $e) { |
|
| 1054 | 1054 | return "error s : ".$e->getMessage(); |
| 1055 | 1055 | } |
| 1056 | 1056 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
@@ -1063,8 +1063,8 @@ discard block |
||
| 1063 | 1063 | //} |
| 1064 | 1064 | try { |
| 1065 | 1065 | $sthi = $Connection->db->prepare($queryi); |
| 1066 | - $sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode'])); |
|
| 1067 | - } catch(PDOException $e) { |
|
| 1066 | + $sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode'])); |
|
| 1067 | + } catch (PDOException $e) { |
|
| 1068 | 1068 | return "error u : ".$e->getMessage(); |
| 1069 | 1069 | } |
| 1070 | 1070 | } else { |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | try { |
| 1073 | 1073 | $sthsm = $Connection->db->prepare($query_search_mfr); |
| 1074 | 1074 | $sthsm->execute(array(':mfr' => $data[2])); |
| 1075 | - } catch(PDOException $e) { |
|
| 1075 | + } catch (PDOException $e) { |
|
| 1076 | 1076 | return "error mfr : ".$e->getMessage(); |
| 1077 | 1077 | } |
| 1078 | 1078 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
@@ -1082,8 +1082,8 @@ discard block |
||
| 1082 | 1082 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
| 1083 | 1083 | try { |
| 1084 | 1084 | $sthf = $Connection->db->prepare($queryf); |
| 1085 | - $sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa')); |
|
| 1086 | - } catch(PDOException $e) { |
|
| 1085 | + $sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa')); |
|
| 1086 | + } catch (PDOException $e) { |
|
| 1087 | 1087 | return "error f : ".$e->getMessage(); |
| 1088 | 1088 | } |
| 1089 | 1089 | } |
@@ -1093,13 +1093,13 @@ discard block |
||
| 1093 | 1093 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 1094 | 1094 | try { |
| 1095 | 1095 | $sth = $Connection->db->prepare($query); |
| 1096 | - $sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa')); |
|
| 1097 | - } catch(PDOException $e) { |
|
| 1096 | + $sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa')); |
|
| 1097 | + } catch (PDOException $e) { |
|
| 1098 | 1098 | return "error i : ".$e->getMessage(); |
| 1099 | 1099 | } |
| 1100 | 1100 | } |
| 1101 | 1101 | } |
| 1102 | - if ($i % 90 == 0) { |
|
| 1102 | + if ($i%90 == 0) { |
|
| 1103 | 1103 | if ($globalTransaction) $Connection->db->commit(); |
| 1104 | 1104 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 1105 | 1105 | } |
@@ -1118,7 +1118,7 @@ discard block |
||
| 1118 | 1118 | $Connection = new Connection(); |
| 1119 | 1119 | $sth = $Connection->db->prepare($query); |
| 1120 | 1120 | $sth->execute(array(':source' => 'website_fam')); |
| 1121 | - } catch(PDOException $e) { |
|
| 1121 | + } catch (PDOException $e) { |
|
| 1122 | 1122 | return "error : ".$e->getMessage(); |
| 1123 | 1123 | } |
| 1124 | 1124 | |
@@ -1139,8 +1139,8 @@ discard block |
||
| 1139 | 1139 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
| 1140 | 1140 | try { |
| 1141 | 1141 | $sth = $Connection->db->prepare($query); |
| 1142 | - $sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam')); |
|
| 1143 | - } catch(PDOException $e) { |
|
| 1142 | + $sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam')); |
|
| 1143 | + } catch (PDOException $e) { |
|
| 1144 | 1144 | return "error : ".$e->getMessage(); |
| 1145 | 1145 | } |
| 1146 | 1146 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | $Connection = new Connection(); |
| 1160 | 1160 | $sth = $Connection->db->prepare($query); |
| 1161 | 1161 | $sth->execute(array(':source' => 'website_fam')); |
| 1162 | - } catch(PDOException $e) { |
|
| 1162 | + } catch (PDOException $e) { |
|
| 1163 | 1163 | return "error : ".$e->getMessage(); |
| 1164 | 1164 | } |
| 1165 | 1165 | |
@@ -1175,8 +1175,8 @@ discard block |
||
| 1175 | 1175 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)'; |
| 1176 | 1176 | try { |
| 1177 | 1177 | $sth = $Connection->db->prepare($query); |
| 1178 | - $sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam')); |
|
| 1179 | - } catch(PDOException $e) { |
|
| 1178 | + $sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam')); |
|
| 1179 | + } catch (PDOException $e) { |
|
| 1180 | 1180 | print_r($data); |
| 1181 | 1181 | return "error : ".$e->getMessage(); |
| 1182 | 1182 | } |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | $Connection = new Connection(); |
| 1197 | 1197 | $sth = $Connection->db->prepare($query); |
| 1198 | 1198 | $sth->execute(array(':source' => 'website_fam')); |
| 1199 | - } catch(PDOException $e) { |
|
| 1199 | + } catch (PDOException $e) { |
|
| 1200 | 1200 | return "error : ".$e->getMessage(); |
| 1201 | 1201 | } |
| 1202 | 1202 | $delimiter = "\t"; |
@@ -1211,9 +1211,9 @@ discard block |
||
| 1211 | 1211 | $query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)'; |
| 1212 | 1212 | try { |
| 1213 | 1213 | $sth = $Connection->db->prepare($query); |
| 1214 | - $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
|
| 1215 | - } catch(PDOException $e) { |
|
| 1216 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1214 | + $sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam')); |
|
| 1215 | + } catch (PDOException $e) { |
|
| 1216 | + if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',', $data); |
|
| 1217 | 1217 | } |
| 1218 | 1218 | } |
| 1219 | 1219 | $i++; |
@@ -1231,7 +1231,7 @@ discard block |
||
| 1231 | 1231 | $Connection = new Connection(); |
| 1232 | 1232 | $sth = $Connection->db->prepare($query); |
| 1233 | 1233 | $sth->execute(); |
| 1234 | - } catch(PDOException $e) { |
|
| 1234 | + } catch (PDOException $e) { |
|
| 1235 | 1235 | return "error : ".$e->getMessage(); |
| 1236 | 1236 | } |
| 1237 | 1237 | |
@@ -1252,8 +1252,8 @@ discard block |
||
| 1252 | 1252 | $query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)'; |
| 1253 | 1253 | try { |
| 1254 | 1254 | $sth = $Connection->db->prepare($query); |
| 1255 | - $sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10])); |
|
| 1256 | - } catch(PDOException $e) { |
|
| 1255 | + $sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10])); |
|
| 1256 | + } catch (PDOException $e) { |
|
| 1257 | 1257 | return "error : ".$e->getMessage(); |
| 1258 | 1258 | } |
| 1259 | 1259 | } |
@@ -1272,7 +1272,7 @@ discard block |
||
| 1272 | 1272 | $Connection = new Connection(); |
| 1273 | 1273 | $sth = $Connection->db->prepare($query); |
| 1274 | 1274 | $sth->execute(); |
| 1275 | - } catch(PDOException $e) { |
|
| 1275 | + } catch (PDOException $e) { |
|
| 1276 | 1276 | return "error : ".$e->getMessage(); |
| 1277 | 1277 | } |
| 1278 | 1278 | |
@@ -1288,7 +1288,7 @@ discard block |
||
| 1288 | 1288 | try { |
| 1289 | 1289 | $sth = $Connection->db->prepare($query); |
| 1290 | 1290 | $sth->execute(array(':icao' => $icao)); |
| 1291 | - } catch(PDOException $e) { |
|
| 1291 | + } catch (PDOException $e) { |
|
| 1292 | 1292 | return "error : ".$e->getMessage(); |
| 1293 | 1293 | } |
| 1294 | 1294 | } |
@@ -1299,7 +1299,7 @@ discard block |
||
| 1299 | 1299 | return ''; |
| 1300 | 1300 | } |
| 1301 | 1301 | |
| 1302 | - public static function tle($filename,$tletype) { |
|
| 1302 | + public static function tle($filename, $tletype) { |
|
| 1303 | 1303 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 1304 | 1304 | global $tmp_dir, $globalTransaction; |
| 1305 | 1305 | //$Spotter = new Spotter(); |
@@ -1309,7 +1309,7 @@ discard block |
||
| 1309 | 1309 | $Connection = new Connection(); |
| 1310 | 1310 | $sth = $Connection->db->prepare($query); |
| 1311 | 1311 | $sth->execute(array(':source' => $filename)); |
| 1312 | - } catch(PDOException $e) { |
|
| 1312 | + } catch (PDOException $e) { |
|
| 1313 | 1313 | return "error : ".$e->getMessage(); |
| 1314 | 1314 | } |
| 1315 | 1315 | |
@@ -1334,8 +1334,8 @@ discard block |
||
| 1334 | 1334 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
| 1335 | 1335 | try { |
| 1336 | 1336 | $sth = $Connection->db->prepare($query); |
| 1337 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
| 1338 | - } catch(PDOException $e) { |
|
| 1337 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
| 1338 | + } catch (PDOException $e) { |
|
| 1339 | 1339 | return "error : ".$e->getMessage(); |
| 1340 | 1340 | } |
| 1341 | 1341 | |
@@ -1355,28 +1355,28 @@ discard block |
||
| 1355 | 1355 | */ |
| 1356 | 1356 | private static function table2array($data) { |
| 1357 | 1357 | $html = str_get_html($data); |
| 1358 | - $tabledata=array(); |
|
| 1359 | - foreach($html->find('tr') as $element) |
|
| 1358 | + $tabledata = array(); |
|
| 1359 | + foreach ($html->find('tr') as $element) |
|
| 1360 | 1360 | { |
| 1361 | 1361 | $td = array(); |
| 1362 | - foreach( $element->find('th') as $row) |
|
| 1362 | + foreach ($element->find('th') as $row) |
|
| 1363 | 1363 | { |
| 1364 | 1364 | $td [] = trim($row->plaintext); |
| 1365 | 1365 | } |
| 1366 | - $td=array_filter($td); |
|
| 1366 | + $td = array_filter($td); |
|
| 1367 | 1367 | $tabledata[] = $td; |
| 1368 | 1368 | |
| 1369 | 1369 | $td = array(); |
| 1370 | 1370 | $tdi = array(); |
| 1371 | - foreach( $element->find('td') as $row) |
|
| 1371 | + foreach ($element->find('td') as $row) |
|
| 1372 | 1372 | { |
| 1373 | 1373 | $td [] = trim($row->plaintext); |
| 1374 | 1374 | $tdi [] = trim($row->innertext); |
| 1375 | 1375 | } |
| 1376 | - $td=array_filter($td); |
|
| 1377 | - $tdi=array_filter($tdi); |
|
| 1376 | + $td = array_filter($td); |
|
| 1377 | + $tdi = array_filter($tdi); |
|
| 1378 | 1378 | // $tabledata[]=array_merge($td,$tdi); |
| 1379 | - $tabledata[]=$td; |
|
| 1379 | + $tabledata[] = $td; |
|
| 1380 | 1380 | } |
| 1381 | 1381 | return(array_filter($tabledata)); |
| 1382 | 1382 | } |
@@ -1449,13 +1449,13 @@ discard block |
||
| 1449 | 1449 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1450 | 1450 | { |
| 1451 | 1451 | $i++; |
| 1452 | - if($i > 3 && count($row) > 2) { |
|
| 1452 | + if ($i > 3 && count($row) > 2) { |
|
| 1453 | 1453 | $data = array_values(array_filter($row)); |
| 1454 | 1454 | $cntdata = count($data); |
| 1455 | 1455 | if ($cntdata > 10) { |
| 1456 | 1456 | $value = $data[9]; |
| 1457 | 1457 | |
| 1458 | - for ($i =10;$i < $cntdata;$i++) { |
|
| 1458 | + for ($i = 10; $i < $cntdata; $i++) { |
|
| 1459 | 1459 | $value .= ' '.$data[$i]; |
| 1460 | 1460 | } |
| 1461 | 1461 | $data[9] = $value; |
@@ -1465,8 +1465,8 @@ discard block |
||
| 1465 | 1465 | $query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)'; |
| 1466 | 1466 | try { |
| 1467 | 1467 | $sth = $Connection->db->prepare($query); |
| 1468 | - $sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
| 1469 | - } catch(PDOException $e) { |
|
| 1468 | + $sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
| 1469 | + } catch (PDOException $e) { |
|
| 1470 | 1470 | return "error : ".$e->getMessage(); |
| 1471 | 1471 | } |
| 1472 | 1472 | } |
@@ -1487,7 +1487,7 @@ discard block |
||
| 1487 | 1487 | $Connection = new Connection(); |
| 1488 | 1488 | $sth = $Connection->db->prepare($query); |
| 1489 | 1489 | $sth->execute(); |
| 1490 | - } catch(PDOException $e) { |
|
| 1490 | + } catch (PDOException $e) { |
|
| 1491 | 1491 | return "error : ".$e->getMessage(); |
| 1492 | 1492 | } |
| 1493 | 1493 | |
@@ -1499,12 +1499,12 @@ discard block |
||
| 1499 | 1499 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 1500 | 1500 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1501 | 1501 | { |
| 1502 | - if(count($row) > 1) { |
|
| 1502 | + if (count($row) > 1) { |
|
| 1503 | 1503 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
| 1504 | 1504 | try { |
| 1505 | 1505 | $sth = $Connection->db->prepare($query); |
| 1506 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
| 1507 | - } catch(PDOException $e) { |
|
| 1506 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
| 1507 | + } catch (PDOException $e) { |
|
| 1508 | 1508 | return "error : ".$e->getMessage(); |
| 1509 | 1509 | } |
| 1510 | 1510 | } |
@@ -1524,21 +1524,21 @@ discard block |
||
| 1524 | 1524 | try { |
| 1525 | 1525 | $sth = $Connection->db->prepare($query); |
| 1526 | 1526 | $sth->execute(); |
| 1527 | - } catch(PDOException $e) { |
|
| 1527 | + } catch (PDOException $e) { |
|
| 1528 | 1528 | return "error : ".$e->getMessage(); |
| 1529 | 1529 | } |
| 1530 | 1530 | } |
| 1531 | 1531 | |
| 1532 | 1532 | |
| 1533 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1533 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1534 | 1534 | else { |
| 1535 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1535 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1536 | 1536 | $query = "CREATE EXTENSION postgis"; |
| 1537 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
| 1537 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
| 1538 | 1538 | try { |
| 1539 | 1539 | $sth = $Connection->db->prepare($query); |
| 1540 | 1540 | $sth->execute(); |
| 1541 | - } catch(PDOException $e) { |
|
| 1541 | + } catch (PDOException $e) { |
|
| 1542 | 1542 | return "error : ".$e->getMessage(); |
| 1543 | 1543 | } |
| 1544 | 1544 | } |
@@ -1551,7 +1551,7 @@ discard block |
||
| 1551 | 1551 | include_once('class.create_db.php'); |
| 1552 | 1552 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1553 | 1553 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
| 1554 | - update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
| 1554 | + update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
| 1555 | 1555 | $error = ''; |
| 1556 | 1556 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 1557 | 1557 | if ($globalDebug) echo "Gunzip..."; |
@@ -1583,14 +1583,14 @@ discard block |
||
| 1583 | 1583 | try { |
| 1584 | 1584 | $sth = $Connection->db->prepare($query); |
| 1585 | 1585 | $sth->execute(); |
| 1586 | - } catch(PDOException $e) { |
|
| 1586 | + } catch (PDOException $e) { |
|
| 1587 | 1587 | echo "error : ".$e->getMessage(); |
| 1588 | 1588 | } |
| 1589 | 1589 | } |
| 1590 | 1590 | if ($globalDBdriver == 'mysql') { |
| 1591 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 1591 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 1592 | 1592 | } else { |
| 1593 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 1593 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 1594 | 1594 | } |
| 1595 | 1595 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
| 1596 | 1596 | return $error; |
@@ -1603,7 +1603,7 @@ discard block |
||
| 1603 | 1603 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
| 1604 | 1604 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
| 1605 | 1605 | // update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
| 1606 | - update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
|
| 1606 | + update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net'); |
|
| 1607 | 1607 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
| 1608 | 1608 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
| 1609 | 1609 | return $error; |
@@ -1623,7 +1623,7 @@ discard block |
||
| 1623 | 1623 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1624 | 1624 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
| 1625 | 1625 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1626 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1626 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1627 | 1627 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
| 1628 | 1628 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
| 1629 | 1629 | if ($error != '') { |
@@ -1636,7 +1636,7 @@ discard block |
||
| 1636 | 1636 | global $tmp_dir, $globalDebug; |
| 1637 | 1637 | $error = ''; |
| 1638 | 1638 | if ($globalDebug) echo "Routes : Download..."; |
| 1639 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
| 1639 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
| 1640 | 1640 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1641 | 1641 | if ($globalDebug) echo "Gunzip..."; |
| 1642 | 1642 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1652,7 +1652,7 @@ discard block |
||
| 1652 | 1652 | global $tmp_dir, $globalDebug; |
| 1653 | 1653 | $error = ''; |
| 1654 | 1654 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
| 1655 | - update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
| 1655 | + update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
| 1656 | 1656 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 1657 | 1657 | if ($globalDebug) echo "Gunzip..."; |
| 1658 | 1658 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -1668,7 +1668,7 @@ discard block |
||
| 1668 | 1668 | global $tmp_dir, $globalDebug; |
| 1669 | 1669 | $error = ''; |
| 1670 | 1670 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
| 1671 | - update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
| 1671 | + update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
| 1672 | 1672 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 1673 | 1673 | if ($globalDebug) echo "Gunzip..."; |
| 1674 | 1674 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -1696,7 +1696,7 @@ discard block |
||
| 1696 | 1696 | */ |
| 1697 | 1697 | if ($globalDebug) echo "Modes : Download..."; |
| 1698 | 1698 | // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
| 1699 | - update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
|
| 1699 | + update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz'); |
|
| 1700 | 1700 | |
| 1701 | 1701 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1702 | 1702 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
@@ -1716,7 +1716,7 @@ discard block |
||
| 1716 | 1716 | public static function update_ModeS_faa() { |
| 1717 | 1717 | global $tmp_dir, $globalDebug; |
| 1718 | 1718 | if ($globalDebug) echo "Modes FAA: Download..."; |
| 1719 | - update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
|
| 1719 | + update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip'); |
|
| 1720 | 1720 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
| 1721 | 1721 | if ($globalDebug) echo "Unzip..."; |
| 1722 | 1722 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
@@ -1732,7 +1732,7 @@ discard block |
||
| 1732 | 1732 | public static function update_ModeS_flarm() { |
| 1733 | 1733 | global $tmp_dir, $globalDebug; |
| 1734 | 1734 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
| 1735 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
| 1735 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
| 1736 | 1736 | if (file_exists($tmp_dir.'data.fln')) { |
| 1737 | 1737 | if ($globalDebug) echo "Add to DB..."; |
| 1738 | 1738 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1746,7 +1746,7 @@ discard block |
||
| 1746 | 1746 | public static function update_ModeS_ogn() { |
| 1747 | 1747 | global $tmp_dir, $globalDebug; |
| 1748 | 1748 | if ($globalDebug) echo "Modes OGN: Download..."; |
| 1749 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
| 1749 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
| 1750 | 1750 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1751 | 1751 | if ($globalDebug) echo "Add to DB..."; |
| 1752 | 1752 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1761,201 +1761,201 @@ discard block |
||
| 1761 | 1761 | global $tmp_dir, $globalDebug, $globalMasterSource; |
| 1762 | 1762 | |
| 1763 | 1763 | if ($globalDebug) echo "Owner France: Download..."; |
| 1764 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
| 1764 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
| 1765 | 1765 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1766 | 1766 | if ($globalDebug) echo "Add to DB..."; |
| 1767 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
| 1767 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
| 1768 | 1768 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
| 1769 | 1769 | if ($error != '') { |
| 1770 | 1770 | return $error; |
| 1771 | 1771 | } elseif ($globalDebug) echo "Done\n"; |
| 1772 | 1772 | |
| 1773 | 1773 | if ($globalDebug) echo "Owner Ireland: Download..."; |
| 1774 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
| 1774 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
| 1775 | 1775 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1776 | 1776 | if ($globalDebug) echo "Add to DB..."; |
| 1777 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
| 1777 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
| 1778 | 1778 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
| 1779 | 1779 | if ($error != '') { |
| 1780 | 1780 | return $error; |
| 1781 | 1781 | } elseif ($globalDebug) echo "Done\n"; |
| 1782 | 1782 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
| 1783 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
| 1783 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
| 1784 | 1784 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1785 | 1785 | if ($globalDebug) echo "Add to DB..."; |
| 1786 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
| 1786 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
| 1787 | 1787 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
| 1788 | 1788 | if ($error != '') { |
| 1789 | 1789 | return $error; |
| 1790 | 1790 | } elseif ($globalDebug) echo "Done\n"; |
| 1791 | 1791 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
| 1792 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
| 1792 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
| 1793 | 1793 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1794 | 1794 | if ($globalDebug) echo "Add to DB..."; |
| 1795 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
| 1795 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
| 1796 | 1796 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
| 1797 | 1797 | if ($error != '') { |
| 1798 | 1798 | return $error; |
| 1799 | 1799 | } elseif ($globalDebug) echo "Done\n"; |
| 1800 | 1800 | if ($globalDebug) echo "Owner Australia: Download..."; |
| 1801 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
| 1801 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
| 1802 | 1802 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1803 | 1803 | if ($globalDebug) echo "Add to DB..."; |
| 1804 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
| 1804 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
| 1805 | 1805 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
| 1806 | 1806 | if ($error != '') { |
| 1807 | 1807 | return $error; |
| 1808 | 1808 | } elseif ($globalDebug) echo "Done\n"; |
| 1809 | 1809 | if ($globalDebug) echo "Owner Austria: Download..."; |
| 1810 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
| 1810 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
| 1811 | 1811 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1812 | 1812 | if ($globalDebug) echo "Add to DB..."; |
| 1813 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
| 1813 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
| 1814 | 1814 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
| 1815 | 1815 | if ($error != '') { |
| 1816 | 1816 | return $error; |
| 1817 | 1817 | } elseif ($globalDebug) echo "Done\n"; |
| 1818 | 1818 | if ($globalDebug) echo "Owner Chile: Download..."; |
| 1819 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
| 1819 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
| 1820 | 1820 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1821 | 1821 | if ($globalDebug) echo "Add to DB..."; |
| 1822 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
| 1822 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
| 1823 | 1823 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
| 1824 | 1824 | if ($error != '') { |
| 1825 | 1825 | return $error; |
| 1826 | 1826 | } elseif ($globalDebug) echo "Done\n"; |
| 1827 | 1827 | if ($globalDebug) echo "Owner Colombia: Download..."; |
| 1828 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
| 1828 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
| 1829 | 1829 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1830 | 1830 | if ($globalDebug) echo "Add to DB..."; |
| 1831 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
| 1831 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
| 1832 | 1832 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
| 1833 | 1833 | if ($error != '') { |
| 1834 | 1834 | return $error; |
| 1835 | 1835 | } elseif ($globalDebug) echo "Done\n"; |
| 1836 | 1836 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
| 1837 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
| 1837 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
| 1838 | 1838 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1839 | 1839 | if ($globalDebug) echo "Add to DB..."; |
| 1840 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
| 1840 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
| 1841 | 1841 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
| 1842 | 1842 | if ($error != '') { |
| 1843 | 1843 | return $error; |
| 1844 | 1844 | } elseif ($globalDebug) echo "Done\n"; |
| 1845 | 1845 | if ($globalDebug) echo "Owner Brazil: Download..."; |
| 1846 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
| 1846 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
| 1847 | 1847 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1848 | 1848 | if ($globalDebug) echo "Add to DB..."; |
| 1849 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
| 1849 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
| 1850 | 1850 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
| 1851 | 1851 | if ($error != '') { |
| 1852 | 1852 | return $error; |
| 1853 | 1853 | } elseif ($globalDebug) echo "Done\n"; |
| 1854 | 1854 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
| 1855 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
| 1855 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
| 1856 | 1856 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1857 | 1857 | if ($globalDebug) echo "Add to DB..."; |
| 1858 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
| 1858 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
| 1859 | 1859 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
| 1860 | 1860 | if ($error != '') { |
| 1861 | 1861 | return $error; |
| 1862 | 1862 | } elseif ($globalDebug) echo "Done\n"; |
| 1863 | 1863 | if ($globalDebug) echo "Owner Croatia: Download..."; |
| 1864 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
| 1864 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
| 1865 | 1865 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1866 | 1866 | if ($globalDebug) echo "Add to DB..."; |
| 1867 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
| 1867 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
| 1868 | 1868 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
| 1869 | 1869 | if ($error != '') { |
| 1870 | 1870 | return $error; |
| 1871 | 1871 | } elseif ($globalDebug) echo "Done\n"; |
| 1872 | 1872 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
| 1873 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
| 1873 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
| 1874 | 1874 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1875 | 1875 | if ($globalDebug) echo "Add to DB..."; |
| 1876 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
| 1876 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
| 1877 | 1877 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
| 1878 | 1878 | if ($error != '') { |
| 1879 | 1879 | return $error; |
| 1880 | 1880 | } elseif ($globalDebug) echo "Done\n"; |
| 1881 | 1881 | if ($globalDebug) echo "Owner Maldives: Download..."; |
| 1882 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
| 1882 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
| 1883 | 1883 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1884 | 1884 | if ($globalDebug) echo "Add to DB..."; |
| 1885 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
| 1885 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
| 1886 | 1886 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
| 1887 | 1887 | if ($error != '') { |
| 1888 | 1888 | return $error; |
| 1889 | 1889 | } elseif ($globalDebug) echo "Done\n"; |
| 1890 | 1890 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
| 1891 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
| 1891 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
| 1892 | 1892 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1893 | 1893 | if ($globalDebug) echo "Add to DB..."; |
| 1894 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
| 1894 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
| 1895 | 1895 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
| 1896 | 1896 | if ($error != '') { |
| 1897 | 1897 | return $error; |
| 1898 | 1898 | } elseif ($globalDebug) echo "Done\n"; |
| 1899 | 1899 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
| 1900 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
| 1900 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
| 1901 | 1901 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1902 | 1902 | if ($globalDebug) echo "Add to DB..."; |
| 1903 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
| 1903 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
| 1904 | 1904 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
| 1905 | 1905 | if ($error != '') { |
| 1906 | 1906 | return $error; |
| 1907 | 1907 | } elseif ($globalDebug) echo "Done\n"; |
| 1908 | 1908 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
| 1909 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
| 1909 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
| 1910 | 1910 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1911 | 1911 | if ($globalDebug) echo "Add to DB..."; |
| 1912 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
| 1912 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
| 1913 | 1913 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
| 1914 | 1914 | if ($error != '') { |
| 1915 | 1915 | return $error; |
| 1916 | 1916 | } elseif ($globalDebug) echo "Done\n"; |
| 1917 | 1917 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
| 1918 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
| 1918 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
| 1919 | 1919 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1920 | 1920 | if ($globalDebug) echo "Add to DB..."; |
| 1921 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
| 1921 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
| 1922 | 1922 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
| 1923 | 1923 | if ($error != '') { |
| 1924 | 1924 | return $error; |
| 1925 | 1925 | } elseif ($globalDebug) echo "Done\n"; |
| 1926 | 1926 | if ($globalDebug) echo "Owner Iceland: Download..."; |
| 1927 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
| 1927 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
| 1928 | 1928 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1929 | 1929 | if ($globalDebug) echo "Add to DB..."; |
| 1930 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
| 1930 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
| 1931 | 1931 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
| 1932 | 1932 | if ($error != '') { |
| 1933 | 1933 | return $error; |
| 1934 | 1934 | } elseif ($globalDebug) echo "Done\n"; |
| 1935 | 1935 | if ($globalDebug) echo "Owner Isle of Man: Download..."; |
| 1936 | - update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
|
| 1936 | + update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv'); |
|
| 1937 | 1937 | if (file_exists($tmp_dir.'owner_m.csv')) { |
| 1938 | 1938 | if ($globalDebug) echo "Add to DB..."; |
| 1939 | - $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
|
| 1939 | + $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M'); |
|
| 1940 | 1940 | } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
| 1941 | 1941 | if ($error != '') { |
| 1942 | 1942 | return $error; |
| 1943 | 1943 | } elseif ($globalDebug) echo "Done\n"; |
| 1944 | 1944 | if ($globalMasterSource) { |
| 1945 | 1945 | if ($globalDebug) echo "ModeS Netherlands: Download..."; |
| 1946 | - update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
|
| 1946 | + update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv'); |
|
| 1947 | 1947 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
| 1948 | 1948 | if ($globalDebug) echo "Add to DB..."; |
| 1949 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
|
| 1949 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH'); |
|
| 1950 | 1950 | } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
| 1951 | 1951 | if ($error != '') { |
| 1952 | 1952 | return $error; |
| 1953 | 1953 | } elseif ($globalDebug) echo "Done\n"; |
| 1954 | 1954 | if ($globalDebug) echo "ModeS Denmark: Download..."; |
| 1955 | - update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
|
| 1955 | + update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv'); |
|
| 1956 | 1956 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
| 1957 | 1957 | if ($globalDebug) echo "Add to DB..."; |
| 1958 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
|
| 1958 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY'); |
|
| 1959 | 1959 | } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
| 1960 | 1960 | if ($error != '') { |
| 1961 | 1961 | return $error; |
@@ -1968,7 +1968,7 @@ discard block |
||
| 1968 | 1968 | global $tmp_dir, $globalDebug; |
| 1969 | 1969 | $error = ''; |
| 1970 | 1970 | if ($globalDebug) echo "Translation : Download..."; |
| 1971 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
| 1971 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
| 1972 | 1972 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1973 | 1973 | if ($globalDebug) echo "Unzip..."; |
| 1974 | 1974 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1984,7 +1984,7 @@ discard block |
||
| 1984 | 1984 | public static function update_translation_fam() { |
| 1985 | 1985 | global $tmp_dir, $globalDebug; |
| 1986 | 1986 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
| 1987 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
| 1987 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
| 1988 | 1988 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1989 | 1989 | if ($globalDebug) echo "Gunzip..."; |
| 1990 | 1990 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -1999,7 +1999,7 @@ discard block |
||
| 1999 | 1999 | public static function update_ModeS_fam() { |
| 2000 | 2000 | global $tmp_dir, $globalDebug; |
| 2001 | 2001 | if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
| 2002 | - update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
|
| 2002 | + update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz'); |
|
| 2003 | 2003 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
| 2004 | 2004 | if ($globalDebug) echo "Gunzip..."; |
| 2005 | 2005 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
@@ -2015,9 +2015,9 @@ discard block |
||
| 2015 | 2015 | global $tmp_dir, $globalDebug, $globalOwner; |
| 2016 | 2016 | if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
| 2017 | 2017 | if ($globalOwner === TRUE) { |
| 2018 | - update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
| 2018 | + update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
| 2019 | 2019 | } else { |
| 2020 | - update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
| 2020 | + update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
| 2021 | 2021 | } |
| 2022 | 2022 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
| 2023 | 2023 | if ($globalDebug) echo "Gunzip..."; |
@@ -2033,7 +2033,7 @@ discard block |
||
| 2033 | 2033 | public static function update_routes_fam() { |
| 2034 | 2034 | global $tmp_dir, $globalDebug; |
| 2035 | 2035 | if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
| 2036 | - update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
|
| 2036 | + update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz'); |
|
| 2037 | 2037 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
| 2038 | 2038 | if ($globalDebug) echo "Gunzip..."; |
| 2039 | 2039 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
@@ -2047,13 +2047,13 @@ discard block |
||
| 2047 | 2047 | } |
| 2048 | 2048 | public static function update_marine_identity_fam() { |
| 2049 | 2049 | global $tmp_dir, $globalDebug; |
| 2050 | - update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5'); |
|
| 2050 | + update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5'); |
|
| 2051 | 2051 | if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) { |
| 2052 | - $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
|
| 2052 | + $marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
|
| 2053 | 2053 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
| 2054 | 2054 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
| 2055 | 2055 | if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
| 2056 | - update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
|
| 2056 | + update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz'); |
|
| 2057 | 2057 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
| 2058 | 2058 | if ($globalDebug) echo "Gunzip..."; |
| 2059 | 2059 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
@@ -2073,7 +2073,7 @@ discard block |
||
| 2073 | 2073 | public static function update_banned_fam() { |
| 2074 | 2074 | global $tmp_dir, $globalDebug; |
| 2075 | 2075 | if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
| 2076 | - update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
|
| 2076 | + update_db::download('http://data.flightairmap.fr/data/ban-eu.csv', $tmp_dir.'ban_eu.csv'); |
|
| 2077 | 2077 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
| 2078 | 2078 | //if ($globalDebug) echo "Gunzip..."; |
| 2079 | 2079 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
@@ -2092,18 +2092,18 @@ discard block |
||
| 2092 | 2092 | $error = ''; |
| 2093 | 2093 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
| 2094 | 2094 | if ($globalDBdriver == 'mysql') { |
| 2095 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
| 2095 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
| 2096 | 2096 | } else { |
| 2097 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
| 2097 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
| 2098 | 2098 | } |
| 2099 | 2099 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
| 2100 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
| 2100 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
| 2101 | 2101 | $airspace_md5 = $airspace_md5_file[0]; |
| 2102 | 2102 | if (!update_db::check_airspace_version($airspace_md5)) { |
| 2103 | 2103 | if ($globalDBdriver == 'mysql') { |
| 2104 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
| 2104 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
| 2105 | 2105 | } else { |
| 2106 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
| 2106 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
| 2107 | 2107 | } |
| 2108 | 2108 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 2109 | 2109 | if ($globalDebug) echo "Gunzip..."; |
@@ -2115,7 +2115,7 @@ discard block |
||
| 2115 | 2115 | try { |
| 2116 | 2116 | $sth = $Connection->db->prepare($query); |
| 2117 | 2117 | $sth->execute(); |
| 2118 | - } catch(PDOException $e) { |
|
| 2118 | + } catch (PDOException $e) { |
|
| 2119 | 2119 | return "error : ".$e->getMessage(); |
| 2120 | 2120 | } |
| 2121 | 2121 | } |
@@ -2134,15 +2134,15 @@ discard block |
||
| 2134 | 2134 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
| 2135 | 2135 | $error = ''; |
| 2136 | 2136 | if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
| 2137 | - update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
|
| 2137 | + update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
|
| 2138 | 2138 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
| 2139 | - $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
|
| 2139 | + $geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
|
| 2140 | 2140 | $geoid_md5 = $geoid_md5_file[0]; |
| 2141 | 2141 | if (!update_db::check_geoid_version($geoid_md5)) { |
| 2142 | - update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
|
| 2142 | + update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz'); |
|
| 2143 | 2143 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
| 2144 | 2144 | if ($globalDebug) echo "Gunzip..."; |
| 2145 | - update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
|
| 2145 | + update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
|
| 2146 | 2146 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
| 2147 | 2147 | update_db::insert_geoid_version($geoid_md5); |
| 2148 | 2148 | } |
@@ -2158,15 +2158,15 @@ discard block |
||
| 2158 | 2158 | public static function update_tle() { |
| 2159 | 2159 | global $tmp_dir, $globalDebug; |
| 2160 | 2160 | if ($globalDebug) echo "Download TLE : Download..."; |
| 2161 | - $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
|
| 2162 | - 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
|
| 2163 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
|
| 2161 | + $alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt', |
|
| 2162 | + 'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt', |
|
| 2163 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt'); |
|
| 2164 | 2164 | foreach ($alltle as $filename) { |
| 2165 | 2165 | if ($globalDebug) echo "downloading ".$filename.'...'; |
| 2166 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
| 2166 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
| 2167 | 2167 | if (file_exists($tmp_dir.$filename)) { |
| 2168 | 2168 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
| 2169 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
| 2169 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
| 2170 | 2170 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
| 2171 | 2171 | if ($error != '') { |
| 2172 | 2172 | echo $error."\n"; |
@@ -2179,32 +2179,32 @@ discard block |
||
| 2179 | 2179 | global $tmp_dir, $globalDebug; |
| 2180 | 2180 | $error = ''; |
| 2181 | 2181 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
| 2182 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
| 2182 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
| 2183 | 2183 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 2184 | 2184 | if ($globalDebug) echo "Check files...\n"; |
| 2185 | 2185 | $newmodelsdb = array(); |
| 2186 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
| 2187 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2186 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
| 2187 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2188 | 2188 | $model = trim($row[2]); |
| 2189 | 2189 | $newmodelsdb[$model] = trim($row[0]); |
| 2190 | 2190 | } |
| 2191 | 2191 | } |
| 2192 | 2192 | $modelsdb = array(); |
| 2193 | 2193 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
| 2194 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
| 2195 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2194 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
| 2195 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2196 | 2196 | $model = trim($row[2]); |
| 2197 | 2197 | $modelsdb[$model] = trim($row[0]); |
| 2198 | 2198 | } |
| 2199 | 2199 | } |
| 2200 | 2200 | } |
| 2201 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 2201 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 2202 | 2202 | foreach ($diff as $key => $value) { |
| 2203 | 2203 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
| 2204 | - update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
| 2204 | + update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
| 2205 | 2205 | |
| 2206 | 2206 | } |
| 2207 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
| 2207 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
| 2208 | 2208 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 2209 | 2209 | if ($error != '') { |
| 2210 | 2210 | return $error; |
@@ -2216,32 +2216,32 @@ discard block |
||
| 2216 | 2216 | global $tmp_dir, $globalDebug; |
| 2217 | 2217 | $error = ''; |
| 2218 | 2218 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
| 2219 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
| 2219 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
| 2220 | 2220 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 2221 | 2221 | if ($globalDebug) echo "Check files...\n"; |
| 2222 | 2222 | $newmodelsdb = array(); |
| 2223 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
| 2224 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2223 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
| 2224 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2225 | 2225 | $model = trim($row[2]); |
| 2226 | 2226 | $newmodelsdb[$model] = trim($row[0]); |
| 2227 | 2227 | } |
| 2228 | 2228 | } |
| 2229 | 2229 | $modelsdb = array(); |
| 2230 | 2230 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
| 2231 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
| 2232 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2231 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
| 2232 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2233 | 2233 | $model = trim($row[2]); |
| 2234 | 2234 | $modelsdb[$model] = trim($row[0]); |
| 2235 | 2235 | } |
| 2236 | 2236 | } |
| 2237 | 2237 | } |
| 2238 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 2238 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 2239 | 2239 | foreach ($diff as $key => $value) { |
| 2240 | 2240 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
| 2241 | - update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
| 2241 | + update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
| 2242 | 2242 | |
| 2243 | 2243 | } |
| 2244 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 2244 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 2245 | 2245 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 2246 | 2246 | if ($error != '') { |
| 2247 | 2247 | return $error; |
@@ -2253,32 +2253,32 @@ discard block |
||
| 2253 | 2253 | global $tmp_dir, $globalDebug; |
| 2254 | 2254 | $error = ''; |
| 2255 | 2255 | if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
| 2256 | - update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
|
| 2256 | + update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum'); |
|
| 2257 | 2257 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
| 2258 | 2258 | if ($globalDebug) echo "Check files...\n"; |
| 2259 | 2259 | $newmodelsdb = array(); |
| 2260 | - if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
|
| 2261 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2260 | + if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) { |
|
| 2261 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2262 | 2262 | $model = trim($row[2]); |
| 2263 | 2263 | $newmodelsdb[$model] = trim($row[0]); |
| 2264 | 2264 | } |
| 2265 | 2265 | } |
| 2266 | 2266 | $modelsdb = array(); |
| 2267 | 2267 | if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) { |
| 2268 | - if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) { |
|
| 2269 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2268 | + if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) { |
|
| 2269 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2270 | 2270 | $model = trim($row[2]); |
| 2271 | 2271 | $modelsdb[$model] = trim($row[0]); |
| 2272 | 2272 | } |
| 2273 | 2273 | } |
| 2274 | 2274 | } |
| 2275 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 2275 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 2276 | 2276 | foreach ($diff as $key => $value) { |
| 2277 | 2277 | if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
| 2278 | - update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
|
| 2278 | + update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key); |
|
| 2279 | 2279 | |
| 2280 | 2280 | } |
| 2281 | - update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
| 2281 | + update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
| 2282 | 2282 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 2283 | 2283 | if ($error != '') { |
| 2284 | 2284 | return $error; |
@@ -2301,8 +2301,8 @@ discard block |
||
| 2301 | 2301 | */ |
| 2302 | 2302 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 2303 | 2303 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
| 2304 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 2305 | - $result = fread($fh,100000000); |
|
| 2304 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
| 2305 | + $result = fread($fh, 100000000); |
|
| 2306 | 2306 | //echo $result; |
| 2307 | 2307 | //var_dump(str_get_html($result)); |
| 2308 | 2308 | //print_r(self::table2array($result)); |
@@ -2320,23 +2320,23 @@ discard block |
||
| 2320 | 2320 | $Connection = new Connection(); |
| 2321 | 2321 | $sth = $Connection->db->prepare($query); |
| 2322 | 2322 | $sth->execute(); |
| 2323 | - } catch(PDOException $e) { |
|
| 2323 | + } catch (PDOException $e) { |
|
| 2324 | 2324 | return "error : ".$e->getMessage(); |
| 2325 | 2325 | } |
| 2326 | 2326 | |
| 2327 | 2327 | $error = ''; |
| 2328 | 2328 | if ($globalDebug) echo "Notam : Download..."; |
| 2329 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
| 2329 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
| 2330 | 2330 | if (file_exists($tmp_dir.'notam.rss')) { |
| 2331 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
| 2331 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
| 2332 | 2332 | foreach ($notams['channel']['item'] as $notam) { |
| 2333 | - $title = explode(':',$notam['title']); |
|
| 2333 | + $title = explode(':', $notam['title']); |
|
| 2334 | 2334 | $data['ref'] = trim($title[0]); |
| 2335 | 2335 | unset($title[0]); |
| 2336 | - $data['title'] = trim(implode(':',$title)); |
|
| 2337 | - $description = strip_tags($notam['description'],'<pre>'); |
|
| 2338 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
| 2339 | - $q = explode('/',$match[1]); |
|
| 2336 | + $data['title'] = trim(implode(':', $title)); |
|
| 2337 | + $description = strip_tags($notam['description'], '<pre>'); |
|
| 2338 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
| 2339 | + $q = explode('/', $match[1]); |
|
| 2340 | 2340 | $data['fir'] = $q[0]; |
| 2341 | 2341 | $data['code'] = $q[1]; |
| 2342 | 2342 | $ifrvfr = $q[2]; |
@@ -2352,30 +2352,30 @@ discard block |
||
| 2352 | 2352 | $data['lower_limit'] = $q[5]; |
| 2353 | 2353 | $data['upper_limit'] = $q[6]; |
| 2354 | 2354 | $latlonrad = $q[7]; |
| 2355 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
| 2356 | - $latitude = $Common->convertDec($las,'latitude'); |
|
| 2357 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
| 2355 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
| 2356 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
| 2357 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
| 2358 | 2358 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 2359 | 2359 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 2360 | 2360 | $data['center_latitude'] = $latitude; |
| 2361 | 2361 | $data['center_longitude'] = $longitude; |
| 2362 | 2362 | $data['radius'] = intval($radius); |
| 2363 | 2363 | |
| 2364 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
| 2364 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
| 2365 | 2365 | $data['text'] = $match[1]; |
| 2366 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
| 2366 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
| 2367 | 2367 | $fromto = $match[1]; |
| 2368 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
| 2368 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
| 2369 | 2369 | $fromall = trim($match[1]); |
| 2370 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
| 2370 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
| 2371 | 2371 | $from = trim($match[1]); |
| 2372 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
| 2373 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
| 2372 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
| 2373 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
| 2374 | 2374 | $toall = trim($match[1]); |
| 2375 | - if (!preg_match(':Permanent:',$toall)) { |
|
| 2376 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
| 2375 | + if (!preg_match(':Permanent:', $toall)) { |
|
| 2376 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
| 2377 | 2377 | $to = trim($match[1]); |
| 2378 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
| 2378 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
| 2379 | 2379 | $data['permanent'] = 0; |
| 2380 | 2380 | } else { |
| 2381 | 2381 | $data['date_end'] = NULL; |
@@ -2383,7 +2383,7 @@ discard block |
||
| 2383 | 2383 | } |
| 2384 | 2384 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 2385 | 2385 | $NOTAM = new NOTAM(); |
| 2386 | - $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 2386 | + $NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
| 2387 | 2387 | unset($data); |
| 2388 | 2388 | } |
| 2389 | 2389 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -2406,16 +2406,16 @@ discard block |
||
| 2406 | 2406 | $Connection = new Connection(); |
| 2407 | 2407 | $sth = $Connection->db->prepare($query); |
| 2408 | 2408 | $sth->execute(); |
| 2409 | - } catch(PDOException $e) { |
|
| 2409 | + } catch (PDOException $e) { |
|
| 2410 | 2410 | return "error : ".$e->getMessage(); |
| 2411 | 2411 | } |
| 2412 | 2412 | } |
| 2413 | 2413 | $Common = new Common(); |
| 2414 | 2414 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 2415 | - $airspace_json = json_decode($airspace_lst,true); |
|
| 2415 | + $airspace_json = json_decode($airspace_lst, true); |
|
| 2416 | 2416 | foreach ($airspace_json['records'] as $airspace) { |
| 2417 | 2417 | if ($globalDebug) echo $airspace['name']."...\n"; |
| 2418 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
| 2418 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
| 2419 | 2419 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 2420 | 2420 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
| 2421 | 2421 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -2437,7 +2437,7 @@ discard block |
||
| 2437 | 2437 | $Connection = new Connection(); |
| 2438 | 2438 | $sth = $Connection->db->prepare($query); |
| 2439 | 2439 | $sth->execute(array(':new' => $new, ':old' => $old)); |
| 2440 | - } catch(PDOException $e) { |
|
| 2440 | + } catch (PDOException $e) { |
|
| 2441 | 2441 | return "error : ".$e->getMessage(); |
| 2442 | 2442 | } |
| 2443 | 2443 | } |
@@ -2454,7 +2454,7 @@ discard block |
||
| 2454 | 2454 | $Connection = new Connection(); |
| 2455 | 2455 | $sth = $Connection->db->prepare($query); |
| 2456 | 2456 | $sth->execute(); |
| 2457 | - } catch(PDOException $e) { |
|
| 2457 | + } catch (PDOException $e) { |
|
| 2458 | 2458 | return "error : ".$e->getMessage(); |
| 2459 | 2459 | } |
| 2460 | 2460 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2469,7 +2469,7 @@ discard block |
||
| 2469 | 2469 | $Connection = new Connection(); |
| 2470 | 2470 | $sth = $Connection->db->prepare($query); |
| 2471 | 2471 | $sth->execute(); |
| 2472 | - } catch(PDOException $e) { |
|
| 2472 | + } catch (PDOException $e) { |
|
| 2473 | 2473 | return "error : ".$e->getMessage(); |
| 2474 | 2474 | } |
| 2475 | 2475 | } |
@@ -2480,7 +2480,7 @@ discard block |
||
| 2480 | 2480 | $Connection = new Connection(); |
| 2481 | 2481 | $sth = $Connection->db->prepare($query); |
| 2482 | 2482 | $sth->execute(array(':version' => $version)); |
| 2483 | - } catch(PDOException $e) { |
|
| 2483 | + } catch (PDOException $e) { |
|
| 2484 | 2484 | return "error : ".$e->getMessage(); |
| 2485 | 2485 | } |
| 2486 | 2486 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2494,7 +2494,7 @@ discard block |
||
| 2494 | 2494 | $Connection = new Connection(); |
| 2495 | 2495 | $sth = $Connection->db->prepare($query); |
| 2496 | 2496 | $sth->execute(array(':version' => $version)); |
| 2497 | - } catch(PDOException $e) { |
|
| 2497 | + } catch (PDOException $e) { |
|
| 2498 | 2498 | return "error : ".$e->getMessage(); |
| 2499 | 2499 | } |
| 2500 | 2500 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2508,7 +2508,7 @@ discard block |
||
| 2508 | 2508 | $Connection = new Connection(); |
| 2509 | 2509 | $sth = $Connection->db->prepare($query); |
| 2510 | 2510 | $sth->execute(array(':version' => $version)); |
| 2511 | - } catch(PDOException $e) { |
|
| 2511 | + } catch (PDOException $e) { |
|
| 2512 | 2512 | return "error : ".$e->getMessage(); |
| 2513 | 2513 | } |
| 2514 | 2514 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2524,7 +2524,7 @@ discard block |
||
| 2524 | 2524 | $Connection = new Connection(); |
| 2525 | 2525 | $sth = $Connection->db->prepare($query); |
| 2526 | 2526 | $sth->execute(array(':version' => $version)); |
| 2527 | - } catch(PDOException $e) { |
|
| 2527 | + } catch (PDOException $e) { |
|
| 2528 | 2528 | return "error : ".$e->getMessage(); |
| 2529 | 2529 | } |
| 2530 | 2530 | } |
@@ -2536,7 +2536,7 @@ discard block |
||
| 2536 | 2536 | $Connection = new Connection(); |
| 2537 | 2537 | $sth = $Connection->db->prepare($query); |
| 2538 | 2538 | $sth->execute(array(':version' => $version)); |
| 2539 | - } catch(PDOException $e) { |
|
| 2539 | + } catch (PDOException $e) { |
|
| 2540 | 2540 | return "error : ".$e->getMessage(); |
| 2541 | 2541 | } |
| 2542 | 2542 | } |
@@ -2548,7 +2548,7 @@ discard block |
||
| 2548 | 2548 | $Connection = new Connection(); |
| 2549 | 2549 | $sth = $Connection->db->prepare($query); |
| 2550 | 2550 | $sth->execute(array(':version' => $version)); |
| 2551 | - } catch(PDOException $e) { |
|
| 2551 | + } catch (PDOException $e) { |
|
| 2552 | 2552 | return "error : ".$e->getMessage(); |
| 2553 | 2553 | } |
| 2554 | 2554 | } |
@@ -2564,7 +2564,7 @@ discard block |
||
| 2564 | 2564 | $Connection = new Connection(); |
| 2565 | 2565 | $sth = $Connection->db->prepare($query); |
| 2566 | 2566 | $sth->execute(); |
| 2567 | - } catch(PDOException $e) { |
|
| 2567 | + } catch (PDOException $e) { |
|
| 2568 | 2568 | return "error : ".$e->getMessage(); |
| 2569 | 2569 | } |
| 2570 | 2570 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2579,7 +2579,7 @@ discard block |
||
| 2579 | 2579 | $Connection = new Connection(); |
| 2580 | 2580 | $sth = $Connection->db->prepare($query); |
| 2581 | 2581 | $sth->execute(); |
| 2582 | - } catch(PDOException $e) { |
|
| 2582 | + } catch (PDOException $e) { |
|
| 2583 | 2583 | return "error : ".$e->getMessage(); |
| 2584 | 2584 | } |
| 2585 | 2585 | } |
@@ -2595,7 +2595,7 @@ discard block |
||
| 2595 | 2595 | $Connection = new Connection(); |
| 2596 | 2596 | $sth = $Connection->db->prepare($query); |
| 2597 | 2597 | $sth->execute(); |
| 2598 | - } catch(PDOException $e) { |
|
| 2598 | + } catch (PDOException $e) { |
|
| 2599 | 2599 | return "error : ".$e->getMessage(); |
| 2600 | 2600 | } |
| 2601 | 2601 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2610,7 +2610,7 @@ discard block |
||
| 2610 | 2610 | $Connection = new Connection(); |
| 2611 | 2611 | $sth = $Connection->db->prepare($query); |
| 2612 | 2612 | $sth->execute(); |
| 2613 | - } catch(PDOException $e) { |
|
| 2613 | + } catch (PDOException $e) { |
|
| 2614 | 2614 | return "error : ".$e->getMessage(); |
| 2615 | 2615 | } |
| 2616 | 2616 | } |
@@ -2626,7 +2626,7 @@ discard block |
||
| 2626 | 2626 | $Connection = new Connection(); |
| 2627 | 2627 | $sth = $Connection->db->prepare($query); |
| 2628 | 2628 | $sth->execute(); |
| 2629 | - } catch(PDOException $e) { |
|
| 2629 | + } catch (PDOException $e) { |
|
| 2630 | 2630 | return "error : ".$e->getMessage(); |
| 2631 | 2631 | } |
| 2632 | 2632 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2641,7 +2641,7 @@ discard block |
||
| 2641 | 2641 | $Connection = new Connection(); |
| 2642 | 2642 | $sth = $Connection->db->prepare($query); |
| 2643 | 2643 | $sth->execute(); |
| 2644 | - } catch(PDOException $e) { |
|
| 2644 | + } catch (PDOException $e) { |
|
| 2645 | 2645 | return "error : ".$e->getMessage(); |
| 2646 | 2646 | } |
| 2647 | 2647 | } |
@@ -2657,7 +2657,7 @@ discard block |
||
| 2657 | 2657 | $Connection = new Connection(); |
| 2658 | 2658 | $sth = $Connection->db->prepare($query); |
| 2659 | 2659 | $sth->execute(); |
| 2660 | - } catch(PDOException $e) { |
|
| 2660 | + } catch (PDOException $e) { |
|
| 2661 | 2661 | return "error : ".$e->getMessage(); |
| 2662 | 2662 | } |
| 2663 | 2663 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2672,7 +2672,7 @@ discard block |
||
| 2672 | 2672 | $Connection = new Connection(); |
| 2673 | 2673 | $sth = $Connection->db->prepare($query); |
| 2674 | 2674 | $sth->execute(); |
| 2675 | - } catch(PDOException $e) { |
|
| 2675 | + } catch (PDOException $e) { |
|
| 2676 | 2676 | return "error : ".$e->getMessage(); |
| 2677 | 2677 | } |
| 2678 | 2678 | } |
@@ -2687,7 +2687,7 @@ discard block |
||
| 2687 | 2687 | $Connection = new Connection(); |
| 2688 | 2688 | $sth = $Connection->db->prepare($query); |
| 2689 | 2689 | $sth->execute(); |
| 2690 | - } catch(PDOException $e) { |
|
| 2690 | + } catch (PDOException $e) { |
|
| 2691 | 2691 | return "error : ".$e->getMessage(); |
| 2692 | 2692 | } |
| 2693 | 2693 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2702,7 +2702,7 @@ discard block |
||
| 2702 | 2702 | $Connection = new Connection(); |
| 2703 | 2703 | $sth = $Connection->db->prepare($query); |
| 2704 | 2704 | $sth->execute(); |
| 2705 | - } catch(PDOException $e) { |
|
| 2705 | + } catch (PDOException $e) { |
|
| 2706 | 2706 | return "error : ".$e->getMessage(); |
| 2707 | 2707 | } |
| 2708 | 2708 | } |
@@ -2717,7 +2717,7 @@ discard block |
||
| 2717 | 2717 | $Connection = new Connection(); |
| 2718 | 2718 | $sth = $Connection->db->prepare($query); |
| 2719 | 2719 | $sth->execute(); |
| 2720 | - } catch(PDOException $e) { |
|
| 2720 | + } catch (PDOException $e) { |
|
| 2721 | 2721 | return "error : ".$e->getMessage(); |
| 2722 | 2722 | } |
| 2723 | 2723 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2732,7 +2732,7 @@ discard block |
||
| 2732 | 2732 | $Connection = new Connection(); |
| 2733 | 2733 | $sth = $Connection->db->prepare($query); |
| 2734 | 2734 | $sth->execute(); |
| 2735 | - } catch(PDOException $e) { |
|
| 2735 | + } catch (PDOException $e) { |
|
| 2736 | 2736 | return "error : ".$e->getMessage(); |
| 2737 | 2737 | } |
| 2738 | 2738 | } |
@@ -2747,7 +2747,7 @@ discard block |
||
| 2747 | 2747 | $Connection = new Connection(); |
| 2748 | 2748 | $sth = $Connection->db->prepare($query); |
| 2749 | 2749 | $sth->execute(); |
| 2750 | - } catch(PDOException $e) { |
|
| 2750 | + } catch (PDOException $e) { |
|
| 2751 | 2751 | return "error : ".$e->getMessage(); |
| 2752 | 2752 | } |
| 2753 | 2753 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2762,7 +2762,7 @@ discard block |
||
| 2762 | 2762 | $Connection = new Connection(); |
| 2763 | 2763 | $sth = $Connection->db->prepare($query); |
| 2764 | 2764 | $sth->execute(); |
| 2765 | - } catch(PDOException $e) { |
|
| 2765 | + } catch (PDOException $e) { |
|
| 2766 | 2766 | return "error : ".$e->getMessage(); |
| 2767 | 2767 | } |
| 2768 | 2768 | } |
@@ -2777,7 +2777,7 @@ discard block |
||
| 2777 | 2777 | $Connection = new Connection(); |
| 2778 | 2778 | $sth = $Connection->db->prepare($query); |
| 2779 | 2779 | $sth->execute(); |
| 2780 | - } catch(PDOException $e) { |
|
| 2780 | + } catch (PDOException $e) { |
|
| 2781 | 2781 | return "error : ".$e->getMessage(); |
| 2782 | 2782 | } |
| 2783 | 2783 | } |
@@ -2792,7 +2792,7 @@ discard block |
||
| 2792 | 2792 | $Connection = new Connection(); |
| 2793 | 2793 | $sth = $Connection->db->prepare($query); |
| 2794 | 2794 | $sth->execute(); |
| 2795 | - } catch(PDOException $e) { |
|
| 2795 | + } catch (PDOException $e) { |
|
| 2796 | 2796 | return "error : ".$e->getMessage(); |
| 2797 | 2797 | } |
| 2798 | 2798 | } |
@@ -17,7 +17,9 @@ discard block |
||
| 17 | 17 | curl_setopt($ch, CURLOPT_URL, $url); |
| 18 | 18 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 19 | 19 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 20 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 20 | + if ($referer != '') { |
|
| 21 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 22 | + } |
|
| 21 | 23 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
| 22 | 24 | curl_setopt($ch, CURLOPT_FILE, $fp); |
| 23 | 25 | curl_exec($ch); |
@@ -28,12 +30,16 @@ discard block |
||
| 28 | 30 | public static function gunzip($in_file,$out_file_name = '') { |
| 29 | 31 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 30 | 32 | $buffer_size = 4096; // read 4kb at a time |
| 31 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
| 33 | + if ($out_file_name == '') { |
|
| 34 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
| 35 | + } |
|
| 32 | 36 | if ($in_file != '' && file_exists($in_file)) { |
| 33 | 37 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 34 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 35 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 36 | - else { |
|
| 38 | + if (function_exists('gzopen')) { |
|
| 39 | + $file = gzopen($in_file,'rb'); |
|
| 40 | + } elseif (function_exists('gzopen64')) { |
|
| 41 | + $file = gzopen64($in_file,'rb'); |
|
| 42 | + } else { |
|
| 37 | 43 | echo 'gzopen not available'; |
| 38 | 44 | die; |
| 39 | 45 | } |
@@ -54,8 +60,12 @@ discard block |
||
| 54 | 60 | if ($res === TRUE) { |
| 55 | 61 | $zip->extractTo($path); |
| 56 | 62 | $zip->close(); |
| 57 | - } else return false; |
|
| 58 | - } else return false; |
|
| 63 | + } else { |
|
| 64 | + return false; |
|
| 65 | + } |
|
| 66 | + } else { |
|
| 67 | + return false; |
|
| 68 | + } |
|
| 59 | 69 | } |
| 60 | 70 | |
| 61 | 71 | public static function connect_sqlite($database) { |
@@ -70,7 +80,9 @@ discard block |
||
| 70 | 80 | public static function retrieve_route_sqlite_to_dest($database_file) { |
| 71 | 81 | global $globalDebug, $globalTransaction; |
| 72 | 82 | //$query = 'TRUNCATE TABLE routes'; |
| 73 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 83 | + if ($globalDebug) { |
|
| 84 | + echo " - Delete previous routes from DB -"; |
|
| 85 | + } |
|
| 74 | 86 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 75 | 87 | $Connection = new Connection(); |
| 76 | 88 | try { |
@@ -81,7 +93,9 @@ discard block |
||
| 81 | 93 | return "error : ".$e->getMessage(); |
| 82 | 94 | } |
| 83 | 95 | |
| 84 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 96 | + if ($globalDebug) { |
|
| 97 | + echo " - Add routes to DB -"; |
|
| 98 | + } |
|
| 85 | 99 | update_db::connect_sqlite($database_file); |
| 86 | 100 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
| 87 | 101 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -96,15 +110,21 @@ discard block |
||
| 96 | 110 | $Connection = new Connection(); |
| 97 | 111 | $sth_dest = $Connection->db->prepare($query_dest); |
| 98 | 112 | try { |
| 99 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 113 | + if ($globalTransaction) { |
|
| 114 | + $Connection->db->beginTransaction(); |
|
| 115 | + } |
|
| 100 | 116 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 101 | 117 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 102 | 118 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 103 | 119 | $sth_dest->execute($query_dest_values); |
| 104 | 120 | } |
| 105 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 121 | + if ($globalTransaction) { |
|
| 122 | + $Connection->db->commit(); |
|
| 123 | + } |
|
| 106 | 124 | } catch(PDOException $e) { |
| 107 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 125 | + if ($globalTransaction) { |
|
| 126 | + $Connection->db->rollBack(); |
|
| 127 | + } |
|
| 108 | 128 | return "error : ".$e->getMessage(); |
| 109 | 129 | } |
| 110 | 130 | return ''; |
@@ -112,7 +132,9 @@ discard block |
||
| 112 | 132 | public static function retrieve_route_oneworld($database_file) { |
| 113 | 133 | global $globalDebug, $globalTransaction; |
| 114 | 134 | //$query = 'TRUNCATE TABLE routes'; |
| 115 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 135 | + if ($globalDebug) { |
|
| 136 | + echo " - Delete previous routes from DB -"; |
|
| 137 | + } |
|
| 116 | 138 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 117 | 139 | $Connection = new Connection(); |
| 118 | 140 | try { |
@@ -123,14 +145,18 @@ discard block |
||
| 123 | 145 | return "error : ".$e->getMessage(); |
| 124 | 146 | } |
| 125 | 147 | |
| 126 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 148 | + if ($globalDebug) { |
|
| 149 | + echo " - Add routes to DB -"; |
|
| 150 | + } |
|
| 127 | 151 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 128 | 152 | $Spotter = new Spotter(); |
| 129 | 153 | if ($fh = fopen($database_file,"r")) { |
| 130 | 154 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 131 | 155 | $Connection = new Connection(); |
| 132 | 156 | $sth_dest = $Connection->db->prepare($query_dest); |
| 133 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 157 | + if ($globalTransaction) { |
|
| 158 | + $Connection->db->beginTransaction(); |
|
| 159 | + } |
|
| 134 | 160 | while (!feof($fh)) { |
| 135 | 161 | $line = fgetcsv($fh,9999,','); |
| 136 | 162 | if ($line[0] != '') { |
@@ -139,13 +165,17 @@ discard block |
||
| 139 | 165 | $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
| 140 | 166 | $sth_dest->execute($query_dest_values); |
| 141 | 167 | } catch(PDOException $e) { |
| 142 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 168 | + if ($globalTransaction) { |
|
| 169 | + $Connection->db->rollBack(); |
|
| 170 | + } |
|
| 143 | 171 | return "error : ".$e->getMessage(); |
| 144 | 172 | } |
| 145 | 173 | } |
| 146 | 174 | } |
| 147 | 175 | } |
| 148 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 176 | + if ($globalTransaction) { |
|
| 177 | + $Connection->db->commit(); |
|
| 178 | + } |
|
| 149 | 179 | } |
| 150 | 180 | return ''; |
| 151 | 181 | } |
@@ -153,7 +183,9 @@ discard block |
||
| 153 | 183 | public static function retrieve_route_skyteam($database_file) { |
| 154 | 184 | global $globalDebug, $globalTransaction; |
| 155 | 185 | //$query = 'TRUNCATE TABLE routes'; |
| 156 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 186 | + if ($globalDebug) { |
|
| 187 | + echo " - Delete previous routes from DB -"; |
|
| 188 | + } |
|
| 157 | 189 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 158 | 190 | $Connection = new Connection(); |
| 159 | 191 | try { |
@@ -164,7 +196,9 @@ discard block |
||
| 164 | 196 | return "error : ".$e->getMessage(); |
| 165 | 197 | } |
| 166 | 198 | |
| 167 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 199 | + if ($globalDebug) { |
|
| 200 | + echo " - Add routes to DB -"; |
|
| 201 | + } |
|
| 168 | 202 | |
| 169 | 203 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 170 | 204 | $Spotter = new Spotter(); |
@@ -173,7 +207,9 @@ discard block |
||
| 173 | 207 | $Connection = new Connection(); |
| 174 | 208 | $sth_dest = $Connection->db->prepare($query_dest); |
| 175 | 209 | try { |
| 176 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 210 | + if ($globalTransaction) { |
|
| 211 | + $Connection->db->beginTransaction(); |
|
| 212 | + } |
|
| 177 | 213 | while (!feof($fh)) { |
| 178 | 214 | $line = fgetcsv($fh,9999,','); |
| 179 | 215 | if ($line[0] != '') { |
@@ -184,9 +220,13 @@ discard block |
||
| 184 | 220 | } |
| 185 | 221 | } |
| 186 | 222 | } |
| 187 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 223 | + if ($globalTransaction) { |
|
| 224 | + $Connection->db->commit(); |
|
| 225 | + } |
|
| 188 | 226 | } catch(PDOException $e) { |
| 189 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 227 | + if ($globalTransaction) { |
|
| 228 | + $Connection->db->rollBack(); |
|
| 229 | + } |
|
| 190 | 230 | return "error : ".$e->getMessage(); |
| 191 | 231 | } |
| 192 | 232 | } |
@@ -229,11 +269,16 @@ discard block |
||
| 229 | 269 | $sth_dest = $Connection->db->prepare($query_dest); |
| 230 | 270 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 231 | 271 | try { |
| 232 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 272 | + if ($globalTransaction) { |
|
| 273 | + $Connection->db->beginTransaction(); |
|
| 274 | + } |
|
| 233 | 275 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 234 | 276 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 235 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
| 236 | - else $type = null; |
|
| 277 | + if ($values['UserString4'] == 'M') { |
|
| 278 | + $type = 'military'; |
|
| 279 | + } else { |
|
| 280 | + $type = null; |
|
| 281 | + } |
|
| 237 | 282 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 238 | 283 | $sth_dest->execute($query_dest_values); |
| 239 | 284 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -241,7 +286,9 @@ discard block |
||
| 241 | 286 | $sth_dest_owner->execute($query_dest_owner_values); |
| 242 | 287 | } |
| 243 | 288 | } |
| 244 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 289 | + if ($globalTransaction) { |
|
| 290 | + $Connection->db->commit(); |
|
| 291 | + } |
|
| 245 | 292 | } catch(PDOException $e) { |
| 246 | 293 | return "error : ".$e->getMessage(); |
| 247 | 294 | } |
@@ -278,7 +325,9 @@ discard block |
||
| 278 | 325 | $Connection = new Connection(); |
| 279 | 326 | $sth_dest = $Connection->db->prepare($query_dest); |
| 280 | 327 | try { |
| 281 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 328 | + if ($globalTransaction) { |
|
| 329 | + $Connection->db->beginTransaction(); |
|
| 330 | + } |
|
| 282 | 331 | while (!feof($fh)) { |
| 283 | 332 | $values = array(); |
| 284 | 333 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -289,7 +338,9 @@ discard block |
||
| 289 | 338 | // Check if we can find ICAO, else set it to GLID |
| 290 | 339 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 291 | 340 | $search_more = ''; |
| 292 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 341 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 342 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 343 | + } |
|
| 293 | 344 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 294 | 345 | $sth_search = $Connection->db->prepare($query_search); |
| 295 | 346 | try { |
@@ -302,7 +353,9 @@ discard block |
||
| 302 | 353 | } catch(PDOException $e) { |
| 303 | 354 | return "error : ".$e->getMessage(); |
| 304 | 355 | } |
| 305 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
| 356 | + if (!isset($values['ICAOTypeCode'])) { |
|
| 357 | + $values['ICAOTypeCode'] = 'GLID'; |
|
| 358 | + } |
|
| 306 | 359 | // Add data to db |
| 307 | 360 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
| 308 | 361 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
@@ -311,7 +364,9 @@ discard block |
||
| 311 | 364 | $sth_dest->execute($query_dest_values); |
| 312 | 365 | } |
| 313 | 366 | } |
| 314 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 367 | + if ($globalTransaction) { |
|
| 368 | + $Connection->db->commit(); |
|
| 369 | + } |
|
| 315 | 370 | } catch(PDOException $e) { |
| 316 | 371 | return "error : ".$e->getMessage(); |
| 317 | 372 | } |
@@ -347,7 +402,9 @@ discard block |
||
| 347 | 402 | $Connection = new Connection(); |
| 348 | 403 | $sth_dest = $Connection->db->prepare($query_dest); |
| 349 | 404 | try { |
| 350 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 405 | + if ($globalTransaction) { |
|
| 406 | + $Connection->db->beginTransaction(); |
|
| 407 | + } |
|
| 351 | 408 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 352 | 409 | while (!feof($fh)) { |
| 353 | 410 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -361,13 +418,17 @@ discard block |
||
| 361 | 418 | // Check if we can find ICAO, else set it to GLID |
| 362 | 419 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 363 | 420 | $search_more = ''; |
| 364 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 421 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 422 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 423 | + } |
|
| 365 | 424 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 366 | 425 | $sth_search = $Connection->db->prepare($query_search); |
| 367 | 426 | try { |
| 368 | 427 | $sth_search->execute(); |
| 369 | 428 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 370 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 429 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 430 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 431 | + } |
|
| 371 | 432 | } catch(PDOException $e) { |
| 372 | 433 | return "error : ".$e->getMessage(); |
| 373 | 434 | } |
@@ -380,7 +441,9 @@ discard block |
||
| 380 | 441 | $sth_dest->execute($query_dest_values); |
| 381 | 442 | } |
| 382 | 443 | } |
| 383 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 444 | + if ($globalTransaction) { |
|
| 445 | + $Connection->db->commit(); |
|
| 446 | + } |
|
| 384 | 447 | } catch(PDOException $e) { |
| 385 | 448 | return "error : ".$e->getMessage(); |
| 386 | 449 | } |
@@ -419,7 +482,9 @@ discard block |
||
| 419 | 482 | $sth_dest = $Connection->db->prepare($query_dest); |
| 420 | 483 | $sth_modes = $Connection->db->prepare($query_modes); |
| 421 | 484 | try { |
| 422 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 485 | + if ($globalTransaction) { |
|
| 486 | + $Connection->db->beginTransaction(); |
|
| 487 | + } |
|
| 423 | 488 | $tmp = fgetcsv($fh,9999,',','"'); |
| 424 | 489 | while (!feof($fh)) { |
| 425 | 490 | $line = fgetcsv($fh,9999,',','"'); |
@@ -429,16 +494,22 @@ discard block |
||
| 429 | 494 | $values['registration'] = $line[0]; |
| 430 | 495 | $values['base'] = $line[4]; |
| 431 | 496 | $values['owner'] = $line[5]; |
| 432 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 433 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 497 | + if ($line[6] == '') { |
|
| 498 | + $values['date_first_reg'] = null; |
|
| 499 | + } else { |
|
| 500 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 501 | + } |
|
| 434 | 502 | $values['cancel'] = $line[7]; |
| 435 | 503 | } elseif ($country == 'EI') { |
| 436 | 504 | // TODO : add modeS & reg to aircraft_modes |
| 437 | 505 | $values['registration'] = $line[0]; |
| 438 | 506 | $values['base'] = $line[3]; |
| 439 | 507 | $values['owner'] = $line[2]; |
| 440 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 441 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 508 | + if ($line[1] == '') { |
|
| 509 | + $values['date_first_reg'] = null; |
|
| 510 | + } else { |
|
| 511 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 512 | + } |
|
| 442 | 513 | $values['cancel'] = ''; |
| 443 | 514 | $values['modes'] = $line[7]; |
| 444 | 515 | $values['icao'] = $line[8]; |
@@ -457,16 +528,22 @@ discard block |
||
| 457 | 528 | $values['registration'] = $line[3]; |
| 458 | 529 | $values['base'] = null; |
| 459 | 530 | $values['owner'] = $line[5]; |
| 460 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 461 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 531 | + if ($line[18] == '') { |
|
| 532 | + $values['date_first_reg'] = null; |
|
| 533 | + } else { |
|
| 534 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 535 | + } |
|
| 462 | 536 | $values['cancel'] = ''; |
| 463 | 537 | } elseif ($country == 'VH') { |
| 464 | 538 | // TODO : add modeS & reg to aircraft_modes |
| 465 | 539 | $values['registration'] = $line[0]; |
| 466 | 540 | $values['base'] = null; |
| 467 | 541 | $values['owner'] = $line[12]; |
| 468 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 469 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 542 | + if ($line[28] == '') { |
|
| 543 | + $values['date_first_reg'] = null; |
|
| 544 | + } else { |
|
| 545 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 546 | + } |
|
| 470 | 547 | |
| 471 | 548 | $values['cancel'] = $line[39]; |
| 472 | 549 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -485,29 +562,41 @@ discard block |
||
| 485 | 562 | $values['registration'] = $line[0]; |
| 486 | 563 | $values['base'] = null; |
| 487 | 564 | $values['owner'] = $line[8]; |
| 488 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 489 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 565 | + if ($line[7] == '') { |
|
| 566 | + $values['date_first_reg'] = null; |
|
| 567 | + } else { |
|
| 568 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 569 | + } |
|
| 490 | 570 | $values['cancel'] = ''; |
| 491 | 571 | } elseif ($country == 'PP') { |
| 492 | 572 | $values['registration'] = $line[0]; |
| 493 | 573 | $values['base'] = null; |
| 494 | 574 | $values['owner'] = $line[4]; |
| 495 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 496 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 575 | + if ($line[6] == '') { |
|
| 576 | + $values['date_first_reg'] = null; |
|
| 577 | + } else { |
|
| 578 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 579 | + } |
|
| 497 | 580 | $values['cancel'] = $line[7]; |
| 498 | 581 | } elseif ($country == 'E7') { |
| 499 | 582 | $values['registration'] = $line[0]; |
| 500 | 583 | $values['base'] = null; |
| 501 | 584 | $values['owner'] = $line[4]; |
| 502 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 503 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 585 | + if ($line[5] == '') { |
|
| 586 | + $values['date_first_reg'] = null; |
|
| 587 | + } else { |
|
| 588 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 589 | + } |
|
| 504 | 590 | $values['cancel'] = ''; |
| 505 | 591 | } elseif ($country == '8Q') { |
| 506 | 592 | $values['registration'] = $line[0]; |
| 507 | 593 | $values['base'] = null; |
| 508 | 594 | $values['owner'] = $line[3]; |
| 509 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 510 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 595 | + if ($line[7] == '') { |
|
| 596 | + $values['date_first_reg'] = null; |
|
| 597 | + } else { |
|
| 598 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 599 | + } |
|
| 511 | 600 | $values['cancel'] = ''; |
| 512 | 601 | } elseif ($country == 'ZK') { |
| 513 | 602 | $values['registration'] = $line[0]; |
@@ -552,7 +641,9 @@ discard block |
||
| 552 | 641 | $sth_modes->execute($query_modes_values); |
| 553 | 642 | } |
| 554 | 643 | } |
| 555 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 644 | + if ($globalTransaction) { |
|
| 645 | + $Connection->db->commit(); |
|
| 646 | + } |
|
| 556 | 647 | } catch(PDOException $e) { |
| 557 | 648 | return "error : ".$e->getMessage(); |
| 558 | 649 | } |
@@ -688,25 +779,45 @@ discard block |
||
| 688 | 779 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
| 689 | 780 | $Connection = new Connection(); |
| 690 | 781 | $sth_dest = $Connection->db->prepare($query_dest); |
| 691 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 782 | + if ($globalTransaction) { |
|
| 783 | + $Connection->db->beginTransaction(); |
|
| 784 | + } |
|
| 692 | 785 | |
| 693 | 786 | $i = 0; |
| 694 | 787 | while($row = sparql_fetch_array($result)) |
| 695 | 788 | { |
| 696 | 789 | if ($i >= 1) { |
| 697 | 790 | //print_r($row); |
| 698 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
| 699 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
| 700 | - if (!isset($row['type'])) $row['type'] = ''; |
|
| 701 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
| 791 | + if (!isset($row['iata'])) { |
|
| 792 | + $row['iata'] = ''; |
|
| 793 | + } |
|
| 794 | + if (!isset($row['icao'])) { |
|
| 795 | + $row['icao'] = ''; |
|
| 796 | + } |
|
| 797 | + if (!isset($row['type'])) { |
|
| 798 | + $row['type'] = ''; |
|
| 799 | + } |
|
| 800 | + if (!isset($row['altitude'])) { |
|
| 801 | + $row['altitude'] = ''; |
|
| 802 | + } |
|
| 702 | 803 | if (isset($row['city_bis'])) { |
| 703 | 804 | $row['city'] = $row['city_bis']; |
| 704 | 805 | } |
| 705 | - if (!isset($row['city'])) $row['city'] = ''; |
|
| 706 | - if (!isset($row['country'])) $row['country'] = ''; |
|
| 707 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
| 708 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
| 709 | - if (!isset($row['name'])) continue; |
|
| 806 | + if (!isset($row['city'])) { |
|
| 807 | + $row['city'] = ''; |
|
| 808 | + } |
|
| 809 | + if (!isset($row['country'])) { |
|
| 810 | + $row['country'] = ''; |
|
| 811 | + } |
|
| 812 | + if (!isset($row['homepage'])) { |
|
| 813 | + $row['homepage'] = ''; |
|
| 814 | + } |
|
| 815 | + if (!isset($row['wikipedia_page'])) { |
|
| 816 | + $row['wikipedia_page'] = ''; |
|
| 817 | + } |
|
| 818 | + if (!isset($row['name'])) { |
|
| 819 | + continue; |
|
| 820 | + } |
|
| 710 | 821 | if (!isset($row['image'])) { |
| 711 | 822 | $row['image'] = ''; |
| 712 | 823 | $row['image_thumb'] = ''; |
@@ -762,7 +873,9 @@ discard block |
||
| 762 | 873 | |
| 763 | 874 | $i++; |
| 764 | 875 | } |
| 765 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 876 | + if ($globalTransaction) { |
|
| 877 | + $Connection->db->commit(); |
|
| 878 | + } |
|
| 766 | 879 | /* |
| 767 | 880 | echo "Delete duplicate rows...\n"; |
| 768 | 881 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
@@ -805,7 +918,9 @@ discard block |
||
| 805 | 918 | $delimiter = ','; |
| 806 | 919 | $out_file = $tmp_dir.'airports.csv'; |
| 807 | 920 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
| 808 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 921 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 922 | + return FALSE; |
|
| 923 | + } |
|
| 809 | 924 | echo "Add data from ourairports.com...\n"; |
| 810 | 925 | |
| 811 | 926 | $header = NULL; |
@@ -815,8 +930,9 @@ discard block |
||
| 815 | 930 | //$Connection->db->beginTransaction(); |
| 816 | 931 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 817 | 932 | { |
| 818 | - if(!$header) $header = $row; |
|
| 819 | - else { |
|
| 933 | + if(!$header) { |
|
| 934 | + $header = $row; |
|
| 935 | + } else { |
|
| 820 | 936 | $data = array(); |
| 821 | 937 | $data = array_combine($header, $row); |
| 822 | 938 | try { |
@@ -857,7 +973,9 @@ discard block |
||
| 857 | 973 | echo "Download data from another free database...\n"; |
| 858 | 974 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 859 | 975 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
| 860 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 976 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 977 | + return FALSE; |
|
| 978 | + } |
|
| 861 | 979 | update_db::unzip($out_file); |
| 862 | 980 | $header = NULL; |
| 863 | 981 | echo "Add data from another free database...\n"; |
@@ -868,8 +986,9 @@ discard block |
||
| 868 | 986 | //$Connection->db->beginTransaction(); |
| 869 | 987 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 870 | 988 | { |
| 871 | - if(!$header) $header = $row; |
|
| 872 | - else { |
|
| 989 | + if(!$header) { |
|
| 990 | + $header = $row; |
|
| 991 | + } else { |
|
| 873 | 992 | $data = $row; |
| 874 | 993 | |
| 875 | 994 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
@@ -1042,7 +1161,9 @@ discard block |
||
| 1042 | 1161 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
| 1043 | 1162 | { |
| 1044 | 1163 | $i = 0; |
| 1045 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1164 | + if ($globalTransaction) { |
|
| 1165 | + $Connection->db->beginTransaction(); |
|
| 1166 | + } |
|
| 1046 | 1167 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1047 | 1168 | { |
| 1048 | 1169 | if ($i > 0) { |
@@ -1055,7 +1176,9 @@ discard block |
||
| 1055 | 1176 | } |
| 1056 | 1177 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
| 1057 | 1178 | if (!empty($result_search)) { |
| 1058 | - if ($globalDebug) echo '.'; |
|
| 1179 | + if ($globalDebug) { |
|
| 1180 | + echo '.'; |
|
| 1181 | + } |
|
| 1059 | 1182 | //if ($globalDBdriver == 'mysql') { |
| 1060 | 1183 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
| 1061 | 1184 | //} else { |
@@ -1077,8 +1200,12 @@ discard block |
||
| 1077 | 1200 | } |
| 1078 | 1201 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
| 1079 | 1202 | if (!empty($result_search_mfr)) { |
| 1080 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
| 1081 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
| 1203 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
| 1204 | + $data[16] = $data[23]; |
|
| 1205 | + } |
|
| 1206 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
| 1207 | + $data[16] = $data[15]; |
|
| 1208 | + } |
|
| 1082 | 1209 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
| 1083 | 1210 | try { |
| 1084 | 1211 | $sthf = $Connection->db->prepare($queryf); |
@@ -1089,7 +1216,9 @@ discard block |
||
| 1089 | 1216 | } |
| 1090 | 1217 | } |
| 1091 | 1218 | if (strtotime($data[29]) > time()) { |
| 1092 | - if ($globalDebug) echo 'i'; |
|
| 1219 | + if ($globalDebug) { |
|
| 1220 | + echo 'i'; |
|
| 1221 | + } |
|
| 1093 | 1222 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 1094 | 1223 | try { |
| 1095 | 1224 | $sth = $Connection->db->prepare($query); |
@@ -1100,13 +1229,19 @@ discard block |
||
| 1100 | 1229 | } |
| 1101 | 1230 | } |
| 1102 | 1231 | if ($i % 90 == 0) { |
| 1103 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1104 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1232 | + if ($globalTransaction) { |
|
| 1233 | + $Connection->db->commit(); |
|
| 1234 | + } |
|
| 1235 | + if ($globalTransaction) { |
|
| 1236 | + $Connection->db->beginTransaction(); |
|
| 1237 | + } |
|
| 1105 | 1238 | } |
| 1106 | 1239 | $i++; |
| 1107 | 1240 | } |
| 1108 | 1241 | fclose($handle); |
| 1109 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1242 | + if ($globalTransaction) { |
|
| 1243 | + $Connection->db->commit(); |
|
| 1244 | + } |
|
| 1110 | 1245 | } |
| 1111 | 1246 | print_r($mfr); |
| 1112 | 1247 | return ''; |
@@ -1131,11 +1266,15 @@ discard block |
||
| 1131 | 1266 | $i = 0; |
| 1132 | 1267 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
| 1133 | 1268 | //$Connection->db->beginTransaction(); |
| 1134 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1269 | + if ($globalTransaction) { |
|
| 1270 | + $Connection->db->beginTransaction(); |
|
| 1271 | + } |
|
| 1135 | 1272 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1136 | 1273 | { |
| 1137 | 1274 | if ($i > 0) { |
| 1138 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
| 1275 | + if ($data[1] == 'NULL') { |
|
| 1276 | + $data[1] = $data[0]; |
|
| 1277 | + } |
|
| 1139 | 1278 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
| 1140 | 1279 | try { |
| 1141 | 1280 | $sth = $Connection->db->prepare($query); |
@@ -1147,7 +1286,9 @@ discard block |
||
| 1147 | 1286 | $i++; |
| 1148 | 1287 | } |
| 1149 | 1288 | fclose($handle); |
| 1150 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1289 | + if ($globalTransaction) { |
|
| 1290 | + $Connection->db->commit(); |
|
| 1291 | + } |
|
| 1151 | 1292 | } |
| 1152 | 1293 | return ''; |
| 1153 | 1294 | } |
@@ -1168,7 +1309,9 @@ discard block |
||
| 1168 | 1309 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
| 1169 | 1310 | { |
| 1170 | 1311 | $i = 0; |
| 1171 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1312 | + if ($globalTransaction) { |
|
| 1313 | + $Connection->db->beginTransaction(); |
|
| 1314 | + } |
|
| 1172 | 1315 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1173 | 1316 | { |
| 1174 | 1317 | if ($i > 0) { |
@@ -1184,7 +1327,9 @@ discard block |
||
| 1184 | 1327 | $i++; |
| 1185 | 1328 | } |
| 1186 | 1329 | fclose($handle); |
| 1187 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1330 | + if ($globalTransaction) { |
|
| 1331 | + $Connection->db->commit(); |
|
| 1332 | + } |
|
| 1188 | 1333 | } |
| 1189 | 1334 | return ''; |
| 1190 | 1335 | } |
@@ -1204,7 +1349,9 @@ discard block |
||
| 1204 | 1349 | if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE) |
| 1205 | 1350 | { |
| 1206 | 1351 | $i = 0; |
| 1207 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1352 | + if ($globalTransaction) { |
|
| 1353 | + $Connection->db->beginTransaction(); |
|
| 1354 | + } |
|
| 1208 | 1355 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1209 | 1356 | { |
| 1210 | 1357 | if ($i > 0) { |
@@ -1213,13 +1360,17 @@ discard block |
||
| 1213 | 1360 | $sth = $Connection->db->prepare($query); |
| 1214 | 1361 | $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
| 1215 | 1362 | } catch(PDOException $e) { |
| 1216 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1363 | + if ($globalDebug) { |
|
| 1364 | + echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1365 | + } |
|
| 1217 | 1366 | } |
| 1218 | 1367 | } |
| 1219 | 1368 | $i++; |
| 1220 | 1369 | } |
| 1221 | 1370 | fclose($handle); |
| 1222 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1371 | + if ($globalTransaction) { |
|
| 1372 | + $Connection->db->commit(); |
|
| 1373 | + } |
|
| 1223 | 1374 | } |
| 1224 | 1375 | return ''; |
| 1225 | 1376 | } |
@@ -1244,7 +1395,9 @@ discard block |
||
| 1244 | 1395 | $i = 0; |
| 1245 | 1396 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
| 1246 | 1397 | //$Connection->db->beginTransaction(); |
| 1247 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1398 | + if ($globalTransaction) { |
|
| 1399 | + $Connection->db->beginTransaction(); |
|
| 1400 | + } |
|
| 1248 | 1401 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1249 | 1402 | { |
| 1250 | 1403 | if ($i > 0) { |
@@ -1260,7 +1413,9 @@ discard block |
||
| 1260 | 1413 | $i++; |
| 1261 | 1414 | } |
| 1262 | 1415 | fclose($handle); |
| 1263 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1416 | + if ($globalTransaction) { |
|
| 1417 | + $Connection->db->commit(); |
|
| 1418 | + } |
|
| 1264 | 1419 | } |
| 1265 | 1420 | return ''; |
| 1266 | 1421 | } |
@@ -1279,7 +1434,9 @@ discard block |
||
| 1279 | 1434 | $Connection = new Connection(); |
| 1280 | 1435 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
| 1281 | 1436 | { |
| 1282 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1437 | + if ($globalTransaction) { |
|
| 1438 | + $Connection->db->beginTransaction(); |
|
| 1439 | + } |
|
| 1283 | 1440 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
| 1284 | 1441 | { |
| 1285 | 1442 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1294,7 +1451,9 @@ discard block |
||
| 1294 | 1451 | } |
| 1295 | 1452 | } |
| 1296 | 1453 | fclose($handle); |
| 1297 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1454 | + if ($globalTransaction) { |
|
| 1455 | + $Connection->db->commit(); |
|
| 1456 | + } |
|
| 1298 | 1457 | } |
| 1299 | 1458 | return ''; |
| 1300 | 1459 | } |
@@ -1445,7 +1604,9 @@ discard block |
||
| 1445 | 1604 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1446 | 1605 | { |
| 1447 | 1606 | $i = 0; |
| 1448 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1607 | + if ($globalTransaction) { |
|
| 1608 | + $Connection->db->beginTransaction(); |
|
| 1609 | + } |
|
| 1449 | 1610 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1450 | 1611 | { |
| 1451 | 1612 | $i++; |
@@ -1473,7 +1634,9 @@ discard block |
||
| 1473 | 1634 | } |
| 1474 | 1635 | } |
| 1475 | 1636 | fclose($handle); |
| 1476 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1637 | + if ($globalTransaction) { |
|
| 1638 | + $Connection->db->commit(); |
|
| 1639 | + } |
|
| 1477 | 1640 | } |
| 1478 | 1641 | return ''; |
| 1479 | 1642 | } |
@@ -1496,7 +1659,9 @@ discard block |
||
| 1496 | 1659 | $Connection = new Connection(); |
| 1497 | 1660 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1498 | 1661 | { |
| 1499 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1662 | + if ($globalTransaction) { |
|
| 1663 | + $Connection->db->beginTransaction(); |
|
| 1664 | + } |
|
| 1500 | 1665 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1501 | 1666 | { |
| 1502 | 1667 | if(count($row) > 1) { |
@@ -1510,7 +1675,9 @@ discard block |
||
| 1510 | 1675 | } |
| 1511 | 1676 | } |
| 1512 | 1677 | fclose($handle); |
| 1513 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1678 | + if ($globalTransaction) { |
|
| 1679 | + $Connection->db->commit(); |
|
| 1680 | + } |
|
| 1514 | 1681 | } |
| 1515 | 1682 | return ''; |
| 1516 | 1683 | } |
@@ -1530,8 +1697,9 @@ discard block |
||
| 1530 | 1697 | } |
| 1531 | 1698 | |
| 1532 | 1699 | |
| 1533 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1534 | - else { |
|
| 1700 | + if ($globalDBdriver == 'mysql') { |
|
| 1701 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1702 | + } else { |
|
| 1535 | 1703 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
| 1536 | 1704 | $query = "CREATE EXTENSION postgis"; |
| 1537 | 1705 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1550,20 +1718,30 @@ discard block |
||
| 1550 | 1718 | global $tmp_dir, $globalDebug; |
| 1551 | 1719 | include_once('class.create_db.php'); |
| 1552 | 1720 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1553 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
| 1721 | + if ($globalDebug) { |
|
| 1722 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
| 1723 | + } |
|
| 1554 | 1724 | update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
| 1555 | 1725 | $error = ''; |
| 1556 | 1726 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 1557 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1727 | + if ($globalDebug) { |
|
| 1728 | + echo "Gunzip..."; |
|
| 1729 | + } |
|
| 1558 | 1730 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
| 1559 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1731 | + if ($globalDebug) { |
|
| 1732 | + echo "Add to DB..."; |
|
| 1733 | + } |
|
| 1560 | 1734 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
| 1561 | 1735 | $NOTAM = new NOTAM(); |
| 1562 | 1736 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
| 1563 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1737 | + } else { |
|
| 1738 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1739 | + } |
|
| 1564 | 1740 | if ($error != '') { |
| 1565 | 1741 | return $error; |
| 1566 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1742 | + } elseif ($globalDebug) { |
|
| 1743 | + echo "Done\n"; |
|
| 1744 | + } |
|
| 1567 | 1745 | return ''; |
| 1568 | 1746 | } |
| 1569 | 1747 | |
@@ -1617,67 +1795,111 @@ discard block |
||
| 1617 | 1795 | //if ($globalDebug) echo "IVAO : Download..."; |
| 1618 | 1796 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
| 1619 | 1797 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
| 1620 | - if ($globalDebug) echo "Unzip..."; |
|
| 1798 | + if ($globalDebug) { |
|
| 1799 | + echo "Unzip..."; |
|
| 1800 | + } |
|
| 1621 | 1801 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
| 1622 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1802 | + if ($globalDebug) { |
|
| 1803 | + echo "Add to DB..."; |
|
| 1804 | + } |
|
| 1623 | 1805 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1624 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
| 1806 | + if ($globalDebug) { |
|
| 1807 | + echo "Copy airlines logos to airlines images directory..."; |
|
| 1808 | + } |
|
| 1625 | 1809 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1626 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1627 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1628 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1810 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
| 1811 | + $error = "Failed to copy airlines logo."; |
|
| 1812 | + } |
|
| 1813 | + } else { |
|
| 1814 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1815 | + } |
|
| 1816 | + } else { |
|
| 1817 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1818 | + } |
|
| 1629 | 1819 | if ($error != '') { |
| 1630 | 1820 | return $error; |
| 1631 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1821 | + } elseif ($globalDebug) { |
|
| 1822 | + echo "Done\n"; |
|
| 1823 | + } |
|
| 1632 | 1824 | return ''; |
| 1633 | 1825 | } |
| 1634 | 1826 | |
| 1635 | 1827 | public static function update_routes() { |
| 1636 | 1828 | global $tmp_dir, $globalDebug; |
| 1637 | 1829 | $error = ''; |
| 1638 | - if ($globalDebug) echo "Routes : Download..."; |
|
| 1830 | + if ($globalDebug) { |
|
| 1831 | + echo "Routes : Download..."; |
|
| 1832 | + } |
|
| 1639 | 1833 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
| 1640 | 1834 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1641 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1835 | + if ($globalDebug) { |
|
| 1836 | + echo "Gunzip..."; |
|
| 1837 | + } |
|
| 1642 | 1838 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
| 1643 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1839 | + if ($globalDebug) { |
|
| 1840 | + echo "Add to DB..."; |
|
| 1841 | + } |
|
| 1644 | 1842 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
| 1645 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1843 | + } else { |
|
| 1844 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1845 | + } |
|
| 1646 | 1846 | if ($error != '') { |
| 1647 | 1847 | return $error; |
| 1648 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1848 | + } elseif ($globalDebug) { |
|
| 1849 | + echo "Done\n"; |
|
| 1850 | + } |
|
| 1649 | 1851 | return ''; |
| 1650 | 1852 | } |
| 1651 | 1853 | public static function update_oneworld() { |
| 1652 | 1854 | global $tmp_dir, $globalDebug; |
| 1653 | 1855 | $error = ''; |
| 1654 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
| 1856 | + if ($globalDebug) { |
|
| 1857 | + echo "Schedules Oneworld : Download..."; |
|
| 1858 | + } |
|
| 1655 | 1859 | update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
| 1656 | 1860 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 1657 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1861 | + if ($globalDebug) { |
|
| 1862 | + echo "Gunzip..."; |
|
| 1863 | + } |
|
| 1658 | 1864 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
| 1659 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1865 | + if ($globalDebug) { |
|
| 1866 | + echo "Add to DB..."; |
|
| 1867 | + } |
|
| 1660 | 1868 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
| 1661 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 1869 | + } else { |
|
| 1870 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 1871 | + } |
|
| 1662 | 1872 | if ($error != '') { |
| 1663 | 1873 | return $error; |
| 1664 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1874 | + } elseif ($globalDebug) { |
|
| 1875 | + echo "Done\n"; |
|
| 1876 | + } |
|
| 1665 | 1877 | return ''; |
| 1666 | 1878 | } |
| 1667 | 1879 | public static function update_skyteam() { |
| 1668 | 1880 | global $tmp_dir, $globalDebug; |
| 1669 | 1881 | $error = ''; |
| 1670 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
| 1882 | + if ($globalDebug) { |
|
| 1883 | + echo "Schedules Skyteam : Download..."; |
|
| 1884 | + } |
|
| 1671 | 1885 | update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
| 1672 | 1886 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 1673 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1887 | + if ($globalDebug) { |
|
| 1888 | + echo "Gunzip..."; |
|
| 1889 | + } |
|
| 1674 | 1890 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
| 1675 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1891 | + if ($globalDebug) { |
|
| 1892 | + echo "Add to DB..."; |
|
| 1893 | + } |
|
| 1676 | 1894 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
| 1677 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 1895 | + } else { |
|
| 1896 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 1897 | + } |
|
| 1678 | 1898 | if ($error != '') { |
| 1679 | 1899 | return $error; |
| 1680 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1900 | + } elseif ($globalDebug) { |
|
| 1901 | + echo "Done\n"; |
|
| 1902 | + } |
|
| 1681 | 1903 | return ''; |
| 1682 | 1904 | } |
| 1683 | 1905 | public static function update_ModeS() { |
@@ -1694,355 +1916,619 @@ discard block |
||
| 1694 | 1916 | exit; |
| 1695 | 1917 | } elseif ($globalDebug) echo "Done\n"; |
| 1696 | 1918 | */ |
| 1697 | - if ($globalDebug) echo "Modes : Download..."; |
|
| 1698 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 1919 | + if ($globalDebug) { |
|
| 1920 | + echo "Modes : Download..."; |
|
| 1921 | + } |
|
| 1922 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 1699 | 1923 | update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
| 1700 | 1924 | |
| 1701 | 1925 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1702 | 1926 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
| 1703 | - if ($globalDebug) echo "Unzip..."; |
|
| 1704 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 1927 | + if ($globalDebug) { |
|
| 1928 | + echo "Unzip..."; |
|
| 1929 | + } |
|
| 1930 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 1705 | 1931 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
| 1706 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1932 | + if ($globalDebug) { |
|
| 1933 | + echo "Add to DB..."; |
|
| 1934 | + } |
|
| 1707 | 1935 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
| 1708 | 1936 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
| 1709 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1937 | + } else { |
|
| 1938 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1939 | + } |
|
| 1710 | 1940 | if ($error != '') { |
| 1711 | 1941 | return $error; |
| 1712 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1942 | + } elseif ($globalDebug) { |
|
| 1943 | + echo "Done\n"; |
|
| 1944 | + } |
|
| 1713 | 1945 | return ''; |
| 1714 | 1946 | } |
| 1715 | 1947 | |
| 1716 | 1948 | public static function update_ModeS_faa() { |
| 1717 | 1949 | global $tmp_dir, $globalDebug; |
| 1718 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
| 1950 | + if ($globalDebug) { |
|
| 1951 | + echo "Modes FAA: Download..."; |
|
| 1952 | + } |
|
| 1719 | 1953 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
| 1720 | 1954 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
| 1721 | - if ($globalDebug) echo "Unzip..."; |
|
| 1955 | + if ($globalDebug) { |
|
| 1956 | + echo "Unzip..."; |
|
| 1957 | + } |
|
| 1722 | 1958 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
| 1723 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1959 | + if ($globalDebug) { |
|
| 1960 | + echo "Add to DB..."; |
|
| 1961 | + } |
|
| 1724 | 1962 | $error = update_db::modes_faa(); |
| 1725 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
| 1963 | + } else { |
|
| 1964 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
| 1965 | + } |
|
| 1726 | 1966 | if ($error != '') { |
| 1727 | 1967 | return $error; |
| 1728 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1968 | + } elseif ($globalDebug) { |
|
| 1969 | + echo "Done\n"; |
|
| 1970 | + } |
|
| 1729 | 1971 | return ''; |
| 1730 | 1972 | } |
| 1731 | 1973 | |
| 1732 | 1974 | public static function update_ModeS_flarm() { |
| 1733 | 1975 | global $tmp_dir, $globalDebug; |
| 1734 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
| 1976 | + if ($globalDebug) { |
|
| 1977 | + echo "Modes Flarmnet: Download..."; |
|
| 1978 | + } |
|
| 1735 | 1979 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
| 1736 | 1980 | if (file_exists($tmp_dir.'data.fln')) { |
| 1737 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1981 | + if ($globalDebug) { |
|
| 1982 | + echo "Add to DB..."; |
|
| 1983 | + } |
|
| 1738 | 1984 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
| 1739 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1985 | + } else { |
|
| 1986 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1987 | + } |
|
| 1740 | 1988 | if ($error != '') { |
| 1741 | 1989 | return $error; |
| 1742 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1990 | + } elseif ($globalDebug) { |
|
| 1991 | + echo "Done\n"; |
|
| 1992 | + } |
|
| 1743 | 1993 | return ''; |
| 1744 | 1994 | } |
| 1745 | 1995 | |
| 1746 | 1996 | public static function update_ModeS_ogn() { |
| 1747 | 1997 | global $tmp_dir, $globalDebug; |
| 1748 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
| 1998 | + if ($globalDebug) { |
|
| 1999 | + echo "Modes OGN: Download..."; |
|
| 2000 | + } |
|
| 1749 | 2001 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
| 1750 | 2002 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1751 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2003 | + if ($globalDebug) { |
|
| 2004 | + echo "Add to DB..."; |
|
| 2005 | + } |
|
| 1752 | 2006 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
| 1753 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 2007 | + } else { |
|
| 2008 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 2009 | + } |
|
| 1754 | 2010 | if ($error != '') { |
| 1755 | 2011 | return $error; |
| 1756 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2012 | + } elseif ($globalDebug) { |
|
| 2013 | + echo "Done\n"; |
|
| 2014 | + } |
|
| 1757 | 2015 | return ''; |
| 1758 | 2016 | } |
| 1759 | 2017 | |
| 1760 | 2018 | public static function update_owner() { |
| 1761 | 2019 | global $tmp_dir, $globalDebug, $globalMasterSource; |
| 1762 | 2020 | |
| 1763 | - if ($globalDebug) echo "Owner France: Download..."; |
|
| 2021 | + if ($globalDebug) { |
|
| 2022 | + echo "Owner France: Download..."; |
|
| 2023 | + } |
|
| 1764 | 2024 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
| 1765 | 2025 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1766 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2026 | + if ($globalDebug) { |
|
| 2027 | + echo "Add to DB..."; |
|
| 2028 | + } |
|
| 1767 | 2029 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
| 1768 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 2030 | + } else { |
|
| 2031 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 2032 | + } |
|
| 1769 | 2033 | if ($error != '') { |
| 1770 | 2034 | return $error; |
| 1771 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2035 | + } elseif ($globalDebug) { |
|
| 2036 | + echo "Done\n"; |
|
| 2037 | + } |
|
| 1772 | 2038 | |
| 1773 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
| 2039 | + if ($globalDebug) { |
|
| 2040 | + echo "Owner Ireland: Download..."; |
|
| 2041 | + } |
|
| 1774 | 2042 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
| 1775 | 2043 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1776 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2044 | + if ($globalDebug) { |
|
| 2045 | + echo "Add to DB..."; |
|
| 2046 | + } |
|
| 1777 | 2047 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
| 1778 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 2048 | + } else { |
|
| 2049 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 2050 | + } |
|
| 1779 | 2051 | if ($error != '') { |
| 1780 | 2052 | return $error; |
| 1781 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1782 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
| 2053 | + } elseif ($globalDebug) { |
|
| 2054 | + echo "Done\n"; |
|
| 2055 | + } |
|
| 2056 | + if ($globalDebug) { |
|
| 2057 | + echo "Owner Switzerland: Download..."; |
|
| 2058 | + } |
|
| 1783 | 2059 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
| 1784 | 2060 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1785 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2061 | + if ($globalDebug) { |
|
| 2062 | + echo "Add to DB..."; |
|
| 2063 | + } |
|
| 1786 | 2064 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
| 1787 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 2065 | + } else { |
|
| 2066 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 2067 | + } |
|
| 1788 | 2068 | if ($error != '') { |
| 1789 | 2069 | return $error; |
| 1790 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1791 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
| 2070 | + } elseif ($globalDebug) { |
|
| 2071 | + echo "Done\n"; |
|
| 2072 | + } |
|
| 2073 | + if ($globalDebug) { |
|
| 2074 | + echo "Owner Czech Republic: Download..."; |
|
| 2075 | + } |
|
| 1792 | 2076 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
| 1793 | 2077 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1794 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2078 | + if ($globalDebug) { |
|
| 2079 | + echo "Add to DB..."; |
|
| 2080 | + } |
|
| 1795 | 2081 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
| 1796 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 2082 | + } else { |
|
| 2083 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 2084 | + } |
|
| 1797 | 2085 | if ($error != '') { |
| 1798 | 2086 | return $error; |
| 1799 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1800 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
| 2087 | + } elseif ($globalDebug) { |
|
| 2088 | + echo "Done\n"; |
|
| 2089 | + } |
|
| 2090 | + if ($globalDebug) { |
|
| 2091 | + echo "Owner Australia: Download..."; |
|
| 2092 | + } |
|
| 1801 | 2093 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
| 1802 | 2094 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1803 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2095 | + if ($globalDebug) { |
|
| 2096 | + echo "Add to DB..."; |
|
| 2097 | + } |
|
| 1804 | 2098 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
| 1805 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 2099 | + } else { |
|
| 2100 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 2101 | + } |
|
| 1806 | 2102 | if ($error != '') { |
| 1807 | 2103 | return $error; |
| 1808 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1809 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
| 2104 | + } elseif ($globalDebug) { |
|
| 2105 | + echo "Done\n"; |
|
| 2106 | + } |
|
| 2107 | + if ($globalDebug) { |
|
| 2108 | + echo "Owner Austria: Download..."; |
|
| 2109 | + } |
|
| 1810 | 2110 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
| 1811 | 2111 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1812 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2112 | + if ($globalDebug) { |
|
| 2113 | + echo "Add to DB..."; |
|
| 2114 | + } |
|
| 1813 | 2115 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
| 1814 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 2116 | + } else { |
|
| 2117 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 2118 | + } |
|
| 1815 | 2119 | if ($error != '') { |
| 1816 | 2120 | return $error; |
| 1817 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1818 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
| 2121 | + } elseif ($globalDebug) { |
|
| 2122 | + echo "Done\n"; |
|
| 2123 | + } |
|
| 2124 | + if ($globalDebug) { |
|
| 2125 | + echo "Owner Chile: Download..."; |
|
| 2126 | + } |
|
| 1819 | 2127 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
| 1820 | 2128 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1821 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2129 | + if ($globalDebug) { |
|
| 2130 | + echo "Add to DB..."; |
|
| 2131 | + } |
|
| 1822 | 2132 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
| 1823 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 2133 | + } else { |
|
| 2134 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 2135 | + } |
|
| 1824 | 2136 | if ($error != '') { |
| 1825 | 2137 | return $error; |
| 1826 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1827 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
| 2138 | + } elseif ($globalDebug) { |
|
| 2139 | + echo "Done\n"; |
|
| 2140 | + } |
|
| 2141 | + if ($globalDebug) { |
|
| 2142 | + echo "Owner Colombia: Download..."; |
|
| 2143 | + } |
|
| 1828 | 2144 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
| 1829 | 2145 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1830 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2146 | + if ($globalDebug) { |
|
| 2147 | + echo "Add to DB..."; |
|
| 2148 | + } |
|
| 1831 | 2149 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
| 1832 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 2150 | + } else { |
|
| 2151 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 2152 | + } |
|
| 1833 | 2153 | if ($error != '') { |
| 1834 | 2154 | return $error; |
| 1835 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1836 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
| 2155 | + } elseif ($globalDebug) { |
|
| 2156 | + echo "Done\n"; |
|
| 2157 | + } |
|
| 2158 | + if ($globalDebug) { |
|
| 2159 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
| 2160 | + } |
|
| 1837 | 2161 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
| 1838 | 2162 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1839 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2163 | + if ($globalDebug) { |
|
| 2164 | + echo "Add to DB..."; |
|
| 2165 | + } |
|
| 1840 | 2166 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
| 1841 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 2167 | + } else { |
|
| 2168 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 2169 | + } |
|
| 1842 | 2170 | if ($error != '') { |
| 1843 | 2171 | return $error; |
| 1844 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1845 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
| 2172 | + } elseif ($globalDebug) { |
|
| 2173 | + echo "Done\n"; |
|
| 2174 | + } |
|
| 2175 | + if ($globalDebug) { |
|
| 2176 | + echo "Owner Brazil: Download..."; |
|
| 2177 | + } |
|
| 1846 | 2178 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
| 1847 | 2179 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1848 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2180 | + if ($globalDebug) { |
|
| 2181 | + echo "Add to DB..."; |
|
| 2182 | + } |
|
| 1849 | 2183 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
| 1850 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 2184 | + } else { |
|
| 2185 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 2186 | + } |
|
| 1851 | 2187 | if ($error != '') { |
| 1852 | 2188 | return $error; |
| 1853 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1854 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
| 2189 | + } elseif ($globalDebug) { |
|
| 2190 | + echo "Done\n"; |
|
| 2191 | + } |
|
| 2192 | + if ($globalDebug) { |
|
| 2193 | + echo "Owner Cayman Islands: Download..."; |
|
| 2194 | + } |
|
| 1855 | 2195 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
| 1856 | 2196 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1857 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2197 | + if ($globalDebug) { |
|
| 2198 | + echo "Add to DB..."; |
|
| 2199 | + } |
|
| 1858 | 2200 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
| 1859 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 2201 | + } else { |
|
| 2202 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 2203 | + } |
|
| 1860 | 2204 | if ($error != '') { |
| 1861 | 2205 | return $error; |
| 1862 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1863 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
| 2206 | + } elseif ($globalDebug) { |
|
| 2207 | + echo "Done\n"; |
|
| 2208 | + } |
|
| 2209 | + if ($globalDebug) { |
|
| 2210 | + echo "Owner Croatia: Download..."; |
|
| 2211 | + } |
|
| 1864 | 2212 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
| 1865 | 2213 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1866 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2214 | + if ($globalDebug) { |
|
| 2215 | + echo "Add to DB..."; |
|
| 2216 | + } |
|
| 1867 | 2217 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
| 1868 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 2218 | + } else { |
|
| 2219 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 2220 | + } |
|
| 1869 | 2221 | if ($error != '') { |
| 1870 | 2222 | return $error; |
| 1871 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1872 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
| 2223 | + } elseif ($globalDebug) { |
|
| 2224 | + echo "Done\n"; |
|
| 2225 | + } |
|
| 2226 | + if ($globalDebug) { |
|
| 2227 | + echo "Owner Luxembourg: Download..."; |
|
| 2228 | + } |
|
| 1873 | 2229 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
| 1874 | 2230 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1875 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2231 | + if ($globalDebug) { |
|
| 2232 | + echo "Add to DB..."; |
|
| 2233 | + } |
|
| 1876 | 2234 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
| 1877 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 2235 | + } else { |
|
| 2236 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 2237 | + } |
|
| 1878 | 2238 | if ($error != '') { |
| 1879 | 2239 | return $error; |
| 1880 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1881 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
| 2240 | + } elseif ($globalDebug) { |
|
| 2241 | + echo "Done\n"; |
|
| 2242 | + } |
|
| 2243 | + if ($globalDebug) { |
|
| 2244 | + echo "Owner Maldives: Download..."; |
|
| 2245 | + } |
|
| 1882 | 2246 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
| 1883 | 2247 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1884 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2248 | + if ($globalDebug) { |
|
| 2249 | + echo "Add to DB..."; |
|
| 2250 | + } |
|
| 1885 | 2251 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
| 1886 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 2252 | + } else { |
|
| 2253 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 2254 | + } |
|
| 1887 | 2255 | if ($error != '') { |
| 1888 | 2256 | return $error; |
| 1889 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1890 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
| 2257 | + } elseif ($globalDebug) { |
|
| 2258 | + echo "Done\n"; |
|
| 2259 | + } |
|
| 2260 | + if ($globalDebug) { |
|
| 2261 | + echo "Owner New Zealand: Download..."; |
|
| 2262 | + } |
|
| 1891 | 2263 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
| 1892 | 2264 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1893 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2265 | + if ($globalDebug) { |
|
| 2266 | + echo "Add to DB..."; |
|
| 2267 | + } |
|
| 1894 | 2268 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
| 1895 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 2269 | + } else { |
|
| 2270 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 2271 | + } |
|
| 1896 | 2272 | if ($error != '') { |
| 1897 | 2273 | return $error; |
| 1898 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1899 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
| 2274 | + } elseif ($globalDebug) { |
|
| 2275 | + echo "Done\n"; |
|
| 2276 | + } |
|
| 2277 | + if ($globalDebug) { |
|
| 2278 | + echo "Owner Papua New Guinea: Download..."; |
|
| 2279 | + } |
|
| 1900 | 2280 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
| 1901 | 2281 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1902 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2282 | + if ($globalDebug) { |
|
| 2283 | + echo "Add to DB..."; |
|
| 2284 | + } |
|
| 1903 | 2285 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
| 1904 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 2286 | + } else { |
|
| 2287 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 2288 | + } |
|
| 1905 | 2289 | if ($error != '') { |
| 1906 | 2290 | return $error; |
| 1907 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1908 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
| 2291 | + } elseif ($globalDebug) { |
|
| 2292 | + echo "Done\n"; |
|
| 2293 | + } |
|
| 2294 | + if ($globalDebug) { |
|
| 2295 | + echo "Owner Slovakia: Download..."; |
|
| 2296 | + } |
|
| 1909 | 2297 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
| 1910 | 2298 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1911 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2299 | + if ($globalDebug) { |
|
| 2300 | + echo "Add to DB..."; |
|
| 2301 | + } |
|
| 1912 | 2302 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
| 1913 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 2303 | + } else { |
|
| 2304 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 2305 | + } |
|
| 1914 | 2306 | if ($error != '') { |
| 1915 | 2307 | return $error; |
| 1916 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1917 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
| 2308 | + } elseif ($globalDebug) { |
|
| 2309 | + echo "Done\n"; |
|
| 2310 | + } |
|
| 2311 | + if ($globalDebug) { |
|
| 2312 | + echo "Owner Ecuador: Download..."; |
|
| 2313 | + } |
|
| 1918 | 2314 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
| 1919 | 2315 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1920 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2316 | + if ($globalDebug) { |
|
| 2317 | + echo "Add to DB..."; |
|
| 2318 | + } |
|
| 1921 | 2319 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
| 1922 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 2320 | + } else { |
|
| 2321 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 2322 | + } |
|
| 1923 | 2323 | if ($error != '') { |
| 1924 | 2324 | return $error; |
| 1925 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1926 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
| 2325 | + } elseif ($globalDebug) { |
|
| 2326 | + echo "Done\n"; |
|
| 2327 | + } |
|
| 2328 | + if ($globalDebug) { |
|
| 2329 | + echo "Owner Iceland: Download..."; |
|
| 2330 | + } |
|
| 1927 | 2331 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
| 1928 | 2332 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1929 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2333 | + if ($globalDebug) { |
|
| 2334 | + echo "Add to DB..."; |
|
| 2335 | + } |
|
| 1930 | 2336 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
| 1931 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 2337 | + } else { |
|
| 2338 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 2339 | + } |
|
| 1932 | 2340 | if ($error != '') { |
| 1933 | 2341 | return $error; |
| 1934 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1935 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
| 2342 | + } elseif ($globalDebug) { |
|
| 2343 | + echo "Done\n"; |
|
| 2344 | + } |
|
| 2345 | + if ($globalDebug) { |
|
| 2346 | + echo "Owner Isle of Man: Download..."; |
|
| 2347 | + } |
|
| 1936 | 2348 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
| 1937 | 2349 | if (file_exists($tmp_dir.'owner_m.csv')) { |
| 1938 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2350 | + if ($globalDebug) { |
|
| 2351 | + echo "Add to DB..."; |
|
| 2352 | + } |
|
| 1939 | 2353 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
| 1940 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
| 2354 | + } else { |
|
| 2355 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
| 2356 | + } |
|
| 1941 | 2357 | if ($error != '') { |
| 1942 | 2358 | return $error; |
| 1943 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2359 | + } elseif ($globalDebug) { |
|
| 2360 | + echo "Done\n"; |
|
| 2361 | + } |
|
| 1944 | 2362 | if ($globalMasterSource) { |
| 1945 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
| 2363 | + if ($globalDebug) { |
|
| 2364 | + echo "ModeS Netherlands: Download..."; |
|
| 2365 | + } |
|
| 1946 | 2366 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
| 1947 | 2367 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
| 1948 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2368 | + if ($globalDebug) { |
|
| 2369 | + echo "Add to DB..."; |
|
| 2370 | + } |
|
| 1949 | 2371 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
| 1950 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
| 2372 | + } else { |
|
| 2373 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
| 2374 | + } |
|
| 1951 | 2375 | if ($error != '') { |
| 1952 | 2376 | return $error; |
| 1953 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1954 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
| 2377 | + } elseif ($globalDebug) { |
|
| 2378 | + echo "Done\n"; |
|
| 2379 | + } |
|
| 2380 | + if ($globalDebug) { |
|
| 2381 | + echo "ModeS Denmark: Download..."; |
|
| 2382 | + } |
|
| 1955 | 2383 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
| 1956 | 2384 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
| 1957 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2385 | + if ($globalDebug) { |
|
| 2386 | + echo "Add to DB..."; |
|
| 2387 | + } |
|
| 1958 | 2388 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
| 1959 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
| 2389 | + } else { |
|
| 2390 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
| 2391 | + } |
|
| 1960 | 2392 | if ($error != '') { |
| 1961 | 2393 | return $error; |
| 1962 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1963 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2394 | + } elseif ($globalDebug) { |
|
| 2395 | + echo "Done\n"; |
|
| 2396 | + } |
|
| 2397 | + } elseif ($globalDebug) { |
|
| 2398 | + echo "Done\n"; |
|
| 2399 | + } |
|
| 1964 | 2400 | return ''; |
| 1965 | 2401 | } |
| 1966 | 2402 | |
| 1967 | 2403 | public static function update_translation() { |
| 1968 | 2404 | global $tmp_dir, $globalDebug; |
| 1969 | 2405 | $error = ''; |
| 1970 | - if ($globalDebug) echo "Translation : Download..."; |
|
| 2406 | + if ($globalDebug) { |
|
| 2407 | + echo "Translation : Download..."; |
|
| 2408 | + } |
|
| 1971 | 2409 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
| 1972 | 2410 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1973 | - if ($globalDebug) echo "Unzip..."; |
|
| 2411 | + if ($globalDebug) { |
|
| 2412 | + echo "Unzip..."; |
|
| 2413 | + } |
|
| 1974 | 2414 | update_db::unzip($tmp_dir.'translation.zip'); |
| 1975 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2415 | + if ($globalDebug) { |
|
| 2416 | + echo "Add to DB..."; |
|
| 2417 | + } |
|
| 1976 | 2418 | $error = update_db::translation(); |
| 1977 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 2419 | + } else { |
|
| 2420 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 2421 | + } |
|
| 1978 | 2422 | if ($error != '') { |
| 1979 | 2423 | return $error; |
| 1980 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2424 | + } elseif ($globalDebug) { |
|
| 2425 | + echo "Done\n"; |
|
| 2426 | + } |
|
| 1981 | 2427 | return ''; |
| 1982 | 2428 | } |
| 1983 | 2429 | |
| 1984 | 2430 | public static function update_translation_fam() { |
| 1985 | 2431 | global $tmp_dir, $globalDebug; |
| 1986 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
| 2432 | + if ($globalDebug) { |
|
| 2433 | + echo "Translation from FlightAirMap website : Download..."; |
|
| 2434 | + } |
|
| 1987 | 2435 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
| 1988 | 2436 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1989 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2437 | + if ($globalDebug) { |
|
| 2438 | + echo "Gunzip..."; |
|
| 2439 | + } |
|
| 1990 | 2440 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
| 1991 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2441 | + if ($globalDebug) { |
|
| 2442 | + echo "Add to DB..."; |
|
| 2443 | + } |
|
| 1992 | 2444 | $error = update_db::translation_fam(); |
| 1993 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 2445 | + } else { |
|
| 2446 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 2447 | + } |
|
| 1994 | 2448 | if ($error != '') { |
| 1995 | 2449 | return $error; |
| 1996 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2450 | + } elseif ($globalDebug) { |
|
| 2451 | + echo "Done\n"; |
|
| 2452 | + } |
|
| 1997 | 2453 | return ''; |
| 1998 | 2454 | } |
| 1999 | 2455 | public static function update_ModeS_fam() { |
| 2000 | 2456 | global $tmp_dir, $globalDebug; |
| 2001 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
| 2457 | + if ($globalDebug) { |
|
| 2458 | + echo "ModeS from FlightAirMap website : Download..."; |
|
| 2459 | + } |
|
| 2002 | 2460 | update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
| 2003 | 2461 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
| 2004 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2462 | + if ($globalDebug) { |
|
| 2463 | + echo "Gunzip..."; |
|
| 2464 | + } |
|
| 2005 | 2465 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
| 2006 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2466 | + if ($globalDebug) { |
|
| 2467 | + echo "Add to DB..."; |
|
| 2468 | + } |
|
| 2007 | 2469 | $error = update_db::modes_fam(); |
| 2008 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2470 | + } else { |
|
| 2471 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2472 | + } |
|
| 2009 | 2473 | if ($error != '') { |
| 2010 | 2474 | return $error; |
| 2011 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2475 | + } elseif ($globalDebug) { |
|
| 2476 | + echo "Done\n"; |
|
| 2477 | + } |
|
| 2012 | 2478 | return ''; |
| 2013 | 2479 | } |
| 2014 | 2480 | public static function update_owner_fam() { |
| 2015 | 2481 | global $tmp_dir, $globalDebug, $globalOwner; |
| 2016 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
| 2482 | + if ($globalDebug) { |
|
| 2483 | + echo "owner from FlightAirMap website : Download..."; |
|
| 2484 | + } |
|
| 2017 | 2485 | if ($globalOwner === TRUE) { |
| 2018 | 2486 | update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
| 2019 | 2487 | } else { |
| 2020 | 2488 | update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
| 2021 | 2489 | } |
| 2022 | 2490 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
| 2023 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2491 | + if ($globalDebug) { |
|
| 2492 | + echo "Gunzip..."; |
|
| 2493 | + } |
|
| 2024 | 2494 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
| 2025 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2495 | + if ($globalDebug) { |
|
| 2496 | + echo "Add to DB..."; |
|
| 2497 | + } |
|
| 2026 | 2498 | $error = update_db::owner_fam(); |
| 2027 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
| 2499 | + } else { |
|
| 2500 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
| 2501 | + } |
|
| 2028 | 2502 | if ($error != '') { |
| 2029 | 2503 | return $error; |
| 2030 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2504 | + } elseif ($globalDebug) { |
|
| 2505 | + echo "Done\n"; |
|
| 2506 | + } |
|
| 2031 | 2507 | return ''; |
| 2032 | 2508 | } |
| 2033 | 2509 | public static function update_routes_fam() { |
| 2034 | 2510 | global $tmp_dir, $globalDebug; |
| 2035 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
| 2511 | + if ($globalDebug) { |
|
| 2512 | + echo "Routes from FlightAirMap website : Download..."; |
|
| 2513 | + } |
|
| 2036 | 2514 | update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
| 2037 | 2515 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
| 2038 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2516 | + if ($globalDebug) { |
|
| 2517 | + echo "Gunzip..."; |
|
| 2518 | + } |
|
| 2039 | 2519 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
| 2040 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2520 | + if ($globalDebug) { |
|
| 2521 | + echo "Add to DB..."; |
|
| 2522 | + } |
|
| 2041 | 2523 | $error = update_db::routes_fam(); |
| 2042 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2524 | + } else { |
|
| 2525 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2526 | + } |
|
| 2043 | 2527 | if ($error != '') { |
| 2044 | 2528 | return $error; |
| 2045 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2529 | + } elseif ($globalDebug) { |
|
| 2530 | + echo "Done\n"; |
|
| 2531 | + } |
|
| 2046 | 2532 | return ''; |
| 2047 | 2533 | } |
| 2048 | 2534 | public static function update_marine_identity_fam() { |
@@ -2052,14 +2538,22 @@ discard block |
||
| 2052 | 2538 | $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
| 2053 | 2539 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
| 2054 | 2540 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
| 2055 | - if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
|
| 2541 | + if ($globalDebug) { |
|
| 2542 | + echo "Marine identity from FlightAirMap website : Download..."; |
|
| 2543 | + } |
|
| 2056 | 2544 | update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
| 2057 | 2545 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
| 2058 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2546 | + if ($globalDebug) { |
|
| 2547 | + echo "Gunzip..."; |
|
| 2548 | + } |
|
| 2059 | 2549 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
| 2060 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2550 | + if ($globalDebug) { |
|
| 2551 | + echo "Add to DB..."; |
|
| 2552 | + } |
|
| 2061 | 2553 | $error = update_db::marine_identity_fam(); |
| 2062 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
| 2554 | + } else { |
|
| 2555 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
| 2556 | + } |
|
| 2063 | 2557 | if ($error != '') { |
| 2064 | 2558 | return $error; |
| 2065 | 2559 | } elseif ($globalDebug) { |
@@ -2072,17 +2566,25 @@ discard block |
||
| 2072 | 2566 | } |
| 2073 | 2567 | public static function update_banned_fam() { |
| 2074 | 2568 | global $tmp_dir, $globalDebug; |
| 2075 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
| 2569 | + if ($globalDebug) { |
|
| 2570 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
| 2571 | + } |
|
| 2076 | 2572 | update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
| 2077 | 2573 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
| 2078 | 2574 | //if ($globalDebug) echo "Gunzip..."; |
| 2079 | 2575 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
| 2080 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2576 | + if ($globalDebug) { |
|
| 2577 | + echo "Add to DB..."; |
|
| 2578 | + } |
|
| 2081 | 2579 | $error = update_db::banned_fam(); |
| 2082 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
| 2580 | + } else { |
|
| 2581 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
| 2582 | + } |
|
| 2083 | 2583 | if ($error != '') { |
| 2084 | 2584 | return $error; |
| 2085 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2585 | + } elseif ($globalDebug) { |
|
| 2586 | + echo "Done\n"; |
|
| 2587 | + } |
|
| 2086 | 2588 | return ''; |
| 2087 | 2589 | } |
| 2088 | 2590 | |
@@ -2090,7 +2592,9 @@ discard block |
||
| 2090 | 2592 | global $tmp_dir, $globalDebug, $globalDBdriver; |
| 2091 | 2593 | include_once('class.create_db.php'); |
| 2092 | 2594 | $error = ''; |
| 2093 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
| 2595 | + if ($globalDebug) { |
|
| 2596 | + echo "Airspace from FlightAirMap website : Download..."; |
|
| 2597 | + } |
|
| 2094 | 2598 | if ($globalDBdriver == 'mysql') { |
| 2095 | 2599 | update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
| 2096 | 2600 | } else { |
@@ -2106,9 +2610,13 @@ discard block |
||
| 2106 | 2610 | update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
| 2107 | 2611 | } |
| 2108 | 2612 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 2109 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2613 | + if ($globalDebug) { |
|
| 2614 | + echo "Gunzip..."; |
|
| 2615 | + } |
|
| 2110 | 2616 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
| 2111 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2617 | + if ($globalDebug) { |
|
| 2618 | + echo "Add to DB..."; |
|
| 2619 | + } |
|
| 2112 | 2620 | $Connection = new Connection(); |
| 2113 | 2621 | if ($Connection->tableExists('airspace')) { |
| 2114 | 2622 | $query = 'DROP TABLE airspace'; |
@@ -2121,19 +2629,27 @@ discard block |
||
| 2121 | 2629 | } |
| 2122 | 2630 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 2123 | 2631 | update_db::insert_airspace_version($airspace_md5); |
| 2124 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
| 2632 | + } else { |
|
| 2633 | + $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
| 2634 | + } |
|
| 2125 | 2635 | } |
| 2126 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 2636 | + } else { |
|
| 2637 | + $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 2638 | + } |
|
| 2127 | 2639 | if ($error != '') { |
| 2128 | 2640 | return $error; |
| 2129 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2641 | + } elseif ($globalDebug) { |
|
| 2642 | + echo "Done\n"; |
|
| 2643 | + } |
|
| 2130 | 2644 | return ''; |
| 2131 | 2645 | } |
| 2132 | 2646 | |
| 2133 | 2647 | public static function update_geoid_fam() { |
| 2134 | 2648 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
| 2135 | 2649 | $error = ''; |
| 2136 | - if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
|
| 2650 | + if ($globalDebug) { |
|
| 2651 | + echo "Geoid from FlightAirMap website : Download..."; |
|
| 2652 | + } |
|
| 2137 | 2653 | update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
| 2138 | 2654 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
| 2139 | 2655 | $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
@@ -2141,36 +2657,54 @@ discard block |
||
| 2141 | 2657 | if (!update_db::check_geoid_version($geoid_md5)) { |
| 2142 | 2658 | update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
| 2143 | 2659 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
| 2144 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2660 | + if ($globalDebug) { |
|
| 2661 | + echo "Gunzip..."; |
|
| 2662 | + } |
|
| 2145 | 2663 | update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
| 2146 | 2664 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
| 2147 | 2665 | update_db::insert_geoid_version($geoid_md5); |
| 2148 | 2666 | } |
| 2149 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
| 2667 | + } else { |
|
| 2668 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
| 2669 | + } |
|
| 2150 | 2670 | } |
| 2151 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
| 2671 | + } else { |
|
| 2672 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
| 2673 | + } |
|
| 2152 | 2674 | if ($error != '') { |
| 2153 | 2675 | return $error; |
| 2154 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2676 | + } elseif ($globalDebug) { |
|
| 2677 | + echo "Done\n"; |
|
| 2678 | + } |
|
| 2155 | 2679 | return ''; |
| 2156 | 2680 | } |
| 2157 | 2681 | |
| 2158 | 2682 | public static function update_tle() { |
| 2159 | 2683 | global $tmp_dir, $globalDebug; |
| 2160 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
| 2684 | + if ($globalDebug) { |
|
| 2685 | + echo "Download TLE : Download..."; |
|
| 2686 | + } |
|
| 2161 | 2687 | $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
| 2162 | 2688 | 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
| 2163 | 2689 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
| 2164 | 2690 | foreach ($alltle as $filename) { |
| 2165 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
| 2691 | + if ($globalDebug) { |
|
| 2692 | + echo "downloading ".$filename.'...'; |
|
| 2693 | + } |
|
| 2166 | 2694 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
| 2167 | 2695 | if (file_exists($tmp_dir.$filename)) { |
| 2168 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
| 2696 | + if ($globalDebug) { |
|
| 2697 | + echo "Add to DB ".$filename."..."; |
|
| 2698 | + } |
|
| 2169 | 2699 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
| 2170 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 2700 | + } else { |
|
| 2701 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 2702 | + } |
|
| 2171 | 2703 | if ($error != '') { |
| 2172 | 2704 | echo $error."\n"; |
| 2173 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2705 | + } elseif ($globalDebug) { |
|
| 2706 | + echo "Done\n"; |
|
| 2707 | + } |
|
| 2174 | 2708 | } |
| 2175 | 2709 | return ''; |
| 2176 | 2710 | } |
@@ -2178,10 +2712,14 @@ discard block |
||
| 2178 | 2712 | public static function update_models() { |
| 2179 | 2713 | global $tmp_dir, $globalDebug; |
| 2180 | 2714 | $error = ''; |
| 2181 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
| 2715 | + if ($globalDebug) { |
|
| 2716 | + echo "Models from FlightAirMap website : Download..."; |
|
| 2717 | + } |
|
| 2182 | 2718 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
| 2183 | 2719 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 2184 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2720 | + if ($globalDebug) { |
|
| 2721 | + echo "Check files...\n"; |
|
| 2722 | + } |
|
| 2185 | 2723 | $newmodelsdb = array(); |
| 2186 | 2724 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
| 2187 | 2725 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2200,25 +2738,35 @@ discard block |
||
| 2200 | 2738 | } |
| 2201 | 2739 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2202 | 2740 | foreach ($diff as $key => $value) { |
| 2203 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2741 | + if ($globalDebug) { |
|
| 2742 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2743 | + } |
|
| 2204 | 2744 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
| 2205 | 2745 | |
| 2206 | 2746 | } |
| 2207 | 2747 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
| 2208 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2748 | + } else { |
|
| 2749 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2750 | + } |
|
| 2209 | 2751 | if ($error != '') { |
| 2210 | 2752 | return $error; |
| 2211 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2753 | + } elseif ($globalDebug) { |
|
| 2754 | + echo "Done\n"; |
|
| 2755 | + } |
|
| 2212 | 2756 | return ''; |
| 2213 | 2757 | } |
| 2214 | 2758 | |
| 2215 | 2759 | public static function update_space_models() { |
| 2216 | 2760 | global $tmp_dir, $globalDebug; |
| 2217 | 2761 | $error = ''; |
| 2218 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
| 2762 | + if ($globalDebug) { |
|
| 2763 | + echo "Space models from FlightAirMap website : Download..."; |
|
| 2764 | + } |
|
| 2219 | 2765 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
| 2220 | 2766 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 2221 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2767 | + if ($globalDebug) { |
|
| 2768 | + echo "Check files...\n"; |
|
| 2769 | + } |
|
| 2222 | 2770 | $newmodelsdb = array(); |
| 2223 | 2771 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
| 2224 | 2772 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2237,25 +2785,35 @@ discard block |
||
| 2237 | 2785 | } |
| 2238 | 2786 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2239 | 2787 | foreach ($diff as $key => $value) { |
| 2240 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2788 | + if ($globalDebug) { |
|
| 2789 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2790 | + } |
|
| 2241 | 2791 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
| 2242 | 2792 | |
| 2243 | 2793 | } |
| 2244 | 2794 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
| 2245 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2795 | + } else { |
|
| 2796 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2797 | + } |
|
| 2246 | 2798 | if ($error != '') { |
| 2247 | 2799 | return $error; |
| 2248 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2800 | + } elseif ($globalDebug) { |
|
| 2801 | + echo "Done\n"; |
|
| 2802 | + } |
|
| 2249 | 2803 | return ''; |
| 2250 | 2804 | } |
| 2251 | 2805 | |
| 2252 | 2806 | public static function update_vehicules_models() { |
| 2253 | 2807 | global $tmp_dir, $globalDebug; |
| 2254 | 2808 | $error = ''; |
| 2255 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
| 2809 | + if ($globalDebug) { |
|
| 2810 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
| 2811 | + } |
|
| 2256 | 2812 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
| 2257 | 2813 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
| 2258 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2814 | + if ($globalDebug) { |
|
| 2815 | + echo "Check files...\n"; |
|
| 2816 | + } |
|
| 2259 | 2817 | $newmodelsdb = array(); |
| 2260 | 2818 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
| 2261 | 2819 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2274,15 +2832,21 @@ discard block |
||
| 2274 | 2832 | } |
| 2275 | 2833 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2276 | 2834 | foreach ($diff as $key => $value) { |
| 2277 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
| 2835 | + if ($globalDebug) { |
|
| 2836 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
| 2837 | + } |
|
| 2278 | 2838 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
| 2279 | 2839 | |
| 2280 | 2840 | } |
| 2281 | 2841 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
| 2282 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2842 | + } else { |
|
| 2843 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2844 | + } |
|
| 2283 | 2845 | if ($error != '') { |
| 2284 | 2846 | return $error; |
| 2285 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2847 | + } elseif ($globalDebug) { |
|
| 2848 | + echo "Done\n"; |
|
| 2849 | + } |
|
| 2286 | 2850 | return ''; |
| 2287 | 2851 | } |
| 2288 | 2852 | |
@@ -2325,7 +2889,9 @@ discard block |
||
| 2325 | 2889 | } |
| 2326 | 2890 | |
| 2327 | 2891 | $error = ''; |
| 2328 | - if ($globalDebug) echo "Notam : Download..."; |
|
| 2892 | + if ($globalDebug) { |
|
| 2893 | + echo "Notam : Download..."; |
|
| 2894 | + } |
|
| 2329 | 2895 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
| 2330 | 2896 | if (file_exists($tmp_dir.'notam.rss')) { |
| 2331 | 2897 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -2340,14 +2906,30 @@ discard block |
||
| 2340 | 2906 | $data['fir'] = $q[0]; |
| 2341 | 2907 | $data['code'] = $q[1]; |
| 2342 | 2908 | $ifrvfr = $q[2]; |
| 2343 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
| 2344 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
| 2345 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
| 2346 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
| 2347 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
| 2348 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
| 2349 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
| 2350 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
| 2909 | + if ($ifrvfr == 'IV') { |
|
| 2910 | + $data['rules'] = 'IFR/VFR'; |
|
| 2911 | + } |
|
| 2912 | + if ($ifrvfr == 'I') { |
|
| 2913 | + $data['rules'] = 'IFR'; |
|
| 2914 | + } |
|
| 2915 | + if ($ifrvfr == 'V') { |
|
| 2916 | + $data['rules'] = 'VFR'; |
|
| 2917 | + } |
|
| 2918 | + if ($q[4] == 'A') { |
|
| 2919 | + $data['scope'] = 'Airport warning'; |
|
| 2920 | + } |
|
| 2921 | + if ($q[4] == 'E') { |
|
| 2922 | + $data['scope'] = 'Enroute warning'; |
|
| 2923 | + } |
|
| 2924 | + if ($q[4] == 'W') { |
|
| 2925 | + $data['scope'] = 'Navigation warning'; |
|
| 2926 | + } |
|
| 2927 | + if ($q[4] == 'AE') { |
|
| 2928 | + $data['scope'] = 'Airport/Enroute warning'; |
|
| 2929 | + } |
|
| 2930 | + if ($q[4] == 'AW') { |
|
| 2931 | + $data['scope'] = 'Airport/Navigation warning'; |
|
| 2932 | + } |
|
| 2351 | 2933 | //$data['scope'] = $q[4]; |
| 2352 | 2934 | $data['lower_limit'] = $q[5]; |
| 2353 | 2935 | $data['upper_limit'] = $q[6]; |
@@ -2355,8 +2937,12 @@ discard block |
||
| 2355 | 2937 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
| 2356 | 2938 | $latitude = $Common->convertDec($las,'latitude'); |
| 2357 | 2939 | $longitude = $Common->convertDec($lns,'longitude'); |
| 2358 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 2359 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 2940 | + if ($lac == 'S') { |
|
| 2941 | + $latitude = '-'.$latitude; |
|
| 2942 | + } |
|
| 2943 | + if ($lnc == 'W') { |
|
| 2944 | + $longitude = '-'.$longitude; |
|
| 2945 | + } |
|
| 2360 | 2946 | $data['center_latitude'] = $latitude; |
| 2361 | 2947 | $data['center_longitude'] = $longitude; |
| 2362 | 2948 | $data['radius'] = intval($radius); |
@@ -2386,10 +2972,14 @@ discard block |
||
| 2386 | 2972 | $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
| 2387 | 2973 | unset($data); |
| 2388 | 2974 | } |
| 2389 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2975 | + } else { |
|
| 2976 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2977 | + } |
|
| 2390 | 2978 | if ($error != '') { |
| 2391 | 2979 | return $error; |
| 2392 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2980 | + } elseif ($globalDebug) { |
|
| 2981 | + echo "Done\n"; |
|
| 2982 | + } |
|
| 2393 | 2983 | return ''; |
| 2394 | 2984 | } |
| 2395 | 2985 | |
@@ -2414,7 +3004,9 @@ discard block |
||
| 2414 | 3004 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 2415 | 3005 | $airspace_json = json_decode($airspace_lst,true); |
| 2416 | 3006 | foreach ($airspace_json['records'] as $airspace) { |
| 2417 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
| 3007 | + if ($globalDebug) { |
|
| 3008 | + echo $airspace['name']."...\n"; |
|
| 3009 | + } |
|
| 2418 | 3010 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
| 2419 | 3011 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 2420 | 3012 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -2458,8 +3050,11 @@ discard block |
||
| 2458 | 3050 | return "error : ".$e->getMessage(); |
| 2459 | 3051 | } |
| 2460 | 3052 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2461 | - if ($row['nb'] > 0) return false; |
|
| 2462 | - else return true; |
|
| 3053 | + if ($row['nb'] > 0) { |
|
| 3054 | + return false; |
|
| 3055 | + } else { |
|
| 3056 | + return true; |
|
| 3057 | + } |
|
| 2463 | 3058 | } |
| 2464 | 3059 | |
| 2465 | 3060 | public static function insert_last_update() { |
@@ -2484,8 +3079,11 @@ discard block |
||
| 2484 | 3079 | return "error : ".$e->getMessage(); |
| 2485 | 3080 | } |
| 2486 | 3081 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2487 | - if ($row['nb'] > 0) return true; |
|
| 2488 | - else return false; |
|
| 3082 | + if ($row['nb'] > 0) { |
|
| 3083 | + return true; |
|
| 3084 | + } else { |
|
| 3085 | + return false; |
|
| 3086 | + } |
|
| 2489 | 3087 | } |
| 2490 | 3088 | |
| 2491 | 3089 | public static function check_geoid_version($version) { |
@@ -2498,8 +3096,11 @@ discard block |
||
| 2498 | 3096 | return "error : ".$e->getMessage(); |
| 2499 | 3097 | } |
| 2500 | 3098 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2501 | - if ($row['nb'] > 0) return true; |
|
| 2502 | - else return false; |
|
| 3099 | + if ($row['nb'] > 0) { |
|
| 3100 | + return true; |
|
| 3101 | + } else { |
|
| 3102 | + return false; |
|
| 3103 | + } |
|
| 2503 | 3104 | } |
| 2504 | 3105 | |
| 2505 | 3106 | public static function check_marine_identity_version($version) { |
@@ -2512,8 +3113,11 @@ discard block |
||
| 2512 | 3113 | return "error : ".$e->getMessage(); |
| 2513 | 3114 | } |
| 2514 | 3115 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2515 | - if ($row['nb'] > 0) return true; |
|
| 2516 | - else return false; |
|
| 3116 | + if ($row['nb'] > 0) { |
|
| 3117 | + return true; |
|
| 3118 | + } else { |
|
| 3119 | + return false; |
|
| 3120 | + } |
|
| 2517 | 3121 | } |
| 2518 | 3122 | |
| 2519 | 3123 | |
@@ -2568,8 +3172,11 @@ discard block |
||
| 2568 | 3172 | return "error : ".$e->getMessage(); |
| 2569 | 3173 | } |
| 2570 | 3174 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2571 | - if ($row['nb'] > 0) return false; |
|
| 2572 | - else return true; |
|
| 3175 | + if ($row['nb'] > 0) { |
|
| 3176 | + return false; |
|
| 3177 | + } else { |
|
| 3178 | + return true; |
|
| 3179 | + } |
|
| 2573 | 3180 | } |
| 2574 | 3181 | |
| 2575 | 3182 | public static function insert_last_notam_update() { |
@@ -2599,8 +3206,11 @@ discard block |
||
| 2599 | 3206 | return "error : ".$e->getMessage(); |
| 2600 | 3207 | } |
| 2601 | 3208 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2602 | - if ($row['nb'] > 0) return false; |
|
| 2603 | - else return true; |
|
| 3209 | + if ($row['nb'] > 0) { |
|
| 3210 | + return false; |
|
| 3211 | + } else { |
|
| 3212 | + return true; |
|
| 3213 | + } |
|
| 2604 | 3214 | } |
| 2605 | 3215 | |
| 2606 | 3216 | public static function insert_last_airspace_update() { |
@@ -2630,8 +3240,11 @@ discard block |
||
| 2630 | 3240 | return "error : ".$e->getMessage(); |
| 2631 | 3241 | } |
| 2632 | 3242 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2633 | - if ($row['nb'] > 0) return false; |
|
| 2634 | - else return true; |
|
| 3243 | + if ($row['nb'] > 0) { |
|
| 3244 | + return false; |
|
| 3245 | + } else { |
|
| 3246 | + return true; |
|
| 3247 | + } |
|
| 2635 | 3248 | } |
| 2636 | 3249 | |
| 2637 | 3250 | public static function insert_last_geoid_update() { |
@@ -2661,8 +3274,11 @@ discard block |
||
| 2661 | 3274 | return "error : ".$e->getMessage(); |
| 2662 | 3275 | } |
| 2663 | 3276 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2664 | - if ($row['nb'] > 0) return false; |
|
| 2665 | - else return true; |
|
| 3277 | + if ($row['nb'] > 0) { |
|
| 3278 | + return false; |
|
| 3279 | + } else { |
|
| 3280 | + return true; |
|
| 3281 | + } |
|
| 2666 | 3282 | } |
| 2667 | 3283 | |
| 2668 | 3284 | public static function insert_last_owner_update() { |
@@ -2691,8 +3307,11 @@ discard block |
||
| 2691 | 3307 | return "error : ".$e->getMessage(); |
| 2692 | 3308 | } |
| 2693 | 3309 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2694 | - if ($row['nb'] > 0) return false; |
|
| 2695 | - else return true; |
|
| 3310 | + if ($row['nb'] > 0) { |
|
| 3311 | + return false; |
|
| 3312 | + } else { |
|
| 3313 | + return true; |
|
| 3314 | + } |
|
| 2696 | 3315 | } |
| 2697 | 3316 | |
| 2698 | 3317 | public static function insert_last_schedules_update() { |
@@ -2721,8 +3340,11 @@ discard block |
||
| 2721 | 3340 | return "error : ".$e->getMessage(); |
| 2722 | 3341 | } |
| 2723 | 3342 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2724 | - if ($row['nb'] > 0) return false; |
|
| 2725 | - else return true; |
|
| 3343 | + if ($row['nb'] > 0) { |
|
| 3344 | + return false; |
|
| 3345 | + } else { |
|
| 3346 | + return true; |
|
| 3347 | + } |
|
| 2726 | 3348 | } |
| 2727 | 3349 | |
| 2728 | 3350 | public static function insert_last_tle_update() { |
@@ -2751,8 +3373,11 @@ discard block |
||
| 2751 | 3373 | return "error : ".$e->getMessage(); |
| 2752 | 3374 | } |
| 2753 | 3375 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2754 | - if ($row['nb'] > 0) return false; |
|
| 2755 | - else return true; |
|
| 3376 | + if ($row['nb'] > 0) { |
|
| 3377 | + return false; |
|
| 3378 | + } else { |
|
| 3379 | + return true; |
|
| 3380 | + } |
|
| 2756 | 3381 | } |
| 2757 | 3382 | |
| 2758 | 3383 | public static function insert_last_marine_identity_update() { |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | $this->SI = new SpotterImport($this->db); |
| 17 | 17 | } |
| 18 | 18 | /** |
| 19 | - * Change IATA to ICAO value for ident |
|
| 20 | - * |
|
| 21 | - * @param String $ident ident |
|
| 22 | - * @return String the icao |
|
| 23 | - */ |
|
| 19 | + * Change IATA to ICAO value for ident |
|
| 20 | + * |
|
| 21 | + * @param String $ident ident |
|
| 22 | + * @return String the icao |
|
| 23 | + */ |
|
| 24 | 24 | public function ident2icao($ident) { |
| 25 | 25 | if (substr($ident,0,2) == 'AF') { |
| 26 | 26 | if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | - * Deletes all info in the live table |
|
| 40 | - * |
|
| 41 | - * @return String success or false |
|
| 42 | - * |
|
| 43 | - */ |
|
| 39 | + * Deletes all info in the live table |
|
| 40 | + * |
|
| 41 | + * @return String success or false |
|
| 42 | + * |
|
| 43 | + */ |
|
| 44 | 44 | public function deleteLiveAcarsData() |
| 45 | 45 | { |
| 46 | 46 | global $globalDBdriver; |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | - * Deletes all info in the archive table |
|
| 64 | - * |
|
| 65 | - * @return String success or false |
|
| 66 | - * |
|
| 67 | - */ |
|
| 63 | + * Deletes all info in the archive table |
|
| 64 | + * |
|
| 65 | + * @return String success or false |
|
| 66 | + * |
|
| 67 | + */ |
|
| 68 | 68 | public function deleteArchiveAcarsData() |
| 69 | 69 | { |
| 70 | 70 | global $globalACARSArchiveKeepMonths, $globalDBdriver; |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | - * Parse ACARS data |
|
| 89 | - * |
|
| 90 | - * @param String ACARS data in acarsdec data |
|
| 91 | - * |
|
| 92 | - */ |
|
| 88 | + * Parse ACARS data |
|
| 89 | + * |
|
| 90 | + * @param String ACARS data in acarsdec data |
|
| 91 | + * |
|
| 92 | + */ |
|
| 93 | 93 | public function parse($data) { |
| 94 | 94 | global $globalDebug, $globalACARSArchive; |
| 95 | 95 | //$Image = new Image($this->db); |
@@ -719,11 +719,11 @@ discard block |
||
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | /** |
| 722 | - * Add ACARS data |
|
| 723 | - * |
|
| 724 | - * @param String ACARS data in acarsdec data |
|
| 725 | - * |
|
| 726 | - */ |
|
| 722 | + * Add ACARS data |
|
| 723 | + * |
|
| 724 | + * @param String ACARS data in acarsdec data |
|
| 725 | + * |
|
| 726 | + */ |
|
| 727 | 727 | function add($data) { |
| 728 | 728 | global $globalDebug, $globalACARSArchive; |
| 729 | 729 | $Image = new Image($this->db); |
@@ -770,15 +770,15 @@ discard block |
||
| 770 | 770 | } |
| 771 | 771 | |
| 772 | 772 | /** |
| 773 | - * Add Live ACARS data in DB |
|
| 774 | - * |
|
| 775 | - * @param String $ident ident |
|
| 776 | - * @param String $registration Registration of the aircraft |
|
| 777 | - * @param String $label Label of the ACARS message |
|
| 778 | - * @param String $block_id Block id of the ACARS message |
|
| 779 | - * @param String $msg_no Number of the ACARS message |
|
| 780 | - * @param String $message ACARS message |
|
| 781 | - */ |
|
| 773 | + * Add Live ACARS data in DB |
|
| 774 | + * |
|
| 775 | + * @param String $ident ident |
|
| 776 | + * @param String $registration Registration of the aircraft |
|
| 777 | + * @param String $label Label of the ACARS message |
|
| 778 | + * @param String $block_id Block id of the ACARS message |
|
| 779 | + * @param String $msg_no Number of the ACARS message |
|
| 780 | + * @param String $message ACARS message |
|
| 781 | + */ |
|
| 782 | 782 | public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
| 783 | 783 | global $globalDebug; |
| 784 | 784 | date_default_timezone_set('UTC'); |
@@ -814,15 +814,15 @@ discard block |
||
| 814 | 814 | } |
| 815 | 815 | |
| 816 | 816 | /** |
| 817 | - * Add Archive ACARS data in DB |
|
| 818 | - * |
|
| 819 | - * @param String $ident ident |
|
| 820 | - * @param String $registration Registration of the aircraft |
|
| 821 | - * @param String $label Label of the ACARS message |
|
| 822 | - * @param String $block_id Block id of the ACARS message |
|
| 823 | - * @param String $msg_no Number of the ACARS message |
|
| 824 | - * @param String $message ACARS message |
|
| 825 | - */ |
|
| 817 | + * Add Archive ACARS data in DB |
|
| 818 | + * |
|
| 819 | + * @param String $ident ident |
|
| 820 | + * @param String $registration Registration of the aircraft |
|
| 821 | + * @param String $label Label of the ACARS message |
|
| 822 | + * @param String $block_id Block id of the ACARS message |
|
| 823 | + * @param String $msg_no Number of the ACARS message |
|
| 824 | + * @param String $message ACARS message |
|
| 825 | + */ |
|
| 826 | 826 | public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
| 827 | 827 | global $globalDebug; |
| 828 | 828 | date_default_timezone_set('UTC'); |
@@ -853,11 +853,11 @@ discard block |
||
| 853 | 853 | } |
| 854 | 854 | |
| 855 | 855 | /** |
| 856 | - * Get Message title from label from DB |
|
| 857 | - * |
|
| 858 | - * @param String $label |
|
| 859 | - * @return String Return ACARS title |
|
| 860 | - */ |
|
| 856 | + * Get Message title from label from DB |
|
| 857 | + * |
|
| 858 | + * @param String $label |
|
| 859 | + * @return String Return ACARS title |
|
| 860 | + */ |
|
| 861 | 861 | public function getTitlefromLabel($label) { |
| 862 | 862 | $Connection = new Connection($this->db); |
| 863 | 863 | $this->db = $Connection->db; |
@@ -876,10 +876,10 @@ discard block |
||
| 876 | 876 | } |
| 877 | 877 | |
| 878 | 878 | /** |
| 879 | - * List all Message title & label from DB |
|
| 880 | - * |
|
| 881 | - * @return Array Return ACARS data in array |
|
| 882 | - */ |
|
| 879 | + * List all Message title & label from DB |
|
| 880 | + * |
|
| 881 | + * @return Array Return ACARS data in array |
|
| 882 | + */ |
|
| 883 | 883 | public function getAllTitleLabel() { |
| 884 | 884 | $query = "SELECT * FROM acars_label ORDER BY title"; |
| 885 | 885 | $query_values = array(); |
@@ -896,11 +896,11 @@ discard block |
||
| 896 | 896 | } |
| 897 | 897 | |
| 898 | 898 | /** |
| 899 | - * Get Live ACARS data from DB |
|
| 900 | - * |
|
| 901 | - * @param String $ident |
|
| 902 | - * @return Array Return ACARS data in array |
|
| 903 | - */ |
|
| 899 | + * Get Live ACARS data from DB |
|
| 900 | + * |
|
| 901 | + * @param String $ident |
|
| 902 | + * @return Array Return ACARS data in array |
|
| 903 | + */ |
|
| 904 | 904 | public function getLiveAcarsData($ident) { |
| 905 | 905 | $query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC"; |
| 906 | 906 | $query_values = array(':ident' => $ident); |
@@ -917,10 +917,10 @@ discard block |
||
| 917 | 917 | } |
| 918 | 918 | |
| 919 | 919 | /** |
| 920 | - * Get Latest ACARS data from DB |
|
| 921 | - * |
|
| 922 | - * @return Array Return ACARS data in array |
|
| 923 | - */ |
|
| 920 | + * Get Latest ACARS data from DB |
|
| 921 | + * |
|
| 922 | + * @return Array Return ACARS data in array |
|
| 923 | + */ |
|
| 924 | 924 | public function getLatestAcarsData($limit = '',$label = '') { |
| 925 | 925 | global $globalURL, $globalDBdriver; |
| 926 | 926 | $Image = new Image($this->db); |
@@ -1008,10 +1008,10 @@ discard block |
||
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | 1010 | /** |
| 1011 | - * Get Archive ACARS data from DB |
|
| 1012 | - * |
|
| 1013 | - * @return Array Return ACARS data in array |
|
| 1014 | - */ |
|
| 1011 | + * Get Archive ACARS data from DB |
|
| 1012 | + * |
|
| 1013 | + * @return Array Return ACARS data in array |
|
| 1014 | + */ |
|
| 1015 | 1015 | public function getArchiveAcarsData($limit = '',$label = '') { |
| 1016 | 1016 | global $globalURL, $globalDBdriver; |
| 1017 | 1017 | $Image = new Image($this->db); |
@@ -1099,13 +1099,13 @@ discard block |
||
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | 1101 | /** |
| 1102 | - * Add ModeS data to DB |
|
| 1103 | - * |
|
| 1104 | - * @param String $ident ident |
|
| 1105 | - * @param String $registration Registration of the aircraft |
|
| 1106 | - * @param String $icao |
|
| 1107 | - * @param String $ICAOTypeCode |
|
| 1108 | - */ |
|
| 1102 | + * Add ModeS data to DB |
|
| 1103 | + * |
|
| 1104 | + * @param String $ident ident |
|
| 1105 | + * @param String $registration Registration of the aircraft |
|
| 1106 | + * @param String $icao |
|
| 1107 | + * @param String $ICAOTypeCode |
|
| 1108 | + */ |
|
| 1109 | 1109 | public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
| 1110 | 1110 | global $globalDebug, $globalDBdriver; |
| 1111 | 1111 | $ident = trim($ident); |
@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | * @return String the icao |
| 23 | 23 | */ |
| 24 | 24 | public function ident2icao($ident) { |
| 25 | - if (substr($ident,0,2) == 'AF') { |
|
| 26 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 27 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 25 | + if (substr($ident, 0, 2) == 'AF') { |
|
| 26 | + if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 27 | + else $icao = 'AFR'.ltrim(substr($ident, 2), '0'); |
|
| 28 | 28 | } else { |
| 29 | 29 | $Spotter = new Spotter($this->db); |
| 30 | - $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
|
| 30 | + $identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2)); |
|
| 31 | 31 | if (isset($identicao[0])) { |
| 32 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
| 32 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
| 33 | 33 | } else $icao = $ident; |
| 34 | 34 | } |
| 35 | 35 | return $icao; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | $sth = $this->db->prepare($query); |
| 55 | 55 | $sth->execute(); |
| 56 | - } catch(PDOException $e) { |
|
| 56 | + } catch (PDOException $e) { |
|
| 57 | 57 | return "error"; |
| 58 | 58 | } |
| 59 | 59 | return "success"; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | $sth = $this->db->prepare($query); |
| 79 | 79 | $sth->execute(); |
| 80 | - } catch(PDOException $e) { |
|
| 80 | + } catch (PDOException $e) { |
|
| 81 | 81 | return "error"; |
| 82 | 82 | } |
| 83 | 83 | return "success"; |
@@ -102,13 +102,13 @@ discard block |
||
| 102 | 102 | $ident = ''; |
| 103 | 103 | $message = ''; |
| 104 | 104 | $result = array(); |
| 105 | - $n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 106 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 107 | - 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); |
|
| 108 | - 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); |
|
| 105 | + $n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
| 106 | + if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
| 107 | + 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); |
|
| 108 | + 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); |
|
| 109 | 109 | if ($n != 0) { |
| 110 | - $registration = str_replace('.','',$registration); |
|
| 111 | - $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
|
| 110 | + $registration = str_replace('.', '', $registration); |
|
| 111 | + $result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message); |
|
| 112 | 112 | if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
| 113 | 113 | } else $message = $data; |
| 114 | 114 | $decode = array(); |
@@ -128,14 +128,14 @@ discard block |
||
| 128 | 128 | $temp = ''; |
| 129 | 129 | $n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp); |
| 130 | 130 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
| 131 | - $latitude = $la / 10000.0; |
|
| 132 | - $longitude = $ln / 10000.0; |
|
| 131 | + $latitude = $la/10000.0; |
|
| 132 | + $longitude = $ln/10000.0; |
|
| 133 | 133 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 134 | 134 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 135 | 135 | // Temp not always available |
| 136 | 136 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
| 137 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 138 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 137 | + if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt); |
|
| 138 | + else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C'); |
|
| 139 | 139 | |
| 140 | 140 | //$icao = $Translation->checkTranslation($ident); |
| 141 | 141 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -147,19 +147,19 @@ discard block |
||
| 147 | 147 | $dhour = ''; |
| 148 | 148 | $darr = ''; |
| 149 | 149 | $ahour = ''; |
| 150 | - $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
|
| 150 | + $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour); |
|
| 151 | 151 | if ($n == 4 && strlen($darr) == 4) { |
| 152 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 153 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 154 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 152 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
| 153 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
| 154 | + if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n"; |
|
| 155 | 155 | //$icao = ACARS->ident2icao($ident); |
| 156 | 156 | //$icao = $Translation->checkTranslation($ident); |
| 157 | 157 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 158 | 158 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
| 159 | 159 | $found = true; |
| 160 | 160 | } |
| 161 | - elseif ($n == 2 || $n == 4) { |
|
| 162 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 161 | + elseif ($n == 2 || $n == 4) { |
|
| 162 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
| 163 | 163 | if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
| 164 | 164 | //$icao = ACARS->ident2icao($ident); |
| 165 | 165 | //$icao = $Translation->checkTranslation($ident); |
@@ -217,11 +217,11 @@ discard block |
||
| 217 | 217 | $ahour = ''; |
| 218 | 218 | $aair = ''; |
| 219 | 219 | $apiste = ''; |
| 220 | - $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); |
|
| 220 | + $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); |
|
| 221 | 221 | if ($n > 8) { |
| 222 | - 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"; |
|
| 223 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 224 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 222 | + 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"; |
|
| 223 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
| 224 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
| 225 | 225 | $icao = trim($aident); |
| 226 | 226 | |
| 227 | 227 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
@@ -246,8 +246,8 @@ discard block |
||
| 246 | 246 | if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
| 247 | 247 | $las = $las.'.'.$lass; |
| 248 | 248 | $lns = $lns.'.'.$lns; |
| 249 | - $latitude = $las / 1000.0; |
|
| 250 | - $longitude = $lns / 1000.0; |
|
| 249 | + $latitude = $las/1000.0; |
|
| 250 | + $longitude = $lns/1000.0; |
|
| 251 | 251 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 252 | 252 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 253 | 253 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
@@ -342,17 +342,17 @@ discard block |
||
| 342 | 342 | $alt = ''; |
| 343 | 343 | $fuel = ''; |
| 344 | 344 | $speed = ''; |
| 345 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
| 345 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
| 346 | 346 | if ($n == 9) { |
| 347 | 347 | //if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 348 | 348 | $icao = trim($aident); |
| 349 | 349 | $decode['icao'] = $icao; |
| 350 | - $latitude = $las / 100.0; |
|
| 351 | - $longitude = $lns / 100.0; |
|
| 350 | + $latitude = $las/100.0; |
|
| 351 | + $longitude = $lns/100.0; |
|
| 352 | 352 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 353 | 353 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 354 | 354 | |
| 355 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
|
| 355 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed); |
|
| 356 | 356 | $found = true; |
| 357 | 357 | } |
| 358 | 358 | } |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 372 | 372 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 373 | 373 | |
| 374 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
|
| 374 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
|
| 375 | 375 | $found = true; |
| 376 | 376 | } |
| 377 | 377 | } |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | $dair = ''; |
| 405 | 405 | $darr = ''; |
| 406 | 406 | $aident = ''; |
| 407 | - $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); |
|
| 407 | + $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); |
|
| 408 | 408 | if ($n == 8) { |
| 409 | 409 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 410 | 410 | $icao = trim($aident); |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | */ |
| 437 | 437 | $dair = ''; |
| 438 | 438 | $darr = ''; |
| 439 | - $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
|
| 439 | + $n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr); |
|
| 440 | 440 | if ($n == 3) { |
| 441 | 441 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 442 | 442 | //$icao = $Translation->checkTranslation($ident); |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | */ |
| 452 | 452 | $dair = ''; |
| 453 | 453 | $darr = ''; |
| 454 | - $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
|
| 454 | + $n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr); |
|
| 455 | 455 | if ($n == 3) { |
| 456 | 456 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 457 | 457 | //$icao = $Translation->checkTranslation($ident); |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | 463 | if (!$found) { |
| 464 | - $n = sscanf($message,'MET01%4c',$airport); |
|
| 464 | + $n = sscanf($message, 'MET01%4c', $airport); |
|
| 465 | 465 | if ($n == 1) { |
| 466 | 466 | if ($globalDebug) echo 'airport name : '.$airport; |
| 467 | 467 | $decode = array('Airport/Waypoint name' => $airport); |
@@ -469,241 +469,241 @@ discard block |
||
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | 471 | if ($label == 'H1') { |
| 472 | - if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
|
| 473 | - $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
|
| 472 | + if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) { |
|
| 473 | + $decode = array_merge(array('Message nature' => 'Equipment failure'), $decode); |
|
| 474 | 474 | } |
| 475 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 476 | - $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
|
| 475 | + elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) { |
|
| 476 | + $decode = array_merge(array('Message nature' => 'Take off performance data'), $decode); |
|
| 477 | 477 | } |
| 478 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 479 | - $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
|
| 478 | + elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) { |
|
| 479 | + $decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode); |
|
| 480 | 480 | } |
| 481 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 482 | - $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
|
| 481 | + elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) { |
|
| 482 | + $decode = array_merge(array('Message nature' => 'Weather observation'), $decode); |
|
| 483 | 483 | } |
| 484 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 485 | - $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
|
| 484 | + elseif (preg_match(':^#DFB/PIREP:', $message)) { |
|
| 485 | + $decode = array_merge(array('Message nature' => 'Pilot Report'), $decode); |
|
| 486 | 486 | } |
| 487 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 488 | - $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
|
| 487 | + elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) { |
|
| 488 | + $decode = array_merge(array('Message nature' => 'Engine Data'), $decode); |
|
| 489 | 489 | } |
| 490 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 491 | - $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
|
| 490 | + elseif (preg_match(':^#M1AAEP:', $message)) { |
|
| 491 | + $decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode); |
|
| 492 | 492 | } |
| 493 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 494 | - $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
|
| 493 | + elseif (preg_match(':^#M2APWD:', $message)) { |
|
| 494 | + $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode); |
|
| 495 | 495 | } |
| 496 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 497 | - $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
|
| 496 | + elseif (preg_match(':^#M1BREQPWI:', $message)) { |
|
| 497 | + $decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode); |
|
| 498 | 498 | } |
| 499 | - elseif (preg_match(':^#CF:',$message)) { |
|
| 500 | - $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
|
| 499 | + elseif (preg_match(':^#CF:', $message)) { |
|
| 500 | + $decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode); |
|
| 501 | 501 | } |
| 502 | - elseif (preg_match(':^#DF:',$message)) { |
|
| 503 | - $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
|
| 502 | + elseif (preg_match(':^#DF:', $message)) { |
|
| 503 | + $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode); |
|
| 504 | 504 | } |
| 505 | - elseif (preg_match(':^#EC:',$message)) { |
|
| 506 | - $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
|
| 505 | + elseif (preg_match(':^#EC:', $message)) { |
|
| 506 | + $decode = array_merge(array('Message nature' => 'Engine Display System'), $decode); |
|
| 507 | 507 | } |
| 508 | - elseif (preg_match(':^#EI:',$message)) { |
|
| 509 | - $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
|
| 508 | + elseif (preg_match(':^#EI:', $message)) { |
|
| 509 | + $decode = array_merge(array('Message nature' => 'Engine Report'), $decode); |
|
| 510 | 510 | } |
| 511 | - elseif (preg_match(':^#H1:',$message)) { |
|
| 512 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
|
| 511 | + elseif (preg_match(':^#H1:', $message)) { |
|
| 512 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode); |
|
| 513 | 513 | } |
| 514 | - elseif (preg_match(':^#H2:',$message)) { |
|
| 515 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
|
| 514 | + elseif (preg_match(':^#H2:', $message)) { |
|
| 515 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode); |
|
| 516 | 516 | } |
| 517 | - elseif (preg_match(':^#HD:',$message)) { |
|
| 518 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
|
| 517 | + elseif (preg_match(':^#HD:', $message)) { |
|
| 518 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode); |
|
| 519 | 519 | } |
| 520 | - elseif (preg_match(':^#M1:',$message)) { |
|
| 521 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
|
| 520 | + elseif (preg_match(':^#M1:', $message)) { |
|
| 521 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode); |
|
| 522 | 522 | } |
| 523 | - elseif (preg_match(':^#M2:',$message)) { |
|
| 524 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
|
| 523 | + elseif (preg_match(':^#M2:', $message)) { |
|
| 524 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode); |
|
| 525 | 525 | } |
| 526 | - elseif (preg_match(':^#M3:',$message)) { |
|
| 527 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
|
| 526 | + elseif (preg_match(':^#M3:', $message)) { |
|
| 527 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode); |
|
| 528 | 528 | } |
| 529 | - elseif (preg_match(':^#MD:',$message)) { |
|
| 530 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
|
| 529 | + elseif (preg_match(':^#MD:', $message)) { |
|
| 530 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode); |
|
| 531 | 531 | } |
| 532 | - elseif (preg_match(':^#PS:',$message)) { |
|
| 533 | - $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
|
| 532 | + elseif (preg_match(':^#PS:', $message)) { |
|
| 533 | + $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode); |
|
| 534 | 534 | } |
| 535 | - elseif (preg_match(':^#S1:',$message)) { |
|
| 536 | - $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
|
| 535 | + elseif (preg_match(':^#S1:', $message)) { |
|
| 536 | + $decode = array_merge(array('Message nature' => 'SDU - Left'), $decode); |
|
| 537 | 537 | } |
| 538 | - elseif (preg_match(':^#S2:',$message)) { |
|
| 539 | - $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
|
| 538 | + elseif (preg_match(':^#S2:', $message)) { |
|
| 539 | + $decode = array_merge(array('Message nature' => 'SDU - Right'), $decode); |
|
| 540 | 540 | } |
| 541 | - elseif (preg_match(':^#SD:',$message)) { |
|
| 542 | - $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
|
| 541 | + elseif (preg_match(':^#SD:', $message)) { |
|
| 542 | + $decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode); |
|
| 543 | 543 | } |
| 544 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 545 | - $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
|
| 544 | + elseif (preg_match(':^#T[0-8]:', $message)) { |
|
| 545 | + $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode); |
|
| 546 | 546 | } |
| 547 | - elseif (preg_match(':^#WO:',$message)) { |
|
| 548 | - $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
|
| 547 | + elseif (preg_match(':^#WO:', $message)) { |
|
| 548 | + $decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode); |
|
| 549 | 549 | } |
| 550 | - elseif (preg_match(':^#A1:',$message)) { |
|
| 551 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
|
| 550 | + elseif (preg_match(':^#A1:', $message)) { |
|
| 551 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode); |
|
| 552 | 552 | } |
| 553 | - elseif (preg_match(':^#A3:',$message)) { |
|
| 554 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
|
| 553 | + elseif (preg_match(':^#A3:', $message)) { |
|
| 554 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode); |
|
| 555 | 555 | } |
| 556 | - elseif (preg_match(':^#A4:',$message)) { |
|
| 557 | - $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
|
| 556 | + elseif (preg_match(':^#A4:', $message)) { |
|
| 557 | + $decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode); |
|
| 558 | 558 | } |
| 559 | - elseif (preg_match(':^#A6:',$message)) { |
|
| 560 | - $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
|
| 559 | + elseif (preg_match(':^#A6:', $message)) { |
|
| 560 | + $decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode); |
|
| 561 | 561 | } |
| 562 | - elseif (preg_match(':^#A8:',$message)) { |
|
| 563 | - $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
|
| 562 | + elseif (preg_match(':^#A8:', $message)) { |
|
| 563 | + $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode); |
|
| 564 | 564 | } |
| 565 | - elseif (preg_match(':^#A9:',$message)) { |
|
| 566 | - $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
|
| 565 | + elseif (preg_match(':^#A9:', $message)) { |
|
| 566 | + $decode = array_merge(array('Message nature' => 'ATIS report'), $decode); |
|
| 567 | 567 | } |
| 568 | - elseif (preg_match(':^#A0:',$message)) { |
|
| 569 | - $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
|
| 568 | + elseif (preg_match(':^#A0:', $message)) { |
|
| 569 | + $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode); |
|
| 570 | 570 | } |
| 571 | - elseif (preg_match(':^#AA:',$message)) { |
|
| 572 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
| 571 | + elseif (preg_match(':^#AA:', $message)) { |
|
| 572 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
| 573 | 573 | } |
| 574 | - elseif (preg_match(':^#AB:',$message)) { |
|
| 575 | - $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
|
| 574 | + elseif (preg_match(':^#AB:', $message)) { |
|
| 575 | + $decode = array_merge(array('Message nature' => 'TWIP Report'), $decode); |
|
| 576 | 576 | } |
| 577 | - elseif (preg_match(':^#AC:',$message)) { |
|
| 578 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
|
| 577 | + elseif (preg_match(':^#AC:', $message)) { |
|
| 578 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode); |
|
| 579 | 579 | } |
| 580 | - elseif (preg_match(':^#AD:',$message)) { |
|
| 581 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
|
| 580 | + elseif (preg_match(':^#AD:', $message)) { |
|
| 581 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode); |
|
| 582 | 582 | } |
| 583 | - elseif (preg_match(':^#AF:',$message)) { |
|
| 584 | - $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
|
| 583 | + elseif (preg_match(':^#AF:', $message)) { |
|
| 584 | + $decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode); |
|
| 585 | 585 | } |
| 586 | - elseif (preg_match(':^#B1:',$message)) { |
|
| 587 | - $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
|
| 586 | + elseif (preg_match(':^#B1:', $message)) { |
|
| 587 | + $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode); |
|
| 588 | 588 | } |
| 589 | - elseif (preg_match(':^#B2:',$message)) { |
|
| 590 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
|
| 589 | + elseif (preg_match(':^#B2:', $message)) { |
|
| 590 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode); |
|
| 591 | 591 | } |
| 592 | - elseif (preg_match(':^#B3:',$message)) { |
|
| 593 | - $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
|
| 592 | + elseif (preg_match(':^#B3:', $message)) { |
|
| 593 | + $decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode); |
|
| 594 | 594 | } |
| 595 | - elseif (preg_match(':^#B4:',$message)) { |
|
| 596 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
|
| 595 | + elseif (preg_match(':^#B4:', $message)) { |
|
| 596 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode); |
|
| 597 | 597 | } |
| 598 | - elseif (preg_match(':^#B6:',$message)) { |
|
| 599 | - $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
|
| 598 | + elseif (preg_match(':^#B6:', $message)) { |
|
| 599 | + $decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode); |
|
| 600 | 600 | } |
| 601 | - elseif (preg_match(':^#B8:',$message)) { |
|
| 602 | - $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
|
| 601 | + elseif (preg_match(':^#B8:', $message)) { |
|
| 602 | + $decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode); |
|
| 603 | 603 | } |
| 604 | - elseif (preg_match(':^#B9:',$message)) { |
|
| 605 | - $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
|
| 604 | + elseif (preg_match(':^#B9:', $message)) { |
|
| 605 | + $decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode); |
|
| 606 | 606 | } |
| 607 | - elseif (preg_match(':^#B0:',$message)) { |
|
| 608 | - $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
|
| 607 | + elseif (preg_match(':^#B0:', $message)) { |
|
| 608 | + $decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode); |
|
| 609 | 609 | } |
| 610 | - elseif (preg_match(':^#BA:',$message)) { |
|
| 611 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
| 610 | + elseif (preg_match(':^#BA:', $message)) { |
|
| 611 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
| 612 | 612 | } |
| 613 | - elseif (preg_match(':^#BB:',$message)) { |
|
| 614 | - $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
|
| 613 | + elseif (preg_match(':^#BB:', $message)) { |
|
| 614 | + $decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode); |
|
| 615 | 615 | } |
| 616 | - elseif (preg_match(':^#BC:',$message)) { |
|
| 617 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
|
| 616 | + elseif (preg_match(':^#BC:', $message)) { |
|
| 617 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode); |
|
| 618 | 618 | } |
| 619 | - elseif (preg_match(':^#BD:',$message)) { |
|
| 620 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
|
| 619 | + elseif (preg_match(':^#BD:', $message)) { |
|
| 620 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode); |
|
| 621 | 621 | } |
| 622 | - elseif (preg_match(':^#BE:',$message)) { |
|
| 623 | - $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
|
| 622 | + elseif (preg_match(':^#BE:', $message)) { |
|
| 623 | + $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode); |
|
| 624 | 624 | } |
| 625 | - elseif (preg_match(':^#BF:',$message)) { |
|
| 626 | - $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
|
| 625 | + elseif (preg_match(':^#BF:', $message)) { |
|
| 626 | + $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode); |
|
| 627 | 627 | } |
| 628 | - elseif (preg_match(':^#H3:',$message)) { |
|
| 629 | - $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
|
| 628 | + elseif (preg_match(':^#H3:', $message)) { |
|
| 629 | + $decode = array_merge(array('Message nature' => 'Icing Report'), $decode); |
|
| 630 | 630 | } |
| 631 | 631 | } |
| 632 | 632 | if ($label == '10') { |
| 633 | - if (preg_match(':^DTO01:',$message)) { |
|
| 634 | - $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
|
| 633 | + if (preg_match(':^DTO01:', $message)) { |
|
| 634 | + $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode); |
|
| 635 | 635 | } |
| 636 | - elseif (preg_match(':^AIS01:',$message)) { |
|
| 637 | - $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
|
| 636 | + elseif (preg_match(':^AIS01:', $message)) { |
|
| 637 | + $decode = array_merge(array('Message nature' => 'AIS Request'), $decode); |
|
| 638 | 638 | } |
| 639 | - elseif (preg_match(':^FTX01:',$message)) { |
|
| 640 | - $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
|
| 639 | + elseif (preg_match(':^FTX01:', $message)) { |
|
| 640 | + $decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode); |
|
| 641 | 641 | } |
| 642 | - elseif (preg_match(':^FPL01:',$message)) { |
|
| 643 | - $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
|
| 642 | + elseif (preg_match(':^FPL01:', $message)) { |
|
| 643 | + $decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode); |
|
| 644 | 644 | } |
| 645 | - elseif (preg_match(':^WAB01:',$message)) { |
|
| 646 | - $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
|
| 645 | + elseif (preg_match(':^WAB01:', $message)) { |
|
| 646 | + $decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode); |
|
| 647 | 647 | } |
| 648 | - elseif (preg_match(':^MET01:',$message)) { |
|
| 649 | - $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
|
| 648 | + elseif (preg_match(':^MET01:', $message)) { |
|
| 649 | + $decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode); |
|
| 650 | 650 | } |
| 651 | - elseif (preg_match(':^WAB02:',$message)) { |
|
| 652 | - $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
|
| 651 | + elseif (preg_match(':^WAB02:', $message)) { |
|
| 652 | + $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode); |
|
| 653 | 653 | } |
| 654 | 654 | } |
| 655 | 655 | if ($label == '15') { |
| 656 | - if (preg_match(':^FST01:',$message)) { |
|
| 657 | - $decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode); |
|
| 656 | + if (preg_match(':^FST01:', $message)) { |
|
| 657 | + $decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode); |
|
| 658 | 658 | } |
| 659 | 659 | } |
| 660 | 660 | if (!$found && $label == 'SA') { |
| 661 | - $n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at); |
|
| 661 | + $n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at); |
|
| 662 | 662 | if ($n == 4) { |
| 663 | 663 | $vsta = array('Version' => $version); |
| 664 | 664 | if ($state == 'E') { |
| 665 | - $vsta = array_merge($vsta,array('Link state' => 'Established')); |
|
| 665 | + $vsta = array_merge($vsta, array('Link state' => 'Established')); |
|
| 666 | 666 | } |
| 667 | 667 | elseif ($state == 'L') { |
| 668 | - $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
|
| 668 | + $vsta = array_merge($vsta, array('Link state' => 'Lost')); |
|
| 669 | 669 | } |
| 670 | 670 | else { |
| 671 | - $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
|
| 671 | + $vsta = array_merge($vsta, array('Link state' => 'Unknown')); |
|
| 672 | 672 | } |
| 673 | 673 | if ($type == 'V') { |
| 674 | - $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
|
| 674 | + $vsta = array_merge($vsta, array('Link type' => 'VHF ACARS')); |
|
| 675 | 675 | } |
| 676 | 676 | elseif ($type == 'S') { |
| 677 | - $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
|
| 677 | + $vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM')); |
|
| 678 | 678 | } |
| 679 | 679 | elseif ($type == 'H') { |
| 680 | - $vsta = array_merge($vsta,array('Link type' => 'HF')); |
|
| 680 | + $vsta = array_merge($vsta, array('Link type' => 'HF')); |
|
| 681 | 681 | } |
| 682 | 682 | elseif ($type == 'G') { |
| 683 | - $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
|
| 683 | + $vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM')); |
|
| 684 | 684 | } |
| 685 | 685 | elseif ($type == 'C') { |
| 686 | - $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
|
| 686 | + $vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM')); |
|
| 687 | 687 | } |
| 688 | 688 | elseif ($type == '2') { |
| 689 | - $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
|
| 689 | + $vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2')); |
|
| 690 | 690 | } |
| 691 | 691 | elseif ($type == 'X') { |
| 692 | - $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
|
| 692 | + $vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero')); |
|
| 693 | 693 | } |
| 694 | 694 | elseif ($type == 'I') { |
| 695 | - $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
|
| 695 | + $vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM')); |
|
| 696 | 696 | } |
| 697 | 697 | else { |
| 698 | - $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
|
| 698 | + $vsta = array_merge($vsta, array('Link type' => 'Unknown')); |
|
| 699 | 699 | } |
| 700 | - $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
|
| 701 | - $decode = array_merge($vsta,$decode); |
|
| 700 | + $vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2)))); |
|
| 701 | + $decode = array_merge($vsta, $decode); |
|
| 702 | 702 | } |
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | $title = $this->getTitlefromLabel($label); |
| 706 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
| 706 | + if ($title != '') $decode = array_merge(array('Message title' => $title), $decode); |
|
| 707 | 707 | /* |
| 708 | 708 | // Business jets always use GS0001 |
| 709 | 709 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -731,13 +731,13 @@ discard block |
||
| 731 | 731 | $Translation = new Translation($this->db); |
| 732 | 732 | $message = $this->parse($data); |
| 733 | 733 | if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') { |
| 734 | - $ident = (string)$message['ident']; |
|
| 734 | + $ident = (string) $message['ident']; |
|
| 735 | 735 | $label = $message['label']; |
| 736 | 736 | $block_id = $message['block_id']; |
| 737 | 737 | $msg_no = $message['msg_no']; |
| 738 | 738 | $msg = $message['message']; |
| 739 | 739 | $decode = $message['decode']; |
| 740 | - $registration = (string)$message['registration']; |
|
| 740 | + $registration = (string) $message['registration']; |
|
| 741 | 741 | if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
| 742 | 742 | else $latitude = ''; |
| 743 | 743 | if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
@@ -751,20 +751,20 @@ discard block |
||
| 751 | 751 | $Image->addSpotterImage($registration); |
| 752 | 752 | } |
| 753 | 753 | // Business jets always use GS0001 |
| 754 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 754 | + if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude); |
|
| 755 | 755 | if ($globalDebug && isset($info) && $info != '') echo $info; |
| 756 | 756 | if (count($decode) > 0) $decode_json = json_encode($decode); |
| 757 | 757 | else $decode_json = ''; |
| 758 | 758 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
| 759 | - $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
|
| 759 | + $Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS'); |
|
| 760 | 760 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
| 761 | - $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
|
| 761 | + $Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS'); |
|
| 762 | 762 | } |
| 763 | - $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 764 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 765 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 763 | + $result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
| 764 | + if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F'); |
|
| 765 | + if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
| 766 | 766 | if ($globalDebug && count($decode) > 0) { |
| 767 | - echo "Human readable data : ".implode(' - ',$decode)."\n"; |
|
| 767 | + echo "Human readable data : ".implode(' - ', $decode)."\n"; |
|
| 768 | 768 | } |
| 769 | 769 | } |
| 770 | 770 | } |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | * @param String $msg_no Number of the ACARS message |
| 780 | 780 | * @param String $message ACARS message |
| 781 | 781 | */ |
| 782 | - public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
| 782 | + public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
| 783 | 783 | global $globalDebug; |
| 784 | 784 | date_default_timezone_set('UTC'); |
| 785 | 785 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
@@ -787,21 +787,21 @@ discard block |
||
| 787 | 787 | $this->db = $Connection->db; |
| 788 | 788 | if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
| 789 | 789 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
| 790 | - $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
|
| 790 | + $query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message); |
|
| 791 | 791 | try { |
| 792 | 792 | $stht = $this->db->prepare($query_test); |
| 793 | 793 | $stht->execute($query_test_values); |
| 794 | - } catch(PDOException $e) { |
|
| 794 | + } catch (PDOException $e) { |
|
| 795 | 795 | return "error : ".$e->getMessage(); |
| 796 | 796 | } |
| 797 | 797 | if ($stht->fetchColumn() == 0) { |
| 798 | 798 | if ($globalDebug) echo "Add Live ACARS data..."; |
| 799 | 799 | $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)"; |
| 800 | - $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")); |
|
| 800 | + $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")); |
|
| 801 | 801 | try { |
| 802 | 802 | $sth = $this->db->prepare($query); |
| 803 | 803 | $sth->execute($query_values); |
| 804 | - } catch(PDOException $e) { |
|
| 804 | + } catch (PDOException $e) { |
|
| 805 | 805 | return "error : ".$e->getMessage(); |
| 806 | 806 | } |
| 807 | 807 | } else { |
@@ -823,10 +823,10 @@ discard block |
||
| 823 | 823 | * @param String $msg_no Number of the ACARS message |
| 824 | 824 | * @param String $message ACARS message |
| 825 | 825 | */ |
| 826 | - public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
| 826 | + public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
| 827 | 827 | global $globalDebug; |
| 828 | 828 | date_default_timezone_set('UTC'); |
| 829 | - if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) { |
|
| 829 | + if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) { |
|
| 830 | 830 | /* |
| 831 | 831 | if ($globalDebug) echo "Test if not already in Archive ACARS table..."; |
| 832 | 832 | $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message"; |
@@ -841,11 +841,11 @@ discard block |
||
| 841 | 841 | */ |
| 842 | 842 | if ($globalDebug) echo "Add Live ACARS data..."; |
| 843 | 843 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
| 844 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
| 844 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
| 845 | 845 | try { |
| 846 | 846 | $sth = $this->db->prepare($query); |
| 847 | 847 | $sth->execute($query_values); |
| 848 | - } catch(PDOException $e) { |
|
| 848 | + } catch (PDOException $e) { |
|
| 849 | 849 | return "error : ".$e->getMessage(); |
| 850 | 850 | } |
| 851 | 851 | if ($globalDebug) echo "Done\n"; |
@@ -866,7 +866,7 @@ discard block |
||
| 866 | 866 | try { |
| 867 | 867 | $sth = $this->db->prepare($query); |
| 868 | 868 | $sth->execute($query_values); |
| 869 | - } catch(PDOException $e) { |
|
| 869 | + } catch (PDOException $e) { |
|
| 870 | 870 | echo "error : ".$e->getMessage(); |
| 871 | 871 | die; |
| 872 | 872 | } |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | try { |
| 887 | 887 | $sth = $this->db->prepare($query); |
| 888 | 888 | $sth->execute($query_values); |
| 889 | - } catch(PDOException $e) { |
|
| 889 | + } catch (PDOException $e) { |
|
| 890 | 890 | echo "error : ".$e->getMessage(); |
| 891 | 891 | die; |
| 892 | 892 | } |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | try { |
| 908 | 908 | $sth = $this->db->prepare($query); |
| 909 | 909 | $sth->execute($query_values); |
| 910 | - } catch(PDOException $e) { |
|
| 910 | + } catch (PDOException $e) { |
|
| 911 | 911 | echo "error : ".$e->getMessage(); |
| 912 | 912 | die; |
| 913 | 913 | } |
@@ -921,7 +921,7 @@ discard block |
||
| 921 | 921 | * |
| 922 | 922 | * @return Array Return ACARS data in array |
| 923 | 923 | */ |
| 924 | - public function getLatestAcarsData($limit = '',$label = '') { |
|
| 924 | + public function getLatestAcarsData($limit = '', $label = '') { |
|
| 925 | 925 | global $globalURL, $globalDBdriver; |
| 926 | 926 | $Image = new Image($this->db); |
| 927 | 927 | $Spotter = new Spotter($this->db); |
@@ -932,8 +932,8 @@ discard block |
||
| 932 | 932 | if ($limit != "") |
| 933 | 933 | { |
| 934 | 934 | $limit_array = explode(",", $limit); |
| 935 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 936 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 935 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 936 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 937 | 937 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 938 | 938 | { |
| 939 | 939 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -949,46 +949,46 @@ discard block |
||
| 949 | 949 | try { |
| 950 | 950 | $sth = $this->db->prepare($query); |
| 951 | 951 | $sth->execute($query_values); |
| 952 | - } catch(PDOException $e) { |
|
| 952 | + } catch (PDOException $e) { |
|
| 953 | 953 | return "error : ".$e->getMessage(); |
| 954 | 954 | } |
| 955 | 955 | $i = 0; |
| 956 | 956 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 957 | 957 | $data = array(); |
| 958 | 958 | if ($row['registration'] != '') { |
| 959 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
| 959 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
| 960 | 960 | $image_array = $Image->getSpotterImage($row['registration']); |
| 961 | - 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'])); |
|
| 962 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 963 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 961 | + 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'])); |
|
| 962 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 963 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 964 | 964 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
| 965 | 965 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
| 966 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
| 966 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
| 967 | 967 | if (isset($identicao[0])) { |
| 968 | - if (substr($row['ident'],0,2) == 'AF') { |
|
| 969 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 970 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 971 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 972 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
| 968 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
| 969 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 970 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
| 971 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
| 972 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
| 973 | 973 | } else $icao = $row['ident']; |
| 974 | - $icao = $Translation->checkTranslation($icao,false); |
|
| 975 | - $decode = json_decode($row['decode'],true); |
|
| 974 | + $icao = $Translation->checkTranslation($icao, false); |
|
| 975 | + $decode = json_decode($row['decode'], true); |
|
| 976 | 976 | $found = false; |
| 977 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
| 977 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
| 978 | 978 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
| 979 | 979 | if (isset($airport_info[0]['icao'])) { |
| 980 | 980 | $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
| 981 | 981 | $found = true; |
| 982 | 982 | } |
| 983 | 983 | } |
| 984 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
| 984 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
| 985 | 985 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
| 986 | 986 | if (isset($airport_info[0]['icao'])) { |
| 987 | 987 | $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
| 988 | 988 | $found = true; |
| 989 | 989 | } |
| 990 | 990 | } |
| 991 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
| 991 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
| 992 | 992 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
| 993 | 993 | if (isset($airport_info[0]['icao'])) { |
| 994 | 994 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | } |
| 997 | 997 | } |
| 998 | 998 | if ($found) $row['decode'] = json_encode($decode); |
| 999 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 999 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 1000 | 1000 | $result[] = $data; |
| 1001 | 1001 | $i++; |
| 1002 | 1002 | } |
@@ -1012,7 +1012,7 @@ discard block |
||
| 1012 | 1012 | * |
| 1013 | 1013 | * @return Array Return ACARS data in array |
| 1014 | 1014 | */ |
| 1015 | - public function getArchiveAcarsData($limit = '',$label = '') { |
|
| 1015 | + public function getArchiveAcarsData($limit = '', $label = '') { |
|
| 1016 | 1016 | global $globalURL, $globalDBdriver; |
| 1017 | 1017 | $Image = new Image($this->db); |
| 1018 | 1018 | $Spotter = new Spotter($this->db); |
@@ -1022,8 +1022,8 @@ discard block |
||
| 1022 | 1022 | if ($limit != "") |
| 1023 | 1023 | { |
| 1024 | 1024 | $limit_array = explode(",", $limit); |
| 1025 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1026 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1025 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1026 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1027 | 1027 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1028 | 1028 | { |
| 1029 | 1029 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1044,43 +1044,43 @@ discard block |
||
| 1044 | 1044 | try { |
| 1045 | 1045 | $sth = $this->db->prepare($query); |
| 1046 | 1046 | $sth->execute($query_values); |
| 1047 | - } catch(PDOException $e) { |
|
| 1047 | + } catch (PDOException $e) { |
|
| 1048 | 1048 | return "error : ".$e->getMessage(); |
| 1049 | 1049 | } |
| 1050 | - $i=0; |
|
| 1050 | + $i = 0; |
|
| 1051 | 1051 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 1052 | 1052 | $data = array(); |
| 1053 | 1053 | if ($row['registration'] != '') { |
| 1054 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
| 1054 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
| 1055 | 1055 | $image_array = $Image->getSpotterImage($row['registration']); |
| 1056 | - 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'])); |
|
| 1057 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1058 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1056 | + 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'])); |
|
| 1057 | + else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 1058 | + } else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 1059 | 1059 | $icao = ''; |
| 1060 | 1060 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
| 1061 | 1061 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
| 1062 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
| 1062 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
| 1063 | 1063 | if (isset($identicao[0])) { |
| 1064 | - if (substr($row['ident'],0,2) == 'AF') { |
|
| 1065 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 1066 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1067 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1068 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
| 1064 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
| 1065 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 1066 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
| 1067 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
| 1068 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
| 1069 | 1069 | } else $icao = $row['ident']; |
| 1070 | 1070 | $icao = $Translation->checkTranslation($icao); |
| 1071 | - $decode = json_decode($row['decode'],true); |
|
| 1071 | + $decode = json_decode($row['decode'], true); |
|
| 1072 | 1072 | $found = false; |
| 1073 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
| 1073 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
| 1074 | 1074 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
| 1075 | 1075 | 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>'; |
| 1076 | 1076 | $found = true; |
| 1077 | 1077 | } |
| 1078 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
| 1078 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
| 1079 | 1079 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
| 1080 | 1080 | 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>'; |
| 1081 | 1081 | $found = true; |
| 1082 | 1082 | } |
| 1083 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
| 1083 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
| 1084 | 1084 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
| 1085 | 1085 | if (isset($airport_info[0]['icao'])) { |
| 1086 | 1086 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1088,7 +1088,7 @@ discard block |
||
| 1088 | 1088 | } |
| 1089 | 1089 | } |
| 1090 | 1090 | if ($found) $row['decode'] = json_encode($decode); |
| 1091 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 1091 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 1092 | 1092 | $result[] = $data; |
| 1093 | 1093 | $i++; |
| 1094 | 1094 | } |
@@ -1106,7 +1106,7 @@ discard block |
||
| 1106 | 1106 | * @param String $icao |
| 1107 | 1107 | * @param String $ICAOTypeCode |
| 1108 | 1108 | */ |
| 1109 | - public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
|
| 1109 | + public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') { |
|
| 1110 | 1110 | global $globalDebug, $globalDBdriver; |
| 1111 | 1111 | $ident = trim($ident); |
| 1112 | 1112 | $Translation = new Translation($this->db); |
@@ -1119,7 +1119,7 @@ discard block |
||
| 1119 | 1119 | if ($globalDebug) echo "Ident or registration null, exit\n"; |
| 1120 | 1120 | return ''; |
| 1121 | 1121 | } |
| 1122 | - $registration = str_replace('.','',$registration); |
|
| 1122 | + $registration = str_replace('.', '', $registration); |
|
| 1123 | 1123 | $ident = $Translation->ident2icao($ident); |
| 1124 | 1124 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
| 1125 | 1125 | if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
@@ -1128,7 +1128,7 @@ discard block |
||
| 1128 | 1128 | try { |
| 1129 | 1129 | $sthsi = $this->db->prepare($querysi); |
| 1130 | 1130 | $sthsi->execute($querysi_values); |
| 1131 | - } catch(PDOException $e) { |
|
| 1131 | + } catch (PDOException $e) { |
|
| 1132 | 1132 | if ($globalDebug) echo $e->getMessage(); |
| 1133 | 1133 | return "error : ".$e->getMessage(); |
| 1134 | 1134 | } |
@@ -1138,8 +1138,8 @@ discard block |
||
| 1138 | 1138 | $Translation = new Translation($this->db); |
| 1139 | 1139 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
| 1140 | 1140 | if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
| 1141 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1142 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1141 | + if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS'); |
|
| 1142 | + elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS'); |
|
| 1143 | 1143 | } else { |
| 1144 | 1144 | if ($registration != '' && $latitude != '' && $longitude != '') { |
| 1145 | 1145 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1147,7 +1147,7 @@ discard block |
||
| 1147 | 1147 | try { |
| 1148 | 1148 | $sth = $this->db->prepare($query); |
| 1149 | 1149 | $sth->execute($query_values); |
| 1150 | - } catch(PDOException $e) { |
|
| 1150 | + } catch (PDOException $e) { |
|
| 1151 | 1151 | if ($globalDebug) echo $e->getMessage(); |
| 1152 | 1152 | return "error : ".$e->getMessage(); |
| 1153 | 1153 | } |
@@ -1155,7 +1155,7 @@ discard block |
||
| 1155 | 1155 | $sth->closeCursor(); |
| 1156 | 1156 | if (isset($result['modes'])) $hex = $result['modes']; |
| 1157 | 1157 | else $hex = ''; |
| 1158 | - $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
|
| 1158 | + $SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS'); |
|
| 1159 | 1159 | $this->SI->add($SI_data); |
| 1160 | 1160 | } |
| 1161 | 1161 | } |
@@ -1165,7 +1165,7 @@ discard block |
||
| 1165 | 1165 | try { |
| 1166 | 1166 | $sth = $this->db->prepare($query); |
| 1167 | 1167 | $sth->execute($query_values); |
| 1168 | - } catch(PDOException $e) { |
|
| 1168 | + } catch (PDOException $e) { |
|
| 1169 | 1169 | if ($globalDebug) echo $e->getMessage(); |
| 1170 | 1170 | return "error : ".$e->getMessage(); |
| 1171 | 1171 | } |
@@ -1175,7 +1175,7 @@ discard block |
||
| 1175 | 1175 | if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
| 1176 | 1176 | else $ModeS = ''; |
| 1177 | 1177 | if ($ModeS == '') { |
| 1178 | - $id = explode('-',$result['flightaware_id']); |
|
| 1178 | + $id = explode('-', $result['flightaware_id']); |
|
| 1179 | 1179 | $ModeS = $id[0]; |
| 1180 | 1180 | } |
| 1181 | 1181 | if ($ModeS != '') { |
@@ -1185,20 +1185,20 @@ discard block |
||
| 1185 | 1185 | try { |
| 1186 | 1186 | $sthc = $this->db->prepare($queryc); |
| 1187 | 1187 | $sthc->execute($queryc_values); |
| 1188 | - } catch(PDOException $e) { |
|
| 1188 | + } catch (PDOException $e) { |
|
| 1189 | 1189 | if ($globalDebug) echo $e->getMessage(); |
| 1190 | 1190 | return "error : ".$e->getMessage(); |
| 1191 | 1191 | } |
| 1192 | 1192 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
| 1193 | 1193 | $sthc->closeCursor(); |
| 1194 | - if (count($row) == 0) { |
|
| 1194 | + if (count($row) == 0) { |
|
| 1195 | 1195 | if ($globalDebug) echo " Add to ModeS table - "; |
| 1196 | 1196 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
| 1197 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1197 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1198 | 1198 | try { |
| 1199 | 1199 | $sthi = $this->db->prepare($queryi); |
| 1200 | 1200 | $sthi->execute($queryi_values); |
| 1201 | - } catch(PDOException $e) { |
|
| 1201 | + } catch (PDOException $e) { |
|
| 1202 | 1202 | if ($globalDebug) echo $e->getMessage(); |
| 1203 | 1203 | return "error : ".$e->getMessage(); |
| 1204 | 1204 | } |
@@ -1206,15 +1206,15 @@ discard block |
||
| 1206 | 1206 | if ($globalDebug) echo " Update ModeS table - "; |
| 1207 | 1207 | if ($ICAOTypeCode != '') { |
| 1208 | 1208 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
| 1209 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1209 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1210 | 1210 | } else { |
| 1211 | 1211 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
| 1212 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration); |
|
| 1212 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration); |
|
| 1213 | 1213 | } |
| 1214 | 1214 | try { |
| 1215 | 1215 | $sthi = $this->db->prepare($queryi); |
| 1216 | 1216 | $sthi->execute($queryi_values); |
| 1217 | - } catch(PDOException $e) { |
|
| 1217 | + } catch (PDOException $e) { |
|
| 1218 | 1218 | if ($globalDebug) echo $e->getMessage(); |
| 1219 | 1219 | return "error : ".$e->getMessage(); |
| 1220 | 1220 | } |
@@ -1251,12 +1251,12 @@ discard block |
||
| 1251 | 1251 | elseif ($globalDBdriver == 'pgsql') { |
| 1252 | 1252 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
| 1253 | 1253 | } |
| 1254 | - $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
|
| 1254 | + $queryi_values = array(':Registration' => $registration, ':ident' => $icao); |
|
| 1255 | 1255 | } |
| 1256 | 1256 | try { |
| 1257 | 1257 | $sthi = $this->db->prepare($queryi); |
| 1258 | 1258 | $sthi->execute($queryi_values); |
| 1259 | - } catch(PDOException $e) { |
|
| 1259 | + } catch (PDOException $e) { |
|
| 1260 | 1260 | if ($globalDebug) echo $e->getMessage(); |
| 1261 | 1261 | return "error : ".$e->getMessage(); |
| 1262 | 1262 | } |
@@ -23,14 +23,19 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function ident2icao($ident) { |
| 25 | 25 | if (substr($ident,0,2) == 'AF') { |
| 26 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 27 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 26 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 27 | + $icao = $ident; |
|
| 28 | + } else { |
|
| 29 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 30 | + } |
|
| 28 | 31 | } else { |
| 29 | 32 | $Spotter = new Spotter($this->db); |
| 30 | 33 | $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
| 31 | 34 | if (isset($identicao[0])) { |
| 32 | 35 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
| 33 | - } else $icao = $ident; |
|
| 36 | + } else { |
|
| 37 | + $icao = $ident; |
|
| 38 | + } |
|
| 34 | 39 | } |
| 35 | 40 | return $icao; |
| 36 | 41 | } |
@@ -103,14 +108,24 @@ discard block |
||
| 103 | 108 | $message = ''; |
| 104 | 109 | $result = array(); |
| 105 | 110 | $n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
| 106 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 107 | - 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); |
|
| 108 | - 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); |
|
| 111 | + if ($n == 0) { |
|
| 112 | + $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 113 | + } |
|
| 114 | + if ($n == 0) { |
|
| 115 | + $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); |
|
| 116 | + } |
|
| 117 | + if ($n == 0) { |
|
| 118 | + $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); |
|
| 119 | + } |
|
| 109 | 120 | if ($n != 0) { |
| 110 | 121 | $registration = str_replace('.','',$registration); |
| 111 | 122 | $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
| 112 | - if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
| 113 | - } else $message = $data; |
|
| 123 | + if ($globalDebug) { |
|
| 124 | + echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
| 125 | + } |
|
| 126 | + } else { |
|
| 127 | + $message = $data; |
|
| 128 | + } |
|
| 114 | 129 | $decode = array(); |
| 115 | 130 | $found = false; |
| 116 | 131 | // if ($registration != '' && $ident != '' && $registration != '!') { |
@@ -130,12 +145,21 @@ discard block |
||
| 130 | 145 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
| 131 | 146 | $latitude = $la / 10000.0; |
| 132 | 147 | $longitude = $ln / 10000.0; |
| 133 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 134 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 148 | + if ($lac == 'S') { |
|
| 149 | + $latitude = '-'.$latitude; |
|
| 150 | + } |
|
| 151 | + if ($lnc == 'W') { |
|
| 152 | + $longitude = '-'.$longitude; |
|
| 153 | + } |
|
| 135 | 154 | // Temp not always available |
| 136 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
| 137 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 138 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 155 | + if ($globalDebug) { |
|
| 156 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
| 157 | + } |
|
| 158 | + if ($temp == '') { |
|
| 159 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 160 | + } else { |
|
| 161 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 162 | + } |
|
| 139 | 163 | |
| 140 | 164 | //$icao = $Translation->checkTranslation($ident); |
| 141 | 165 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -149,25 +173,35 @@ discard block |
||
| 149 | 173 | $ahour = ''; |
| 150 | 174 | $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
| 151 | 175 | if ($n == 4 && strlen($darr) == 4) { |
| 152 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 153 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 154 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 176 | + if ($dhour != '') { |
|
| 177 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 178 | + } |
|
| 179 | + if ($ahour != '') { |
|
| 180 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 181 | + } |
|
| 182 | + if ($globalDebug) { |
|
| 183 | + echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 184 | + } |
|
| 155 | 185 | //$icao = ACARS->ident2icao($ident); |
| 156 | 186 | //$icao = $Translation->checkTranslation($ident); |
| 157 | 187 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 158 | 188 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
| 159 | 189 | $found = true; |
| 160 | - } |
|
| 161 | - elseif ($n == 2 || $n == 4) { |
|
| 162 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 163 | - if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
| 190 | + } elseif ($n == 2 || $n == 4) { |
|
| 191 | + if ($dhour != '') { |
|
| 192 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 193 | + } |
|
| 194 | + if ($globalDebug) { |
|
| 195 | + echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
| 196 | + } |
|
| 164 | 197 | //$icao = ACARS->ident2icao($ident); |
| 165 | 198 | //$icao = $Translation->checkTranslation($ident); |
| 166 | 199 | $decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour); |
| 167 | 200 | $found = true; |
| 168 | - } |
|
| 169 | - elseif ($n == 1) { |
|
| 170 | - if ($globalDebug) echo 'airport arrival : '.$darr."\n"; |
|
| 201 | + } elseif ($n == 1) { |
|
| 202 | + if ($globalDebug) { |
|
| 203 | + echo 'airport arrival : '.$darr."\n"; |
|
| 204 | + } |
|
| 171 | 205 | //$icao = ACARS->ident2icao($ident); |
| 172 | 206 | //$icao = $Translation->checkTranslation($ident); |
| 173 | 207 | $decode = array('Arrival airport' => $darr); |
@@ -185,7 +219,9 @@ discard block |
||
| 185 | 219 | $darr = ''; |
| 186 | 220 | $n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr); |
| 187 | 221 | if ($n == 4) { |
| 188 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 222 | + if ($globalDebug) { |
|
| 223 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 224 | + } |
|
| 189 | 225 | //$icao = ACARS->ident2icao($ident); |
| 190 | 226 | //$icao = $Translation->checkTranslation($ident); |
| 191 | 227 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -219,14 +255,23 @@ discard block |
||
| 219 | 255 | $apiste = ''; |
| 220 | 256 | $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); |
| 221 | 257 | if ($n > 8) { |
| 222 | - 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"; |
|
| 223 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 224 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 258 | + if ($globalDebug) { |
|
| 259 | + 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"; |
|
| 260 | + } |
|
| 261 | + if ($dhour != '') { |
|
| 262 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 263 | + } |
|
| 264 | + if ($ahour != '') { |
|
| 265 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 266 | + } |
|
| 225 | 267 | $icao = trim($aident); |
| 226 | 268 | |
| 227 | 269 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
| 228 | - if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
| 229 | - else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
| 270 | + if ($ahour == '') { |
|
| 271 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
| 272 | + } else { |
|
| 273 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
| 274 | + } |
|
| 230 | 275 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 231 | 276 | $decode['icao'] = $icao; |
| 232 | 277 | $found = true; |
@@ -248,9 +293,15 @@ discard block |
||
| 248 | 293 | $lns = $lns.'.'.$lns; |
| 249 | 294 | $latitude = $las / 1000.0; |
| 250 | 295 | $longitude = $lns / 1000.0; |
| 251 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 252 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 253 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
| 296 | + if ($lac == 'S') { |
|
| 297 | + $latitude = '-'.$latitude; |
|
| 298 | + } |
|
| 299 | + if ($lnc == 'W') { |
|
| 300 | + $longitude = '-'.$longitude; |
|
| 301 | + } |
|
| 302 | + if ($globalDebug) { |
|
| 303 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
| 304 | + } |
|
| 254 | 305 | $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
| 255 | 306 | $found = true; |
| 256 | 307 | } |
@@ -268,7 +319,9 @@ discard block |
||
| 268 | 319 | $darr = ''; |
| 269 | 320 | $n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr); |
| 270 | 321 | if ($n == 4) { |
| 271 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 322 | + if ($globalDebug) { |
|
| 323 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 324 | + } |
|
| 272 | 325 | //$icao = $Translation->checkTranslation($ident); |
| 273 | 326 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 274 | 327 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -281,7 +334,9 @@ discard block |
||
| 281 | 334 | $darr = ''; |
| 282 | 335 | $n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr); |
| 283 | 336 | if ($n == 4) { |
| 284 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 337 | + if ($globalDebug) { |
|
| 338 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 339 | + } |
|
| 285 | 340 | //$icao = $Translation->checkTranslation($ident); |
| 286 | 341 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 287 | 342 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -294,7 +349,9 @@ discard block |
||
| 294 | 349 | $darr = ''; |
| 295 | 350 | $n = sscanf($message, "002AF %4c %4c ", $dair, $darr); |
| 296 | 351 | if ($n == 2) { |
| 297 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 352 | + if ($globalDebug) { |
|
| 353 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 354 | + } |
|
| 298 | 355 | //$icao = $Translation->checkTranslation($ident); |
| 299 | 356 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
| 300 | 357 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -308,7 +365,9 @@ discard block |
||
| 308 | 365 | $darr = ''; |
| 309 | 366 | $n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
| 310 | 367 | if ($n == 6) { |
| 311 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 368 | + if ($globalDebug) { |
|
| 369 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 370 | + } |
|
| 312 | 371 | //$icao = $Translation->checkTranslation($ident); |
| 313 | 372 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 314 | 373 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -321,7 +380,9 @@ discard block |
||
| 321 | 380 | $darr = ''; |
| 322 | 381 | $n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
| 323 | 382 | if ($n == 7) { |
| 324 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 383 | + if ($globalDebug) { |
|
| 384 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 385 | + } |
|
| 325 | 386 | //$icao = $Translation->checkTranslation($ident); |
| 326 | 387 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 327 | 388 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -349,8 +410,12 @@ discard block |
||
| 349 | 410 | $decode['icao'] = $icao; |
| 350 | 411 | $latitude = $las / 100.0; |
| 351 | 412 | $longitude = $lns / 100.0; |
| 352 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 353 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 413 | + if ($lac == 'S') { |
|
| 414 | + $latitude = '-'.$latitude; |
|
| 415 | + } |
|
| 416 | + if ($lnc == 'W') { |
|
| 417 | + $longitude = '-'.$longitude; |
|
| 418 | + } |
|
| 354 | 419 | |
| 355 | 420 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
| 356 | 421 | $found = true; |
@@ -368,8 +433,12 @@ discard block |
||
| 368 | 433 | if ($n == 4) { |
| 369 | 434 | $latitude = $las; |
| 370 | 435 | $longitude = $lns; |
| 371 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 372 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 436 | + if ($lac == 'S') { |
|
| 437 | + $latitude = '-'.$latitude; |
|
| 438 | + } |
|
| 439 | + if ($lnc == 'W') { |
|
| 440 | + $longitude = '-'.$longitude; |
|
| 441 | + } |
|
| 373 | 442 | |
| 374 | 443 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
| 375 | 444 | $found = true; |
@@ -385,7 +454,9 @@ discard block |
||
| 385 | 454 | $darr = ''; |
| 386 | 455 | $n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr); |
| 387 | 456 | if ($n == 5) { |
| 388 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 457 | + if ($globalDebug) { |
|
| 458 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 459 | + } |
|
| 389 | 460 | //$icao = $Translation->checkTranslation($ident); |
| 390 | 461 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 391 | 462 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -406,7 +477,9 @@ discard block |
||
| 406 | 477 | $aident = ''; |
| 407 | 478 | $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); |
| 408 | 479 | if ($n == 8) { |
| 409 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 480 | + if ($globalDebug) { |
|
| 481 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 482 | + } |
|
| 410 | 483 | $icao = trim($aident); |
| 411 | 484 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 412 | 485 | $decode['icao'] = $icao; |
@@ -423,7 +496,9 @@ discard block |
||
| 423 | 496 | $darr = ''; |
| 424 | 497 | $n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr); |
| 425 | 498 | if ($n == 5) { |
| 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 = $Translation->checkTranslation($ident); |
| 428 | 503 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 429 | 504 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -438,7 +513,9 @@ discard block |
||
| 438 | 513 | $darr = ''; |
| 439 | 514 | $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
| 440 | 515 | if ($n == 3) { |
| 441 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 516 | + if ($globalDebug) { |
|
| 517 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 518 | + } |
|
| 442 | 519 | //$icao = $Translation->checkTranslation($ident); |
| 443 | 520 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 444 | 521 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -453,7 +530,9 @@ discard block |
||
| 453 | 530 | $darr = ''; |
| 454 | 531 | $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
| 455 | 532 | if ($n == 3) { |
| 456 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 533 | + if ($globalDebug) { |
|
| 534 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 535 | + } |
|
| 457 | 536 | //$icao = $Translation->checkTranslation($ident); |
| 458 | 537 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 459 | 538 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -463,7 +542,9 @@ discard block |
||
| 463 | 542 | if (!$found) { |
| 464 | 543 | $n = sscanf($message,'MET01%4c',$airport); |
| 465 | 544 | if ($n == 1) { |
| 466 | - if ($globalDebug) echo 'airport name : '.$airport; |
|
| 545 | + if ($globalDebug) { |
|
| 546 | + echo 'airport name : '.$airport; |
|
| 547 | + } |
|
| 467 | 548 | $decode = array('Airport/Waypoint name' => $airport); |
| 468 | 549 | $found = true; |
| 469 | 550 | } |
@@ -471,184 +552,126 @@ discard block |
||
| 471 | 552 | if ($label == 'H1') { |
| 472 | 553 | if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
| 473 | 554 | $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
| 474 | - } |
|
| 475 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 555 | + } elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 476 | 556 | $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
| 477 | - } |
|
| 478 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 557 | + } elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 479 | 558 | $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
| 480 | - } |
|
| 481 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 559 | + } elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 482 | 560 | $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
| 483 | - } |
|
| 484 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 561 | + } elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 485 | 562 | $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
| 486 | - } |
|
| 487 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 563 | + } elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 488 | 564 | $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
| 489 | - } |
|
| 490 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 565 | + } elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 491 | 566 | $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
| 492 | - } |
|
| 493 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 567 | + } elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 494 | 568 | $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
| 495 | - } |
|
| 496 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 569 | + } elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 497 | 570 | $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
| 498 | - } |
|
| 499 | - elseif (preg_match(':^#CF:',$message)) { |
|
| 571 | + } elseif (preg_match(':^#CF:',$message)) { |
|
| 500 | 572 | $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
| 501 | - } |
|
| 502 | - elseif (preg_match(':^#DF:',$message)) { |
|
| 573 | + } elseif (preg_match(':^#DF:',$message)) { |
|
| 503 | 574 | $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
| 504 | - } |
|
| 505 | - elseif (preg_match(':^#EC:',$message)) { |
|
| 575 | + } elseif (preg_match(':^#EC:',$message)) { |
|
| 506 | 576 | $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
| 507 | - } |
|
| 508 | - elseif (preg_match(':^#EI:',$message)) { |
|
| 577 | + } elseif (preg_match(':^#EI:',$message)) { |
|
| 509 | 578 | $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
| 510 | - } |
|
| 511 | - elseif (preg_match(':^#H1:',$message)) { |
|
| 579 | + } elseif (preg_match(':^#H1:',$message)) { |
|
| 512 | 580 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
| 513 | - } |
|
| 514 | - elseif (preg_match(':^#H2:',$message)) { |
|
| 581 | + } elseif (preg_match(':^#H2:',$message)) { |
|
| 515 | 582 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
| 516 | - } |
|
| 517 | - elseif (preg_match(':^#HD:',$message)) { |
|
| 583 | + } elseif (preg_match(':^#HD:',$message)) { |
|
| 518 | 584 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
| 519 | - } |
|
| 520 | - elseif (preg_match(':^#M1:',$message)) { |
|
| 585 | + } elseif (preg_match(':^#M1:',$message)) { |
|
| 521 | 586 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
| 522 | - } |
|
| 523 | - elseif (preg_match(':^#M2:',$message)) { |
|
| 587 | + } elseif (preg_match(':^#M2:',$message)) { |
|
| 524 | 588 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
| 525 | - } |
|
| 526 | - elseif (preg_match(':^#M3:',$message)) { |
|
| 589 | + } elseif (preg_match(':^#M3:',$message)) { |
|
| 527 | 590 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
| 528 | - } |
|
| 529 | - elseif (preg_match(':^#MD:',$message)) { |
|
| 591 | + } elseif (preg_match(':^#MD:',$message)) { |
|
| 530 | 592 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
| 531 | - } |
|
| 532 | - elseif (preg_match(':^#PS:',$message)) { |
|
| 593 | + } elseif (preg_match(':^#PS:',$message)) { |
|
| 533 | 594 | $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
| 534 | - } |
|
| 535 | - elseif (preg_match(':^#S1:',$message)) { |
|
| 595 | + } elseif (preg_match(':^#S1:',$message)) { |
|
| 536 | 596 | $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
| 537 | - } |
|
| 538 | - elseif (preg_match(':^#S2:',$message)) { |
|
| 597 | + } elseif (preg_match(':^#S2:',$message)) { |
|
| 539 | 598 | $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
| 540 | - } |
|
| 541 | - elseif (preg_match(':^#SD:',$message)) { |
|
| 599 | + } elseif (preg_match(':^#SD:',$message)) { |
|
| 542 | 600 | $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
| 543 | - } |
|
| 544 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 601 | + } elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 545 | 602 | $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
| 546 | - } |
|
| 547 | - elseif (preg_match(':^#WO:',$message)) { |
|
| 603 | + } elseif (preg_match(':^#WO:',$message)) { |
|
| 548 | 604 | $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
| 549 | - } |
|
| 550 | - elseif (preg_match(':^#A1:',$message)) { |
|
| 605 | + } elseif (preg_match(':^#A1:',$message)) { |
|
| 551 | 606 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
| 552 | - } |
|
| 553 | - elseif (preg_match(':^#A3:',$message)) { |
|
| 607 | + } elseif (preg_match(':^#A3:',$message)) { |
|
| 554 | 608 | $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
| 555 | - } |
|
| 556 | - elseif (preg_match(':^#A4:',$message)) { |
|
| 609 | + } elseif (preg_match(':^#A4:',$message)) { |
|
| 557 | 610 | $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
| 558 | - } |
|
| 559 | - elseif (preg_match(':^#A6:',$message)) { |
|
| 611 | + } elseif (preg_match(':^#A6:',$message)) { |
|
| 560 | 612 | $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
| 561 | - } |
|
| 562 | - elseif (preg_match(':^#A8:',$message)) { |
|
| 613 | + } elseif (preg_match(':^#A8:',$message)) { |
|
| 563 | 614 | $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
| 564 | - } |
|
| 565 | - elseif (preg_match(':^#A9:',$message)) { |
|
| 615 | + } elseif (preg_match(':^#A9:',$message)) { |
|
| 566 | 616 | $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
| 567 | - } |
|
| 568 | - elseif (preg_match(':^#A0:',$message)) { |
|
| 617 | + } elseif (preg_match(':^#A0:',$message)) { |
|
| 569 | 618 | $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
| 570 | - } |
|
| 571 | - elseif (preg_match(':^#AA:',$message)) { |
|
| 619 | + } elseif (preg_match(':^#AA:',$message)) { |
|
| 572 | 620 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
| 573 | - } |
|
| 574 | - elseif (preg_match(':^#AB:',$message)) { |
|
| 621 | + } elseif (preg_match(':^#AB:',$message)) { |
|
| 575 | 622 | $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
| 576 | - } |
|
| 577 | - elseif (preg_match(':^#AC:',$message)) { |
|
| 623 | + } elseif (preg_match(':^#AC:',$message)) { |
|
| 578 | 624 | $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
| 579 | - } |
|
| 580 | - elseif (preg_match(':^#AD:',$message)) { |
|
| 625 | + } elseif (preg_match(':^#AD:',$message)) { |
|
| 581 | 626 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
| 582 | - } |
|
| 583 | - elseif (preg_match(':^#AF:',$message)) { |
|
| 627 | + } elseif (preg_match(':^#AF:',$message)) { |
|
| 584 | 628 | $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
| 585 | - } |
|
| 586 | - elseif (preg_match(':^#B1:',$message)) { |
|
| 629 | + } elseif (preg_match(':^#B1:',$message)) { |
|
| 587 | 630 | $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
| 588 | - } |
|
| 589 | - elseif (preg_match(':^#B2:',$message)) { |
|
| 631 | + } elseif (preg_match(':^#B2:',$message)) { |
|
| 590 | 632 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
| 591 | - } |
|
| 592 | - elseif (preg_match(':^#B3:',$message)) { |
|
| 633 | + } elseif (preg_match(':^#B3:',$message)) { |
|
| 593 | 634 | $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
| 594 | - } |
|
| 595 | - elseif (preg_match(':^#B4:',$message)) { |
|
| 635 | + } elseif (preg_match(':^#B4:',$message)) { |
|
| 596 | 636 | $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
| 597 | - } |
|
| 598 | - elseif (preg_match(':^#B6:',$message)) { |
|
| 637 | + } elseif (preg_match(':^#B6:',$message)) { |
|
| 599 | 638 | $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
| 600 | - } |
|
| 601 | - elseif (preg_match(':^#B8:',$message)) { |
|
| 639 | + } elseif (preg_match(':^#B8:',$message)) { |
|
| 602 | 640 | $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
| 603 | - } |
|
| 604 | - elseif (preg_match(':^#B9:',$message)) { |
|
| 641 | + } elseif (preg_match(':^#B9:',$message)) { |
|
| 605 | 642 | $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
| 606 | - } |
|
| 607 | - elseif (preg_match(':^#B0:',$message)) { |
|
| 643 | + } elseif (preg_match(':^#B0:',$message)) { |
|
| 608 | 644 | $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
| 609 | - } |
|
| 610 | - elseif (preg_match(':^#BA:',$message)) { |
|
| 645 | + } elseif (preg_match(':^#BA:',$message)) { |
|
| 611 | 646 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
| 612 | - } |
|
| 613 | - elseif (preg_match(':^#BB:',$message)) { |
|
| 647 | + } elseif (preg_match(':^#BB:',$message)) { |
|
| 614 | 648 | $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
| 615 | - } |
|
| 616 | - elseif (preg_match(':^#BC:',$message)) { |
|
| 649 | + } elseif (preg_match(':^#BC:',$message)) { |
|
| 617 | 650 | $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
| 618 | - } |
|
| 619 | - elseif (preg_match(':^#BD:',$message)) { |
|
| 651 | + } elseif (preg_match(':^#BD:',$message)) { |
|
| 620 | 652 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
| 621 | - } |
|
| 622 | - elseif (preg_match(':^#BE:',$message)) { |
|
| 653 | + } elseif (preg_match(':^#BE:',$message)) { |
|
| 623 | 654 | $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
| 624 | - } |
|
| 625 | - elseif (preg_match(':^#BF:',$message)) { |
|
| 655 | + } elseif (preg_match(':^#BF:',$message)) { |
|
| 626 | 656 | $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
| 627 | - } |
|
| 628 | - elseif (preg_match(':^#H3:',$message)) { |
|
| 657 | + } elseif (preg_match(':^#H3:',$message)) { |
|
| 629 | 658 | $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
| 630 | 659 | } |
| 631 | 660 | } |
| 632 | 661 | if ($label == '10') { |
| 633 | 662 | if (preg_match(':^DTO01:',$message)) { |
| 634 | 663 | $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
| 635 | - } |
|
| 636 | - elseif (preg_match(':^AIS01:',$message)) { |
|
| 664 | + } elseif (preg_match(':^AIS01:',$message)) { |
|
| 637 | 665 | $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
| 638 | - } |
|
| 639 | - elseif (preg_match(':^FTX01:',$message)) { |
|
| 666 | + } elseif (preg_match(':^FTX01:',$message)) { |
|
| 640 | 667 | $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
| 641 | - } |
|
| 642 | - elseif (preg_match(':^FPL01:',$message)) { |
|
| 668 | + } elseif (preg_match(':^FPL01:',$message)) { |
|
| 643 | 669 | $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
| 644 | - } |
|
| 645 | - elseif (preg_match(':^WAB01:',$message)) { |
|
| 670 | + } elseif (preg_match(':^WAB01:',$message)) { |
|
| 646 | 671 | $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
| 647 | - } |
|
| 648 | - elseif (preg_match(':^MET01:',$message)) { |
|
| 672 | + } elseif (preg_match(':^MET01:',$message)) { |
|
| 649 | 673 | $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
| 650 | - } |
|
| 651 | - elseif (preg_match(':^WAB02:',$message)) { |
|
| 674 | + } elseif (preg_match(':^WAB02:',$message)) { |
|
| 652 | 675 | $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
| 653 | 676 | } |
| 654 | 677 | } |
@@ -663,38 +686,28 @@ discard block |
||
| 663 | 686 | $vsta = array('Version' => $version); |
| 664 | 687 | if ($state == 'E') { |
| 665 | 688 | $vsta = array_merge($vsta,array('Link state' => 'Established')); |
| 666 | - } |
|
| 667 | - elseif ($state == 'L') { |
|
| 689 | + } elseif ($state == 'L') { |
|
| 668 | 690 | $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
| 669 | - } |
|
| 670 | - else { |
|
| 691 | + } else { |
|
| 671 | 692 | $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
| 672 | 693 | } |
| 673 | 694 | if ($type == 'V') { |
| 674 | 695 | $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
| 675 | - } |
|
| 676 | - elseif ($type == 'S') { |
|
| 696 | + } elseif ($type == 'S') { |
|
| 677 | 697 | $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
| 678 | - } |
|
| 679 | - elseif ($type == 'H') { |
|
| 698 | + } elseif ($type == 'H') { |
|
| 680 | 699 | $vsta = array_merge($vsta,array('Link type' => 'HF')); |
| 681 | - } |
|
| 682 | - elseif ($type == 'G') { |
|
| 700 | + } elseif ($type == 'G') { |
|
| 683 | 701 | $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
| 684 | - } |
|
| 685 | - elseif ($type == 'C') { |
|
| 702 | + } elseif ($type == 'C') { |
|
| 686 | 703 | $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
| 687 | - } |
|
| 688 | - elseif ($type == '2') { |
|
| 704 | + } elseif ($type == '2') { |
|
| 689 | 705 | $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
| 690 | - } |
|
| 691 | - elseif ($type == 'X') { |
|
| 706 | + } elseif ($type == 'X') { |
|
| 692 | 707 | $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
| 693 | - } |
|
| 694 | - elseif ($type == 'I') { |
|
| 708 | + } elseif ($type == 'I') { |
|
| 695 | 709 | $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
| 696 | - } |
|
| 697 | - else { |
|
| 710 | + } else { |
|
| 698 | 711 | $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
| 699 | 712 | } |
| 700 | 713 | $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
@@ -703,7 +716,9 @@ discard block |
||
| 703 | 716 | } |
| 704 | 717 | |
| 705 | 718 | $title = $this->getTitlefromLabel($label); |
| 706 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
| 719 | + if ($title != '') { |
|
| 720 | + $decode = array_merge(array('Message title' => $title),$decode); |
|
| 721 | + } |
|
| 707 | 722 | /* |
| 708 | 723 | // Business jets always use GS0001 |
| 709 | 724 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -738,31 +753,54 @@ discard block |
||
| 738 | 753 | $msg = $message['message']; |
| 739 | 754 | $decode = $message['decode']; |
| 740 | 755 | $registration = (string)$message['registration']; |
| 741 | - if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
|
| 742 | - else $latitude = ''; |
|
| 743 | - if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
|
| 744 | - else $longitude = ''; |
|
| 745 | - if (isset($decode['airicao'])) $airicao = $decode['airicao']; |
|
| 746 | - else $airicao = ''; |
|
| 747 | - if (isset($decode['icao'])) $icao = $decode['icao']; |
|
| 748 | - else $icao = $Translation->checkTranslation($ident); |
|
| 756 | + if (isset($decode['latitude'])) { |
|
| 757 | + $latitude = $decode['latitude']; |
|
| 758 | + } else { |
|
| 759 | + $latitude = ''; |
|
| 760 | + } |
|
| 761 | + if (isset($decode['longitude'])) { |
|
| 762 | + $longitude = $decode['longitude']; |
|
| 763 | + } else { |
|
| 764 | + $longitude = ''; |
|
| 765 | + } |
|
| 766 | + if (isset($decode['airicao'])) { |
|
| 767 | + $airicao = $decode['airicao']; |
|
| 768 | + } else { |
|
| 769 | + $airicao = ''; |
|
| 770 | + } |
|
| 771 | + if (isset($decode['icao'])) { |
|
| 772 | + $icao = $decode['icao']; |
|
| 773 | + } else { |
|
| 774 | + $icao = $Translation->checkTranslation($ident); |
|
| 775 | + } |
|
| 749 | 776 | $image_array = $Image->getSpotterImage($registration); |
| 750 | 777 | if (!isset($image_array[0]['registration'])) { |
| 751 | 778 | $Image->addSpotterImage($registration); |
| 752 | 779 | } |
| 753 | 780 | // Business jets always use GS0001 |
| 754 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 755 | - if ($globalDebug && isset($info) && $info != '') echo $info; |
|
| 756 | - if (count($decode) > 0) $decode_json = json_encode($decode); |
|
| 757 | - else $decode_json = ''; |
|
| 781 | + if ($ident != 'GS0001') { |
|
| 782 | + $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 783 | + } |
|
| 784 | + if ($globalDebug && isset($info) && $info != '') { |
|
| 785 | + echo $info; |
|
| 786 | + } |
|
| 787 | + if (count($decode) > 0) { |
|
| 788 | + $decode_json = json_encode($decode); |
|
| 789 | + } else { |
|
| 790 | + $decode_json = ''; |
|
| 791 | + } |
|
| 758 | 792 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
| 759 | 793 | $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
| 760 | 794 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
| 761 | 795 | $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
| 762 | 796 | } |
| 763 | 797 | $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
| 764 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 765 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 798 | + if (!isset($globalACARSArchive)) { |
|
| 799 | + $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 800 | + } |
|
| 801 | + if ($result && in_array($label,$globalACARSArchive)) { |
|
| 802 | + $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 803 | + } |
|
| 766 | 804 | if ($globalDebug && count($decode) > 0) { |
| 767 | 805 | echo "Human readable data : ".implode(' - ',$decode)."\n"; |
| 768 | 806 | } |
@@ -785,7 +823,9 @@ discard block |
||
| 785 | 823 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
| 786 | 824 | $Connection = new Connection($this->db); |
| 787 | 825 | $this->db = $Connection->db; |
| 788 | - if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
|
| 826 | + if ($globalDebug) { |
|
| 827 | + echo "Test if not already in Live ACARS table..."; |
|
| 828 | + } |
|
| 789 | 829 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
| 790 | 830 | $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
| 791 | 831 | try { |
@@ -795,7 +835,9 @@ discard block |
||
| 795 | 835 | return "error : ".$e->getMessage(); |
| 796 | 836 | } |
| 797 | 837 | if ($stht->fetchColumn() == 0) { |
| 798 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
| 838 | + if ($globalDebug) { |
|
| 839 | + echo "Add Live ACARS data..."; |
|
| 840 | + } |
|
| 799 | 841 | $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)"; |
| 800 | 842 | $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")); |
| 801 | 843 | try { |
@@ -805,10 +847,14 @@ discard block |
||
| 805 | 847 | return "error : ".$e->getMessage(); |
| 806 | 848 | } |
| 807 | 849 | } else { |
| 808 | - if ($globalDebug) echo "Data already in DB...\n"; |
|
| 850 | + if ($globalDebug) { |
|
| 851 | + echo "Data already in DB...\n"; |
|
| 852 | + } |
|
| 809 | 853 | return false; |
| 810 | 854 | } |
| 811 | - if ($globalDebug) echo "Done\n"; |
|
| 855 | + if ($globalDebug) { |
|
| 856 | + echo "Done\n"; |
|
| 857 | + } |
|
| 812 | 858 | return true; |
| 813 | 859 | } |
| 814 | 860 | } |
@@ -839,7 +885,9 @@ discard block |
||
| 839 | 885 | } |
| 840 | 886 | if ($stht->fetchColumn() == 0) { |
| 841 | 887 | */ |
| 842 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
| 888 | + if ($globalDebug) { |
|
| 889 | + echo "Add Live ACARS data..."; |
|
| 890 | + } |
|
| 843 | 891 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
| 844 | 892 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
| 845 | 893 | try { |
@@ -848,7 +896,9 @@ discard block |
||
| 848 | 896 | } catch(PDOException $e) { |
| 849 | 897 | return "error : ".$e->getMessage(); |
| 850 | 898 | } |
| 851 | - if ($globalDebug) echo "Done\n"; |
|
| 899 | + if ($globalDebug) { |
|
| 900 | + echo "Done\n"; |
|
| 901 | + } |
|
| 852 | 902 | } |
| 853 | 903 | } |
| 854 | 904 | |
@@ -871,8 +921,11 @@ discard block |
||
| 871 | 921 | die; |
| 872 | 922 | } |
| 873 | 923 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 874 | - if (count($row) > 0) return $row[0]['title']; |
|
| 875 | - else return ''; |
|
| 924 | + if (count($row) > 0) { |
|
| 925 | + return $row[0]['title']; |
|
| 926 | + } else { |
|
| 927 | + return ''; |
|
| 928 | + } |
|
| 876 | 929 | } |
| 877 | 930 | |
| 878 | 931 | /** |
@@ -891,8 +944,11 @@ discard block |
||
| 891 | 944 | die; |
| 892 | 945 | } |
| 893 | 946 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 894 | - if (count($row) > 0) return $row; |
|
| 895 | - else return array(); |
|
| 947 | + if (count($row) > 0) { |
|
| 948 | + return $row; |
|
| 949 | + } else { |
|
| 950 | + return array(); |
|
| 951 | + } |
|
| 896 | 952 | } |
| 897 | 953 | |
| 898 | 954 | /** |
@@ -912,8 +968,11 @@ discard block |
||
| 912 | 968 | die; |
| 913 | 969 | } |
| 914 | 970 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 915 | - if (count($row) > 0) return $row[0]; |
|
| 916 | - else return array(); |
|
| 971 | + if (count($row) > 0) { |
|
| 972 | + return $row[0]; |
|
| 973 | + } else { |
|
| 974 | + return array(); |
|
| 975 | + } |
|
| 917 | 976 | } |
| 918 | 977 | |
| 919 | 978 | /** |
@@ -958,19 +1017,35 @@ discard block |
||
| 958 | 1017 | if ($row['registration'] != '') { |
| 959 | 1018 | $row['registration'] = str_replace('.','',$row['registration']); |
| 960 | 1019 | $image_array = $Image->getSpotterImage($row['registration']); |
| 961 | - 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'])); |
|
| 962 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 963 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 964 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 965 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 1020 | + if (count($image_array) > 0) { |
|
| 1021 | + $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'])); |
|
| 1022 | + } else { |
|
| 1023 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1024 | + } |
|
| 1025 | + } else { |
|
| 1026 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1027 | + } |
|
| 1028 | + if ($row['registration'] == '') { |
|
| 1029 | + $row['registration'] = 'NA'; |
|
| 1030 | + } |
|
| 1031 | + if ($row['ident'] == '') { |
|
| 1032 | + $row['ident'] = 'NA'; |
|
| 1033 | + } |
|
| 966 | 1034 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
| 967 | 1035 | if (isset($identicao[0])) { |
| 968 | 1036 | if (substr($row['ident'],0,2) == 'AF') { |
| 969 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 970 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 971 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1037 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 1038 | + $icao = $row['ident']; |
|
| 1039 | + } else { |
|
| 1040 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1041 | + } |
|
| 1042 | + } else { |
|
| 1043 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1044 | + } |
|
| 972 | 1045 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 973 | - } else $icao = $row['ident']; |
|
| 1046 | + } else { |
|
| 1047 | + $icao = $row['ident']; |
|
| 1048 | + } |
|
| 974 | 1049 | $icao = $Translation->checkTranslation($icao,false); |
| 975 | 1050 | $decode = json_decode($row['decode'],true); |
| 976 | 1051 | $found = false; |
@@ -995,7 +1070,9 @@ discard block |
||
| 995 | 1070 | $found = true; |
| 996 | 1071 | } |
| 997 | 1072 | } |
| 998 | - if ($found) $row['decode'] = json_encode($decode); |
|
| 1073 | + if ($found) { |
|
| 1074 | + $row['decode'] = json_encode($decode); |
|
| 1075 | + } |
|
| 999 | 1076 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
| 1000 | 1077 | $result[] = $data; |
| 1001 | 1078 | $i++; |
@@ -1003,8 +1080,9 @@ discard block |
||
| 1003 | 1080 | if (isset($result)) { |
| 1004 | 1081 | $result[0]['query_number_rows'] = $i; |
| 1005 | 1082 | return $result; |
| 1083 | + } else { |
|
| 1084 | + return array(); |
|
| 1006 | 1085 | } |
| 1007 | - else return array(); |
|
| 1008 | 1086 | } |
| 1009 | 1087 | |
| 1010 | 1088 | /** |
@@ -1053,31 +1131,51 @@ discard block |
||
| 1053 | 1131 | if ($row['registration'] != '') { |
| 1054 | 1132 | $row['registration'] = str_replace('.','',$row['registration']); |
| 1055 | 1133 | $image_array = $Image->getSpotterImage($row['registration']); |
| 1056 | - 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'])); |
|
| 1057 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1058 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1134 | + if (count($image_array) > 0) { |
|
| 1135 | + $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'])); |
|
| 1136 | + } else { |
|
| 1137 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1138 | + } |
|
| 1139 | + } else { |
|
| 1140 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1141 | + } |
|
| 1059 | 1142 | $icao = ''; |
| 1060 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 1061 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 1143 | + if ($row['registration'] == '') { |
|
| 1144 | + $row['registration'] = 'NA'; |
|
| 1145 | + } |
|
| 1146 | + if ($row['ident'] == '') { |
|
| 1147 | + $row['ident'] = 'NA'; |
|
| 1148 | + } |
|
| 1062 | 1149 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
| 1063 | 1150 | if (isset($identicao[0])) { |
| 1064 | 1151 | if (substr($row['ident'],0,2) == 'AF') { |
| 1065 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 1066 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1067 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1152 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 1153 | + $icao = $row['ident']; |
|
| 1154 | + } else { |
|
| 1155 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1156 | + } |
|
| 1157 | + } else { |
|
| 1158 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1159 | + } |
|
| 1068 | 1160 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 1069 | - } else $icao = $row['ident']; |
|
| 1161 | + } else { |
|
| 1162 | + $icao = $row['ident']; |
|
| 1163 | + } |
|
| 1070 | 1164 | $icao = $Translation->checkTranslation($icao); |
| 1071 | 1165 | $decode = json_decode($row['decode'],true); |
| 1072 | 1166 | $found = false; |
| 1073 | 1167 | if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
| 1074 | 1168 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
| 1075 | - 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>'; |
|
| 1169 | + if (isset($airport_info[0]['icao'])) { |
|
| 1170 | + $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1171 | + } |
|
| 1076 | 1172 | $found = true; |
| 1077 | 1173 | } |
| 1078 | 1174 | if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
| 1079 | 1175 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
| 1080 | - 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>'; |
|
| 1176 | + if (isset($airport_info[0]['icao'])) { |
|
| 1177 | + $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1178 | + } |
|
| 1081 | 1179 | $found = true; |
| 1082 | 1180 | } |
| 1083 | 1181 | if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
@@ -1087,7 +1185,9 @@ discard block |
||
| 1087 | 1185 | $found = true; |
| 1088 | 1186 | } |
| 1089 | 1187 | } |
| 1090 | - if ($found) $row['decode'] = json_encode($decode); |
|
| 1188 | + if ($found) { |
|
| 1189 | + $row['decode'] = json_encode($decode); |
|
| 1190 | + } |
|
| 1091 | 1191 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
| 1092 | 1192 | $result[] = $data; |
| 1093 | 1193 | $i++; |
@@ -1095,7 +1195,9 @@ discard block |
||
| 1095 | 1195 | if (isset($result)) { |
| 1096 | 1196 | $result[0]['query_number_rows'] = $i; |
| 1097 | 1197 | return $result; |
| 1098 | - } else return array(); |
|
| 1198 | + } else { |
|
| 1199 | + return array(); |
|
| 1200 | + } |
|
| 1099 | 1201 | } |
| 1100 | 1202 | |
| 1101 | 1203 | /** |
@@ -1111,25 +1213,37 @@ discard block |
||
| 1111 | 1213 | $ident = trim($ident); |
| 1112 | 1214 | $Translation = new Translation($this->db); |
| 1113 | 1215 | $Spotter = new Spotter($this->db); |
| 1114 | - if ($globalDebug) echo "Test if we add ModeS data..."; |
|
| 1216 | + if ($globalDebug) { |
|
| 1217 | + echo "Test if we add ModeS data..."; |
|
| 1218 | + } |
|
| 1115 | 1219 | //if ($icao == '') $icao = ACARS->ident2icao($ident); |
| 1116 | - if ($icao == '') $icao = $Translation->checkTranslation($ident); |
|
| 1117 | - if ($globalDebug) echo '- Ident : '.$icao.' - '; |
|
| 1220 | + if ($icao == '') { |
|
| 1221 | + $icao = $Translation->checkTranslation($ident); |
|
| 1222 | + } |
|
| 1223 | + if ($globalDebug) { |
|
| 1224 | + echo '- Ident : '.$icao.' - '; |
|
| 1225 | + } |
|
| 1118 | 1226 | if ($ident == '' || $registration == '') { |
| 1119 | - if ($globalDebug) echo "Ident or registration null, exit\n"; |
|
| 1227 | + if ($globalDebug) { |
|
| 1228 | + echo "Ident or registration null, exit\n"; |
|
| 1229 | + } |
|
| 1120 | 1230 | return ''; |
| 1121 | 1231 | } |
| 1122 | 1232 | $registration = str_replace('.','',$registration); |
| 1123 | 1233 | $ident = $Translation->ident2icao($ident); |
| 1124 | 1234 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
| 1125 | - if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
|
| 1235 | + if ($globalDebug) { |
|
| 1236 | + echo "Check if needed to add translation ".$ident.'... '; |
|
| 1237 | + } |
|
| 1126 | 1238 | $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"; |
| 1127 | 1239 | $querysi_values = array(':registration' => $registration); |
| 1128 | 1240 | try { |
| 1129 | 1241 | $sthsi = $this->db->prepare($querysi); |
| 1130 | 1242 | $sthsi->execute($querysi_values); |
| 1131 | 1243 | } catch(PDOException $e) { |
| 1132 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1244 | + if ($globalDebug) { |
|
| 1245 | + echo $e->getMessage(); |
|
| 1246 | + } |
|
| 1133 | 1247 | return "error : ".$e->getMessage(); |
| 1134 | 1248 | } |
| 1135 | 1249 | $resultsi = $sthsi->fetch(PDO::FETCH_ASSOC); |
@@ -1137,9 +1251,14 @@ discard block |
||
| 1137 | 1251 | if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') { |
| 1138 | 1252 | $Translation = new Translation($this->db); |
| 1139 | 1253 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
| 1140 | - if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
| 1141 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1142 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1254 | + if ($globalDebug) { |
|
| 1255 | + echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
| 1256 | + } |
|
| 1257 | + if ($ident != $trans_ident) { |
|
| 1258 | + $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1259 | + } elseif ($trans_ident == $ident) { |
|
| 1260 | + $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1261 | + } |
|
| 1143 | 1262 | } else { |
| 1144 | 1263 | if ($registration != '' && $latitude != '' && $longitude != '') { |
| 1145 | 1264 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1148,32 +1267,44 @@ discard block |
||
| 1148 | 1267 | $sth = $this->db->prepare($query); |
| 1149 | 1268 | $sth->execute($query_values); |
| 1150 | 1269 | } catch(PDOException $e) { |
| 1151 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1270 | + if ($globalDebug) { |
|
| 1271 | + echo $e->getMessage(); |
|
| 1272 | + } |
|
| 1152 | 1273 | return "error : ".$e->getMessage(); |
| 1153 | 1274 | } |
| 1154 | 1275 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 1155 | 1276 | $sth->closeCursor(); |
| 1156 | - if (isset($result['modes'])) $hex = $result['modes']; |
|
| 1157 | - else $hex = ''; |
|
| 1277 | + if (isset($result['modes'])) { |
|
| 1278 | + $hex = $result['modes']; |
|
| 1279 | + } else { |
|
| 1280 | + $hex = ''; |
|
| 1281 | + } |
|
| 1158 | 1282 | $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
| 1159 | 1283 | $this->SI->add($SI_data); |
| 1160 | 1284 | } |
| 1161 | 1285 | } |
| 1162 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 1286 | + if ($globalDebug) { |
|
| 1287 | + echo 'Done'."\n"; |
|
| 1288 | + } |
|
| 1163 | 1289 | $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1"; |
| 1164 | 1290 | $query_values = array(':ident' => $icao); |
| 1165 | 1291 | try { |
| 1166 | 1292 | $sth = $this->db->prepare($query); |
| 1167 | 1293 | $sth->execute($query_values); |
| 1168 | 1294 | } catch(PDOException $e) { |
| 1169 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1295 | + if ($globalDebug) { |
|
| 1296 | + echo $e->getMessage(); |
|
| 1297 | + } |
|
| 1170 | 1298 | return "error : ".$e->getMessage(); |
| 1171 | 1299 | } |
| 1172 | 1300 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 1173 | 1301 | $sth->closeCursor(); |
| 1174 | 1302 | if (isset($result['flightaware_id'])) { |
| 1175 | - if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
|
| 1176 | - else $ModeS = ''; |
|
| 1303 | + if (isset($result['ModeS'])) { |
|
| 1304 | + $ModeS = $result['ModeS']; |
|
| 1305 | + } else { |
|
| 1306 | + $ModeS = ''; |
|
| 1307 | + } |
|
| 1177 | 1308 | if ($ModeS == '') { |
| 1178 | 1309 | $id = explode('-',$result['flightaware_id']); |
| 1179 | 1310 | $ModeS = $id[0]; |
@@ -1186,24 +1317,32 @@ discard block |
||
| 1186 | 1317 | $sthc = $this->db->prepare($queryc); |
| 1187 | 1318 | $sthc->execute($queryc_values); |
| 1188 | 1319 | } catch(PDOException $e) { |
| 1189 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1320 | + if ($globalDebug) { |
|
| 1321 | + echo $e->getMessage(); |
|
| 1322 | + } |
|
| 1190 | 1323 | return "error : ".$e->getMessage(); |
| 1191 | 1324 | } |
| 1192 | 1325 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
| 1193 | 1326 | $sthc->closeCursor(); |
| 1194 | 1327 | if (count($row) == 0) { |
| 1195 | - if ($globalDebug) echo " Add to ModeS table - "; |
|
| 1328 | + if ($globalDebug) { |
|
| 1329 | + echo " Add to ModeS table - "; |
|
| 1330 | + } |
|
| 1196 | 1331 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
| 1197 | 1332 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
| 1198 | 1333 | try { |
| 1199 | 1334 | $sthi = $this->db->prepare($queryi); |
| 1200 | 1335 | $sthi->execute($queryi_values); |
| 1201 | 1336 | } catch(PDOException $e) { |
| 1202 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1337 | + if ($globalDebug) { |
|
| 1338 | + echo $e->getMessage(); |
|
| 1339 | + } |
|
| 1203 | 1340 | return "error : ".$e->getMessage(); |
| 1204 | 1341 | } |
| 1205 | 1342 | } else { |
| 1206 | - if ($globalDebug) echo " Update ModeS table - "; |
|
| 1343 | + if ($globalDebug) { |
|
| 1344 | + echo " Update ModeS table - "; |
|
| 1345 | + } |
|
| 1207 | 1346 | if ($ICAOTypeCode != '') { |
| 1208 | 1347 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
| 1209 | 1348 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
@@ -1215,7 +1354,9 @@ discard block |
||
| 1215 | 1354 | $sthi = $this->db->prepare($queryi); |
| 1216 | 1355 | $sthi->execute($queryi_values); |
| 1217 | 1356 | } catch(PDOException $e) { |
| 1218 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1357 | + if ($globalDebug) { |
|
| 1358 | + echo $e->getMessage(); |
|
| 1359 | + } |
|
| 1219 | 1360 | return "error : ".$e->getMessage(); |
| 1220 | 1361 | } |
| 1221 | 1362 | } |
@@ -1236,7 +1377,9 @@ discard block |
||
| 1236 | 1377 | return "error : ".$e->getMessage(); |
| 1237 | 1378 | } |
| 1238 | 1379 | */ |
| 1239 | - if ($globalDebug) echo " Update Spotter_output table - "; |
|
| 1380 | + if ($globalDebug) { |
|
| 1381 | + echo " Update Spotter_output table - "; |
|
| 1382 | + } |
|
| 1240 | 1383 | if ($ICAOTypeCode != '') { |
| 1241 | 1384 | if ($globalDBdriver == 'mysql') { |
| 1242 | 1385 | $queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
@@ -1247,8 +1390,7 @@ discard block |
||
| 1247 | 1390 | } else { |
| 1248 | 1391 | if ($globalDBdriver == 'mysql') { |
| 1249 | 1392 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
| 1250 | - } |
|
| 1251 | - elseif ($globalDBdriver == 'pgsql') { |
|
| 1393 | + } elseif ($globalDBdriver == 'pgsql') { |
|
| 1252 | 1394 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
| 1253 | 1395 | } |
| 1254 | 1396 | $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
@@ -1257,14 +1399,20 @@ discard block |
||
| 1257 | 1399 | $sthi = $this->db->prepare($queryi); |
| 1258 | 1400 | $sthi->execute($queryi_values); |
| 1259 | 1401 | } catch(PDOException $e) { |
| 1260 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1402 | + if ($globalDebug) { |
|
| 1403 | + echo $e->getMessage(); |
|
| 1404 | + } |
|
| 1261 | 1405 | return "error : ".$e->getMessage(); |
| 1262 | 1406 | } |
| 1263 | 1407 | } |
| 1264 | 1408 | } else { |
| 1265 | - if ($globalDebug) echo " Can't find ModeS in spotter_output - "; |
|
| 1409 | + if ($globalDebug) { |
|
| 1410 | + echo " Can't find ModeS in spotter_output - "; |
|
| 1411 | + } |
|
| 1412 | + } |
|
| 1413 | + if ($globalDebug) { |
|
| 1414 | + echo "Done\n"; |
|
| 1266 | 1415 | } |
| 1267 | - if ($globalDebug) echo "Done\n"; |
|
| 1268 | 1416 | } |
| 1269 | 1417 | } |
| 1270 | 1418 | ?> |
@@ -9,20 +9,20 @@ discard block |
||
| 9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
| 10 | 10 | require_once(dirname(__FILE__).'/class.GeoidHeight.php'); |
| 11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | class SpotterImport { |
| 16 | - private $all_flights = array(); |
|
| 17 | - private $last_delete_hourly = 0; |
|
| 18 | - private $last_delete = 0; |
|
| 19 | - private $stats = array(); |
|
| 20 | - private $tmd = 0; |
|
| 21 | - private $source_location = array(); |
|
| 22 | - public $db = null; |
|
| 23 | - public $nb = 0; |
|
| 16 | + private $all_flights = array(); |
|
| 17 | + private $last_delete_hourly = 0; |
|
| 18 | + private $last_delete = 0; |
|
| 19 | + private $stats = array(); |
|
| 20 | + private $tmd = 0; |
|
| 21 | + private $source_location = array(); |
|
| 22 | + public $db = null; |
|
| 23 | + public $nb = 0; |
|
| 24 | 24 | |
| 25 | - public function __construct($dbc = null) { |
|
| 25 | + public function __construct($dbc = null) { |
|
| 26 | 26 | global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid; |
| 27 | 27 | if (!(isset($globalNoDB) && $globalNoDB)) { |
| 28 | 28 | $Connection = new Connection($dbc); |
@@ -34,14 +34,14 @@ discard block |
||
| 34 | 34 | $currentdate = date('Y-m-d'); |
| 35 | 35 | $sourcestat = $Stats->getStatsSource($currentdate); |
| 36 | 36 | if (!empty($sourcestat)) { |
| 37 | - foreach($sourcestat as $srcst) { |
|
| 38 | - $type = $srcst['stats_type']; |
|
| 37 | + foreach($sourcestat as $srcst) { |
|
| 38 | + $type = $srcst['stats_type']; |
|
| 39 | 39 | if ($type == 'polar' || $type == 'hist') { |
| 40 | - $source = $srcst['source_name']; |
|
| 41 | - $data = $srcst['source_data']; |
|
| 42 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 43 | - } |
|
| 44 | - } |
|
| 40 | + $source = $srcst['source_name']; |
|
| 41 | + $data = $srcst['source_data']; |
|
| 42 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | $GeoidClass = FALSE; |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function get_Schedule($id,$ident) { |
|
| 61 | + public function get_Schedule($id,$ident) { |
|
| 62 | 62 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
| 63 | 63 | // Get schedule here, so it's done only one time |
| 64 | 64 | |
@@ -78,42 +78,42 @@ discard block |
||
| 78 | 78 | $operator = $Spotter->getOperator($ident); |
| 79 | 79 | $scheduleexist = false; |
| 80 | 80 | if ($Schedule->checkSchedule($operator) == 0) { |
| 81 | - $operator = $Translation->checkTranslation($ident); |
|
| 82 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
| 81 | + $operator = $Translation->checkTranslation($ident); |
|
| 82 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
| 83 | 83 | $schedule = $Schedule->fetchSchedule($operator); |
| 84 | 84 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 85 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 86 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 87 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 88 | - // Should also check if route schedule = route from DB |
|
| 89 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
| 85 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 86 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 87 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 88 | + // Should also check if route schedule = route from DB |
|
| 89 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
| 90 | 90 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
| 91 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
| 92 | - if (trim($airport_icao) != '') { |
|
| 91 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
| 92 | + if (trim($airport_icao) != '') { |
|
| 93 | 93 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
| 94 | 94 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
| 95 | - } |
|
| 95 | + } |
|
| 96 | + } |
|
| 96 | 97 | } |
| 97 | - } |
|
| 98 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
| 98 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
| 99 | 99 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
| 100 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
| 101 | - if (trim($airport_icao) != '') { |
|
| 100 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
| 101 | + if (trim($airport_icao) != '') { |
|
| 102 | 102 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
| 103 | 103 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
| 104 | - } |
|
| 104 | + } |
|
| 105 | 105 | } |
| 106 | - } |
|
| 107 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
| 106 | + } |
|
| 107 | + $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
| 108 | 108 | } |
| 109 | - } else $scheduleexist = true; |
|
| 109 | + } else $scheduleexist = true; |
|
| 110 | 110 | } else $scheduleexist = true; |
| 111 | 111 | // close connection, at least one way will work ? |
| 112 | - if ($scheduleexist) { |
|
| 112 | + if ($scheduleexist) { |
|
| 113 | 113 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
| 114 | - $sch = $Schedule->getSchedule($operator); |
|
| 114 | + $sch = $Schedule->getSchedule($operator); |
|
| 115 | 115 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
| 116 | - } |
|
| 116 | + } |
|
| 117 | 117 | $Spotter->db = null; |
| 118 | 118 | $Schedule->db = null; |
| 119 | 119 | $Translation->db = null; |
@@ -128,78 +128,78 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | */ |
| 130 | 130 | } |
| 131 | - } |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - public function checkAll() { |
|
| 133 | + public function checkAll() { |
|
| 134 | 134 | global $globalDebug, $globalNoImport; |
| 135 | 135 | if ($globalDebug) echo "Update last seen flights data...\n"; |
| 136 | 136 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 137 | - foreach ($this->all_flights as $key => $flight) { |
|
| 137 | + foreach ($this->all_flights as $key => $flight) { |
|
| 138 | 138 | if (isset($this->all_flights[$key]['id'])) { |
| 139 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
| 140 | - $Spotter = new Spotter($this->db); |
|
| 141 | - $real_arrival = $this->arrival($key); |
|
| 142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 143 | - } |
|
| 144 | - } |
|
| 139 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
| 140 | + $Spotter = new Spotter($this->db); |
|
| 141 | + $real_arrival = $this->arrival($key); |
|
| 142 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + } |
|
| 145 | 146 | } |
| 146 | - } |
|
| 147 | 147 | |
| 148 | - public function arrival($key) { |
|
| 148 | + public function arrival($key) { |
|
| 149 | 149 | global $globalClosestMinDist, $globalDebug; |
| 150 | 150 | if ($globalDebug) echo 'Update arrival...'."\n"; |
| 151 | 151 | $Spotter = new Spotter($this->db); |
| 152 | - $airport_icao = ''; |
|
| 153 | - $airport_time = ''; |
|
| 154 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 152 | + $airport_icao = ''; |
|
| 153 | + $airport_time = ''; |
|
| 154 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 155 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 156 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 157 | - if (isset($closestAirports[0])) { |
|
| 158 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
| 159 | - $airport_icao = $closestAirports[0]['icao']; |
|
| 160 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 161 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 162 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
| 163 | - foreach ($closestAirports as $airport) { |
|
| 164 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
| 165 | - $airport_icao = $airport['icao']; |
|
| 166 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 167 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 168 | - break; |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
| 172 | - $airport_icao = $closestAirports[0]['icao']; |
|
| 173 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 174 | - } else { |
|
| 175 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 176 | - } |
|
| 177 | - } else { |
|
| 178 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 179 | - } |
|
| 156 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 157 | + if (isset($closestAirports[0])) { |
|
| 158 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
| 159 | + $airport_icao = $closestAirports[0]['icao']; |
|
| 160 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 161 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 162 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
| 163 | + foreach ($closestAirports as $airport) { |
|
| 164 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
| 165 | + $airport_icao = $airport['icao']; |
|
| 166 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 167 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 168 | + break; |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
| 172 | + $airport_icao = $closestAirports[0]['icao']; |
|
| 173 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 174 | + } else { |
|
| 175 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 176 | + } |
|
| 177 | + } else { |
|
| 178 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - } else { |
|
| 182 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 183 | - } |
|
| 184 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 185 | - } |
|
| 181 | + } else { |
|
| 182 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 183 | + } |
|
| 184 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | 187 | |
| 188 | 188 | |
| 189 | - public function del() { |
|
| 189 | + public function del() { |
|
| 190 | 190 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 191 | 191 | // Delete old infos |
| 192 | 192 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 193 | 193 | foreach ($this->all_flights as $key => $flight) { |
| 194 | - if (isset($flight['lastupdate'])) { |
|
| 194 | + if (isset($flight['lastupdate'])) { |
|
| 195 | 195 | if ($flight['lastupdate'] < (time()-5900)) { |
| 196 | - $this->delKey($key); |
|
| 196 | + $this->delKey($key); |
|
| 197 | 197 | } |
| 198 | - } |
|
| 198 | + } |
|
| 199 | + } |
|
| 199 | 200 | } |
| 200 | - } |
|
| 201 | 201 | |
| 202 | - public function delKey($key) { |
|
| 202 | + public function delKey($key) { |
|
| 203 | 203 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 204 | 204 | // Delete old infos |
| 205 | 205 | if (isset($this->all_flights[$key]['id'])) { |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | unset($this->all_flights[$key]); |
| 217 | - } |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - public function add($line) { |
|
| 219 | + public function add($line) { |
|
| 220 | 220 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass; |
| 221 | 221 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
| 222 | 222 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
@@ -242,20 +242,20 @@ discard block |
||
| 242 | 242 | |
| 243 | 243 | // SBS format is CSV format |
| 244 | 244 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
| 245 | - //print_r($line); |
|
| 246 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
| 247 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
| 245 | + //print_r($line); |
|
| 246 | + if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
| 247 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
| 248 | 248 | |
| 249 | 249 | // Increment message number |
| 250 | 250 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
| 251 | - $current_date = date('Y-m-d'); |
|
| 252 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 253 | - else $source = ''; |
|
| 254 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 255 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 256 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 257 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 258 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 251 | + $current_date = date('Y-m-d'); |
|
| 252 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 253 | + else $source = ''; |
|
| 254 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 255 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 256 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 257 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 258 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /* |
@@ -271,54 +271,54 @@ discard block |
||
| 271 | 271 | //$this->db = $dbc; |
| 272 | 272 | |
| 273 | 273 | //$hex = trim($line['hex']); |
| 274 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 275 | - else $id = trim($line['id']); |
|
| 274 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 275 | + else $id = trim($line['id']); |
|
| 276 | 276 | |
| 277 | 277 | if (!isset($this->all_flights[$id])) { |
| 278 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
| 279 | - $this->all_flights[$id] = array(); |
|
| 280 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 281 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
| 282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 283 | - if (!isset($line['id'])) { |
|
| 278 | + if ($globalDebug) echo 'New flight...'."\n"; |
|
| 279 | + $this->all_flights[$id] = array(); |
|
| 280 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 281 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
| 282 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 283 | + if (!isset($line['id'])) { |
|
| 284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 285 | 285 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
| 286 | 286 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 287 | 287 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 288 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 290 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 288 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 289 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 290 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 291 | 291 | } |
| 292 | 292 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 293 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 293 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | //print_r($this->all_flights); |
| 297 | 297 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
| 298 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 299 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 298 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 299 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 300 | 300 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 301 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 302 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
| 301 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 302 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
| 303 | 303 | $timeelapsed = microtime(true); |
| 304 | 304 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 305 | - $Spotter = new Spotter($this->db); |
|
| 306 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
| 305 | + $Spotter = new Spotter($this->db); |
|
| 306 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
| 307 | 307 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
| 308 | - } else { |
|
| 308 | + } else { |
|
| 309 | 309 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 310 | - } |
|
| 311 | - $Spotter->db = null; |
|
| 312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 310 | + } |
|
| 311 | + $Spotter->db = null; |
|
| 312 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 313 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 314 | 314 | } |
| 315 | - } |
|
| 316 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 317 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 315 | + } |
|
| 316 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 317 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 318 | 318 | } |
| 319 | - if (isset($line['id']) && !isset($line['hex'])) { |
|
| 320 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 321 | - } |
|
| 319 | + if (isset($line['id']) && !isset($line['hex'])) { |
|
| 320 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 321 | + } |
|
| 322 | 322 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 323 | 323 | $icao = $line['aircraft_icao']; |
| 324 | 324 | $Spotter = new Spotter($this->db); |
@@ -347,9 +347,9 @@ discard block |
||
| 347 | 347 | } |
| 348 | 348 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 349 | 349 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
| 350 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
| 350 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
| 351 | 351 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 352 | - } else { |
|
| 352 | + } else { |
|
| 353 | 353 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 354 | 354 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 355 | 355 | /* |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | print_r($line); |
| 359 | 359 | */ |
| 360 | 360 | return ''; |
| 361 | - } |
|
| 361 | + } |
|
| 362 | 362 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 363 | 363 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
| 364 | 364 | return ''; |
@@ -374,21 +374,21 @@ discard block |
||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
| 377 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 377 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 378 | 378 | } |
| 379 | 379 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 380 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 380 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 381 | 381 | } |
| 382 | 382 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
| 383 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 383 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 384 | 384 | } |
| 385 | 385 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
| 386 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 386 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
| 390 | 390 | |
| 391 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 391 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 392 | 392 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 393 | 393 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
| 394 | 394 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -397,23 +397,23 @@ discard block |
||
| 397 | 397 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 398 | 398 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 399 | 399 | } else { |
| 400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 401 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 401 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 402 | 402 | $timeelapsed = microtime(true); |
| 403 | - $Spotter = new Spotter($this->db); |
|
| 404 | - $fromsource = NULL; |
|
| 405 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 406 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 403 | + $Spotter = new Spotter($this->db); |
|
| 404 | + $fromsource = NULL; |
|
| 405 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 406 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 407 | 407 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 408 | 408 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 409 | 409 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 410 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 410 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 411 | 411 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 412 | 412 | $Spotter->db = null; |
| 413 | 413 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 414 | - } |
|
| 414 | + } |
|
| 415 | 415 | } |
| 416 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 416 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 417 | 417 | |
| 418 | 418 | /* |
| 419 | 419 | if (!isset($line['id'])) { |
@@ -423,63 +423,63 @@ discard block |
||
| 423 | 423 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 424 | 424 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 425 | 425 | */ |
| 426 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 426 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 427 | 427 | |
| 428 | - //$putinarchive = true; |
|
| 429 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
| 428 | + //$putinarchive = true; |
|
| 429 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
| 430 | 430 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
| 431 | - } |
|
| 432 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
| 431 | + } |
|
| 432 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
| 433 | 433 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
| 434 | - } |
|
| 435 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
| 436 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 437 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
| 434 | + } |
|
| 435 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
| 436 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 437 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
| 438 | 438 | $timeelapsed = microtime(true); |
| 439 | 439 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 440 | 440 | $Spotter = new Spotter($this->db); |
| 441 | 441 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 442 | 442 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 443 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 443 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 444 | 444 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 445 | - } |
|
| 446 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
| 445 | + } |
|
| 446 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
| 447 | 447 | $timeelapsed = microtime(true); |
| 448 | 448 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 449 | - $Spotter = new Spotter($this->db); |
|
| 450 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
| 451 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
| 449 | + $Spotter = new Spotter($this->db); |
|
| 450 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
| 451 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
| 452 | 452 | $Translation = new Translation($this->db); |
| 453 | 453 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
| 454 | 454 | $route = $Spotter->getRouteInfo($ident); |
| 455 | 455 | $Translation->db = null; |
| 456 | - } |
|
| 457 | - $Spotter->db = null; |
|
| 458 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 459 | - } |
|
| 456 | + } |
|
| 457 | + $Spotter->db = null; |
|
| 458 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 459 | + } |
|
| 460 | 460 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 461 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
| 462 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
| 461 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
| 462 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
| 463 | 463 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
| 464 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
| 465 | - } |
|
| 464 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
| 465 | + } |
|
| 466 | 466 | } |
| 467 | 467 | if (!isset($globalFork)) $globalFork = TRUE; |
| 468 | 468 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 469 | 469 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
| 470 | 470 | } |
| 471 | - } |
|
| 471 | + } |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
| 475 | 475 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
| 476 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 477 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 478 | - //$dataFound = true; |
|
| 476 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 477 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 478 | + //$dataFound = true; |
|
| 479 | 479 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 480 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 481 | - if ($distance > 1000 && $distance < 10000) { |
|
| 482 | - // use datetime |
|
| 480 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 481 | + if ($distance > 1000 && $distance < 10000) { |
|
| 482 | + // use datetime |
|
| 483 | 483 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 484 | 484 | $speed = $speed*3.6; |
| 485 | 485 | if ($speed < 1000) { |
@@ -488,48 +488,48 @@ discard block |
||
| 488 | 488 | } else { |
| 489 | 489 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
| 490 | 490 | } |
| 491 | - } |
|
| 491 | + } |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | |
| 495 | 495 | |
| 496 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 497 | - if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
| 498 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 499 | - return false; |
|
| 500 | - } |
|
| 501 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 502 | - else unset($timediff); |
|
| 503 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 504 | - else unset($timediff_archive); |
|
| 505 | - if ($this->tmd > 5 |
|
| 506 | - || (isset($line['format_source']) |
|
| 507 | - && $line['format_source'] == 'airwhere' |
|
| 508 | - && ((!isset($this->all_flights[$id]['latitude']) |
|
| 509 | - || !isset($this->all_flights[$id]['longitude'])) |
|
| 510 | - || (isset($this->all_flights[$id]['latitude']) |
|
| 511 | - && isset($this->all_flights[$id]['longitude']) |
|
| 512 | - && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
| 513 | - && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
| 514 | - ) |
|
| 515 | - ) |
|
| 516 | - ) |
|
| 517 | - || (isset($globalVA) && $globalVA) |
|
| 518 | - || (isset($globalIVAO) && $globalIVAO) |
|
| 519 | - || (isset($globalVATSIM) && $globalVATSIM) |
|
| 520 | - || (isset($globalphpVMS) && $globalphpVMS) |
|
| 521 | - || (isset($globalVAM) && $globalVAM) |
|
| 522 | - || !isset($timediff) |
|
| 523 | - || $timediff > $globalLiveInterval |
|
| 524 | - || ($timediff > 30 |
|
| 525 | - && isset($this->all_flights[$id]['latitude']) |
|
| 526 | - && isset($this->all_flights[$id]['longitude']) |
|
| 527 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 528 | - ) |
|
| 529 | - ) { |
|
| 496 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 497 | + if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
| 498 | + if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 499 | + return false; |
|
| 500 | + } |
|
| 501 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 502 | + else unset($timediff); |
|
| 503 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 504 | + else unset($timediff_archive); |
|
| 505 | + if ($this->tmd > 5 |
|
| 506 | + || (isset($line['format_source']) |
|
| 507 | + && $line['format_source'] == 'airwhere' |
|
| 508 | + && ((!isset($this->all_flights[$id]['latitude']) |
|
| 509 | + || !isset($this->all_flights[$id]['longitude'])) |
|
| 510 | + || (isset($this->all_flights[$id]['latitude']) |
|
| 511 | + && isset($this->all_flights[$id]['longitude']) |
|
| 512 | + && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
| 513 | + && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
| 514 | + ) |
|
| 515 | + ) |
|
| 516 | + ) |
|
| 517 | + || (isset($globalVA) && $globalVA) |
|
| 518 | + || (isset($globalIVAO) && $globalIVAO) |
|
| 519 | + || (isset($globalVATSIM) && $globalVATSIM) |
|
| 520 | + || (isset($globalphpVMS) && $globalphpVMS) |
|
| 521 | + || (isset($globalVAM) && $globalVAM) |
|
| 522 | + || !isset($timediff) |
|
| 523 | + || $timediff > $globalLiveInterval |
|
| 524 | + || ($timediff > 30 |
|
| 525 | + && isset($this->all_flights[$id]['latitude']) |
|
| 526 | + && isset($this->all_flights[$id]['longitude']) |
|
| 527 | + && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 528 | + ) |
|
| 529 | + ) { |
|
| 530 | 530 | |
| 531 | 531 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
| 532 | - if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
| 532 | + if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
| 533 | 533 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
| 534 | 534 | || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
| 535 | 535 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -537,9 +537,9 @@ discard block |
||
| 537 | 537 | $this->all_flights[$id]['putinarchive'] = true; |
| 538 | 538 | $this->tmd = 0; |
| 539 | 539 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 540 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 541 | - $timeelapsed = microtime(true); |
|
| 542 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 540 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 541 | + $timeelapsed = microtime(true); |
|
| 542 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 543 | 543 | $Spotter = new Spotter($this->db); |
| 544 | 544 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 545 | 545 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
@@ -547,11 +547,11 @@ discard block |
||
| 547 | 547 | $Spotter->db = null; |
| 548 | 548 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 549 | 549 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 550 | - } |
|
| 550 | + } |
|
| 551 | 551 | } |
| 552 | 552 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
| 553 | - } |
|
| 554 | - /* |
|
| 553 | + } |
|
| 554 | + /* |
|
| 555 | 555 | else { |
| 556 | 556 | if (!isset($timediff)) echo 'NO TIMEDIFF'; |
| 557 | 557 | else { |
@@ -565,16 +565,16 @@ discard block |
||
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 568 | - //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 568 | + //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 569 | 569 | if (!isset($this->all_flights[$id]['archive_latitude'])) { |
| 570 | 570 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 571 | 571 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 572 | 572 | } |
| 573 | 573 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
| 574 | 574 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
| 575 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
| 576 | - $dataFound = true; |
|
| 577 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 575 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
| 576 | + $dataFound = true; |
|
| 577 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 578 | 578 | } |
| 579 | 579 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 580 | 580 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -585,24 +585,24 @@ discard block |
||
| 585 | 585 | //$putinarchive = true; |
| 586 | 586 | } |
| 587 | 587 | */ |
| 588 | - /* |
|
| 588 | + /* |
|
| 589 | 589 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
| 590 | 590 | if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n"; |
| 591 | 591 | } |
| 592 | 592 | */ |
| 593 | 593 | } |
| 594 | 594 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 595 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 596 | - //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 595 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 596 | + //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 597 | 597 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
| 598 | 598 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 599 | 599 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 600 | 600 | } |
| 601 | 601 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
| 602 | 602 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
| 603 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
| 604 | - $dataFound = true; |
|
| 605 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 603 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
| 604 | + $dataFound = true; |
|
| 605 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 606 | 606 | } |
| 607 | 607 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 608 | 608 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -620,67 +620,67 @@ discard block |
||
| 620 | 620 | */ |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - } else if ($globalDebug && $timediff > 30) { |
|
| 623 | + } else if ($globalDebug && $timediff > 30) { |
|
| 624 | 624 | $this->tmd = $this->tmd + 1; |
| 625 | 625 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
| 626 | 626 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
| 627 | 627 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 628 | 628 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
| 629 | - } |
|
| 629 | + } |
|
| 630 | 630 | } |
| 631 | 631 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 632 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 633 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 632 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 633 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 634 | 634 | } |
| 635 | 635 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 636 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 637 | - //$dataFound = true; |
|
| 636 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 637 | + //$dataFound = true; |
|
| 638 | 638 | } |
| 639 | 639 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 640 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 640 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 641 | 641 | } |
| 642 | 642 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 643 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 643 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 644 | 644 | } |
| 645 | 645 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 646 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 647 | - //$dataFound = true; |
|
| 646 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 647 | + //$dataFound = true; |
|
| 648 | 648 | } |
| 649 | 649 | if (isset($line['ground']) && $line['ground'] != '') { |
| 650 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
| 650 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
| 651 | 651 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 652 | 652 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 653 | 653 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 654 | 654 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 655 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 655 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 656 | 656 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 657 | - } |
|
| 658 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 659 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 660 | - //$dataFound = true; |
|
| 657 | + } |
|
| 658 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 659 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 660 | + //$dataFound = true; |
|
| 661 | 661 | } |
| 662 | 662 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 663 | - if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
| 664 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 665 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 666 | - $highlight = ''; |
|
| 667 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 668 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 669 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 670 | - if ($highlight != '') { |
|
| 663 | + if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
| 664 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 665 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 666 | + $highlight = ''; |
|
| 667 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 668 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 669 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 670 | + if ($highlight != '') { |
|
| 671 | 671 | $timeelapsed = microtime(true); |
| 672 | 672 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 673 | - $Spotter = new Spotter($this->db); |
|
| 674 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 675 | - $Spotter->db = null; |
|
| 676 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 673 | + $Spotter = new Spotter($this->db); |
|
| 674 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 675 | + $Spotter->db = null; |
|
| 676 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 677 | 677 | } |
| 678 | 678 | //$putinarchive = true; |
| 679 | 679 | //$highlight = ''; |
| 680 | - } |
|
| 680 | + } |
|
| 681 | 681 | |
| 682 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 683 | - //$dataFound = true; |
|
| 682 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 683 | + //$dataFound = true; |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | if (isset($line['altitude']) && $line['altitude'] != '') { |
@@ -691,13 +691,13 @@ discard block |
||
| 691 | 691 | $line['altitude'] = $line['altitude'] - $geoid; |
| 692 | 692 | } |
| 693 | 693 | } |
| 694 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 694 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 695 | 695 | if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
| 696 | 696 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
| 697 | 697 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
| 698 | 698 | //$dataFound = true; |
| 699 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 700 | - if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
| 699 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 700 | + if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
| 701 | 701 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 702 | 702 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
| 703 | 703 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -706,27 +706,27 @@ discard block |
||
| 706 | 706 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 707 | 707 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 708 | 708 | } |
| 709 | - } |
|
| 710 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 709 | + } |
|
| 710 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 714 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 714 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | if (isset($line['heading']) && $line['heading'] != '') { |
| 718 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 719 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 720 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 721 | - //$dataFound = true; |
|
| 718 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 719 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 720 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 721 | + //$dataFound = true; |
|
| 722 | 722 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 723 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 724 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 725 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 726 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
| 723 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 724 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 725 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 726 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
| 727 | 727 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 728 | - // If not enough messages and ACARS set heading to 0 |
|
| 729 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 728 | + // If not enough messages and ACARS set heading to 0 |
|
| 729 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 730 | 730 | } |
| 731 | 731 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 732 | 732 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -739,125 +739,125 @@ discard block |
||
| 739 | 739 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
| 740 | 740 | //if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
| 741 | 741 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
| 742 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
| 743 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
| 744 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 745 | - //print_r($this->all_flights); |
|
| 746 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
| 747 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
| 748 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
| 742 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
| 743 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
| 744 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 745 | + //print_r($this->all_flights); |
|
| 746 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
| 747 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
| 748 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
| 749 | 749 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 750 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 751 | - $timeelapsed = microtime(true); |
|
| 752 | - $SpotterLive = new SpotterLive($this->db); |
|
| 753 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 750 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 751 | + $timeelapsed = microtime(true); |
|
| 752 | + $SpotterLive = new SpotterLive($this->db); |
|
| 753 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 754 | 754 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 755 | 755 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 756 | - } elseif (isset($line['id'])) { |
|
| 756 | + } elseif (isset($line['id'])) { |
|
| 757 | 757 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 758 | 758 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 759 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
| 759 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
| 760 | 760 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 761 | 761 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 762 | - } else $recent_ident = ''; |
|
| 763 | - $SpotterLive->db=null; |
|
| 764 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 765 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 762 | + } else $recent_ident = ''; |
|
| 763 | + $SpotterLive->db=null; |
|
| 764 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 765 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 766 | 766 | } else $recent_ident = ''; |
| 767 | - } else { |
|
| 767 | + } else { |
|
| 768 | 768 | $recent_ident = ''; |
| 769 | 769 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
| 770 | - } |
|
| 771 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 772 | - if($recent_ident == "") |
|
| 773 | - { |
|
| 770 | + } |
|
| 771 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 772 | + if($recent_ident == "") |
|
| 773 | + { |
|
| 774 | 774 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
| 775 | 775 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 776 | 776 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 777 | 777 | //adds the spotter data for the archive |
| 778 | 778 | $ignoreImport = false; |
| 779 | 779 | foreach($globalAirportIgnore as $airportIgnore) { |
| 780 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 780 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 781 | 781 | $ignoreImport = true; |
| 782 | - } |
|
| 782 | + } |
|
| 783 | 783 | } |
| 784 | 784 | if (count($globalAirportAccept) > 0) { |
| 785 | - $ignoreImport = true; |
|
| 786 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 785 | + $ignoreImport = true; |
|
| 786 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 787 | 787 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 788 | - $ignoreImport = false; |
|
| 788 | + $ignoreImport = false; |
|
| 789 | + } |
|
| 789 | 790 | } |
| 790 | - } |
|
| 791 | 791 | } |
| 792 | 792 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 793 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 793 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 794 | 794 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
| 795 | - $ignoreImport = true; |
|
| 795 | + $ignoreImport = true; |
|
| 796 | + } |
|
| 796 | 797 | } |
| 797 | - } |
|
| 798 | 798 | } |
| 799 | 799 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 800 | - $ignoreImport = true; |
|
| 801 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 800 | + $ignoreImport = true; |
|
| 801 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
| 802 | 802 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
| 803 | - $ignoreImport = false; |
|
| 803 | + $ignoreImport = false; |
|
| 804 | + } |
|
| 804 | 805 | } |
| 805 | - } |
|
| 806 | 806 | } |
| 807 | 807 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 808 | - $ignoreImport = true; |
|
| 809 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 808 | + $ignoreImport = true; |
|
| 809 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 810 | 810 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 811 | - $ignoreImport = false; |
|
| 811 | + $ignoreImport = false; |
|
| 812 | + } |
|
| 812 | 813 | } |
| 813 | - } |
|
| 814 | 814 | } |
| 815 | 815 | |
| 816 | 816 | if (!$ignoreImport) { |
| 817 | - $highlight = ''; |
|
| 818 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 819 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 820 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 821 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 822 | - $timeelapsed = microtime(true); |
|
| 823 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 817 | + $highlight = ''; |
|
| 818 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 819 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 820 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 821 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 822 | + $timeelapsed = microtime(true); |
|
| 823 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 824 | 824 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 825 | - $Spotter = new Spotter($this->db); |
|
| 826 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
| 827 | - $Spotter->db = null; |
|
| 828 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 825 | + $Spotter = new Spotter($this->db); |
|
| 826 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
| 827 | + $Spotter->db = null; |
|
| 828 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 829 | 829 | } |
| 830 | - } |
|
| 831 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 832 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 830 | + } |
|
| 831 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 832 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 833 | 833 | |
| 834 | - // Add source stat in DB |
|
| 835 | - $Stats = new Stats($this->db); |
|
| 836 | - if (!empty($this->stats)) { |
|
| 834 | + // Add source stat in DB |
|
| 835 | + $Stats = new Stats($this->db); |
|
| 836 | + if (!empty($this->stats)) { |
|
| 837 | 837 | if ($globalDebug) echo 'Add source stats : '; |
| 838 | - foreach($this->stats as $date => $data) { |
|
| 839 | - foreach($data as $source => $sourced) { |
|
| 840 | - //print_r($sourced); |
|
| 841 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 842 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 843 | - if (isset($sourced['msg'])) { |
|
| 844 | - if (time() - $sourced['msg']['date'] > 10) { |
|
| 845 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 846 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 847 | - unset($this->stats[$date][$source]['msg']); |
|
| 848 | - } |
|
| 849 | - } |
|
| 850 | - } |
|
| 851 | - if ($date != date('Y-m-d')) { |
|
| 852 | - unset($this->stats[$date]); |
|
| 853 | - } |
|
| 854 | - } |
|
| 855 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 838 | + foreach($this->stats as $date => $data) { |
|
| 839 | + foreach($data as $source => $sourced) { |
|
| 840 | + //print_r($sourced); |
|
| 841 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 842 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 843 | + if (isset($sourced['msg'])) { |
|
| 844 | + if (time() - $sourced['msg']['date'] > 10) { |
|
| 845 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 846 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 847 | + unset($this->stats[$date][$source]['msg']); |
|
| 848 | + } |
|
| 849 | + } |
|
| 850 | + } |
|
| 851 | + if ($date != date('Y-m-d')) { |
|
| 852 | + unset($this->stats[$date]); |
|
| 853 | + } |
|
| 854 | + } |
|
| 855 | + if ($globalDebug) echo 'Done'."\n"; |
|
| 856 | 856 | |
| 857 | - } |
|
| 858 | - $Stats->db = null; |
|
| 859 | - } |
|
| 860 | - $this->del(); |
|
| 857 | + } |
|
| 858 | + $Stats->db = null; |
|
| 859 | + } |
|
| 860 | + $this->del(); |
|
| 861 | 861 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
| 862 | 862 | //$ignoreImport = false; |
| 863 | 863 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -875,41 +875,41 @@ discard block |
||
| 875 | 875 | */ |
| 876 | 876 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
| 877 | 877 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 878 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 879 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 880 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 878 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 879 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 880 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 881 | 881 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 882 | - $SpotterLive = new SpotterLive($this->db); |
|
| 883 | - $SpotterLive->deleteLiveSpotterData(); |
|
| 884 | - $SpotterLive->db=null; |
|
| 882 | + $SpotterLive = new SpotterLive($this->db); |
|
| 883 | + $SpotterLive->deleteLiveSpotterData(); |
|
| 884 | + $SpotterLive->db=null; |
|
| 885 | 885 | } |
| 886 | - } |
|
| 887 | - if ($globalDebug) echo " Done\n"; |
|
| 888 | - $this->last_delete = time(); |
|
| 886 | + } |
|
| 887 | + if ($globalDebug) echo " Done\n"; |
|
| 888 | + $this->last_delete = time(); |
|
| 889 | 889 | } |
| 890 | - } else { |
|
| 890 | + } else { |
|
| 891 | 891 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
| 892 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
| 893 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
| 892 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
| 893 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
| 894 | 894 | } |
| 895 | 895 | if (isset($globalDaemon) && !$globalDaemon) { |
| 896 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 896 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 897 | 897 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 898 | - $Spotter = new Spotter($this->db); |
|
| 899 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
| 900 | - $Spotter->db = null; |
|
| 898 | + $Spotter = new Spotter($this->db); |
|
| 899 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
| 900 | + $Spotter->db = null; |
|
| 901 | + } |
|
| 901 | 902 | } |
| 902 | - } |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | - } |
|
| 905 | + } |
|
| 906 | 906 | } |
| 907 | - } |
|
| 908 | - //adds the spotter LIVE data |
|
| 909 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
| 910 | - //echo "\nAdd in Live !! \n"; |
|
| 911 | - //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
| 912 | - if ($globalDebug) { |
|
| 907 | + } |
|
| 908 | + //adds the spotter LIVE data |
|
| 909 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
| 910 | + //echo "\nAdd in Live !! \n"; |
|
| 911 | + //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
| 912 | + if ($globalDebug) { |
|
| 913 | 913 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
| 914 | 914 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
| 915 | 915 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
@@ -917,60 +917,60 @@ discard block |
||
| 917 | 917 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
| 918 | 918 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
| 919 | 919 | } |
| 920 | - } |
|
| 921 | - $ignoreImport = false; |
|
| 922 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
| 923 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
| 920 | + } |
|
| 921 | + $ignoreImport = false; |
|
| 922 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
| 923 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
| 924 | 924 | |
| 925 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 926 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 927 | - $ignoreImport = true; |
|
| 925 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 926 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 927 | + $ignoreImport = true; |
|
| 928 | + } |
|
| 928 | 929 | } |
| 929 | - } |
|
| 930 | - if (count($globalAirportAccept) > 0) { |
|
| 931 | - $ignoreImport = true; |
|
| 932 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 933 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 930 | + if (count($globalAirportAccept) > 0) { |
|
| 931 | + $ignoreImport = true; |
|
| 932 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 933 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 934 | 934 | $ignoreImport = false; |
| 935 | - } |
|
| 935 | + } |
|
| 936 | 936 | } |
| 937 | - } |
|
| 938 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
| 937 | + } |
|
| 938 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
| 939 | 939 | foreach($globalAirlineIgnore as $airlineIgnore) { |
| 940 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 940 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 941 | 941 | $ignoreImport = true; |
| 942 | - } |
|
| 942 | + } |
|
| 943 | 943 | } |
| 944 | - } |
|
| 945 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
| 944 | + } |
|
| 945 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
| 946 | 946 | $ignoreImport = true; |
| 947 | 947 | foreach($globalAirlineAccept as $airlineAccept) { |
| 948 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 948 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 949 | 949 | $ignoreImport = false; |
| 950 | - } |
|
| 950 | + } |
|
| 951 | + } |
|
| 951 | 952 | } |
| 952 | - } |
|
| 953 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
| 953 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
| 954 | 954 | $ignoreImport = true; |
| 955 | 955 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
| 956 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
| 957 | - $ignoreImport = false; |
|
| 958 | - } |
|
| 956 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
| 957 | + $ignoreImport = false; |
|
| 958 | + } |
|
| 959 | + } |
|
| 959 | 960 | } |
| 960 | - } |
|
| 961 | 961 | |
| 962 | - if (!$ignoreImport) { |
|
| 962 | + if (!$ignoreImport) { |
|
| 963 | 963 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 964 | 964 | if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 965 | 965 | $timeelapsed = microtime(true); |
| 966 | 966 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 967 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 967 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 968 | 968 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
| 969 | 969 | $SpotterLive = new SpotterLive($this->db); |
| 970 | 970 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
| 971 | 971 | $SpotterLive->db = null; |
| 972 | 972 | if ($globalDebug) echo $result."\n"; |
| 973 | - } |
|
| 973 | + } |
|
| 974 | 974 | } |
| 975 | 975 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 976 | 976 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
@@ -982,7 +982,7 @@ discard block |
||
| 982 | 982 | //if ($line['format_source'] != 'aprs') { |
| 983 | 983 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
| 984 | 984 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 985 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
| 985 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
| 986 | 986 | $source = $this->all_flights[$id]['source_name']; |
| 987 | 987 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
| 988 | 988 | if (!isset($this->source_location[$source])) { |
@@ -1008,7 +1008,7 @@ discard block |
||
| 1008 | 1008 | if ($stats_heading == 16) $stats_heading = 0; |
| 1009 | 1009 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 1010 | 1010 | for ($i=0;$i<=15;$i++) { |
| 1011 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 1011 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 1012 | 1012 | } |
| 1013 | 1013 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
| 1014 | 1014 | } else { |
@@ -1021,17 +1021,17 @@ discard block |
||
| 1021 | 1021 | //var_dump($this->stats); |
| 1022 | 1022 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 1023 | 1023 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1024 | - end($this->stats[$current_date][$source]['hist']); |
|
| 1025 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1024 | + end($this->stats[$current_date][$source]['hist']); |
|
| 1025 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1026 | 1026 | } else $mini = 0; |
| 1027 | 1027 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 1028 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 1028 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 1029 | 1029 | } |
| 1030 | 1030 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
| 1031 | 1031 | } else { |
| 1032 | 1032 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
| 1033 | 1033 | } |
| 1034 | - } |
|
| 1034 | + } |
|
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | 1037 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -1041,7 +1041,7 @@ discard block |
||
| 1041 | 1041 | //$this->del(); |
| 1042 | 1042 | |
| 1043 | 1043 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 1044 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 1044 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 1045 | 1045 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
| 1046 | 1046 | $SpotterLive = new SpotterLive($this->db); |
| 1047 | 1047 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -1049,19 +1049,19 @@ discard block |
||
| 1049 | 1049 | //SpotterLive->deleteLiveSpotterData(); |
| 1050 | 1050 | if ($globalDebug) echo " Done\n"; |
| 1051 | 1051 | $this->last_delete_hourly = time(); |
| 1052 | - } else { |
|
| 1052 | + } else { |
|
| 1053 | 1053 | $this->del(); |
| 1054 | 1054 | $this->last_delete_hourly = time(); |
| 1055 | - } |
|
| 1055 | + } |
|
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | - } |
|
| 1059 | - //$ignoreImport = false; |
|
| 1058 | + } |
|
| 1059 | + //$ignoreImport = false; |
|
| 1060 | 1060 | } |
| 1061 | 1061 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 1062 | 1062 | if ($send) return $this->all_flights[$id]; |
| 1063 | - } |
|
| 1063 | + } |
|
| 1064 | + } |
|
| 1064 | 1065 | } |
| 1065 | - } |
|
| 1066 | 1066 | } |
| 1067 | 1067 | ?> |
@@ -34,12 +34,12 @@ discard block |
||
| 34 | 34 | $currentdate = date('Y-m-d'); |
| 35 | 35 | $sourcestat = $Stats->getStatsSource($currentdate); |
| 36 | 36 | if (!empty($sourcestat)) { |
| 37 | - foreach($sourcestat as $srcst) { |
|
| 37 | + foreach ($sourcestat as $srcst) { |
|
| 38 | 38 | $type = $srcst['stats_type']; |
| 39 | 39 | if ($type == 'polar' || $type == 'hist') { |
| 40 | 40 | $source = $srcst['source_name']; |
| 41 | 41 | $data = $srcst['source_data']; |
| 42 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 42 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | if (isset($globalGeoid) && $globalGeoid) { |
| 52 | 52 | try { |
| 53 | 53 | $GeoidClass = new GeoidHeight(); |
| 54 | - } catch(Exception $e) { |
|
| 54 | + } catch (Exception $e) { |
|
| 55 | 55 | if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php \n"; |
| 56 | 56 | $GeoidClass = FALSE; |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - public function get_Schedule($id,$ident) { |
|
| 61 | + public function get_Schedule($id, $ident) { |
|
| 62 | 62 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
| 63 | 63 | // Get schedule here, so it's done only one time |
| 64 | 64 | |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | $schedule = $Schedule->fetchSchedule($operator); |
| 84 | 84 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 85 | 85 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
| 86 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 87 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 86 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 87 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 88 | 88 | // Should also check if route schedule = route from DB |
| 89 | 89 | if ($schedule['DepartureAirportIATA'] != '') { |
| 90 | 90 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
| 107 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
| 108 | 108 | } |
| 109 | 109 | } else $scheduleexist = true; |
| 110 | 110 | } else $scheduleexist = true; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | if ($scheduleexist) { |
| 113 | 113 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
| 114 | 114 | $sch = $Schedule->getSchedule($operator); |
| 115 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
| 115 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
| 116 | 116 | } |
| 117 | 117 | $Spotter->db = null; |
| 118 | 118 | $Schedule->db = null; |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
| 140 | 140 | $Spotter = new Spotter($this->db); |
| 141 | 141 | $real_arrival = $this->arrival($key); |
| 142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 142 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | $airport_time = ''; |
| 154 | 154 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
| 155 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 156 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 156 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
| 157 | 157 | if (isset($closestAirports[0])) { |
| 158 | 158 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
| 159 | 159 | $airport_icao = $closestAirports[0]['icao']; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | break; |
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
| 171 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
| 172 | 172 | $airport_icao = $closestAirports[0]['icao']; |
| 173 | 173 | $airport_time = $this->all_flights[$key]['datetime']; |
| 174 | 174 | } else { |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | } else { |
| 182 | 182 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
| 183 | 183 | } |
| 184 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 184 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 193 | 193 | foreach ($this->all_flights as $key => $flight) { |
| 194 | 194 | if (isset($flight['lastupdate'])) { |
| 195 | - if ($flight['lastupdate'] < (time()-5900)) { |
|
| 195 | + if ($flight['lastupdate'] < (time() - 5900)) { |
|
| 196 | 196 | $this->delKey($key); |
| 197 | 197 | } |
| 198 | 198 | } |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $real_arrival = $this->arrival($key); |
| 209 | 209 | $Spotter = new Spotter($this->db); |
| 210 | 210 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 211 | - $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 211 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
| 212 | 212 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 213 | 213 | } |
| 214 | 214 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $send = false; |
| 242 | 242 | |
| 243 | 243 | // SBS format is CSV format |
| 244 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
| 244 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
| 245 | 245 | //print_r($line); |
| 246 | 246 | if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
| 247 | 247 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
@@ -277,25 +277,25 @@ discard block |
||
| 277 | 277 | if (!isset($this->all_flights[$id])) { |
| 278 | 278 | if ($globalDebug) echo 'New flight...'."\n"; |
| 279 | 279 | $this->all_flights[$id] = array(); |
| 280 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 281 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
| 282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 280 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 281 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '')); |
|
| 282 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
| 283 | 283 | if (!isset($line['id'])) { |
| 284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 285 | 285 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
| 286 | 286 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 287 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 287 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 288 | 288 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 289 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 290 | 290 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 291 | 291 | } |
| 292 | 292 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 293 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 293 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | //print_r($this->all_flights); |
| 297 | 297 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
| 298 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 298 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
| 299 | 299 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 300 | 300 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 301 | 301 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -304,27 +304,27 @@ discard block |
||
| 304 | 304 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 305 | 305 | $Spotter = new Spotter($this->db); |
| 306 | 306 | if (isset($this->all_flights[$id]['source_type'])) { |
| 307 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
| 307 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
| 308 | 308 | } else { |
| 309 | 309 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 310 | 310 | } |
| 311 | 311 | $Spotter->db = null; |
| 312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 312 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 313 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 317 | 317 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
| 318 | 318 | } |
| 319 | 319 | if (isset($line['id']) && !isset($line['hex'])) { |
| 320 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 320 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
| 321 | 321 | } |
| 322 | 322 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 323 | 323 | $icao = $line['aircraft_icao']; |
| 324 | 324 | $Spotter = new Spotter($this->db); |
| 325 | 325 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
| 326 | 326 | $Spotter->db = null; |
| 327 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
| 327 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
| 328 | 328 | } |
| 329 | 329 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
| 330 | 330 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | $Spotter = new Spotter($this->db); |
| 333 | 333 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
| 334 | 334 | $Spotter->db = null; |
| 335 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 335 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -340,15 +340,15 @@ discard block |
||
| 340 | 340 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
| 341 | 341 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
| 342 | 342 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
| 343 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 343 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 344 | 344 | } |
| 345 | 345 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
| 346 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
| 346 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
| 347 | 347 | } |
| 348 | 348 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 349 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
| 349 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
| 350 | 350 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 351 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
| 351 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
| 352 | 352 | } else { |
| 353 | 353 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 354 | 354 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -359,31 +359,31 @@ discard block |
||
| 359 | 359 | */ |
| 360 | 360 | return ''; |
| 361 | 361 | } |
| 362 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
| 362 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
| 363 | 363 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
| 364 | 364 | return ''; |
| 365 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
| 365 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
| 366 | 366 | if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
| 367 | 367 | return ''; |
| 368 | 368 | } elseif (!isset($line['datetime'])) { |
| 369 | 369 | date_default_timezone_set('UTC'); |
| 370 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 370 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 371 | 371 | } else { |
| 372 | 372 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
| 373 | 373 | return ''; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
| 377 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 377 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
| 378 | 378 | } |
| 379 | 379 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 380 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 380 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
| 381 | 381 | } |
| 382 | 382 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
| 383 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 383 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
| 384 | 384 | } |
| 385 | 385 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
| 386 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 386 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
@@ -391,13 +391,13 @@ discard block |
||
| 391 | 391 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
| 392 | 392 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 393 | 393 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
| 394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 395 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 396 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 397 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 398 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 395 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 396 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 397 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 398 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 399 | 399 | } else { |
| 400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
| 401 | 401 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 402 | 402 | $timeelapsed = microtime(true); |
| 403 | 403 | $Spotter = new Spotter($this->db); |
@@ -407,13 +407,13 @@ discard block |
||
| 407 | 407 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 408 | 408 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 409 | 409 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 410 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 410 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
| 411 | 411 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 412 | 412 | $Spotter->db = null; |
| 413 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 413 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 414 | 414 | } |
| 415 | 415 | } |
| 416 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 416 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
| 417 | 417 | |
| 418 | 418 | /* |
| 419 | 419 | if (!isset($line['id'])) { |
@@ -423,25 +423,25 @@ discard block |
||
| 423 | 423 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 424 | 424 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 425 | 425 | */ |
| 426 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 426 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 427 | 427 | |
| 428 | 428 | //$putinarchive = true; |
| 429 | 429 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
| 430 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 430 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 431 | 431 | } |
| 432 | 432 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
| 433 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 433 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 434 | 434 | } |
| 435 | 435 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
| 436 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 436 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
| 437 | 437 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
| 438 | 438 | $timeelapsed = microtime(true); |
| 439 | 439 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 440 | 440 | $Spotter = new Spotter($this->db); |
| 441 | 441 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 442 | 442 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 443 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 444 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 443 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
| 444 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 445 | 445 | } |
| 446 | 446 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 447 | 447 | $timeelapsed = microtime(true); |
@@ -455,35 +455,35 @@ discard block |
||
| 455 | 455 | $Translation->db = null; |
| 456 | 456 | } |
| 457 | 457 | $Spotter->db = null; |
| 458 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 458 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 459 | 459 | } |
| 460 | 460 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 461 | 461 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
| 462 | 462 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
| 463 | 463 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
| 464 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
| 464 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | if (!isset($globalFork)) $globalFork = TRUE; |
| 468 | 468 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 469 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
| 469 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
| 475 | 475 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
| 476 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 477 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 476 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
| 477 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
| 478 | 478 | //$dataFound = true; |
| 479 | 479 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 480 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 480 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
| 481 | 481 | if ($distance > 1000 && $distance < 10000) { |
| 482 | 482 | // use datetime |
| 483 | 483 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 484 | 484 | $speed = $speed*3.6; |
| 485 | 485 | if ($speed < 1000) { |
| 486 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 486 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
| 487 | 487 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
| 488 | 488 | } else { |
| 489 | 489 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
@@ -498,9 +498,9 @@ discard block |
||
| 498 | 498 | if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
| 499 | 499 | return false; |
| 500 | 500 | } |
| 501 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 501 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
| 502 | 502 | else unset($timediff); |
| 503 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 503 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
| 504 | 504 | else unset($timediff_archive); |
| 505 | 505 | if ($this->tmd > 5 |
| 506 | 506 | || (isset($line['format_source']) |
@@ -524,14 +524,14 @@ discard block |
||
| 524 | 524 | || ($timediff > 30 |
| 525 | 525 | && isset($this->all_flights[$id]['latitude']) |
| 526 | 526 | && isset($this->all_flights[$id]['longitude']) |
| 527 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 527 | + && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
| 528 | 528 | ) |
| 529 | 529 | ) { |
| 530 | 530 | |
| 531 | 531 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
| 532 | 532 | if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
| 533 | 533 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
| 534 | - || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 534 | + || !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
| 535 | 535 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 536 | 536 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 537 | 537 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -541,11 +541,11 @@ discard block |
||
| 541 | 541 | $timeelapsed = microtime(true); |
| 542 | 542 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 543 | 543 | $Spotter = new Spotter($this->db); |
| 544 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 544 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 545 | 545 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
| 546 | 546 | else $this->all_flights[$id]['over_country'] = ''; |
| 547 | 547 | $Spotter->db = null; |
| 548 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 548 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 549 | 549 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 550 | 550 | } |
| 551 | 551 | } |
@@ -571,13 +571,13 @@ discard block |
||
| 571 | 571 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 572 | 572 | } |
| 573 | 573 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
| 574 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
|
| 574 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) { |
|
| 575 | 575 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
| 576 | 576 | $dataFound = true; |
| 577 | 577 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 578 | 578 | } |
| 579 | 579 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 580 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
| 580 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
| 581 | 581 | /* |
| 582 | 582 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
| 583 | 583 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -599,13 +599,13 @@ discard block |
||
| 599 | 599 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 600 | 600 | } |
| 601 | 601 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
| 602 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
|
| 602 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) { |
|
| 603 | 603 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
| 604 | 604 | $dataFound = true; |
| 605 | 605 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 606 | 606 | } |
| 607 | 607 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 608 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
| 608 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
| 609 | 609 | /* |
| 610 | 610 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
| 611 | 611 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -623,46 +623,46 @@ discard block |
||
| 623 | 623 | } else if ($globalDebug && $timediff > 30) { |
| 624 | 624 | $this->tmd = $this->tmd + 1; |
| 625 | 625 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
| 626 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
| 627 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 626 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
| 627 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 628 | 628 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
| 629 | 629 | } |
| 630 | 630 | } |
| 631 | 631 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 632 | 632 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 633 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 633 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
| 634 | 634 | } |
| 635 | 635 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 636 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 636 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
| 637 | 637 | //$dataFound = true; |
| 638 | 638 | } |
| 639 | 639 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 640 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 640 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
| 641 | 641 | } |
| 642 | 642 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 643 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 643 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
| 644 | 644 | } |
| 645 | 645 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 646 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 646 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
| 647 | 647 | //$dataFound = true; |
| 648 | 648 | } |
| 649 | 649 | if (isset($line['ground']) && $line['ground'] != '') { |
| 650 | 650 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
| 651 | 651 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 652 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 653 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 654 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 655 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 656 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 652 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 653 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 654 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 655 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 656 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 657 | 657 | } |
| 658 | 658 | if ($line['ground'] != 1) $line['ground'] = 0; |
| 659 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 659 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
| 660 | 660 | //$dataFound = true; |
| 661 | 661 | } |
| 662 | 662 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 663 | 663 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
| 664 | 664 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
| 665 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 665 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 666 | 666 | $highlight = ''; |
| 667 | 667 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
| 668 | 668 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -671,66 +671,66 @@ discard block |
||
| 671 | 671 | $timeelapsed = microtime(true); |
| 672 | 672 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 673 | 673 | $Spotter = new Spotter($this->db); |
| 674 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 674 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
| 675 | 675 | $Spotter->db = null; |
| 676 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 676 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 677 | 677 | } |
| 678 | 678 | //$putinarchive = true; |
| 679 | 679 | //$highlight = ''; |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 682 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 683 | 683 | //$dataFound = true; |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 687 | 687 | if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) { |
| 688 | 688 | if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') { |
| 689 | - $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2); |
|
| 689 | + $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2); |
|
| 690 | 690 | //if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n"; |
| 691 | 691 | $line['altitude'] = $line['altitude'] - $geoid; |
| 692 | 692 | } |
| 693 | 693 | } |
| 694 | 694 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 695 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
| 696 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
| 697 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
| 695 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
| 696 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
| 697 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
| 698 | 698 | //$dataFound = true; |
| 699 | 699 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
| 700 | 700 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
| 701 | 701 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 702 | 702 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
| 703 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 704 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 705 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 706 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 707 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 703 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 704 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 705 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 706 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 707 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 708 | 708 | } |
| 709 | 709 | } |
| 710 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 710 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 714 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 714 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | if (isset($line['heading']) && $line['heading'] != '') { |
| 718 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 719 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 720 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 718 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 719 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
| 720 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
| 721 | 721 | //$dataFound = true; |
| 722 | 722 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 723 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 724 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 725 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 723 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 724 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
| 725 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 726 | 726 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
| 727 | 727 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 728 | 728 | // If not enough messages and ACARS set heading to 0 |
| 729 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 729 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
| 730 | 730 | } |
| 731 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 732 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 733 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false; |
|
| 731 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 732 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 733 | + elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false; |
|
| 734 | 734 | |
| 735 | 735 | // print_r($this->all_flights[$id]); |
| 736 | 736 | //gets the callsign from the last hour |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
| 742 | 742 | $this->all_flights[$id]['lastupdate'] = time(); |
| 743 | 743 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
| 744 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 744 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 745 | 745 | //print_r($this->all_flights); |
| 746 | 746 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
| 747 | 747 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -752,61 +752,61 @@ discard block |
||
| 752 | 752 | $SpotterLive = new SpotterLive($this->db); |
| 753 | 753 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
| 754 | 754 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 755 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 755 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 756 | 756 | } elseif (isset($line['id'])) { |
| 757 | 757 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 758 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 758 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 759 | 759 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 760 | 760 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 761 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 761 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 762 | 762 | } else $recent_ident = ''; |
| 763 | - $SpotterLive->db=null; |
|
| 763 | + $SpotterLive->db = null; |
|
| 764 | 764 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 765 | 765 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 766 | 766 | } else $recent_ident = ''; |
| 767 | 767 | } else { |
| 768 | 768 | $recent_ident = ''; |
| 769 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
| 769 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
| 770 | 770 | } |
| 771 | 771 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 772 | - if($recent_ident == "") |
|
| 772 | + if ($recent_ident == "") |
|
| 773 | 773 | { |
| 774 | 774 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
| 775 | 775 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 776 | 776 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 777 | 777 | //adds the spotter data for the archive |
| 778 | 778 | $ignoreImport = false; |
| 779 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 779 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 780 | 780 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 781 | 781 | $ignoreImport = true; |
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | 784 | if (count($globalAirportAccept) > 0) { |
| 785 | 785 | $ignoreImport = true; |
| 786 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 786 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 787 | 787 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 788 | 788 | $ignoreImport = false; |
| 789 | 789 | } |
| 790 | 790 | } |
| 791 | 791 | } |
| 792 | 792 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 793 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 794 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 793 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 794 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
| 795 | 795 | $ignoreImport = true; |
| 796 | 796 | } |
| 797 | 797 | } |
| 798 | 798 | } |
| 799 | 799 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 800 | 800 | $ignoreImport = true; |
| 801 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 802 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 801 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 802 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
| 803 | 803 | $ignoreImport = false; |
| 804 | 804 | } |
| 805 | 805 | } |
| 806 | 806 | } |
| 807 | 807 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 808 | 808 | $ignoreImport = true; |
| 809 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 809 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 810 | 810 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 811 | 811 | $ignoreImport = false; |
| 812 | 812 | } |
@@ -818,32 +818,32 @@ discard block |
||
| 818 | 818 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
| 819 | 819 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
| 820 | 820 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
| 821 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 821 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 822 | 822 | $timeelapsed = microtime(true); |
| 823 | 823 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 824 | 824 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 825 | 825 | $Spotter = new Spotter($this->db); |
| 826 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
| 826 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
| 827 | 827 | $Spotter->db = null; |
| 828 | 828 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 829 | 829 | } |
| 830 | 830 | } |
| 831 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 831 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 832 | 832 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 833 | 833 | |
| 834 | 834 | // Add source stat in DB |
| 835 | 835 | $Stats = new Stats($this->db); |
| 836 | 836 | if (!empty($this->stats)) { |
| 837 | 837 | if ($globalDebug) echo 'Add source stats : '; |
| 838 | - foreach($this->stats as $date => $data) { |
|
| 839 | - foreach($data as $source => $sourced) { |
|
| 838 | + foreach ($this->stats as $date => $data) { |
|
| 839 | + foreach ($data as $source => $sourced) { |
|
| 840 | 840 | //print_r($sourced); |
| 841 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 842 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 841 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
| 842 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
| 843 | 843 | if (isset($sourced['msg'])) { |
| 844 | 844 | if (time() - $sourced['msg']['date'] > 10) { |
| 845 | 845 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
| 846 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 846 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
| 847 | 847 | unset($this->stats[$date][$source]['msg']); |
| 848 | 848 | } |
| 849 | 849 | } |
@@ -881,14 +881,14 @@ discard block |
||
| 881 | 881 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 882 | 882 | $SpotterLive = new SpotterLive($this->db); |
| 883 | 883 | $SpotterLive->deleteLiveSpotterData(); |
| 884 | - $SpotterLive->db=null; |
|
| 884 | + $SpotterLive->db = null; |
|
| 885 | 885 | } |
| 886 | 886 | } |
| 887 | 887 | if ($globalDebug) echo " Done\n"; |
| 888 | 888 | $this->last_delete = time(); |
| 889 | 889 | } |
| 890 | 890 | } else { |
| 891 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
| 891 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
| 892 | 892 | $this->all_flights[$id]['id'] = $recent_ident; |
| 893 | 893 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 894 | 894 | } |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 897 | 897 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 898 | 898 | $Spotter = new Spotter($this->db); |
| 899 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
| 899 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
| 900 | 900 | $Spotter->db = null; |
| 901 | 901 | } |
| 902 | 902 | } |
@@ -922,37 +922,37 @@ discard block |
||
| 922 | 922 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 923 | 923 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 924 | 924 | |
| 925 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 925 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 926 | 926 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 927 | 927 | $ignoreImport = true; |
| 928 | 928 | } |
| 929 | 929 | } |
| 930 | 930 | if (count($globalAirportAccept) > 0) { |
| 931 | 931 | $ignoreImport = true; |
| 932 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 932 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 933 | 933 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 934 | 934 | $ignoreImport = false; |
| 935 | 935 | } |
| 936 | 936 | } |
| 937 | 937 | } |
| 938 | 938 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 939 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 940 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 939 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 940 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
| 941 | 941 | $ignoreImport = true; |
| 942 | 942 | } |
| 943 | 943 | } |
| 944 | 944 | } |
| 945 | 945 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 946 | 946 | $ignoreImport = true; |
| 947 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 948 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 947 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 948 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
| 949 | 949 | $ignoreImport = false; |
| 950 | 950 | } |
| 951 | 951 | } |
| 952 | 952 | } |
| 953 | 953 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 954 | 954 | $ignoreImport = true; |
| 955 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 955 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 956 | 956 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 957 | 957 | $ignoreImport = false; |
| 958 | 958 | } |
@@ -960,23 +960,23 @@ discard block |
||
| 960 | 960 | } |
| 961 | 961 | |
| 962 | 962 | if (!$ignoreImport) { |
| 963 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 964 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 963 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 964 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 965 | 965 | $timeelapsed = microtime(true); |
| 966 | 966 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 967 | 967 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 968 | 968 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
| 969 | 969 | $SpotterLive = new SpotterLive($this->db); |
| 970 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
| 970 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
| 971 | 971 | $SpotterLive->db = null; |
| 972 | 972 | if ($globalDebug) echo $result."\n"; |
| 973 | 973 | } |
| 974 | 974 | } |
| 975 | 975 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 976 | - $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
| 976 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
| 977 | 977 | } |
| 978 | 978 | $this->all_flights[$id]['putinarchive'] = false; |
| 979 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 979 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 980 | 980 | |
| 981 | 981 | // Put statistics in $this->stats variable |
| 982 | 982 | //if ($line['format_source'] != 'aprs') { |
@@ -995,19 +995,19 @@ discard block |
||
| 995 | 995 | $latitude = $globalCenterLatitude; |
| 996 | 996 | $longitude = $globalCenterLongitude; |
| 997 | 997 | } |
| 998 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
| 998 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
| 999 | 999 | } else { |
| 1000 | 1000 | $latitude = $this->source_location[$source]['latitude']; |
| 1001 | 1001 | $longitude = $this->source_location[$source]['longitude']; |
| 1002 | 1002 | } |
| 1003 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 1003 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 1004 | 1004 | //$stats_heading = $stats_heading%22.5; |
| 1005 | 1005 | $stats_heading = round($stats_heading/22.5); |
| 1006 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 1006 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 1007 | 1007 | $current_date = date('Y-m-d'); |
| 1008 | 1008 | if ($stats_heading == 16) $stats_heading = 0; |
| 1009 | 1009 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 1010 | - for ($i=0;$i<=15;$i++) { |
|
| 1010 | + for ($i = 0; $i <= 15; $i++) { |
|
| 1011 | 1011 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
| 1012 | 1012 | } |
| 1013 | 1013 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -1022,9 +1022,9 @@ discard block |
||
| 1022 | 1022 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 1023 | 1023 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1024 | 1024 | end($this->stats[$current_date][$source]['hist']); |
| 1025 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1025 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
| 1026 | 1026 | } else $mini = 0; |
| 1027 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
| 1027 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
| 1028 | 1028 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 1029 | 1029 | } |
| 1030 | 1030 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | $this->all_flights[$id]['lastupdate'] = time(); |
| 1038 | 1038 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
| 1039 | 1039 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 1040 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1040 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
| 1041 | 1041 | //$this->del(); |
| 1042 | 1042 | |
| 1043 | 1043 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
@@ -7,35 +7,35 @@ discard block |
||
| 7 | 7 | public $db; |
| 8 | 8 | |
| 9 | 9 | protected $texts = Array( |
| 10 | - 'MI' => 'Shallow', |
|
| 11 | - 'PR' => 'Partial', |
|
| 12 | - 'BC' => 'Low drifting', |
|
| 13 | - 'BL' => 'Blowing', |
|
| 14 | - 'SH' => 'Showers', |
|
| 15 | - 'TS' => 'Thunderstorm', |
|
| 16 | - 'FZ' => 'Freezing', |
|
| 17 | - 'DZ' => 'Drizzle', |
|
| 18 | - 'RA' => 'Rain', |
|
| 19 | - 'SN' => 'Snow', |
|
| 20 | - 'SG' => 'Snow Grains', |
|
| 21 | - 'IC' => 'Ice crystals', |
|
| 22 | - 'PL' => 'Ice pellets', |
|
| 23 | - 'GR' => 'Hail', |
|
| 24 | - 'GS' => 'Small hail', |
|
| 25 | - 'UP' => 'Unknown', |
|
| 26 | - 'BR' => 'Mist', |
|
| 27 | - 'FG' => 'Fog', |
|
| 28 | - 'FU' => 'Smoke', |
|
| 29 | - 'VA' => 'Volcanic ash', |
|
| 30 | - 'DU' => 'Widespread dust', |
|
| 31 | - 'SA' => 'Sand', |
|
| 32 | - 'HZ' => 'Haze', |
|
| 33 | - 'PY' => 'Spray', |
|
| 34 | - 'PO' => 'Well developed dust / sand whirls', |
|
| 35 | - 'SQ' => 'Squalls', |
|
| 36 | - 'FC' => 'Funnel clouds inc tornadoes or waterspouts', |
|
| 37 | - 'SS' => 'Sandstorm', |
|
| 38 | - 'DS' => 'Duststorm' |
|
| 10 | + 'MI' => 'Shallow', |
|
| 11 | + 'PR' => 'Partial', |
|
| 12 | + 'BC' => 'Low drifting', |
|
| 13 | + 'BL' => 'Blowing', |
|
| 14 | + 'SH' => 'Showers', |
|
| 15 | + 'TS' => 'Thunderstorm', |
|
| 16 | + 'FZ' => 'Freezing', |
|
| 17 | + 'DZ' => 'Drizzle', |
|
| 18 | + 'RA' => 'Rain', |
|
| 19 | + 'SN' => 'Snow', |
|
| 20 | + 'SG' => 'Snow Grains', |
|
| 21 | + 'IC' => 'Ice crystals', |
|
| 22 | + 'PL' => 'Ice pellets', |
|
| 23 | + 'GR' => 'Hail', |
|
| 24 | + 'GS' => 'Small hail', |
|
| 25 | + 'UP' => 'Unknown', |
|
| 26 | + 'BR' => 'Mist', |
|
| 27 | + 'FG' => 'Fog', |
|
| 28 | + 'FU' => 'Smoke', |
|
| 29 | + 'VA' => 'Volcanic ash', |
|
| 30 | + 'DU' => 'Widespread dust', |
|
| 31 | + 'SA' => 'Sand', |
|
| 32 | + 'HZ' => 'Haze', |
|
| 33 | + 'PY' => 'Spray', |
|
| 34 | + 'PO' => 'Well developed dust / sand whirls', |
|
| 35 | + 'SQ' => 'Squalls', |
|
| 36 | + 'FC' => 'Funnel clouds inc tornadoes or waterspouts', |
|
| 37 | + 'SS' => 'Sandstorm', |
|
| 38 | + 'DS' => 'Duststorm' |
|
| 39 | 39 | ); |
| 40 | 40 | |
| 41 | 41 | public function __construct($dbc = null) { |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | $result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg'; |
| 154 | 154 | */ |
| 155 | 155 | } |
| 156 | - /* |
|
| 156 | + /* |
|
| 157 | 157 | // Wind Direction |
| 158 | 158 | if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) { |
| 159 | 159 | $result['wind_direction'] = $matches[1]; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $result['speed_variable'] = $matches[1]; |
| 165 | 165 | } |
| 166 | 166 | */ |
| 167 | - // Visibility |
|
| 167 | + // Visibility |
|
| 168 | 168 | if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
| 169 | 169 | if (isset($matches[3]) && strlen($matches[3]) > 0) { |
| 170 | 170 | $result['visibility'] = (float)$matches[3] * 1609.34; |
@@ -222,9 +222,9 @@ discard block |
||
| 222 | 222 | else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
| 223 | 223 | if (isset($matches[3])) { |
| 224 | 224 | $range = Array( |
| 225 | - 'from' => (float)$matches[2], |
|
| 226 | - 'to' => (float)$matches[4], |
|
| 227 | - 'unit' => $matches[5] ? 'FT' : 'M' |
|
| 225 | + 'from' => (float)$matches[2], |
|
| 226 | + 'to' => (float)$matches[4], |
|
| 227 | + 'unit' => $matches[5] ? 'FT' : 'M' |
|
| 228 | 228 | ); |
| 229 | 229 | } |
| 230 | 230 | $result['RVR'] = $matches[1]; |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | return $result; |
| 260 | - } |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | 262 | public function getMETAR($icao) { |
| 263 | 263 | global $globalMETARcycle, $globalDBdriver; |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $Connection = new Connection(); |
| 55 | 55 | $sth = $Connection->db->prepare($query); |
| 56 | 56 | $sth->execute(); |
| 57 | - } catch(PDOException $e) { |
|
| 57 | + } catch (PDOException $e) { |
|
| 58 | 58 | return "error : ".$e->getMessage(); |
| 59 | 59 | } |
| 60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $Connection = new Connection(); |
| 71 | 71 | $sth = $Connection->db->prepare($query); |
| 72 | 72 | $sth->execute(); |
| 73 | - } catch(PDOException $e) { |
|
| 73 | + } catch (PDOException $e) { |
|
| 74 | 74 | return "error : ".$e->getMessage(); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | public function parse($data) { |
| 79 | 79 | //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
| 80 | 80 | $codes = implode('|', array_keys($this->texts)); |
| 81 | - $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
| 81 | + $regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#'; |
|
| 82 | 82 | //$pieces = explode(' ',$data); |
| 83 | - $pieces = preg_split('/\s/',$data); |
|
| 83 | + $pieces = preg_split('/\s/', $data); |
|
| 84 | 84 | $pos = 0; |
| 85 | 85 | if ($pieces[0] == 'METAR') $pos++; |
| 86 | 86 | elseif ($pieces[0] == 'SPECI') $pos++; |
@@ -88,25 +88,25 @@ discard block |
||
| 88 | 88 | $result = array(); |
| 89 | 89 | $result['location'] = $pieces[$pos]; |
| 90 | 90 | $pos++; |
| 91 | - $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
| 92 | - $result['time'] = substr($pieces[$pos],2,4); |
|
| 91 | + $result['dayofmonth'] = substr($pieces[$pos], 0, 2); |
|
| 92 | + $result['time'] = substr($pieces[$pos], 2, 4); |
|
| 93 | 93 | $c = count($pieces); |
| 94 | - for($pos++; $pos < $c; $pos++) { |
|
| 94 | + for ($pos++; $pos < $c; $pos++) { |
|
| 95 | 95 | $piece = $pieces[$pos]; |
| 96 | 96 | if ($piece == 'RMK') break; |
| 97 | 97 | if ($piece == 'AUTO') $result['auto'] = true; |
| 98 | 98 | if ($piece == 'COR') $result['correction'] = true; |
| 99 | 99 | // Wind Speed |
| 100 | 100 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
| 101 | - $result['wind']['direction'] = (float)$matches[1]; |
|
| 101 | + $result['wind']['direction'] = (float) $matches[1]; |
|
| 102 | 102 | $result['wind']['unit'] = $matches[4]; |
| 103 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 104 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 105 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 106 | - $result['wind']['gust'] = (float)$matches[3]; |
|
| 103 | + if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2); |
|
| 104 | + elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2); |
|
| 105 | + elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2); |
|
| 106 | + $result['wind']['gust'] = (float) $matches[3]; |
|
| 107 | 107 | $result['wind']['unit'] = $matches[4]; |
| 108 | - $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
|
| 109 | - $result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0; |
|
| 108 | + $result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0; |
|
| 109 | + $result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /* if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) { |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | // Temperature |
| 129 | 129 | if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
| 130 | - $temp = (float)$matches[1]; |
|
| 130 | + $temp = (float) $matches[1]; |
|
| 131 | 131 | if ($matches[1]{0} == 'M') { |
| 132 | - $temp = ((float)substr($matches[1], 1)) * -1; |
|
| 132 | + $temp = ((float) substr($matches[1], 1))*-1; |
|
| 133 | 133 | } |
| 134 | 134 | $result['temperature'] = $temp; |
| 135 | - $dew = (float)$matches[2]; |
|
| 135 | + $dew = (float) $matches[2]; |
|
| 136 | 136 | if ($matches[2]{0} == 'M') { |
| 137 | - $dew = ((float)substr($matches[2], 1)) * -1; |
|
| 137 | + $dew = ((float) substr($matches[2], 1))*-1; |
|
| 138 | 138 | } |
| 139 | 139 | $result['dew'] = $dew; |
| 140 | 140 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | $result['QNH'] = $matches[2]; |
| 147 | 147 | } else { |
| 148 | 148 | // inHg |
| 149 | - $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
| 149 | + $result['QNH'] = round(($matches[2]/100)*33.86389, 2); |
|
| 150 | 150 | } |
| 151 | 151 | /* |
| 152 | 152 | $result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100); |
@@ -167,12 +167,12 @@ discard block |
||
| 167 | 167 | // Visibility |
| 168 | 168 | if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
| 169 | 169 | if (isset($matches[3]) && strlen($matches[3]) > 0) { |
| 170 | - $result['visibility'] = (float)$matches[3] * 1609.34; |
|
| 170 | + $result['visibility'] = (float) $matches[3]*1609.34; |
|
| 171 | 171 | } else { |
| 172 | 172 | if ($matches[1] == '9999') { |
| 173 | 173 | $result['visibility'] = '> 10000'; |
| 174 | 174 | } else { |
| 175 | - $result['visibility'] = (float)$matches[1]; |
|
| 175 | + $result['visibility'] = (float) $matches[1]; |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | if (preg_match('#^CAVOK$#', $piece, $matches)) { |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
| 195 | 195 | elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
| 196 | 196 | $cloud['type_code'] = $type; |
| 197 | - $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
| 197 | + $cloud['level'] = round(((float) $matches[2])*100*0.3048); |
|
| 198 | 198 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
| 199 | 199 | $result['cloud'][] = $cloud; |
| 200 | 200 | } |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | $rvr['runway'] = $matches[1]; |
| 205 | 205 | $rvr['assessment'] = $matches[2]; |
| 206 | 206 | $rvr['rvr'] = $matches[3]; |
| 207 | - $rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0; |
|
| 208 | - $rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : ''; |
|
| 207 | + $rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0; |
|
| 208 | + $rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : ''; |
|
| 209 | 209 | $result['RVR'] = $rvr; |
| 210 | 210 | } |
| 211 | 211 | //if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
@@ -218,12 +218,12 @@ discard block |
||
| 218 | 218 | $result['RVR']['friction'] = $matches[5]; |
| 219 | 219 | } |
| 220 | 220 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
| 221 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 222 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 221 | + if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 222 | + else $range = array('exact' => (float) $matches[2], 'unit' => 'M'); |
|
| 223 | 223 | if (isset($matches[3])) { |
| 224 | 224 | $range = Array( |
| 225 | - 'from' => (float)$matches[2], |
|
| 226 | - 'to' => (float)$matches[4], |
|
| 225 | + 'from' => (float) $matches[2], |
|
| 226 | + 'to' => (float) $matches[4], |
|
| 227 | 227 | 'unit' => $matches[5] ? 'FT' : 'M' |
| 228 | 228 | ); |
| 229 | 229 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | try { |
| 272 | 272 | $sth = $this->db->prepare($query); |
| 273 | 273 | $sth->execute($query_values); |
| 274 | - } catch(PDOException $e) { |
|
| 274 | + } catch (PDOException $e) { |
|
| 275 | 275 | return "error : ".$e->getMessage(); |
| 276 | 276 | } |
| 277 | 277 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -281,19 +281,19 @@ discard block |
||
| 281 | 281 | return $all; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - public function addMETAR($location,$metar,$date) { |
|
| 284 | + public function addMETAR($location, $metar, $date) { |
|
| 285 | 285 | global $globalDBdriver; |
| 286 | - $date = date('Y-m-d H:i:s',strtotime($date)); |
|
| 286 | + $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 287 | 287 | if ($globalDBdriver == 'mysql') { |
| 288 | 288 | $query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar"; |
| 289 | 289 | } else { |
| 290 | 290 | $query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);"; |
| 291 | 291 | } |
| 292 | - $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
| 292 | + $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar)); |
|
| 293 | 293 | try { |
| 294 | 294 | $sth = $this->db->prepare($query); |
| 295 | 295 | $sth->execute($query_values); |
| 296 | - } catch(PDOException $e) { |
|
| 296 | + } catch (PDOException $e) { |
|
| 297 | 297 | return "error : ".$e->getMessage(); |
| 298 | 298 | } |
| 299 | 299 | } |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | try { |
| 305 | 305 | $sth = $this->db->prepare($query); |
| 306 | 306 | $sth->execute($query_values); |
| 307 | - } catch(PDOException $e) { |
|
| 307 | + } catch (PDOException $e) { |
|
| 308 | 308 | return "error : ".$e->getMessage(); |
| 309 | 309 | } |
| 310 | 310 | } |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | try { |
| 315 | 315 | $sth = $this->db->prepare($query); |
| 316 | 316 | $sth->execute(); |
| 317 | - } catch(PDOException $e) { |
|
| 317 | + } catch (PDOException $e) { |
|
| 318 | 318 | return "error : ".$e->getMessage(); |
| 319 | 319 | } |
| 320 | 320 | } |
@@ -325,27 +325,27 @@ discard block |
||
| 325 | 325 | date_default_timezone_set("UTC"); |
| 326 | 326 | $Common = new Common(); |
| 327 | 327 | if (isset($globalIVAO) && $globalIVAO) { |
| 328 | - $Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
| 329 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r"); |
|
| 328 | + $Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
| 329 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r"); |
|
| 330 | 330 | } else { |
| 331 | - $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
| 332 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
|
| 331 | + $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
| 332 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r"); |
|
| 333 | 333 | } |
| 334 | 334 | if ($handle) { |
| 335 | 335 | if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
| 336 | 336 | $date = ''; |
| 337 | 337 | if ($globalTransaction) $this->db->beginTransaction(); |
| 338 | - while(($line = fgets($handle,4096)) !== false) { |
|
| 339 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
| 338 | + while (($line = fgets($handle, 4096)) !== false) { |
|
| 339 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
| 340 | 340 | $date = $line; |
| 341 | 341 | } elseif ($line != '') { |
| 342 | 342 | if ($date == '') $date = date('Y/m/d H:m'); |
| 343 | 343 | $pos = 0; |
| 344 | - $pieces = preg_split('/\s/',$line); |
|
| 344 | + $pieces = preg_split('/\s/', $line); |
|
| 345 | 345 | if ($pieces[0] == 'METAR') $pos++; |
| 346 | 346 | if (strlen($pieces[$pos]) != 4) $pos++; |
| 347 | 347 | $location = $pieces[$pos]; |
| 348 | - echo $this->addMETAR($location,$line,$date); |
|
| 348 | + echo $this->addMETAR($location, $line, $date); |
|
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | 351 | fclose($handle); |
@@ -359,22 +359,22 @@ discard block |
||
| 359 | 359 | if ($globalMETARurl == '') return array(); |
| 360 | 360 | date_default_timezone_set("UTC"); |
| 361 | 361 | $Common = new Common(); |
| 362 | - $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
| 362 | + $url = str_replace('{icao}', $icao, $globalMETARurl); |
|
| 363 | 363 | $cycle = $Common->getData($url); |
| 364 | 364 | $date = ''; |
| 365 | - foreach(explode("\n",$cycle) as $line) { |
|
| 366 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
| 365 | + foreach (explode("\n", $cycle) as $line) { |
|
| 366 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
| 367 | 367 | $date = $line; |
| 368 | 368 | } |
| 369 | 369 | if ($line != '') { |
| 370 | 370 | if ($date == '') $date = date('Y/m/d H:m'); |
| 371 | 371 | $pos = 0; |
| 372 | - $pieces = preg_split('/\s/',$line); |
|
| 372 | + $pieces = preg_split('/\s/', $line); |
|
| 373 | 373 | if ($pieces[0] == 'METAR') $pos++; |
| 374 | 374 | if (strlen($pieces[$pos]) != 4) $pos++; |
| 375 | 375 | $location = $pieces[$pos]; |
| 376 | 376 | if (strlen($location == 4)) { |
| 377 | - $this->addMETAR($location,$line,$date); |
|
| 377 | + $this->addMETAR($location, $line, $date); |
|
| 378 | 378 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
| 379 | 379 | } else return array(); |
| 380 | 380 | } |
@@ -59,8 +59,11 @@ discard block |
||
| 59 | 59 | } |
| 60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 61 | 61 | $sth->closeCursor(); |
| 62 | - if ($row['nb'] > 0) return false; |
|
| 63 | - else return true; |
|
| 62 | + if ($row['nb'] > 0) { |
|
| 63 | + return false; |
|
| 64 | + } else { |
|
| 65 | + return true; |
|
| 66 | + } |
|
| 64 | 67 | } |
| 65 | 68 | |
| 66 | 69 | public static function insert_last_update() { |
@@ -82,9 +85,14 @@ discard block |
||
| 82 | 85 | //$pieces = explode(' ',$data); |
| 83 | 86 | $pieces = preg_split('/\s/',$data); |
| 84 | 87 | $pos = 0; |
| 85 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 86 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
| 87 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 88 | + if ($pieces[0] == 'METAR') { |
|
| 89 | + $pos++; |
|
| 90 | + } elseif ($pieces[0] == 'SPECI') { |
|
| 91 | + $pos++; |
|
| 92 | + } |
|
| 93 | + if (strlen($pieces[$pos]) != 4) { |
|
| 94 | + $pos++; |
|
| 95 | + } |
|
| 88 | 96 | $result = array(); |
| 89 | 97 | $result['location'] = $pieces[$pos]; |
| 90 | 98 | $pos++; |
@@ -93,16 +101,26 @@ discard block |
||
| 93 | 101 | $c = count($pieces); |
| 94 | 102 | for($pos++; $pos < $c; $pos++) { |
| 95 | 103 | $piece = $pieces[$pos]; |
| 96 | - if ($piece == 'RMK') break; |
|
| 97 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
| 98 | - if ($piece == 'COR') $result['correction'] = true; |
|
| 104 | + if ($piece == 'RMK') { |
|
| 105 | + break; |
|
| 106 | + } |
|
| 107 | + if ($piece == 'AUTO') { |
|
| 108 | + $result['auto'] = true; |
|
| 109 | + } |
|
| 110 | + if ($piece == 'COR') { |
|
| 111 | + $result['correction'] = true; |
|
| 112 | + } |
|
| 99 | 113 | // Wind Speed |
| 100 | 114 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
| 101 | 115 | $result['wind']['direction'] = (float)$matches[1]; |
| 102 | 116 | $result['wind']['unit'] = $matches[4]; |
| 103 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 104 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 105 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 117 | + if ($result['wind']['unit'] == 'KT') { |
|
| 118 | + $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 119 | + } elseif ($result['wind']['unit'] == 'KPH') { |
|
| 120 | + $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 121 | + } elseif ($result['wind']['unit'] == 'MPS') { |
|
| 122 | + $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 123 | + } |
|
| 106 | 124 | $result['wind']['gust'] = (float)$matches[3]; |
| 107 | 125 | $result['wind']['unit'] = $matches[4]; |
| 108 | 126 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
@@ -185,14 +203,23 @@ discard block |
||
| 185 | 203 | //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
| 186 | 204 | $type = $matches[1]; |
| 187 | 205 | $cloud = array(); |
| 188 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
| 189 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
| 190 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
| 191 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
| 192 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
| 193 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
| 194 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
| 195 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
| 206 | + if ($type == 'SKC') { |
|
| 207 | + $cloud['type'] = 'No cloud/Sky clear'; |
|
| 208 | + } elseif ($type == 'CLR') { |
|
| 209 | + $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
| 210 | + } elseif ($type == 'NSC') { |
|
| 211 | + $cloud['type'] = 'No significant cloud'; |
|
| 212 | + } elseif ($type == 'FEW') { |
|
| 213 | + $cloud['type'] = 'Few'; |
|
| 214 | + } elseif ($type == 'SCT') { |
|
| 215 | + $cloud['type'] = 'Scattered'; |
|
| 216 | + } elseif ($type == 'BKN') { |
|
| 217 | + $cloud['type'] = 'Broken'; |
|
| 218 | + } elseif ($type == 'OVC') { |
|
| 219 | + $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
| 220 | + } elseif ($type == 'VV') { |
|
| 221 | + $cloud['type'] = 'Vertical visibility'; |
|
| 222 | + } |
|
| 196 | 223 | $cloud['type_code'] = $type; |
| 197 | 224 | $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
| 198 | 225 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
@@ -218,8 +245,11 @@ discard block |
||
| 218 | 245 | $result['RVR']['friction'] = $matches[5]; |
| 219 | 246 | } |
| 220 | 247 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
| 221 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 222 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 248 | + if (isset($matches[5])) { |
|
| 249 | + $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 250 | + } else { |
|
| 251 | + $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 252 | + } |
|
| 223 | 253 | if (isset($matches[3])) { |
| 224 | 254 | $range = Array( |
| 225 | 255 | 'from' => (float)$matches[2], |
@@ -252,8 +282,11 @@ discard block |
||
| 252 | 282 | if (isset($matches[3])) { |
| 253 | 283 | $text[] = $this->texts[$matches[3]]; |
| 254 | 284 | } |
| 255 | - if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
|
| 256 | - else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 285 | + if (!isset($result['weather'])) { |
|
| 286 | + $result['weather'] = implode(' ', $text); |
|
| 287 | + } else { |
|
| 288 | + $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 289 | + } |
|
| 257 | 290 | } |
| 258 | 291 | } |
| 259 | 292 | return $result; |
@@ -264,8 +297,11 @@ discard block |
||
| 264 | 297 | if (isset($globalMETARcycle) && $globalMETARcycle) { |
| 265 | 298 | $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
| 266 | 299 | } else { |
| 267 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 268 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 300 | + if ($globalDBdriver == 'mysql') { |
|
| 301 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 302 | + } else { |
|
| 303 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 304 | + } |
|
| 269 | 305 | } |
| 270 | 306 | $query_values = array(':icao' => $icao); |
| 271 | 307 | try { |
@@ -321,7 +357,9 @@ discard block |
||
| 321 | 357 | |
| 322 | 358 | public function addMETARCycle() { |
| 323 | 359 | global $globalDebug, $globalIVAO, $globalTransaction; |
| 324 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
| 360 | + if (isset($globalDebug) && $globalDebug) { |
|
| 361 | + echo "Downloading METAR cycle..."; |
|
| 362 | + } |
|
| 325 | 363 | date_default_timezone_set("UTC"); |
| 326 | 364 | $Common = new Common(); |
| 327 | 365 | if (isset($globalIVAO) && $globalIVAO) { |
@@ -332,31 +370,47 @@ discard block |
||
| 332 | 370 | $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
| 333 | 371 | } |
| 334 | 372 | if ($handle) { |
| 335 | - if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
| 373 | + if (isset($globalDebug) && $globalDebug) { |
|
| 374 | + echo "Done - Updating DB..."; |
|
| 375 | + } |
|
| 336 | 376 | $date = ''; |
| 337 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
| 377 | + if ($globalTransaction) { |
|
| 378 | + $this->db->beginTransaction(); |
|
| 379 | + } |
|
| 338 | 380 | while(($line = fgets($handle,4096)) !== false) { |
| 339 | 381 | if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
| 340 | 382 | $date = $line; |
| 341 | 383 | } elseif ($line != '') { |
| 342 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 384 | + if ($date == '') { |
|
| 385 | + $date = date('Y/m/d H:m'); |
|
| 386 | + } |
|
| 343 | 387 | $pos = 0; |
| 344 | 388 | $pieces = preg_split('/\s/',$line); |
| 345 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 346 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 389 | + if ($pieces[0] == 'METAR') { |
|
| 390 | + $pos++; |
|
| 391 | + } |
|
| 392 | + if (strlen($pieces[$pos]) != 4) { |
|
| 393 | + $pos++; |
|
| 394 | + } |
|
| 347 | 395 | $location = $pieces[$pos]; |
| 348 | 396 | echo $this->addMETAR($location,$line,$date); |
| 349 | 397 | } |
| 350 | 398 | } |
| 351 | 399 | fclose($handle); |
| 352 | - if ($globalTransaction) $this->db->commit(); |
|
| 400 | + if ($globalTransaction) { |
|
| 401 | + $this->db->commit(); |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + if (isset($globalDebug) && $globalDebug) { |
|
| 405 | + echo "Done\n"; |
|
| 353 | 406 | } |
| 354 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
| 355 | 407 | } |
| 356 | 408 | |
| 357 | 409 | public function downloadMETAR($icao) { |
| 358 | 410 | global $globalMETARurl; |
| 359 | - if ($globalMETARurl == '') return array(); |
|
| 411 | + if ($globalMETARurl == '') { |
|
| 412 | + return array(); |
|
| 413 | + } |
|
| 360 | 414 | date_default_timezone_set("UTC"); |
| 361 | 415 | $Common = new Common(); |
| 362 | 416 | $url = str_replace('{icao}',$icao,$globalMETARurl); |
@@ -367,16 +421,24 @@ discard block |
||
| 367 | 421 | $date = $line; |
| 368 | 422 | } |
| 369 | 423 | if ($line != '') { |
| 370 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 424 | + if ($date == '') { |
|
| 425 | + $date = date('Y/m/d H:m'); |
|
| 426 | + } |
|
| 371 | 427 | $pos = 0; |
| 372 | 428 | $pieces = preg_split('/\s/',$line); |
| 373 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 374 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 429 | + if ($pieces[0] == 'METAR') { |
|
| 430 | + $pos++; |
|
| 431 | + } |
|
| 432 | + if (strlen($pieces[$pos]) != 4) { |
|
| 433 | + $pos++; |
|
| 434 | + } |
|
| 375 | 435 | $location = $pieces[$pos]; |
| 376 | 436 | if (strlen($location == 4)) { |
| 377 | 437 | $this->addMETAR($location,$line,$date); |
| 378 | 438 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
| 379 | - } else return array(); |
|
| 439 | + } else { |
|
| 440 | + return array(); |
|
| 441 | + } |
|
| 380 | 442 | } |
| 381 | 443 | } |
| 382 | 444 | return array(); |