@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | /** |
16 | - * Get SQL query part for filter used |
|
17 | - * @param Array $filter the filter |
|
18 | - * @return Array the SQL part |
|
19 | - */ |
|
16 | + * Get SQL query part for filter used |
|
17 | + * @param Array $filter the filter |
|
18 | + * @return Array the SQL part |
|
19 | + */ |
|
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | - * Gets all the spotter information based on the latest data entry |
|
94 | - * |
|
95 | - * @return Array the spotter information |
|
96 | - * |
|
97 | - */ |
|
93 | + * Gets all the spotter information based on the latest data entry |
|
94 | + * |
|
95 | + * @return Array the spotter information |
|
96 | + * |
|
97 | + */ |
|
98 | 98 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
99 | 99 | { |
100 | 100 | global $globalDBdriver, $globalLiveInterval; |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | - * Gets Minimal Live Spotter data |
|
141 | - * |
|
142 | - * @return Array the spotter information |
|
143 | - * |
|
144 | - */ |
|
140 | + * Gets Minimal Live Spotter data |
|
141 | + * |
|
142 | + * @return Array the spotter information |
|
143 | + * |
|
144 | + */ |
|
145 | 145 | public function getMinLiveMarineData($filter = array()) |
146 | 146 | { |
147 | 147 | global $globalDBdriver, $globalLiveInterval; |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
174 | - * Gets Minimal Live Spotter data since xx seconds |
|
175 | - * |
|
176 | - * @return Array the spotter information |
|
177 | - * |
|
178 | - */ |
|
174 | + * Gets Minimal Live Spotter data since xx seconds |
|
175 | + * |
|
176 | + * @return Array the spotter information |
|
177 | + * |
|
178 | + */ |
|
179 | 179 | public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false) |
180 | 180 | { |
181 | 181 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
@@ -246,11 +246,11 @@ discard block |
||
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
249 | - * Gets number of latest data entry |
|
250 | - * |
|
251 | - * @return String number of entry |
|
252 | - * |
|
253 | - */ |
|
249 | + * Gets number of latest data entry |
|
250 | + * |
|
251 | + * @return String number of entry |
|
252 | + * |
|
253 | + */ |
|
254 | 254 | public function getLiveMarineCount($filter = array()) |
255 | 255 | { |
256 | 256 | global $globalDBdriver, $globalLiveInterval; |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
278 | - * Gets all the spotter information based on the latest data entry and coord |
|
279 | - * |
|
280 | - * @return Array the spotter information |
|
281 | - * |
|
282 | - */ |
|
278 | + * Gets all the spotter information based on the latest data entry and coord |
|
279 | + * |
|
280 | + * @return Array the spotter information |
|
281 | + * |
|
282 | + */ |
|
283 | 283 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
284 | 284 | { |
285 | 285 | global $globalDBdriver, $globalLiveInterval; |
@@ -303,11 +303,11 @@ discard block |
||
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
306 | - * Gets all the spotter information based on the latest data entry and coord |
|
307 | - * |
|
308 | - * @return Array the spotter information |
|
309 | - * |
|
310 | - */ |
|
306 | + * Gets all the spotter information based on the latest data entry and coord |
|
307 | + * |
|
308 | + * @return Array the spotter information |
|
309 | + * |
|
310 | + */ |
|
311 | 311 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
312 | 312 | { |
313 | 313 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -376,11 +376,11 @@ discard block |
||
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
379 | - * Gets all the spotter information based on a user's latitude and longitude |
|
380 | - * |
|
381 | - * @return Array the spotter information |
|
382 | - * |
|
383 | - */ |
|
379 | + * Gets all the spotter information based on a user's latitude and longitude |
|
380 | + * |
|
381 | + * @return Array the spotter information |
|
382 | + * |
|
383 | + */ |
|
384 | 384 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
385 | 385 | { |
386 | 386 | $Marine = new Marine($this->db); |
@@ -393,75 +393,75 @@ discard block |
||
393 | 393 | if ($lng != '') |
394 | 394 | { |
395 | 395 | if (!is_numeric($lng)) |
396 | - { |
|
397 | - return false; |
|
398 | - } |
|
399 | - } |
|
400 | - |
|
401 | - if ($radius != '') |
|
402 | - { |
|
403 | - if (!is_numeric($radius)) |
|
404 | - { |
|
405 | - return false; |
|
406 | - } |
|
407 | - } |
|
396 | + { |
|
397 | + return false; |
|
398 | + } |
|
399 | + } |
|
400 | + |
|
401 | + if ($radius != '') |
|
402 | + { |
|
403 | + if (!is_numeric($radius)) |
|
404 | + { |
|
405 | + return false; |
|
406 | + } |
|
407 | + } |
|
408 | 408 | $additional_query = ''; |
409 | 409 | if ($interval != '') |
410 | - { |
|
411 | - if (!is_string($interval)) |
|
412 | - { |
|
413 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
414 | - return false; |
|
415 | - } else { |
|
416 | - if ($interval == '1m') |
|
417 | - { |
|
418 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
419 | - } else if ($interval == '15m'){ |
|
420 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
421 | - } |
|
422 | - } |
|
423 | - } else { |
|
424 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
425 | - } |
|
426 | - |
|
427 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
410 | + { |
|
411 | + if (!is_string($interval)) |
|
412 | + { |
|
413 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
414 | + return false; |
|
415 | + } else { |
|
416 | + if ($interval == '1m') |
|
417 | + { |
|
418 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
419 | + } else if ($interval == '15m'){ |
|
420 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
421 | + } |
|
422 | + } |
|
423 | + } else { |
|
424 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
425 | + } |
|
426 | + |
|
427 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
428 | 428 | WHERE marine_live.latitude <> '' |
429 | 429 | AND marine_live.longitude <> '' |
430 | 430 | ".$additional_query." |
431 | 431 | HAVING distance < :radius |
432 | 432 | ORDER BY distance"; |
433 | 433 | |
434 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
434 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
435 | 435 | |
436 | - return $spotter_array; |
|
437 | - } |
|
436 | + return $spotter_array; |
|
437 | + } |
|
438 | 438 | |
439 | 439 | |
440 | - /** |
|
441 | - * Gets all the spotter information based on a particular callsign |
|
442 | - * |
|
443 | - * @return Array the spotter information |
|
444 | - * |
|
445 | - */ |
|
440 | + /** |
|
441 | + * Gets all the spotter information based on a particular callsign |
|
442 | + * |
|
443 | + * @return Array the spotter information |
|
444 | + * |
|
445 | + */ |
|
446 | 446 | public function getLastLiveMarineDataByIdent($ident) |
447 | 447 | { |
448 | 448 | $Marine = new Marine($this->db); |
449 | 449 | date_default_timezone_set('UTC'); |
450 | 450 | |
451 | 451 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
452 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
452 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
453 | 453 | |
454 | 454 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
455 | 455 | |
456 | 456 | return $spotter_array; |
457 | 457 | } |
458 | 458 | |
459 | - /** |
|
460 | - * Gets all the spotter information based on a particular callsign |
|
461 | - * |
|
462 | - * @return Array the spotter information |
|
463 | - * |
|
464 | - */ |
|
459 | + /** |
|
460 | + * Gets all the spotter information based on a particular callsign |
|
461 | + * |
|
462 | + * @return Array the spotter information |
|
463 | + * |
|
464 | + */ |
|
465 | 465 | public function getDateLiveMarineDataByIdent($ident,$date) |
466 | 466 | { |
467 | 467 | $Marine = new Marine($this->db); |
@@ -474,11 +474,11 @@ discard block |
||
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
477 | - * Gets all the spotter information based on a particular MMSI |
|
478 | - * |
|
479 | - * @return Array the spotter information |
|
480 | - * |
|
481 | - */ |
|
477 | + * Gets all the spotter information based on a particular MMSI |
|
478 | + * |
|
479 | + * @return Array the spotter information |
|
480 | + * |
|
481 | + */ |
|
482 | 482 | public function getDateLiveMarineDataByMMSI($mmsi,$date) |
483 | 483 | { |
484 | 484 | $Marine = new Marine($this->db); |
@@ -490,51 +490,51 @@ discard block |
||
490 | 490 | return $spotter_array; |
491 | 491 | } |
492 | 492 | |
493 | - /** |
|
494 | - * Gets last spotter information based on a particular callsign |
|
495 | - * |
|
496 | - * @return Array the spotter information |
|
497 | - * |
|
498 | - */ |
|
493 | + /** |
|
494 | + * Gets last spotter information based on a particular callsign |
|
495 | + * |
|
496 | + * @return Array the spotter information |
|
497 | + * |
|
498 | + */ |
|
499 | 499 | public function getLastLiveMarineDataById($id) |
500 | 500 | { |
501 | 501 | $Marine = new Marine($this->db); |
502 | 502 | date_default_timezone_set('UTC'); |
503 | 503 | |
504 | 504 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
505 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
505 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
506 | 506 | |
507 | 507 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
508 | 508 | |
509 | 509 | return $spotter_array; |
510 | 510 | } |
511 | 511 | |
512 | - /** |
|
513 | - * Gets last spotter information based on a particular callsign |
|
514 | - * |
|
515 | - * @return Array the spotter information |
|
516 | - * |
|
517 | - */ |
|
512 | + /** |
|
513 | + * Gets last spotter information based on a particular callsign |
|
514 | + * |
|
515 | + * @return Array the spotter information |
|
516 | + * |
|
517 | + */ |
|
518 | 518 | public function getDateLiveMarineDataById($id,$date) |
519 | 519 | { |
520 | 520 | $Marine = new Marine($this->db); |
521 | 521 | date_default_timezone_set('UTC'); |
522 | 522 | |
523 | 523 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
524 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
525 | - $date = date('c',$date); |
|
524 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
525 | + $date = date('c',$date); |
|
526 | 526 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
527 | 527 | |
528 | 528 | return $spotter_array; |
529 | 529 | } |
530 | 530 | |
531 | 531 | |
532 | - /** |
|
533 | - * Gets all the spotter information based on a particular id |
|
534 | - * |
|
535 | - * @return Array the spotter information |
|
536 | - * |
|
537 | - */ |
|
532 | + /** |
|
533 | + * Gets all the spotter information based on a particular id |
|
534 | + * |
|
535 | + * @return Array the spotter information |
|
536 | + * |
|
537 | + */ |
|
538 | 538 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
539 | 539 | { |
540 | 540 | global $globalDBdriver, $globalLiveInterval; |
@@ -562,18 +562,18 @@ discard block |
||
562 | 562 | return $spotter_array; |
563 | 563 | } |
564 | 564 | |
565 | - /** |
|
566 | - * Gets all the spotter information based on a particular ident |
|
567 | - * |
|
568 | - * @return Array the spotter information |
|
569 | - * |
|
570 | - */ |
|
565 | + /** |
|
566 | + * Gets all the spotter information based on a particular ident |
|
567 | + * |
|
568 | + * @return Array the spotter information |
|
569 | + * |
|
570 | + */ |
|
571 | 571 | public function getAllLiveMarineDataByIdent($ident) |
572 | 572 | { |
573 | 573 | date_default_timezone_set('UTC'); |
574 | 574 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
575 | 575 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
576 | - try { |
|
576 | + try { |
|
577 | 577 | |
578 | 578 | $sth = $this->db->prepare($query); |
579 | 579 | $sth->execute(array(':ident' => $ident)); |
@@ -587,23 +587,23 @@ discard block |
||
587 | 587 | |
588 | 588 | |
589 | 589 | /** |
590 | - * Deletes all info in the table |
|
591 | - * |
|
592 | - * @return String success or false |
|
593 | - * |
|
594 | - */ |
|
590 | + * Deletes all info in the table |
|
591 | + * |
|
592 | + * @return String success or false |
|
593 | + * |
|
594 | + */ |
|
595 | 595 | public function deleteLiveMarineData() |
596 | 596 | { |
597 | 597 | global $globalDBdriver; |
598 | 598 | if ($globalDBdriver == 'mysql') { |
599 | 599 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
600 | 600 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
601 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
601 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
602 | 602 | } else { |
603 | 603 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
604 | 604 | } |
605 | 605 | |
606 | - try { |
|
606 | + try { |
|
607 | 607 | |
608 | 608 | $sth = $this->db->prepare($query); |
609 | 609 | $sth->execute(); |
@@ -615,18 +615,18 @@ discard block |
||
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
618 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
619 | - * |
|
620 | - * @return String success or false |
|
621 | - * |
|
622 | - */ |
|
618 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
619 | + * |
|
620 | + * @return String success or false |
|
621 | + * |
|
622 | + */ |
|
623 | 623 | public function deleteLiveMarineDataNotUpdated() |
624 | 624 | { |
625 | 625 | global $globalDBdriver, $globalDebug; |
626 | 626 | if ($globalDBdriver == 'mysql') { |
627 | 627 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
628 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
629 | - try { |
|
628 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
629 | + try { |
|
630 | 630 | |
631 | 631 | $sth = $this->db->prepare($query); |
632 | 632 | $sth->execute(); |
@@ -634,8 +634,8 @@ discard block |
||
634 | 634 | return "error"; |
635 | 635 | } |
636 | 636 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
637 | - $i = 0; |
|
638 | - $j =0; |
|
637 | + $i = 0; |
|
638 | + $j =0; |
|
639 | 639 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
640 | 640 | foreach($all as $row) |
641 | 641 | { |
@@ -643,20 +643,20 @@ discard block |
||
643 | 643 | $j++; |
644 | 644 | if ($j == 30) { |
645 | 645 | if ($globalDebug) echo "."; |
646 | - try { |
|
646 | + try { |
|
647 | 647 | |
648 | 648 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
649 | 649 | $sth->execute(); |
650 | 650 | } catch(PDOException $e) { |
651 | 651 | return "error"; |
652 | 652 | } |
653 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
654 | - $j = 0; |
|
653 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
654 | + $j = 0; |
|
655 | 655 | } |
656 | 656 | $query_delete .= "'".$row['fammarine_id']."',"; |
657 | 657 | } |
658 | 658 | if ($i > 0) { |
659 | - try { |
|
659 | + try { |
|
660 | 660 | |
661 | 661 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
662 | 662 | $sth->execute(); |
@@ -667,9 +667,9 @@ discard block |
||
667 | 667 | return "success"; |
668 | 668 | } elseif ($globalDBdriver == 'pgsql') { |
669 | 669 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
670 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
671 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
672 | - try { |
|
670 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
671 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
672 | + try { |
|
673 | 673 | |
674 | 674 | $sth = $this->db->prepare($query); |
675 | 675 | $sth->execute(); |
@@ -713,17 +713,17 @@ discard block |
||
713 | 713 | } |
714 | 714 | |
715 | 715 | /** |
716 | - * Deletes all info in the table for an ident |
|
717 | - * |
|
718 | - * @return String success or false |
|
719 | - * |
|
720 | - */ |
|
716 | + * Deletes all info in the table for an ident |
|
717 | + * |
|
718 | + * @return String success or false |
|
719 | + * |
|
720 | + */ |
|
721 | 721 | public function deleteLiveMarineDataByIdent($ident) |
722 | 722 | { |
723 | 723 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
724 | 724 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
725 | 725 | |
726 | - try { |
|
726 | + try { |
|
727 | 727 | |
728 | 728 | $sth = $this->db->prepare($query); |
729 | 729 | $sth->execute(array(':ident' => $ident)); |
@@ -735,17 +735,17 @@ discard block |
||
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
738 | - * Deletes all info in the table for an id |
|
739 | - * |
|
740 | - * @return String success or false |
|
741 | - * |
|
742 | - */ |
|
738 | + * Deletes all info in the table for an id |
|
739 | + * |
|
740 | + * @return String success or false |
|
741 | + * |
|
742 | + */ |
|
743 | 743 | public function deleteLiveMarineDataById($id) |
744 | 744 | { |
745 | 745 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
746 | 746 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
747 | 747 | |
748 | - try { |
|
748 | + try { |
|
749 | 749 | |
750 | 750 | $sth = $this->db->prepare($query); |
751 | 751 | $sth->execute(array(':id' => $id)); |
@@ -758,11 +758,11 @@ discard block |
||
758 | 758 | |
759 | 759 | |
760 | 760 | /** |
761 | - * Gets the aircraft ident within the last hour |
|
762 | - * |
|
763 | - * @return String the ident |
|
764 | - * |
|
765 | - */ |
|
761 | + * Gets the aircraft ident within the last hour |
|
762 | + * |
|
763 | + * @return String the ident |
|
764 | + * |
|
765 | + */ |
|
766 | 766 | public function getIdentFromLastHour($ident) |
767 | 767 | { |
768 | 768 | global $globalDBdriver, $globalTimezone; |
@@ -788,14 +788,14 @@ discard block |
||
788 | 788 | $ident_result = $row['ident']; |
789 | 789 | } |
790 | 790 | return $ident_result; |
791 | - } |
|
791 | + } |
|
792 | 792 | |
793 | 793 | /** |
794 | - * Check recent aircraft |
|
795 | - * |
|
796 | - * @return String the ident |
|
797 | - * |
|
798 | - */ |
|
794 | + * Check recent aircraft |
|
795 | + * |
|
796 | + * @return String the ident |
|
797 | + * |
|
798 | + */ |
|
799 | 799 | public function checkIdentRecent($ident) |
800 | 800 | { |
801 | 801 | global $globalDBdriver, $globalTimezone; |
@@ -821,14 +821,14 @@ discard block |
||
821 | 821 | $ident_result = $row['fammarine_id']; |
822 | 822 | } |
823 | 823 | return $ident_result; |
824 | - } |
|
824 | + } |
|
825 | 825 | |
826 | 826 | /** |
827 | - * Check recent aircraft by id |
|
828 | - * |
|
829 | - * @return String the ident |
|
830 | - * |
|
831 | - */ |
|
827 | + * Check recent aircraft by id |
|
828 | + * |
|
829 | + * @return String the ident |
|
830 | + * |
|
831 | + */ |
|
832 | 832 | public function checkIdRecent($id) |
833 | 833 | { |
834 | 834 | global $globalDBdriver, $globalTimezone; |
@@ -854,14 +854,14 @@ discard block |
||
854 | 854 | $ident_result = $row['fammarine_id']; |
855 | 855 | } |
856 | 856 | return $ident_result; |
857 | - } |
|
857 | + } |
|
858 | 858 | |
859 | 859 | /** |
860 | - * Check recent aircraft by mmsi |
|
861 | - * |
|
862 | - * @return String the ident |
|
863 | - * |
|
864 | - */ |
|
860 | + * Check recent aircraft by mmsi |
|
861 | + * |
|
862 | + * @return String the ident |
|
863 | + * |
|
864 | + */ |
|
865 | 865 | public function checkMMSIRecent($mmsi) |
866 | 866 | { |
867 | 867 | global $globalDBdriver, $globalTimezone; |
@@ -887,19 +887,19 @@ discard block |
||
887 | 887 | $ident_result = $row['fammarine_id']; |
888 | 888 | } |
889 | 889 | return $ident_result; |
890 | - } |
|
890 | + } |
|
891 | 891 | |
892 | 892 | /** |
893 | - * Adds a new spotter data |
|
894 | - * |
|
895 | - * @param String $fammarine_id the ID from flightaware |
|
896 | - * @param String $ident the flight ident |
|
897 | - * @param String $aircraft_icao the aircraft type |
|
898 | - * @param String $departure_airport_icao the departure airport |
|
899 | - * @param String $arrival_airport_icao the arrival airport |
|
900 | - * @return String success or false |
|
901 | - * |
|
902 | - */ |
|
893 | + * Adds a new spotter data |
|
894 | + * |
|
895 | + * @param String $fammarine_id the ID from flightaware |
|
896 | + * @param String $ident the flight ident |
|
897 | + * @param String $aircraft_icao the aircraft type |
|
898 | + * @param String $departure_airport_icao the departure airport |
|
899 | + * @param String $arrival_airport_icao the arrival airport |
|
900 | + * @return String success or false |
|
901 | + * |
|
902 | + */ |
|
903 | 903 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
904 | 904 | { |
905 | 905 | global $globalURL, $globalArchive, $globalDebug; |
@@ -973,10 +973,10 @@ discard block |
||
973 | 973 | if ($typeid == '') $typeid = NULL; |
974 | 974 | if ($statusid == '') $statusid = NULL; |
975 | 975 | |
976 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
977 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
978 | - if ($arrival_date == '') $arrival_date = NULL; |
|
979 | - $query = ''; |
|
976 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
977 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
978 | + if ($arrival_date == '') $arrival_date = NULL; |
|
979 | + $query = ''; |
|
980 | 980 | if ($globalArchive) { |
981 | 981 | if ($globalDebug) echo '-- Delete previous data -- '; |
982 | 982 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
@@ -21,18 +21,18 @@ discard block |
||
21 | 21 | print '<div class="select-item">'; |
22 | 22 | print '<form action="'.$globalURL.'/aircraft" method="get">'; |
23 | 23 | print '<select name="aircraft_type" class="selectpicker" data-live-search="true">'; |
24 | - print '<option></option>'; |
|
25 | - $Stats = new Stats(); |
|
26 | - $aircraft_types = $Stats->getAllAircraftTypes(); |
|
27 | - if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
28 | - foreach($aircraft_types as $aircrafttype) |
|
29 | - { |
|
30 | - if($aircraft_type == $aircrafttype['aircraft_icao']) |
|
31 | - { |
|
32 | - print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
|
33 | - } else { |
|
34 | - print '<option value="'.$aircrafttype['aircraft_icao'].'">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
|
35 | - } |
|
24 | + print '<option></option>'; |
|
25 | + $Stats = new Stats(); |
|
26 | + $aircraft_types = $Stats->getAllAircraftTypes(); |
|
27 | + if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
28 | + foreach($aircraft_types as $aircrafttype) |
|
29 | + { |
|
30 | + if($aircraft_type == $aircrafttype['aircraft_icao']) |
|
31 | + { |
|
32 | + print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
|
33 | + } else { |
|
34 | + print '<option value="'.$aircrafttype['aircraft_icao'].'">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | print '</select>'; |
38 | 38 | print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>'; |
@@ -61,18 +61,18 @@ discard block |
||
61 | 61 | print '<script type="text/javascript" src="'.$globalURL.'/js/datamaps.world.min.js"></script>'; |
62 | 62 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
63 | 63 | print 'var series = ['; |
64 | - $country_data = ''; |
|
64 | + $country_data = ''; |
|
65 | 65 | foreach($airline_array as $airline_item) |
66 | 66 | { |
67 | 67 | $country_data .= '[ "'.$airline_item['airline_country_iso3'].'",'.$airline_item['airline_country_count'].'],'; |
68 | 68 | } |
69 | - $country_data = substr($country_data, 0, -1); |
|
70 | - print $country_data; |
|
71 | - print '];'; |
|
72 | - print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
73 | - print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'; |
|
74 | - print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});'; |
|
75 | - print 'new Datamap({ |
|
69 | + $country_data = substr($country_data, 0, -1); |
|
70 | + print $country_data; |
|
71 | + print '];'; |
|
72 | + print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
73 | + print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'; |
|
74 | + print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});'; |
|
75 | + print 'new Datamap({ |
|
76 | 76 | element: document.getElementById("chartCountry"), |
77 | 77 | projection: "mercator", // big world map |
78 | 78 | fills: { defaultFill: "#F5F5F5" }, |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | |
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | - * Executes the SQL statements to get the spotter information |
|
86 | - * |
|
87 | - * @param String $query the SQL query |
|
88 | - * @param Array $params parameter of the query |
|
89 | - * @param String $limitQuery the limit query |
|
90 | - * @return Array the spotter information |
|
91 | - * |
|
92 | - */ |
|
85 | + * Executes the SQL statements to get the spotter information |
|
86 | + * |
|
87 | + * @param String $query the SQL query |
|
88 | + * @param Array $params parameter of the query |
|
89 | + * @param String $limitQuery the limit query |
|
90 | + * @return Array the spotter information |
|
91 | + * |
|
92 | + */ |
|
93 | 93 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
94 | 94 | { |
95 | 95 | date_default_timezone_set('UTC'); |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | |
221 | 221 | |
222 | 222 | /** |
223 | - * Gets all the spotter information based on the latest data entry |
|
224 | - * |
|
225 | - * @return Array the spotter information |
|
226 | - * |
|
227 | - */ |
|
223 | + * Gets all the spotter information based on the latest data entry |
|
224 | + * |
|
225 | + * @return Array the spotter information |
|
226 | + * |
|
227 | + */ |
|
228 | 228 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
229 | 229 | { |
230 | 230 | global $global_query; |
@@ -273,11 +273,11 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
276 | - * Gets all the spotter information based on the callsign |
|
277 | - * |
|
278 | - * @return Array the spotter information |
|
279 | - * |
|
280 | - */ |
|
276 | + * Gets all the spotter information based on the callsign |
|
277 | + * |
|
278 | + * @return Array the spotter information |
|
279 | + * |
|
280 | + */ |
|
281 | 281 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
282 | 282 | { |
283 | 283 | global $global_query; |
@@ -329,11 +329,11 @@ discard block |
||
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
332 | - * Gets all the marine information based on the type |
|
333 | - * |
|
334 | - * @return Array the marine information |
|
335 | - * |
|
336 | - */ |
|
332 | + * Gets all the marine information based on the type |
|
333 | + * |
|
334 | + * @return Array the marine information |
|
335 | + * |
|
336 | + */ |
|
337 | 337 | public function getMarineDataByType($type = '', $limit = '', $sort = '', $filter = array()) |
338 | 338 | { |
339 | 339 | global $global_query; |
@@ -441,12 +441,12 @@ discard block |
||
441 | 441 | |
442 | 442 | |
443 | 443 | /** |
444 | - * Gets all source name |
|
445 | - * |
|
446 | - * @param String type format of source |
|
447 | - * @return Array list of source name |
|
448 | - * |
|
449 | - */ |
|
444 | + * Gets all source name |
|
445 | + * |
|
446 | + * @param String type format of source |
|
447 | + * @return Array list of source name |
|
448 | + * |
|
449 | + */ |
|
450 | 450 | public function getAllSourceName($type = '',$filters = array()) |
451 | 451 | { |
452 | 452 | $filter_query = $this->getFilter($filters,true,true); |
@@ -476,11 +476,11 @@ discard block |
||
476 | 476 | |
477 | 477 | |
478 | 478 | /** |
479 | - * Gets a list of all idents/callsigns |
|
480 | - * |
|
481 | - * @return Array list of ident/callsign names |
|
482 | - * |
|
483 | - */ |
|
479 | + * Gets a list of all idents/callsigns |
|
480 | + * |
|
481 | + * @return Array list of ident/callsign names |
|
482 | + * |
|
483 | + */ |
|
484 | 484 | public function getAllIdents($filters = array()) |
485 | 485 | { |
486 | 486 | $filter_query = $this->getFilter($filters,true,true); |
@@ -504,11 +504,11 @@ discard block |
||
504 | 504 | } |
505 | 505 | |
506 | 506 | /** |
507 | - * Gets all info from a mmsi |
|
508 | - * |
|
509 | - * @return Array ident |
|
510 | - * |
|
511 | - */ |
|
507 | + * Gets all info from a mmsi |
|
508 | + * |
|
509 | + * @return Array ident |
|
510 | + * |
|
511 | + */ |
|
512 | 512 | public function getIdentity($mmsi) |
513 | 513 | { |
514 | 514 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -521,9 +521,9 @@ discard block |
||
521 | 521 | } |
522 | 522 | |
523 | 523 | /** |
524 | - * Add identity |
|
525 | - * |
|
526 | - */ |
|
524 | + * Add identity |
|
525 | + * |
|
526 | + */ |
|
527 | 527 | public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
528 | 528 | { |
529 | 529 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -589,13 +589,13 @@ discard block |
||
589 | 589 | } |
590 | 590 | |
591 | 591 | /** |
592 | - * Update ident tracker data |
|
593 | - * |
|
594 | - * @param String $fammarine_id the ID |
|
595 | - * @param String $ident the marine ident |
|
596 | - * @return String success or false |
|
597 | - * |
|
598 | - */ |
|
592 | + * Update ident tracker data |
|
593 | + * |
|
594 | + * @param String $fammarine_id the ID |
|
595 | + * @param String $ident the marine ident |
|
596 | + * @return String success or false |
|
597 | + * |
|
598 | + */ |
|
599 | 599 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
600 | 600 | { |
601 | 601 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
@@ -610,13 +610,13 @@ discard block |
||
610 | 610 | } |
611 | 611 | |
612 | 612 | /** |
613 | - * Update arrival marine data |
|
614 | - * |
|
615 | - * @param String $fammarine_id the ID |
|
616 | - * @param String $arrival_code the marine ident |
|
617 | - * @return String success or false |
|
618 | - * |
|
619 | - */ |
|
613 | + * Update arrival marine data |
|
614 | + * |
|
615 | + * @param String $fammarine_id the ID |
|
616 | + * @param String $arrival_code the marine ident |
|
617 | + * @return String success or false |
|
618 | + * |
|
619 | + */ |
|
620 | 620 | public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
621 | 621 | { |
622 | 622 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
@@ -631,19 +631,19 @@ discard block |
||
631 | 631 | } |
632 | 632 | |
633 | 633 | /** |
634 | - * Update Status data |
|
635 | - * |
|
636 | - * @param String $fammarine_id the ID |
|
637 | - * @param String $status_id the marine status id |
|
638 | - * @param String $status the marine status |
|
639 | - * @return String success or false |
|
640 | - * |
|
641 | - */ |
|
634 | + * Update Status data |
|
635 | + * |
|
636 | + * @param String $fammarine_id the ID |
|
637 | + * @param String $status_id the marine status id |
|
638 | + * @param String $status the marine status |
|
639 | + * @return String success or false |
|
640 | + * |
|
641 | + */ |
|
642 | 642 | public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
643 | 643 | { |
644 | 644 | |
645 | 645 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
646 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
646 | + $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
647 | 647 | |
648 | 648 | try { |
649 | 649 | $sth = $this->db->prepare($query); |
@@ -656,17 +656,17 @@ discard block |
||
656 | 656 | |
657 | 657 | } |
658 | 658 | /** |
659 | - * Update latest marine data |
|
660 | - * |
|
661 | - * @param String $fammarine_id the ID |
|
662 | - * @param String $ident the marine ident |
|
663 | - * @return String success or false |
|
664 | - * |
|
665 | - */ |
|
659 | + * Update latest marine data |
|
660 | + * |
|
661 | + * @param String $fammarine_id the ID |
|
662 | + * @param String $ident the marine ident |
|
663 | + * @return String success or false |
|
664 | + * |
|
665 | + */ |
|
666 | 666 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
667 | 667 | { |
668 | 668 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
669 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
669 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
670 | 670 | |
671 | 671 | try { |
672 | 672 | $sth = $this->db->prepare($query); |
@@ -680,30 +680,30 @@ discard block |
||
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
683 | - * Adds a new spotter data |
|
684 | - * |
|
685 | - * @param String $fammarine_id the ID |
|
686 | - * @param String $ident the marine ident |
|
687 | - * @param String $departure_airport_icao the departure airport |
|
688 | - * @param String $arrival_airport_icao the arrival airport |
|
689 | - * @param String $latitude latitude of flight |
|
690 | - * @param String $longitude latitude of flight |
|
691 | - * @param String $waypoints waypoints of flight |
|
692 | - * @param String $heading heading of flight |
|
693 | - * @param String $groundspeed speed of flight |
|
694 | - * @param String $date date of flight |
|
695 | - * @param String $departure_airport_time departure time of flight |
|
696 | - * @param String $arrival_airport_time arrival time of flight |
|
697 | - * @param String $squawk squawk code of flight |
|
698 | - * @param String $route_stop route stop of flight |
|
699 | - * @param String $highlight highlight or not |
|
700 | - * @param String $ModeS ModesS code of flight |
|
701 | - * @param String $registration registration code of flight |
|
702 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
703 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
704 | - * @param String $verticalrate vertival rate of flight |
|
705 | - * @return String success or false |
|
706 | - */ |
|
683 | + * Adds a new spotter data |
|
684 | + * |
|
685 | + * @param String $fammarine_id the ID |
|
686 | + * @param String $ident the marine ident |
|
687 | + * @param String $departure_airport_icao the departure airport |
|
688 | + * @param String $arrival_airport_icao the arrival airport |
|
689 | + * @param String $latitude latitude of flight |
|
690 | + * @param String $longitude latitude of flight |
|
691 | + * @param String $waypoints waypoints of flight |
|
692 | + * @param String $heading heading of flight |
|
693 | + * @param String $groundspeed speed of flight |
|
694 | + * @param String $date date of flight |
|
695 | + * @param String $departure_airport_time departure time of flight |
|
696 | + * @param String $arrival_airport_time arrival time of flight |
|
697 | + * @param String $squawk squawk code of flight |
|
698 | + * @param String $route_stop route stop of flight |
|
699 | + * @param String $highlight highlight or not |
|
700 | + * @param String $ModeS ModesS code of flight |
|
701 | + * @param String $registration registration code of flight |
|
702 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
703 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
704 | + * @param String $verticalrate vertival rate of flight |
|
705 | + * @return String success or false |
|
706 | + */ |
|
707 | 707 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
708 | 708 | { |
709 | 709 | global $globalURL, $globalMarineImageFetch; |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | $sth->execute($query_values); |
819 | 819 | $this->db = null; |
820 | 820 | } catch (PDOException $e) { |
821 | - return "error : ".$e->getMessage(); |
|
821 | + return "error : ".$e->getMessage(); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | return "success"; |
@@ -827,11 +827,11 @@ discard block |
||
827 | 827 | |
828 | 828 | |
829 | 829 | /** |
830 | - * Gets the aircraft ident within the last hour |
|
831 | - * |
|
832 | - * @return String the ident |
|
833 | - * |
|
834 | - */ |
|
830 | + * Gets the aircraft ident within the last hour |
|
831 | + * |
|
832 | + * @return String the ident |
|
833 | + * |
|
834 | + */ |
|
835 | 835 | public function getIdentFromLastHour($ident) |
836 | 836 | { |
837 | 837 | global $globalDBdriver, $globalTimezone; |
@@ -847,11 +847,11 @@ discard block |
||
847 | 847 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
848 | 848 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
849 | 849 | $query_data = array(':ident' => $ident); |
850 | - } |
|
850 | + } |
|
851 | 851 | |
852 | 852 | $sth = $this->db->prepare($query); |
853 | 853 | $sth->execute($query_data); |
854 | - $ident_result=''; |
|
854 | + $ident_result=''; |
|
855 | 855 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
856 | 856 | { |
857 | 857 | $ident_result = $row['ident']; |
@@ -862,11 +862,11 @@ discard block |
||
862 | 862 | |
863 | 863 | |
864 | 864 | /** |
865 | - * Gets the aircraft data from the last 20 seconds |
|
866 | - * |
|
867 | - * @return Array the spotter data |
|
868 | - * |
|
869 | - */ |
|
865 | + * Gets the aircraft data from the last 20 seconds |
|
866 | + * |
|
867 | + * @return Array the spotter data |
|
868 | + * |
|
869 | + */ |
|
870 | 870 | public function getRealTimeData($q = '') |
871 | 871 | { |
872 | 872 | global $globalDBdriver; |
@@ -904,11 +904,11 @@ discard block |
||
904 | 904 | |
905 | 905 | |
906 | 906 | /** |
907 | - * Gets all number of flight over countries |
|
908 | - * |
|
909 | - * @return Array the airline country list |
|
910 | - * |
|
911 | - */ |
|
907 | + * Gets all number of flight over countries |
|
908 | + * |
|
909 | + * @return Array the airline country list |
|
910 | + * |
|
911 | + */ |
|
912 | 912 | |
913 | 913 | public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
914 | 914 | { |
@@ -981,11 +981,11 @@ discard block |
||
981 | 981 | |
982 | 982 | |
983 | 983 | /** |
984 | - * Gets all callsigns that have flown over |
|
985 | - * |
|
986 | - * @return Array the callsign list |
|
987 | - * |
|
988 | - */ |
|
984 | + * Gets all callsigns that have flown over |
|
985 | + * |
|
986 | + * @return Array the callsign list |
|
987 | + * |
|
988 | + */ |
|
989 | 989 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
990 | 990 | { |
991 | 991 | global $globalDBdriver; |
@@ -1052,11 +1052,11 @@ discard block |
||
1052 | 1052 | |
1053 | 1053 | |
1054 | 1054 | /** |
1055 | - * Counts all dates |
|
1056 | - * |
|
1057 | - * @return Array the date list |
|
1058 | - * |
|
1059 | - */ |
|
1055 | + * Counts all dates |
|
1056 | + * |
|
1057 | + * @return Array the date list |
|
1058 | + * |
|
1059 | + */ |
|
1060 | 1060 | public function countAllDates($filters = array()) |
1061 | 1061 | { |
1062 | 1062 | global $globalTimezone, $globalDBdriver; |
@@ -1102,11 +1102,11 @@ discard block |
||
1102 | 1102 | |
1103 | 1103 | |
1104 | 1104 | /** |
1105 | - * Counts all dates during the last 7 days |
|
1106 | - * |
|
1107 | - * @return Array the date list |
|
1108 | - * |
|
1109 | - */ |
|
1105 | + * Counts all dates during the last 7 days |
|
1106 | + * |
|
1107 | + * @return Array the date list |
|
1108 | + * |
|
1109 | + */ |
|
1110 | 1110 | public function countAllDatesLast7Days($filters = array()) |
1111 | 1111 | { |
1112 | 1112 | global $globalTimezone, $globalDBdriver; |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | $query .= " GROUP BY date_name |
1129 | 1129 | ORDER BY date_name ASC"; |
1130 | 1130 | $query_data = array(':offset' => $offset); |
1131 | - } |
|
1131 | + } |
|
1132 | 1132 | |
1133 | 1133 | $sth = $this->db->prepare($query); |
1134 | 1134 | $sth->execute($query_data); |
@@ -1148,11 +1148,11 @@ discard block |
||
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | /** |
1151 | - * Counts all dates during the last month |
|
1152 | - * |
|
1153 | - * @return Array the date list |
|
1154 | - * |
|
1155 | - */ |
|
1151 | + * Counts all dates during the last month |
|
1152 | + * |
|
1153 | + * @return Array the date list |
|
1154 | + * |
|
1155 | + */ |
|
1156 | 1156 | public function countAllDatesLastMonth($filters = array()) |
1157 | 1157 | { |
1158 | 1158 | global $globalTimezone, $globalDBdriver; |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | $query .= " GROUP BY date_name |
1175 | 1175 | ORDER BY date_name ASC"; |
1176 | 1176 | $query_data = array(':offset' => $offset); |
1177 | - } |
|
1177 | + } |
|
1178 | 1178 | |
1179 | 1179 | $sth = $this->db->prepare($query); |
1180 | 1180 | $sth->execute($query_data); |
@@ -1196,11 +1196,11 @@ discard block |
||
1196 | 1196 | |
1197 | 1197 | |
1198 | 1198 | /** |
1199 | - * Counts all month |
|
1200 | - * |
|
1201 | - * @return Array the month list |
|
1202 | - * |
|
1203 | - */ |
|
1199 | + * Counts all month |
|
1200 | + * |
|
1201 | + * @return Array the month list |
|
1202 | + * |
|
1203 | + */ |
|
1204 | 1204 | public function countAllMonths($filters = array()) |
1205 | 1205 | { |
1206 | 1206 | global $globalTimezone, $globalDBdriver; |
@@ -1245,11 +1245,11 @@ discard block |
||
1245 | 1245 | |
1246 | 1246 | |
1247 | 1247 | /** |
1248 | - * Counts all dates during the last year |
|
1249 | - * |
|
1250 | - * @return Array the date list |
|
1251 | - * |
|
1252 | - */ |
|
1248 | + * Counts all dates during the last year |
|
1249 | + * |
|
1250 | + * @return Array the date list |
|
1251 | + * |
|
1252 | + */ |
|
1253 | 1253 | public function countAllMonthsLastYear($filters) |
1254 | 1254 | { |
1255 | 1255 | global $globalTimezone, $globalDBdriver; |
@@ -1271,7 +1271,7 @@ discard block |
||
1271 | 1271 | $query .= " GROUP BY year_name, month_name |
1272 | 1272 | ORDER BY year_name, month_name ASC"; |
1273 | 1273 | $query_data = array(':offset' => $offset); |
1274 | - } |
|
1274 | + } |
|
1275 | 1275 | |
1276 | 1276 | $sth = $this->db->prepare($query); |
1277 | 1277 | $sth->execute($query_data); |
@@ -1294,11 +1294,11 @@ discard block |
||
1294 | 1294 | |
1295 | 1295 | |
1296 | 1296 | /** |
1297 | - * Counts all hours |
|
1298 | - * |
|
1299 | - * @return Array the hour list |
|
1300 | - * |
|
1301 | - */ |
|
1297 | + * Counts all hours |
|
1298 | + * |
|
1299 | + * @return Array the hour list |
|
1300 | + * |
|
1301 | + */ |
|
1302 | 1302 | public function countAllHours($orderby,$filters = array()) |
1303 | 1303 | { |
1304 | 1304 | global $globalTimezone, $globalDBdriver; |
@@ -1361,11 +1361,11 @@ discard block |
||
1361 | 1361 | |
1362 | 1362 | |
1363 | 1363 | /** |
1364 | - * Counts all hours by date |
|
1365 | - * |
|
1366 | - * @return Array the hour list |
|
1367 | - * |
|
1368 | - */ |
|
1364 | + * Counts all hours by date |
|
1365 | + * |
|
1366 | + * @return Array the hour list |
|
1367 | + * |
|
1368 | + */ |
|
1369 | 1369 | public function countAllHoursByDate($date, $filters = array()) |
1370 | 1370 | { |
1371 | 1371 | global $globalTimezone, $globalDBdriver; |
@@ -1409,11 +1409,11 @@ discard block |
||
1409 | 1409 | |
1410 | 1410 | |
1411 | 1411 | /** |
1412 | - * Counts all hours by a ident/callsign |
|
1413 | - * |
|
1414 | - * @return Array the hour list |
|
1415 | - * |
|
1416 | - */ |
|
1412 | + * Counts all hours by a ident/callsign |
|
1413 | + * |
|
1414 | + * @return Array the hour list |
|
1415 | + * |
|
1416 | + */ |
|
1417 | 1417 | public function countAllHoursByIdent($ident, $filters = array()) |
1418 | 1418 | { |
1419 | 1419 | global $globalTimezone, $globalDBdriver; |
@@ -1458,11 +1458,11 @@ discard block |
||
1458 | 1458 | |
1459 | 1459 | |
1460 | 1460 | /** |
1461 | - * Counts all vessels |
|
1462 | - * |
|
1463 | - * @return Integer the number of vessels |
|
1464 | - * |
|
1465 | - */ |
|
1461 | + * Counts all vessels |
|
1462 | + * |
|
1463 | + * @return Integer the number of vessels |
|
1464 | + * |
|
1465 | + */ |
|
1466 | 1466 | public function countOverallMarine($filters = array(),$year = '',$month = '') |
1467 | 1467 | { |
1468 | 1468 | global $globalDBdriver; |
@@ -1497,11 +1497,11 @@ discard block |
||
1497 | 1497 | } |
1498 | 1498 | |
1499 | 1499 | /** |
1500 | - * Counts all vessel type |
|
1501 | - * |
|
1502 | - * @return Integer the number of vessels |
|
1503 | - * |
|
1504 | - */ |
|
1500 | + * Counts all vessel type |
|
1501 | + * |
|
1502 | + * @return Integer the number of vessels |
|
1503 | + * |
|
1504 | + */ |
|
1505 | 1505 | public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
1506 | 1506 | { |
1507 | 1507 | global $globalDBdriver; |
@@ -1536,11 +1536,11 @@ discard block |
||
1536 | 1536 | |
1537 | 1537 | |
1538 | 1538 | /** |
1539 | - * Counts all hours of today |
|
1540 | - * |
|
1541 | - * @return Array the hour list |
|
1542 | - * |
|
1543 | - */ |
|
1539 | + * Counts all hours of today |
|
1540 | + * |
|
1541 | + * @return Array the hour list |
|
1542 | + * |
|
1543 | + */ |
|
1544 | 1544 | public function countAllHoursFromToday($filters = array()) |
1545 | 1545 | { |
1546 | 1546 | global $globalTimezone, $globalDBdriver; |
@@ -1580,12 +1580,12 @@ discard block |
||
1580 | 1580 | } |
1581 | 1581 | |
1582 | 1582 | |
1583 | - /** |
|
1584 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1585 | - * |
|
1586 | - * @return Integer the Barrie Spotter ID |
|
1583 | + /** |
|
1584 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1585 | + * |
|
1586 | + * @return Integer the Barrie Spotter ID |
|
1587 | 1587 | q * |
1588 | - */ |
|
1588 | + */ |
|
1589 | 1589 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1590 | 1590 | { |
1591 | 1591 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1606,13 +1606,13 @@ discard block |
||
1606 | 1606 | |
1607 | 1607 | |
1608 | 1608 | /** |
1609 | - * Parses a date string |
|
1610 | - * |
|
1611 | - * @param String $dateString the date string |
|
1612 | - * @param String $timezone the timezone of a user |
|
1613 | - * @return Array the time information |
|
1614 | - * |
|
1615 | - */ |
|
1609 | + * Parses a date string |
|
1610 | + * |
|
1611 | + * @param String $dateString the date string |
|
1612 | + * @param String $timezone the timezone of a user |
|
1613 | + * @return Array the time information |
|
1614 | + * |
|
1615 | + */ |
|
1616 | 1616 | public function parseDateString($dateString, $timezone = '') |
1617 | 1617 | { |
1618 | 1618 | $time_array = array(); |
@@ -1645,12 +1645,12 @@ discard block |
||
1645 | 1645 | } |
1646 | 1646 | |
1647 | 1647 | /** |
1648 | - * Parses the direction degrees to working |
|
1649 | - * |
|
1650 | - * @param Float $direction the direction in degrees |
|
1651 | - * @return Array the direction information |
|
1652 | - * |
|
1653 | - */ |
|
1648 | + * Parses the direction degrees to working |
|
1649 | + * |
|
1650 | + * @param Float $direction the direction in degrees |
|
1651 | + * @return Array the direction information |
|
1652 | + * |
|
1653 | + */ |
|
1654 | 1654 | public function parseDirection($direction = 0) |
1655 | 1655 | { |
1656 | 1656 | if ($direction == '') $direction = 0; |
@@ -1729,12 +1729,12 @@ discard block |
||
1729 | 1729 | |
1730 | 1730 | |
1731 | 1731 | /** |
1732 | - * Gets Country from latitude/longitude |
|
1733 | - * |
|
1734 | - * @param Float $latitude latitute of the flight |
|
1735 | - * @param Float $longitude longitute of the flight |
|
1736 | - * @return String the countrie |
|
1737 | - */ |
|
1732 | + * Gets Country from latitude/longitude |
|
1733 | + * |
|
1734 | + * @param Float $latitude latitute of the flight |
|
1735 | + * @param Float $longitude longitute of the flight |
|
1736 | + * @return String the countrie |
|
1737 | + */ |
|
1738 | 1738 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
1739 | 1739 | { |
1740 | 1740 | global $globalDBdriver, $globalDebug; |
@@ -1771,11 +1771,11 @@ discard block |
||
1771 | 1771 | } |
1772 | 1772 | |
1773 | 1773 | /** |
1774 | - * Gets Country from iso2 |
|
1775 | - * |
|
1776 | - * @param String $iso2 ISO2 country code |
|
1777 | - * @return String the countrie |
|
1778 | - */ |
|
1774 | + * Gets Country from iso2 |
|
1775 | + * |
|
1776 | + * @param String $iso2 ISO2 country code |
|
1777 | + * @return String the countrie |
|
1778 | + */ |
|
1779 | 1779 | public function getCountryFromISO2($iso2) |
1780 | 1780 | { |
1781 | 1781 | global $globalDBdriver, $globalDebug; |
@@ -1804,12 +1804,12 @@ discard block |
||
1804 | 1804 | |
1805 | 1805 | |
1806 | 1806 | /** |
1807 | - * Gets the short url from bit.ly |
|
1808 | - * |
|
1809 | - * @param String $url the full url |
|
1810 | - * @return String the bit.ly url |
|
1811 | - * |
|
1812 | - */ |
|
1807 | + * Gets the short url from bit.ly |
|
1808 | + * |
|
1809 | + * @param String $url the full url |
|
1810 | + * @return String the bit.ly url |
|
1811 | + * |
|
1812 | + */ |
|
1813 | 1813 | public function getBitlyURL($url) |
1814 | 1814 | { |
1815 | 1815 | global $globalBitlyAccessToken; |
@@ -1836,11 +1836,11 @@ discard block |
||
1836 | 1836 | |
1837 | 1837 | |
1838 | 1838 | /** |
1839 | - * Gets all vessels types that have flown over |
|
1840 | - * |
|
1841 | - * @return Array the vessel type list |
|
1842 | - * |
|
1843 | - */ |
|
1839 | + * Gets all vessels types that have flown over |
|
1840 | + * |
|
1841 | + * @return Array the vessel type list |
|
1842 | + * |
|
1843 | + */ |
|
1844 | 1844 | public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
1845 | 1845 | { |
1846 | 1846 | global $globalDBdriver; |
@@ -1906,11 +1906,11 @@ discard block |
||
1906 | 1906 | } |
1907 | 1907 | |
1908 | 1908 | /** |
1909 | - * Gets all the tracker information |
|
1910 | - * |
|
1911 | - * @return Array the tracker information |
|
1912 | - * |
|
1913 | - */ |
|
1909 | + * Gets all the tracker information |
|
1910 | + * |
|
1911 | + * @return Array the tracker information |
|
1912 | + * |
|
1913 | + */ |
|
1914 | 1914 | public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
1915 | 1915 | { |
1916 | 1916 | global $globalTimezone, $globalDBdriver; |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | print '<div class="select-item">'; |
43 | 43 | print '<form action="'.$globalURL.'/aircraft" method="get">'; |
44 | 44 | print '<select name="aircraft_type" class="selectpicker" data-live-search="true">'; |
45 | - print '<option></option>'; |
|
46 | - $Stats = new Stats(); |
|
45 | + print '<option></option>'; |
|
46 | + $Stats = new Stats(); |
|
47 | 47 | $aircraft_types = $Stats->getAllAircraftTypes(); |
48 | 48 | if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
49 | 49 | foreach($aircraft_types as $aircrafttype) |
@@ -54,20 +54,20 @@ discard block |
||
54 | 54 | } else { |
55 | 55 | print '<option value="'.$aircrafttype['aircraft_icao'].'">'.$aircrafttype['aircraft_manufacturer'].' '.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
56 | 56 | } |
57 | - } |
|
58 | - print '</select>'; |
|
59 | - print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>'; |
|
57 | + } |
|
58 | + print '</select>'; |
|
59 | + print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>'; |
|
60 | 60 | print '</form>'; |
61 | 61 | print '</div>'; |
62 | 62 | |
63 | 63 | if ($aircraft_type != "NA") |
64 | 64 | { |
65 | - print '<div class="info column">'; |
|
66 | - print '<h1>'.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')</h1>'; |
|
67 | - print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['aircraft_name'].'</div>'; |
|
68 | - print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['aircraft_type'].'</div>'; |
|
69 | - if (isset($spotter_array[0]['aircraft_manufacturer'])) print '<div><span class="label">'._("Manufacturer").'</span><a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $spotter_array[0]['aircraft_manufacturer'])).'">'.$spotter_array[0]['aircraft_manufacturer'].'</a></div>'; |
|
70 | - print '</div>'; |
|
65 | + print '<div class="info column">'; |
|
66 | + print '<h1>'.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')</h1>'; |
|
67 | + print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['aircraft_name'].'</div>'; |
|
68 | + print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['aircraft_type'].'</div>'; |
|
69 | + if (isset($spotter_array[0]['aircraft_manufacturer'])) print '<div><span class="label">'._("Manufacturer").'</span><a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $spotter_array[0]['aircraft_manufacturer'])).'">'.$spotter_array[0]['aircraft_manufacturer'].'</a></div>'; |
|
70 | + print '</div>'; |
|
71 | 71 | } else { |
72 | 72 | print '<div class="alert alert-warning">'._("This special aircraft profile shows all flights in where the aircraft type is unknown.").'</div>'; |
73 | 73 | } |
@@ -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,46 +25,46 @@ discard block |
||
25 | 25 | // Check if schema is at latest version |
26 | 26 | $Connection = new Connection(); |
27 | 27 | if ($Connection->connectionExists() === false) { |
28 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | - exit(); |
|
28 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | + exit(); |
|
30 | 30 | } |
31 | 31 | if ($Connection->latest() === false) { |
32 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | - exit(); |
|
32 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | + exit(); |
|
34 | 34 | } |
35 | 35 | if (PHP_SAPI != 'cli') { |
36 | - echo "This script MUST be called from console, not a web browser."; |
|
36 | + echo "This script MUST be called from console, not a web browser."; |
|
37 | 37 | // exit(); |
38 | 38 | } |
39 | 39 | |
40 | 40 | // This is to be compatible with old version of settings.php |
41 | 41 | if (!isset($globalSources)) { |
42 | - if (isset($globalSBS1Hosts)) { |
|
43 | - //$hosts = $globalSBS1Hosts; |
|
44 | - foreach ($globalSBS1Hosts as $host) { |
|
45 | - $globalSources[] = array('host' => $host); |
|
46 | - } |
|
47 | - } else { |
|
48 | - if (!isset($globalSBS1Host)) { |
|
49 | - echo '$globalSources MUST be defined !'; |
|
50 | - die; |
|
42 | + if (isset($globalSBS1Hosts)) { |
|
43 | + //$hosts = $globalSBS1Hosts; |
|
44 | + foreach ($globalSBS1Hosts as $host) { |
|
45 | + $globalSources[] = array('host' => $host); |
|
46 | + } |
|
47 | + } else { |
|
48 | + if (!isset($globalSBS1Host)) { |
|
49 | + echo '$globalSources MUST be defined !'; |
|
50 | + die; |
|
51 | 51 | } |
52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
53 | 53 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
54 | - } |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 60 | if (isset($options['s'])) { |
61 | - $globalSources = array(); |
|
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
61 | + $globalSources = array(); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | + else $globalSources[] = array('host' => $options['s']); |
|
64 | 64 | } elseif (isset($options['source'])) { |
65 | - $globalSources = array(); |
|
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
65 | + $globalSources = array(); |
|
66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | + else $globalSources[] = array('host' => $options['source']); |
|
68 | 68 | } |
69 | 69 | if (isset($options['aprsserverhost'])) { |
70 | 70 | $globalServerAPRS = TRUE; |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
104 | 104 | else $id_source = 1; |
105 | 105 | if (isset($globalServer) && $globalServer) { |
106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
107 | - $SI=new SpotterServer(); |
|
106 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
107 | + $SI=new SpotterServer(); |
|
108 | 108 | /* |
109 | 109 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 110 | $SI = new adsb2aprs(); |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | |
115 | 115 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
116 | 116 | if (isset($globalMarine) && $globalMarine) { |
117 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
118 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
117 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
118 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
122 | 122 | if (isset($globalMarine) && $globalMarine) { |
123 | - $AIS = new AIS(); |
|
124 | - $MI = new MarineImport($Connection->db); |
|
123 | + $AIS = new AIS(); |
|
124 | + $MI = new MarineImport($Connection->db); |
|
125 | 125 | } |
126 | 126 | //$APRS=new APRS($Connection->db); |
127 | 127 | $SBS=new SBS(); |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | //$servertz = system('date +%Z'); |
135 | 135 | // signal handler - playing nice with sockets and dump1090 |
136 | 136 | if (function_exists('pcntl_fork')) { |
137 | - pcntl_signal(SIGINT, function() { |
|
138 | - global $sockets; |
|
139 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
140 | - die("Bye!\n"); |
|
141 | - }); |
|
142 | - pcntl_signal_dispatch(); |
|
137 | + pcntl_signal(SIGINT, function() { |
|
138 | + global $sockets; |
|
139 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
140 | + die("Bye!\n"); |
|
141 | + }); |
|
142 | + pcntl_signal_dispatch(); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // let's try and connect |
@@ -149,36 +149,36 @@ discard block |
||
149 | 149 | $reset = 0; |
150 | 150 | |
151 | 151 | function connect_all($hosts) { |
152 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
153 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
154 | - $reset++; |
|
155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
156 | - foreach ($hosts as $id => $value) { |
|
152 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
153 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
154 | + $reset++; |
|
155 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
156 | + foreach ($hosts as $id => $value) { |
|
157 | 157 | $host = $value['host']; |
158 | 158 | $globalSources[$id]['last_exec'] = 0; |
159 | 159 | // Here we check type of source(s) |
160 | 160 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
161 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
162 | - //$formats[$id] = 'deltadbtxt'; |
|
163 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
164 | - //$last_exec['deltadbtxt'] = 0; |
|
165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
166 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
167 | - //$formats[$id] = 'vatsimtxt'; |
|
168 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
169 | - //$last_exec['vatsimtxt'] = 0; |
|
170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
171 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
172 | - //$formats[$id] = 'aircraftlistjson'; |
|
173 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
174 | - //$last_exec['aircraftlistjson'] = 0; |
|
175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
176 | - } else if (preg_match('/opensky/i',$host)) { |
|
177 | - //$formats[$id] = 'aircraftlistjson'; |
|
178 | - $globalSources[$id]['format'] = 'opensky'; |
|
179 | - //$last_exec['aircraftlistjson'] = 0; |
|
180 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
181 | - /* |
|
161 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
162 | + //$formats[$id] = 'deltadbtxt'; |
|
163 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
164 | + //$last_exec['deltadbtxt'] = 0; |
|
165 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
166 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
167 | + //$formats[$id] = 'vatsimtxt'; |
|
168 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
169 | + //$last_exec['vatsimtxt'] = 0; |
|
170 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
171 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
172 | + //$formats[$id] = 'aircraftlistjson'; |
|
173 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
174 | + //$last_exec['aircraftlistjson'] = 0; |
|
175 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
176 | + } else if (preg_match('/opensky/i',$host)) { |
|
177 | + //$formats[$id] = 'aircraftlistjson'; |
|
178 | + $globalSources[$id]['format'] = 'opensky'; |
|
179 | + //$last_exec['aircraftlistjson'] = 0; |
|
180 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
181 | + /* |
|
182 | 182 | // Disabled for now, site change source format |
183 | 183 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
184 | 184 | //$formats[$id] = 'radarvirtueljson'; |
@@ -190,125 +190,125 @@ discard block |
||
190 | 190 | exit(0); |
191 | 191 | } |
192 | 192 | */ |
193 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
194 | - //$formats[$id] = 'planeupdatefaa'; |
|
195 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
196 | - //$last_exec['planeupdatefaa'] = 0; |
|
197 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
198 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
199 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
200 | - exit(0); |
|
201 | - } |
|
202 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
203 | - //$formats[$id] = 'phpvmacars'; |
|
204 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
205 | - //$last_exec['phpvmacars'] = 0; |
|
206 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
207 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
208 | - //$formats[$id] = 'phpvmacars'; |
|
209 | - $globalSources[$id]['format'] = 'vaos'; |
|
210 | - //$last_exec['phpvmacars'] = 0; |
|
211 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
212 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
213 | - //$formats[$id] = 'phpvmacars'; |
|
214 | - $globalSources[$id]['format'] = 'vam'; |
|
215 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
216 | - } else if (preg_match('/whazzup/i',$host)) { |
|
217 | - //$formats[$id] = 'whazzup'; |
|
218 | - $globalSources[$id]['format'] = 'whazzup'; |
|
219 | - //$last_exec['whazzup'] = 0; |
|
220 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
221 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
222 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
223 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
224 | - } else if (preg_match('/airwhere/i',$host)) { |
|
225 | - $globalSources[$id]['format'] = 'airwhere'; |
|
226 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
227 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
228 | - //$formats[$id] = 'pirepsjson'; |
|
229 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
230 | - //$last_exec['pirepsjson'] = 0; |
|
231 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
232 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
233 | - //$formats[$id] = 'fr24json'; |
|
234 | - $globalSources[$id]['format'] = 'fr24json'; |
|
235 | - //$last_exec['fr24json'] = 0; |
|
236 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
237 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
238 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
239 | - exit(0); |
|
240 | - } |
|
241 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
242 | - //$formats[$id] = 'fr24json'; |
|
243 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
244 | - //$last_exec['fr24json'] = 0; |
|
245 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
246 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
247 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
248 | - exit(0); |
|
249 | - } |
|
250 | - //} else if (preg_match('/10001/',$host)) { |
|
251 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
252 | - //$formats[$id] = 'tsv'; |
|
253 | - $globalSources[$id]['format'] = 'tsv'; |
|
254 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
255 | - } |
|
256 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
257 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
258 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
259 | - if ($idf !== false) { |
|
260 | - $httpfeeds[$id] = $idf; |
|
261 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
262 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
263 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
264 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
265 | - $hostport = explode(':',$host); |
|
266 | - if (isset($hostport[1])) { |
|
193 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
194 | + //$formats[$id] = 'planeupdatefaa'; |
|
195 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
196 | + //$last_exec['planeupdatefaa'] = 0; |
|
197 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
198 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
199 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
200 | + exit(0); |
|
201 | + } |
|
202 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
203 | + //$formats[$id] = 'phpvmacars'; |
|
204 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
205 | + //$last_exec['phpvmacars'] = 0; |
|
206 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
207 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
208 | + //$formats[$id] = 'phpvmacars'; |
|
209 | + $globalSources[$id]['format'] = 'vaos'; |
|
210 | + //$last_exec['phpvmacars'] = 0; |
|
211 | + if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
212 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
213 | + //$formats[$id] = 'phpvmacars'; |
|
214 | + $globalSources[$id]['format'] = 'vam'; |
|
215 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
216 | + } else if (preg_match('/whazzup/i',$host)) { |
|
217 | + //$formats[$id] = 'whazzup'; |
|
218 | + $globalSources[$id]['format'] = 'whazzup'; |
|
219 | + //$last_exec['whazzup'] = 0; |
|
220 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
221 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
222 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
223 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
224 | + } else if (preg_match('/airwhere/i',$host)) { |
|
225 | + $globalSources[$id]['format'] = 'airwhere'; |
|
226 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
227 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
228 | + //$formats[$id] = 'pirepsjson'; |
|
229 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
230 | + //$last_exec['pirepsjson'] = 0; |
|
231 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
232 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
233 | + //$formats[$id] = 'fr24json'; |
|
234 | + $globalSources[$id]['format'] = 'fr24json'; |
|
235 | + //$last_exec['fr24json'] = 0; |
|
236 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
237 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
238 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
239 | + exit(0); |
|
240 | + } |
|
241 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
242 | + //$formats[$id] = 'fr24json'; |
|
243 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
244 | + //$last_exec['fr24json'] = 0; |
|
245 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
246 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
247 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
248 | + exit(0); |
|
249 | + } |
|
250 | + //} else if (preg_match('/10001/',$host)) { |
|
251 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
252 | + //$formats[$id] = 'tsv'; |
|
253 | + $globalSources[$id]['format'] = 'tsv'; |
|
254 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
255 | + } |
|
256 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
257 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
258 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
259 | + if ($idf !== false) { |
|
260 | + $httpfeeds[$id] = $idf; |
|
261 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
262 | + } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
263 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
264 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
265 | + $hostport = explode(':',$host); |
|
266 | + if (isset($hostport[1])) { |
|
267 | 267 | $port = $hostport[1]; |
268 | 268 | $hostn = $hostport[0]; |
269 | - } else { |
|
269 | + } else { |
|
270 | 270 | $port = $globalSources[$id]['port']; |
271 | 271 | $hostn = $globalSources[$id]['host']; |
272 | - } |
|
273 | - $Common = new Common(); |
|
274 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
275 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
276 | - } else { |
|
277 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
278 | - } |
|
279 | - if ($s) { |
|
280 | - $sockets[$id] = $s; |
|
281 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
282 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
272 | + } |
|
273 | + $Common = new Common(); |
|
274 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
275 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
276 | + } else { |
|
277 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
278 | + } |
|
279 | + if ($s) { |
|
280 | + $sockets[$id] = $s; |
|
281 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
282 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
283 | 283 | //$formats[$id] = 'aprs'; |
284 | 284 | $globalSources[$id]['format'] = 'aprs'; |
285 | 285 | //$aprs_connect = 0; |
286 | 286 | //$use_aprs = true; |
287 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
287 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
288 | 288 | $globalSources[$id]['format'] = 'vrstcp'; |
289 | - } elseif ($port == '10001') { |
|
290 | - //$formats[$id] = 'tsv'; |
|
291 | - $globalSources[$id]['format'] = 'tsv'; |
|
292 | - } elseif ($port == '30002') { |
|
293 | - //$formats[$id] = 'raw'; |
|
294 | - $globalSources[$id]['format'] = 'raw'; |
|
295 | - } elseif ($port == '5001') { |
|
296 | - //$formats[$id] = 'raw'; |
|
297 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
298 | - } elseif ($port == '30005') { |
|
289 | + } elseif ($port == '10001') { |
|
290 | + //$formats[$id] = 'tsv'; |
|
291 | + $globalSources[$id]['format'] = 'tsv'; |
|
292 | + } elseif ($port == '30002') { |
|
293 | + //$formats[$id] = 'raw'; |
|
294 | + $globalSources[$id]['format'] = 'raw'; |
|
295 | + } elseif ($port == '5001') { |
|
296 | + //$formats[$id] = 'raw'; |
|
297 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
298 | + } elseif ($port == '30005') { |
|
299 | 299 | // Not yet supported |
300 | - //$formats[$id] = 'beast'; |
|
301 | - $globalSources[$id]['format'] = 'beast'; |
|
302 | - //} else $formats[$id] = 'sbs'; |
|
303 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
304 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
300 | + //$formats[$id] = 'beast'; |
|
301 | + $globalSources[$id]['format'] = 'beast'; |
|
302 | + //} else $formats[$id] = 'sbs'; |
|
303 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
304 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
305 | 305 | } |
306 | 306 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
307 | - } else { |
|
307 | + } else { |
|
308 | 308 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
309 | - } |
|
310 | - } |
|
311 | - } |
|
309 | + } |
|
310 | + } |
|
311 | + } |
|
312 | 312 | } |
313 | 313 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
314 | 314 | |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | //connect_all($globalSources); |
332 | 332 | |
333 | 333 | if (isset($globalProxy) && $globalProxy) { |
334 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
334 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
335 | 335 | } else { |
336 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
336 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | // APRS Configuration |
@@ -342,21 +342,21 @@ discard block |
||
342 | 342 | die; |
343 | 343 | } |
344 | 344 | foreach ($globalSources as $key => $source) { |
345 | - if (!isset($source['format'])) { |
|
346 | - $globalSources[$key]['format'] = 'auto'; |
|
347 | - } |
|
348 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
349 | - unset($globalSources[$key]); |
|
350 | - } |
|
345 | + if (!isset($source['format'])) { |
|
346 | + $globalSources[$key]['format'] = 'auto'; |
|
347 | + } |
|
348 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
349 | + unset($globalSources[$key]); |
|
350 | + } |
|
351 | 351 | } |
352 | 352 | connect_all($globalSources); |
353 | 353 | foreach ($globalSources as $key => $source) { |
354 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
354 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
355 | 355 | $aprs_connect = 0; |
356 | 356 | $use_aprs = true; |
357 | 357 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
358 | 358 | break; |
359 | - } |
|
359 | + } |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | if ($use_aprs) { |
@@ -397,131 +397,131 @@ discard block |
||
397 | 397 | |
398 | 398 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
399 | 399 | while ($i > 0) { |
400 | - if (!$globalDaemon) $i = $endtime-time(); |
|
401 | - // Delete old ATC |
|
402 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
400 | + if (!$globalDaemon) $i = $endtime-time(); |
|
401 | + // Delete old ATC |
|
402 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
403 | 403 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
404 | - $ATC->deleteOldATC(); |
|
405 | - } |
|
404 | + $ATC->deleteOldATC(); |
|
405 | + } |
|
406 | 406 | |
407 | - if (count($last_exec) == count($globalSources)) { |
|
407 | + if (count($last_exec) == count($globalSources)) { |
|
408 | 408 | $max = $globalMinFetch; |
409 | 409 | foreach ($last_exec as $last) { |
410 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
410 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
411 | 411 | } |
412 | 412 | if ($max != $globalMinFetch) { |
413 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
414 | - sleep($globalMinFetch-$max+2); |
|
413 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
414 | + sleep($globalMinFetch-$max+2); |
|
415 | + } |
|
415 | 416 | } |
416 | - } |
|
417 | 417 | |
418 | 418 | |
419 | - //foreach ($formats as $id => $value) { |
|
420 | - foreach ($globalSources as $id => $value) { |
|
419 | + //foreach ($formats as $id => $value) { |
|
420 | + foreach ($globalSources as $id => $value) { |
|
421 | 421 | date_default_timezone_set('UTC'); |
422 | 422 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
423 | 423 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
424 | 424 | if ($value['format'] == 'deltadbtxt' && |
425 | - ( |
|
425 | + ( |
|
426 | 426 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
427 | 427 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
428 | - ) |
|
428 | + ) |
|
429 | 429 | ) { |
430 | - //$buffer = $Common->getData($hosts[$id]); |
|
431 | - $buffer = $Common->getData($value['host']); |
|
432 | - if ($buffer != '') $reset = 0; |
|
433 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
434 | - $buffer = explode('\n',$buffer); |
|
435 | - foreach ($buffer as $line) { |
|
436 | - if ($line != '' && count($line) > 7) { |
|
437 | - $line = explode(',', $line); |
|
438 | - $data = array(); |
|
439 | - $data['hex'] = $line[1]; // hex |
|
440 | - $data['ident'] = $line[2]; // ident |
|
441 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
442 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
443 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
444 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
445 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
446 | - $data['verticalrate'] = ''; // vertical rate |
|
447 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
448 | - $data['emergency'] = ''; // emergency |
|
449 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
450 | - $data['format_source'] = 'deltadbtxt'; |
|
451 | - $data['id_source'] = $id_source; |
|
452 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
453 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
454 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
455 | - $SI->add($data); |
|
456 | - unset($data); |
|
457 | - } |
|
458 | - } |
|
459 | - $last_exec[$id]['last'] = time(); |
|
430 | + //$buffer = $Common->getData($hosts[$id]); |
|
431 | + $buffer = $Common->getData($value['host']); |
|
432 | + if ($buffer != '') $reset = 0; |
|
433 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
434 | + $buffer = explode('\n',$buffer); |
|
435 | + foreach ($buffer as $line) { |
|
436 | + if ($line != '' && count($line) > 7) { |
|
437 | + $line = explode(',', $line); |
|
438 | + $data = array(); |
|
439 | + $data['hex'] = $line[1]; // hex |
|
440 | + $data['ident'] = $line[2]; // ident |
|
441 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
442 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
443 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
444 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
445 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
446 | + $data['verticalrate'] = ''; // vertical rate |
|
447 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
448 | + $data['emergency'] = ''; // emergency |
|
449 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
450 | + $data['format_source'] = 'deltadbtxt'; |
|
451 | + $data['id_source'] = $id_source; |
|
452 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
453 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
454 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
455 | + $SI->add($data); |
|
456 | + unset($data); |
|
457 | + } |
|
458 | + } |
|
459 | + $last_exec[$id]['last'] = time(); |
|
460 | 460 | } elseif ($value['format'] == 'aisnmeatxt' && |
461 | - ( |
|
461 | + ( |
|
462 | 462 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
463 | 463 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
464 | - ) |
|
464 | + ) |
|
465 | 465 | ) { |
466 | - date_default_timezone_set('CET'); |
|
467 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
468 | - date_default_timezone_set('UTC'); |
|
469 | - if ($buffer != '') $reset = 0; |
|
470 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
471 | - $buffer = explode('\n',$buffer); |
|
472 | - foreach ($buffer as $line) { |
|
466 | + date_default_timezone_set('CET'); |
|
467 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
468 | + date_default_timezone_set('UTC'); |
|
469 | + if ($buffer != '') $reset = 0; |
|
470 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
471 | + $buffer = explode('\n',$buffer); |
|
472 | + foreach ($buffer as $line) { |
|
473 | 473 | if ($line != '') { |
474 | - //echo "'".$line."'\n"; |
|
475 | - $add = false; |
|
476 | - $ais_data = $AIS->parse_line(trim($line)); |
|
477 | - $data = array(); |
|
478 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
479 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
480 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
481 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
482 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
483 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
484 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
485 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
486 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
487 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
488 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
489 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
490 | - if (isset($ais_data['timestamp'])) { |
|
474 | + //echo "'".$line."'\n"; |
|
475 | + $add = false; |
|
476 | + $ais_data = $AIS->parse_line(trim($line)); |
|
477 | + $data = array(); |
|
478 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
479 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
480 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
481 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
482 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
483 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
484 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
485 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
486 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
487 | + if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
488 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
489 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
490 | + if (isset($ais_data['timestamp'])) { |
|
491 | 491 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
492 | 492 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
493 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
494 | - $add = true; |
|
493 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
494 | + $add = true; |
|
495 | 495 | } |
496 | - } else { |
|
496 | + } else { |
|
497 | 497 | $data['datetime'] = date('Y-m-d H:i:s'); |
498 | 498 | $add = true; |
499 | - } |
|
500 | - $data['format_source'] = 'aisnmeatxt'; |
|
501 | - $data['id_source'] = $id_source; |
|
502 | - //print_r($data); |
|
503 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
504 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
505 | - unset($data); |
|
499 | + } |
|
500 | + $data['format_source'] = 'aisnmeatxt'; |
|
501 | + $data['id_source'] = $id_source; |
|
502 | + //print_r($data); |
|
503 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
504 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
505 | + unset($data); |
|
506 | 506 | } |
507 | - } |
|
508 | - $last_exec[$id]['last'] = time(); |
|
507 | + } |
|
508 | + $last_exec[$id]['last'] = time(); |
|
509 | 509 | } elseif ($value['format'] == 'aisnmeahttp') { |
510 | - $arr = $httpfeeds; |
|
511 | - $w = $e = null; |
|
510 | + $arr = $httpfeeds; |
|
511 | + $w = $e = null; |
|
512 | 512 | |
513 | - if (isset($arr[$id])) { |
|
513 | + if (isset($arr[$id])) { |
|
514 | 514 | $nn = stream_select($arr,$w,$e,$timeout); |
515 | 515 | if ($nn > 0) { |
516 | - foreach ($httpfeeds as $feed) { |
|
516 | + foreach ($httpfeeds as $feed) { |
|
517 | 517 | $buffer = stream_get_line($feed,2000,"\n"); |
518 | 518 | if ($buffer === FALSE) { |
519 | - connect_all($globalSources); |
|
519 | + connect_all($globalSources); |
|
520 | 520 | } |
521 | 521 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
522 | 522 | $buffer = explode('\n',$buffer); |
523 | 523 | foreach ($buffer as $line) { |
524 | - if ($line != '') { |
|
524 | + if ($line != '') { |
|
525 | 525 | $ais_data = $AIS->parse_line(trim($line)); |
526 | 526 | $data = array(); |
527 | 527 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -539,117 +539,117 @@ discard block |
||
539 | 539 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
540 | 540 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
541 | 541 | if (isset($ais_data['timestamp'])) { |
542 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
542 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
543 | 543 | } else { |
544 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
544 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
545 | 545 | } |
546 | 546 | $data['format_source'] = 'aisnmeahttp'; |
547 | 547 | $data['id_source'] = $id_source; |
548 | 548 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
549 | 549 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
550 | 550 | unset($data); |
551 | - } |
|
551 | + } |
|
552 | + } |
|
552 | 553 | } |
553 | - } |
|
554 | 554 | } else { |
555 | - $format = $value['format']; |
|
556 | - if (isset($tt[$format])) $tt[$format]++; |
|
557 | - else $tt[$format] = 0; |
|
558 | - if ($tt[$format] > 30) { |
|
555 | + $format = $value['format']; |
|
556 | + if (isset($tt[$format])) $tt[$format]++; |
|
557 | + else $tt[$format] = 0; |
|
558 | + if ($tt[$format] > 30) { |
|
559 | 559 | if ($globalDebug) echo 'Reconnect...'."\n"; |
560 | 560 | sleep(2); |
561 | 561 | //$sourceeen[] = $value; |
562 | 562 | //connect_all($sourceeen); |
563 | 563 | //$sourceeen = array(); |
564 | 564 | connect_all($globalSources); |
565 | - } |
|
565 | + } |
|
566 | + } |
|
566 | 567 | } |
567 | - } |
|
568 | 568 | } elseif ($value['format'] == 'myshiptracking' && |
569 | - ( |
|
569 | + ( |
|
570 | 570 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
571 | 571 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
572 | - ) |
|
572 | + ) |
|
573 | 573 | ) { |
574 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
575 | - if ($buffer != '') { |
|
574 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
575 | + if ($buffer != '') { |
|
576 | 576 | //echo $buffer; |
577 | 577 | $all_data = json_decode($buffer,true); |
578 | 578 | //print_r($all_data); |
579 | 579 | if (isset($all_data[0]['DATA'])) { |
580 | - foreach ($all_data[0]['DATA'] as $line) { |
|
580 | + foreach ($all_data[0]['DATA'] as $line) { |
|
581 | 581 | if ($line != '') { |
582 | - $data = array(); |
|
583 | - $data['ident'] = $line['NAME']; |
|
584 | - $data['mmsi'] = $line['MMSI']; |
|
585 | - if (strlen($data['mmsi']) > 9) { |
|
582 | + $data = array(); |
|
583 | + $data['ident'] = $line['NAME']; |
|
584 | + $data['mmsi'] = $line['MMSI']; |
|
585 | + if (strlen($data['mmsi']) > 9) { |
|
586 | 586 | $data['mmsi'] = substr($data['mmsi'],-9); |
587 | - } |
|
588 | - $data['speed'] = $line['SOG']; |
|
589 | - $data['heading'] = $line['COG']; |
|
590 | - $data['latitude'] = $line['LAT']; |
|
591 | - $data['longitude'] = $line['LNG']; |
|
592 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
593 | - //$data['type_id'] = $line['TYPE']; |
|
594 | - $data['imo'] = $line['IMO']; |
|
595 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
596 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
597 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
598 | - $data['format_source'] = 'myshiptracking'; |
|
599 | - $data['id_source'] = $id_source; |
|
600 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
601 | - $MI->add($data); |
|
602 | - unset($data); |
|
587 | + } |
|
588 | + $data['speed'] = $line['SOG']; |
|
589 | + $data['heading'] = $line['COG']; |
|
590 | + $data['latitude'] = $line['LAT']; |
|
591 | + $data['longitude'] = $line['LNG']; |
|
592 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
593 | + //$data['type_id'] = $line['TYPE']; |
|
594 | + $data['imo'] = $line['IMO']; |
|
595 | + if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
596 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
597 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
598 | + $data['format_source'] = 'myshiptracking'; |
|
599 | + $data['id_source'] = $id_source; |
|
600 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
601 | + $MI->add($data); |
|
602 | + unset($data); |
|
603 | + } |
|
603 | 604 | } |
604 | - } |
|
605 | 605 | } |
606 | - } |
|
607 | - $last_exec[$id]['last'] = time(); |
|
606 | + } |
|
607 | + $last_exec[$id]['last'] = time(); |
|
608 | 608 | } elseif ($value['format'] == 'boatbeaconapp' && |
609 | - ( |
|
609 | + ( |
|
610 | 610 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
611 | 611 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
612 | - ) |
|
612 | + ) |
|
613 | 613 | ) { |
614 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
615 | - if ($buffer != '') { |
|
614 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
615 | + if ($buffer != '') { |
|
616 | 616 | $all_data = json_decode($buffer,true); |
617 | 617 | if (isset($all_data[0]['mmsi'])) { |
618 | - foreach ($all_data as $line) { |
|
618 | + foreach ($all_data as $line) { |
|
619 | 619 | if ($line != '') { |
620 | - $data = array(); |
|
621 | - $data['ident'] = $line['shipname']; |
|
622 | - $data['callsign'] = $line['callsign']; |
|
623 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
624 | - $data['speed'] = $line['sog']; |
|
625 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
626 | - $data['latitude'] = $line['latitude']; |
|
627 | - $data['longitude'] = $line['longitude']; |
|
628 | - $data['type_id'] = $line['shiptype']; |
|
629 | - $data['arrival_code'] = $line['destination']; |
|
630 | - $data['datetime'] = $line['time']; |
|
631 | - $data['format_source'] = 'boatbeaconapp'; |
|
632 | - $data['id_source'] = $id_source; |
|
633 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
634 | - $MI->add($data); |
|
635 | - unset($data); |
|
620 | + $data = array(); |
|
621 | + $data['ident'] = $line['shipname']; |
|
622 | + $data['callsign'] = $line['callsign']; |
|
623 | + $data['mmsi'] = substr($line['mmsi'],-9); |
|
624 | + $data['speed'] = $line['sog']; |
|
625 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
626 | + $data['latitude'] = $line['latitude']; |
|
627 | + $data['longitude'] = $line['longitude']; |
|
628 | + $data['type_id'] = $line['shiptype']; |
|
629 | + $data['arrival_code'] = $line['destination']; |
|
630 | + $data['datetime'] = $line['time']; |
|
631 | + $data['format_source'] = 'boatbeaconapp'; |
|
632 | + $data['id_source'] = $id_source; |
|
633 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
634 | + $MI->add($data); |
|
635 | + unset($data); |
|
636 | + } |
|
636 | 637 | } |
637 | - } |
|
638 | 638 | } |
639 | 639 | |
640 | - } |
|
641 | - $last_exec[$id]['last'] = time(); |
|
640 | + } |
|
641 | + $last_exec[$id]['last'] = time(); |
|
642 | 642 | } elseif ($value['format'] == 'boatnerd' && |
643 | - ( |
|
643 | + ( |
|
644 | 644 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
645 | 645 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
646 | - ) |
|
646 | + ) |
|
647 | 647 | ) { |
648 | - $buffer = $Common->getData($value['host']); |
|
649 | - if ($buffer != '') { |
|
648 | + $buffer = $Common->getData($value['host']); |
|
649 | + if ($buffer != '') { |
|
650 | 650 | $all_data = json_decode($buffer,true); |
651 | 651 | if (isset($all_data['features'][0]['id'])) { |
652 | - foreach ($all_data['features'] as $line) { |
|
652 | + foreach ($all_data['features'] as $line) { |
|
653 | 653 | print_r($line); |
654 | 654 | $data = array(); |
655 | 655 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
@@ -669,80 +669,80 @@ discard block |
||
669 | 669 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
670 | 670 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
671 | 671 | unset($data); |
672 | - } |
|
672 | + } |
|
673 | 673 | } |
674 | 674 | |
675 | - } |
|
676 | - $last_exec[$id]['last'] = time(); |
|
675 | + } |
|
676 | + $last_exec[$id]['last'] = time(); |
|
677 | 677 | } elseif ($value['format'] == 'shipplotter' && |
678 | - ( |
|
678 | + ( |
|
679 | 679 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
680 | 680 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
681 | - ) |
|
681 | + ) |
|
682 | 682 | ) { |
683 | - echo 'download...'; |
|
684 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
685 | - echo 'done !'."\n"; |
|
686 | - // FIXME: Need more work |
|
687 | - if ($buffer != '') $reset = 0; |
|
688 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
689 | - $buffer = explode('\n',$buffer); |
|
690 | - foreach ($buffer as $line) { |
|
683 | + echo 'download...'; |
|
684 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
685 | + echo 'done !'."\n"; |
|
686 | + // FIXME: Need more work |
|
687 | + if ($buffer != '') $reset = 0; |
|
688 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
689 | + $buffer = explode('\n',$buffer); |
|
690 | + foreach ($buffer as $line) { |
|
691 | 691 | if ($line != '') { |
692 | - $data = array(); |
|
693 | - echo $line."\n"; |
|
694 | - $data['mmsi'] = (int)substr($line,0,9); |
|
695 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
696 | - $data['status_id'] = substr($line,21,2); |
|
697 | - $data['type_id'] = substr($line,24,3); |
|
698 | - $data['latitude'] = substr($line,29,9); |
|
699 | - $data['longitude'] = substr($line,41,9); |
|
700 | - $data['speed'] = round(substr($line,51,5)); |
|
701 | - //$data['course'] = substr($line,57,5); |
|
702 | - $data['heading'] = round(substr($line,63,3)); |
|
703 | - //$data['draft'] = substr($line,67,4); |
|
704 | - //$data['length'] = substr($line,72,3); |
|
705 | - //$data['beam'] = substr($line,76,2); |
|
706 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
707 | - //$data['callsign'] = trim(substr($line,100,7); |
|
708 | - $data['arrival_code'] = substr($line,108,20); |
|
709 | - //$data['etaDate'] = substr($line,129,5); |
|
710 | - //$data['etaTime'] = substr($line,135,5); |
|
711 | - $data['format_source'] = 'shipplotter'; |
|
712 | - $data['id_source'] = $id_source; |
|
713 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
714 | - //print_r($data); |
|
715 | - echo 'Add...'."\n"; |
|
716 | - $MI->add($data); |
|
717 | - unset($data); |
|
692 | + $data = array(); |
|
693 | + echo $line."\n"; |
|
694 | + $data['mmsi'] = (int)substr($line,0,9); |
|
695 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
696 | + $data['status_id'] = substr($line,21,2); |
|
697 | + $data['type_id'] = substr($line,24,3); |
|
698 | + $data['latitude'] = substr($line,29,9); |
|
699 | + $data['longitude'] = substr($line,41,9); |
|
700 | + $data['speed'] = round(substr($line,51,5)); |
|
701 | + //$data['course'] = substr($line,57,5); |
|
702 | + $data['heading'] = round(substr($line,63,3)); |
|
703 | + //$data['draft'] = substr($line,67,4); |
|
704 | + //$data['length'] = substr($line,72,3); |
|
705 | + //$data['beam'] = substr($line,76,2); |
|
706 | + $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
707 | + //$data['callsign'] = trim(substr($line,100,7); |
|
708 | + $data['arrival_code'] = substr($line,108,20); |
|
709 | + //$data['etaDate'] = substr($line,129,5); |
|
710 | + //$data['etaTime'] = substr($line,135,5); |
|
711 | + $data['format_source'] = 'shipplotter'; |
|
712 | + $data['id_source'] = $id_source; |
|
713 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
714 | + //print_r($data); |
|
715 | + echo 'Add...'."\n"; |
|
716 | + $MI->add($data); |
|
717 | + unset($data); |
|
718 | 718 | } |
719 | - } |
|
720 | - $last_exec[$id]['last'] = time(); |
|
719 | + } |
|
720 | + $last_exec[$id]['last'] = time(); |
|
721 | 721 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
722 | 722 | } elseif ( |
723 | - ( |
|
723 | + ( |
|
724 | 724 | $value['format'] == 'whazzup' && |
725 | 725 | ( |
726 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
727 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
726 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
727 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
728 | 728 | ) |
729 | - ) || ( |
|
729 | + ) || ( |
|
730 | 730 | $value['format'] == 'vatsimtxt' && |
731 | 731 | ( |
732 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
733 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
732 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
733 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
734 | + ) |
|
734 | 735 | ) |
735 | - ) |
|
736 | 736 | ) { |
737 | - //$buffer = $Common->getData($hosts[$id]); |
|
738 | - $buffer = $Common->getData($value['host']); |
|
739 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
740 | - $buffer = explode('\n',$buffer); |
|
741 | - $reset = 0; |
|
742 | - foreach ($buffer as $line) { |
|
743 | - if ($line != '') { |
|
744 | - $line = explode(':', $line); |
|
745 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
737 | + //$buffer = $Common->getData($hosts[$id]); |
|
738 | + $buffer = $Common->getData($value['host']); |
|
739 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
740 | + $buffer = explode('\n',$buffer); |
|
741 | + $reset = 0; |
|
742 | + foreach ($buffer as $line) { |
|
743 | + if ($line != '') { |
|
744 | + $line = explode(':', $line); |
|
745 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
746 | 746 | $data = array(); |
747 | 747 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
748 | 748 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -755,37 +755,37 @@ discard block |
||
755 | 755 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
756 | 756 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
757 | 757 | $data['latitude'] = $line[5]; // lat |
758 | - $data['longitude'] = $line[6]; // long |
|
759 | - $data['verticalrate'] = ''; // vertical rate |
|
760 | - $data['squawk'] = ''; // squawk |
|
761 | - $data['emergency'] = ''; // emergency |
|
762 | - $data['waypoints'] = $line[30]; |
|
758 | + $data['longitude'] = $line[6]; // long |
|
759 | + $data['verticalrate'] = ''; // vertical rate |
|
760 | + $data['squawk'] = ''; // squawk |
|
761 | + $data['emergency'] = ''; // emergency |
|
762 | + $data['waypoints'] = $line[30]; |
|
763 | 763 | $data['datetime'] = date('Y-m-d H:i:s'); |
764 | 764 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
765 | 765 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
766 | - $data['departure_airport_icao'] = $line[11]; |
|
767 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
768 | - $data['arrival_airport_icao'] = $line[13]; |
|
766 | + $data['departure_airport_icao'] = $line[11]; |
|
767 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
768 | + $data['arrival_airport_icao'] = $line[13]; |
|
769 | 769 | $data['frequency'] = $line[4]; |
770 | 770 | $data['type'] = $line[18]; |
771 | 771 | $data['range'] = $line[19]; |
772 | 772 | if (isset($line[35])) $data['info'] = $line[35]; |
773 | - $data['id_source'] = $id_source; |
|
774 | - //$data['arrival_airport_time'] = ; |
|
775 | - if ($line[9] != '') { |
|
776 | - $aircraft_data = explode('/',$line[9]); |
|
777 | - if (isset($aircraft_data[1])) { |
|
778 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
779 | - } |
|
780 | - } |
|
781 | - /* |
|
773 | + $data['id_source'] = $id_source; |
|
774 | + //$data['arrival_airport_time'] = ; |
|
775 | + if ($line[9] != '') { |
|
776 | + $aircraft_data = explode('/',$line[9]); |
|
777 | + if (isset($aircraft_data[1])) { |
|
778 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
779 | + } |
|
780 | + } |
|
781 | + /* |
|
782 | 782 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
783 | 783 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
784 | 784 | */ |
785 | - $data['format_source'] = $value['format']; |
|
785 | + $data['format_source'] = $value['format']; |
|
786 | 786 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
787 | 787 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
788 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
788 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
789 | 789 | elseif ($line[3] == 'ATC') { |
790 | 790 | //print_r($data); |
791 | 791 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -806,21 +806,21 @@ discard block |
||
806 | 806 | 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']); |
807 | 807 | } |
808 | 808 | } |
809 | - unset($data); |
|
810 | - } |
|
811 | - } |
|
812 | - } |
|
813 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
814 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
815 | - $last_exec[$id]['last'] = time(); |
|
816 | - } elseif ($value['format'] == 'airwhere' && |
|
817 | - ( |
|
818 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
819 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
820 | - ) |
|
821 | - ) { |
|
822 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
823 | - if ($buffer != '') { |
|
809 | + unset($data); |
|
810 | + } |
|
811 | + } |
|
812 | + } |
|
813 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
814 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
815 | + $last_exec[$id]['last'] = time(); |
|
816 | + } elseif ($value['format'] == 'airwhere' && |
|
817 | + ( |
|
818 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
819 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
820 | + ) |
|
821 | + ) { |
|
822 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
823 | + if ($buffer != '') { |
|
824 | 824 | $all_data = simplexml_load_string($buffer); |
825 | 825 | foreach($all_data->children() as $childdata) { |
826 | 826 | $data = array(); |
@@ -842,10 +842,10 @@ discard block |
||
842 | 842 | $SI->add($data); |
843 | 843 | unset($data); |
844 | 844 | } |
845 | - } |
|
846 | - $Source->deleteOldLocationByType('gs'); |
|
847 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
848 | - if ($buffer != '') { |
|
845 | + } |
|
846 | + $Source->deleteOldLocationByType('gs'); |
|
847 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
848 | + if ($buffer != '') { |
|
849 | 849 | $all_data = simplexml_load_string($buffer); |
850 | 850 | foreach($all_data->children() as $childdata) { |
851 | 851 | $data = array(); |
@@ -863,8 +863,8 @@ discard block |
||
863 | 863 | } |
864 | 864 | unset($data); |
865 | 865 | } |
866 | - } |
|
867 | - $last_exec[$id]['last'] = time(); |
|
866 | + } |
|
867 | + $last_exec[$id]['last'] = time(); |
|
868 | 868 | /* |
869 | 869 | } if ($value['format'] == 'aircraftlistjson') { |
870 | 870 | print_r($globalSources); |
@@ -872,17 +872,17 @@ discard block |
||
872 | 872 | echo $globalMinFetch; |
873 | 873 | */ |
874 | 874 | } elseif ($value['format'] == 'aircraftlistjson' && |
875 | - ( |
|
875 | + ( |
|
876 | 876 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
877 | 877 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
878 | - ) |
|
878 | + ) |
|
879 | 879 | ) { |
880 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
881 | - if ($buffer != '') { |
|
882 | - $all_data = json_decode($buffer,true); |
|
880 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
881 | + if ($buffer != '') { |
|
882 | + $all_data = json_decode($buffer,true); |
|
883 | 883 | if (isset($all_data['acList'])) { |
884 | - $reset = 0; |
|
885 | - foreach ($all_data['acList'] as $line) { |
|
884 | + $reset = 0; |
|
885 | + foreach ($all_data['acList'] as $line) { |
|
886 | 886 | $data = array(); |
887 | 887 | $data['hex'] = $line['Icao']; // hex |
888 | 888 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -905,10 +905,10 @@ discard block |
||
905 | 905 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
906 | 906 | if (isset($data['latitude'])) $SI->add($data); |
907 | 907 | unset($data); |
908 | - } |
|
908 | + } |
|
909 | 909 | } elseif (is_array($all_data)) { |
910 | - $reset = 0; |
|
911 | - foreach ($all_data as $line) { |
|
910 | + $reset = 0; |
|
911 | + foreach ($all_data as $line) { |
|
912 | 912 | $data = array(); |
913 | 913 | $data['hex'] = $line['hex']; // hex |
914 | 914 | $data['ident'] = $line['flight']; // ident |
@@ -928,218 +928,218 @@ discard block |
||
928 | 928 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
929 | 929 | $SI->add($data); |
930 | 930 | unset($data); |
931 | - } |
|
931 | + } |
|
932 | 932 | } |
933 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
934 | - //$last_exec['aircraftlistjson'] = time(); |
|
935 | - $last_exec[$id]['last'] = time(); |
|
936 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
937 | - } elseif ($value['format'] == 'planeupdatefaa' && |
|
938 | - ( |
|
939 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
940 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
941 | - ) |
|
942 | - ) { |
|
943 | - $buffer = $Common->getData($value['host']); |
|
944 | - $all_data = json_decode($buffer,true); |
|
945 | - if (isset($all_data['planes'])) { |
|
933 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
934 | + //$last_exec['aircraftlistjson'] = time(); |
|
935 | + $last_exec[$id]['last'] = time(); |
|
936 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
937 | + } elseif ($value['format'] == 'planeupdatefaa' && |
|
938 | + ( |
|
939 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
940 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
941 | + ) |
|
942 | + ) { |
|
943 | + $buffer = $Common->getData($value['host']); |
|
944 | + $all_data = json_decode($buffer,true); |
|
945 | + if (isset($all_data['planes'])) { |
|
946 | 946 | $reset = 0; |
947 | 947 | foreach ($all_data['planes'] as $key => $line) { |
948 | - $data = array(); |
|
949 | - $data['hex'] = $key; // hex |
|
950 | - $data['ident'] = $line[3]; // ident |
|
951 | - $data['altitude'] = $line[6]; // altitude |
|
952 | - $data['speed'] = $line[8]; // speed |
|
953 | - $data['heading'] = $line[7]; // heading |
|
954 | - $data['latitude'] = $line[4]; // lat |
|
955 | - $data['longitude'] = $line[5]; // long |
|
956 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
957 | - $data['squawk'] = $line[10]; // squawk |
|
958 | - $data['emergency'] = ''; // emergency |
|
959 | - $data['registration'] = $line[2]; |
|
960 | - $data['aircraft_icao'] = $line[0]; |
|
961 | - $deparr = explode('-',$line[1]); |
|
962 | - if (count($deparr) == 2) { |
|
948 | + $data = array(); |
|
949 | + $data['hex'] = $key; // hex |
|
950 | + $data['ident'] = $line[3]; // ident |
|
951 | + $data['altitude'] = $line[6]; // altitude |
|
952 | + $data['speed'] = $line[8]; // speed |
|
953 | + $data['heading'] = $line[7]; // heading |
|
954 | + $data['latitude'] = $line[4]; // lat |
|
955 | + $data['longitude'] = $line[5]; // long |
|
956 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
957 | + $data['squawk'] = $line[10]; // squawk |
|
958 | + $data['emergency'] = ''; // emergency |
|
959 | + $data['registration'] = $line[2]; |
|
960 | + $data['aircraft_icao'] = $line[0]; |
|
961 | + $deparr = explode('-',$line[1]); |
|
962 | + if (count($deparr) == 2) { |
|
963 | 963 | $data['departure_airport_icao'] = $deparr[0]; |
964 | 964 | $data['arrival_airport_icao'] = $deparr[1]; |
965 | - } |
|
966 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
967 | - $data['format_source'] = 'planeupdatefaa'; |
|
968 | - $data['id_source'] = $id_source; |
|
969 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
970 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
971 | - $SI->add($data); |
|
972 | - unset($data); |
|
965 | + } |
|
966 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
967 | + $data['format_source'] = 'planeupdatefaa'; |
|
968 | + $data['id_source'] = $id_source; |
|
969 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
970 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
971 | + $SI->add($data); |
|
972 | + unset($data); |
|
973 | + } |
|
973 | 974 | } |
974 | - } |
|
975 | - //$last_exec['planeupdatefaa'] = time(); |
|
976 | - $last_exec[$id]['last'] = time(); |
|
975 | + //$last_exec['planeupdatefaa'] = time(); |
|
976 | + $last_exec[$id]['last'] = time(); |
|
977 | 977 | } elseif ($value['format'] == 'opensky' && |
978 | - ( |
|
978 | + ( |
|
979 | 979 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
980 | 980 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
981 | - ) |
|
981 | + ) |
|
982 | 982 | ) { |
983 | - $buffer = $Common->getData($value['host']); |
|
984 | - $all_data = json_decode($buffer,true); |
|
985 | - if (isset($all_data['states'])) { |
|
983 | + $buffer = $Common->getData($value['host']); |
|
984 | + $all_data = json_decode($buffer,true); |
|
985 | + if (isset($all_data['states'])) { |
|
986 | 986 | $reset = 0; |
987 | 987 | foreach ($all_data['states'] as $key => $line) { |
988 | - $data = array(); |
|
989 | - $data['hex'] = $line[0]; // hex |
|
990 | - $data['ident'] = trim($line[1]); // ident |
|
991 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
992 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
993 | - $data['heading'] = round($line[10]); // heading |
|
994 | - $data['latitude'] = $line[6]; // lat |
|
995 | - $data['longitude'] = $line[5]; // long |
|
996 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
997 | - //$data['squawk'] = $line[10]; // squawk |
|
998 | - //$data['emergency'] = ''; // emergency |
|
999 | - //$data['registration'] = $line[2]; |
|
1000 | - //$data['aircraft_icao'] = $line[0]; |
|
1001 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1002 | - $data['format_source'] = 'opensky'; |
|
1003 | - $data['id_source'] = $id_source; |
|
1004 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1005 | - $SI->add($data); |
|
1006 | - unset($data); |
|
988 | + $data = array(); |
|
989 | + $data['hex'] = $line[0]; // hex |
|
990 | + $data['ident'] = trim($line[1]); // ident |
|
991 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
992 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
993 | + $data['heading'] = round($line[10]); // heading |
|
994 | + $data['latitude'] = $line[6]; // lat |
|
995 | + $data['longitude'] = $line[5]; // long |
|
996 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
997 | + //$data['squawk'] = $line[10]; // squawk |
|
998 | + //$data['emergency'] = ''; // emergency |
|
999 | + //$data['registration'] = $line[2]; |
|
1000 | + //$data['aircraft_icao'] = $line[0]; |
|
1001 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1002 | + $data['format_source'] = 'opensky'; |
|
1003 | + $data['id_source'] = $id_source; |
|
1004 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1005 | + $SI->add($data); |
|
1006 | + unset($data); |
|
1007 | + } |
|
1007 | 1008 | } |
1008 | - } |
|
1009 | - //$last_exec['planeupdatefaa'] = time(); |
|
1010 | - $last_exec[$id]['last'] = time(); |
|
1009 | + //$last_exec['planeupdatefaa'] = time(); |
|
1010 | + $last_exec[$id]['last'] = time(); |
|
1011 | 1011 | //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
1012 | 1012 | } elseif ($value['format'] == 'fr24json' && |
1013 | - ( |
|
1013 | + ( |
|
1014 | 1014 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1015 | 1015 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1016 | - ) |
|
1016 | + ) |
|
1017 | 1017 | ) { |
1018 | - //$buffer = $Common->getData($hosts[$id]); |
|
1019 | - $buffer = $Common->getData($value['host']); |
|
1020 | - $all_data = json_decode($buffer,true); |
|
1021 | - if (!empty($all_data)) $reset = 0; |
|
1022 | - foreach ($all_data as $key => $line) { |
|
1018 | + //$buffer = $Common->getData($hosts[$id]); |
|
1019 | + $buffer = $Common->getData($value['host']); |
|
1020 | + $all_data = json_decode($buffer,true); |
|
1021 | + if (!empty($all_data)) $reset = 0; |
|
1022 | + foreach ($all_data as $key => $line) { |
|
1023 | 1023 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1024 | - $data = array(); |
|
1025 | - $data['hex'] = $line[0]; |
|
1026 | - $data['ident'] = $line[16]; //$line[13] |
|
1027 | - $data['altitude'] = $line[4]; // altitude |
|
1028 | - $data['speed'] = $line[5]; // speed |
|
1029 | - $data['heading'] = $line[3]; // heading |
|
1030 | - $data['latitude'] = $line[1]; // lat |
|
1031 | - $data['longitude'] = $line[2]; // long |
|
1032 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
1033 | - $data['squawk'] = $line[6]; // squawk |
|
1034 | - $data['aircraft_icao'] = $line[8]; |
|
1035 | - $data['registration'] = $line[9]; |
|
1036 | - $data['departure_airport_iata'] = $line[11]; |
|
1037 | - $data['arrival_airport_iata'] = $line[12]; |
|
1038 | - $data['emergency'] = ''; // emergency |
|
1039 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1040 | - $data['format_source'] = 'fr24json'; |
|
1041 | - $data['id_source'] = $id_source; |
|
1042 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1043 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1044 | - $SI->add($data); |
|
1045 | - unset($data); |
|
1024 | + $data = array(); |
|
1025 | + $data['hex'] = $line[0]; |
|
1026 | + $data['ident'] = $line[16]; //$line[13] |
|
1027 | + $data['altitude'] = $line[4]; // altitude |
|
1028 | + $data['speed'] = $line[5]; // speed |
|
1029 | + $data['heading'] = $line[3]; // heading |
|
1030 | + $data['latitude'] = $line[1]; // lat |
|
1031 | + $data['longitude'] = $line[2]; // long |
|
1032 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
1033 | + $data['squawk'] = $line[6]; // squawk |
|
1034 | + $data['aircraft_icao'] = $line[8]; |
|
1035 | + $data['registration'] = $line[9]; |
|
1036 | + $data['departure_airport_iata'] = $line[11]; |
|
1037 | + $data['arrival_airport_iata'] = $line[12]; |
|
1038 | + $data['emergency'] = ''; // emergency |
|
1039 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1040 | + $data['format_source'] = 'fr24json'; |
|
1041 | + $data['id_source'] = $id_source; |
|
1042 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1043 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1044 | + $SI->add($data); |
|
1045 | + unset($data); |
|
1046 | 1046 | } |
1047 | - } |
|
1048 | - //$last_exec['fr24json'] = time(); |
|
1049 | - $last_exec[$id]['last'] = time(); |
|
1047 | + } |
|
1048 | + //$last_exec['fr24json'] = time(); |
|
1049 | + $last_exec[$id]['last'] = time(); |
|
1050 | 1050 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
1051 | 1051 | } elseif ($value['format'] == 'radarvirtueljson' && |
1052 | - ( |
|
1052 | + ( |
|
1053 | 1053 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1054 | 1054 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1055 | - ) |
|
1055 | + ) |
|
1056 | 1056 | ) { |
1057 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1058 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1059 | - //echo $buffer; |
|
1060 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1061 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1062 | - $all_data = json_decode($buffer,true); |
|
1063 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1057 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1058 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1059 | + //echo $buffer; |
|
1060 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1061 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1062 | + $all_data = json_decode($buffer,true); |
|
1063 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1064 | 1064 | die(json_last_error_msg()); |
1065 | - } |
|
1066 | - if (isset($all_data['mrkrs'])) { |
|
1065 | + } |
|
1066 | + if (isset($all_data['mrkrs'])) { |
|
1067 | 1067 | $reset = 0; |
1068 | 1068 | foreach ($all_data['mrkrs'] as $key => $line) { |
1069 | - if (isset($line['inf'])) { |
|
1069 | + if (isset($line['inf'])) { |
|
1070 | 1070 | $data = array(); |
1071 | 1071 | $data['hex'] = $line['inf']['ia']; |
1072 | 1072 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1073 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1074 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1075 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1076 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1077 | - $data['longitude'] = $line['pt'][1]; // long |
|
1078 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1079 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1080 | - //$data['aircraft_icao'] = $line[8]; |
|
1081 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1073 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1074 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1075 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1076 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1077 | + $data['longitude'] = $line['pt'][1]; // long |
|
1078 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1079 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1080 | + //$data['aircraft_icao'] = $line[8]; |
|
1081 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1082 | 1082 | //$data['departure_airport_iata'] = $line[11]; |
1083 | 1083 | //$data['arrival_airport_iata'] = $line[12]; |
1084 | - //$data['emergency'] = ''; // emergency |
|
1084 | + //$data['emergency'] = ''; // emergency |
|
1085 | 1085 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1086 | - $data['format_source'] = 'radarvirtueljson'; |
|
1087 | - $data['id_source'] = $id_source; |
|
1086 | + $data['format_source'] = 'radarvirtueljson'; |
|
1087 | + $data['id_source'] = $id_source; |
|
1088 | 1088 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1089 | 1089 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1090 | 1090 | $SI->add($data); |
1091 | 1091 | unset($data); |
1092 | - } |
|
1092 | + } |
|
1093 | 1093 | } |
1094 | - } |
|
1095 | - //$last_exec['radarvirtueljson'] = time(); |
|
1096 | - $last_exec[$id]['last'] = time(); |
|
1094 | + } |
|
1095 | + //$last_exec['radarvirtueljson'] = time(); |
|
1096 | + $last_exec[$id]['last'] = time(); |
|
1097 | 1097 | //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1098 | 1098 | } elseif ($value['format'] == 'pirepsjson' && |
1099 | - ( |
|
1099 | + ( |
|
1100 | 1100 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1101 | 1101 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1102 | - ) |
|
1102 | + ) |
|
1103 | 1103 | ) { |
1104 | - //$buffer = $Common->getData($hosts[$id]); |
|
1105 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1106 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1104 | + //$buffer = $Common->getData($hosts[$id]); |
|
1105 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1106 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1107 | 1107 | |
1108 | - if (isset($all_data['pireps'])) { |
|
1108 | + if (isset($all_data['pireps'])) { |
|
1109 | 1109 | $reset = 0; |
1110 | - foreach ($all_data['pireps'] as $line) { |
|
1111 | - $data = array(); |
|
1112 | - $data['id'] = $line['id']; |
|
1113 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1114 | - $data['ident'] = $line['callsign']; // ident |
|
1115 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1116 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1117 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1118 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1119 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1120 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1121 | - $data['latitude'] = $line['lat']; // lat |
|
1122 | - $data['longitude'] = $line['lon']; // long |
|
1123 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1124 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1125 | - //$data['emergency'] = ''; // emergency |
|
1126 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1127 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1128 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1129 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1130 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1131 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1132 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1133 | - else $data['info'] = ''; |
|
1134 | - $data['format_source'] = 'pireps'; |
|
1135 | - $data['id_source'] = $id_source; |
|
1136 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1137 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1138 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1139 | - if ($line['icon'] == 'plane') { |
|
1110 | + foreach ($all_data['pireps'] as $line) { |
|
1111 | + $data = array(); |
|
1112 | + $data['id'] = $line['id']; |
|
1113 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1114 | + $data['ident'] = $line['callsign']; // ident |
|
1115 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1116 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1117 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1118 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1119 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1120 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1121 | + $data['latitude'] = $line['lat']; // lat |
|
1122 | + $data['longitude'] = $line['lon']; // long |
|
1123 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1124 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1125 | + //$data['emergency'] = ''; // emergency |
|
1126 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1127 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1128 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1129 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1130 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1131 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1132 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1133 | + else $data['info'] = ''; |
|
1134 | + $data['format_source'] = 'pireps'; |
|
1135 | + $data['id_source'] = $id_source; |
|
1136 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1137 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1138 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1139 | + if ($line['icon'] == 'plane') { |
|
1140 | 1140 | $SI->add($data); |
1141 | - // print_r($data); |
|
1142 | - } elseif ($line['icon'] == 'ct') { |
|
1141 | + // print_r($data); |
|
1142 | + } elseif ($line['icon'] == 'ct') { |
|
1143 | 1143 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1144 | 1144 | $data['info'] = str_replace('&sect;','',$data['info']); |
1145 | 1145 | $typec = substr($data['ident'],-3); |
@@ -1154,209 +1154,209 @@ discard block |
||
1154 | 1154 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1155 | 1155 | else $data['type'] = 'Observer'; |
1156 | 1156 | 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']); |
1157 | - } |
|
1158 | - unset($data); |
|
1157 | + } |
|
1158 | + unset($data); |
|
1159 | + } |
|
1159 | 1160 | } |
1160 | - } |
|
1161 | - //$last_exec['pirepsjson'] = time(); |
|
1162 | - $last_exec[$id]['last'] = time(); |
|
1161 | + //$last_exec['pirepsjson'] = time(); |
|
1162 | + $last_exec[$id]['last'] = time(); |
|
1163 | 1163 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1164 | 1164 | } elseif ($value['format'] == 'phpvmacars' && |
1165 | - ( |
|
1165 | + ( |
|
1166 | 1166 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1167 | 1167 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1168 | - ) |
|
1168 | + ) |
|
1169 | 1169 | ) { |
1170 | - //$buffer = $Common->getData($hosts[$id]); |
|
1171 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1172 | - $buffer = $Common->getData($value['host']); |
|
1173 | - $all_data = json_decode($buffer,true); |
|
1174 | - if ($buffer != '' && is_array($all_data)) { |
|
1170 | + //$buffer = $Common->getData($hosts[$id]); |
|
1171 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1172 | + $buffer = $Common->getData($value['host']); |
|
1173 | + $all_data = json_decode($buffer,true); |
|
1174 | + if ($buffer != '' && is_array($all_data)) { |
|
1175 | 1175 | $reset = 0; |
1176 | 1176 | foreach ($all_data as $line) { |
1177 | - $data = array(); |
|
1178 | - //$data['id'] = $line['id']; // id not usable |
|
1179 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1180 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1181 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1182 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1183 | - $data['ident'] = $line['flightnum']; // ident |
|
1184 | - $data['altitude'] = $line['alt']; // altitude |
|
1185 | - $data['speed'] = $line['gs']; // speed |
|
1186 | - $data['heading'] = $line['heading']; // heading |
|
1187 | - $data['latitude'] = $line['lat']; // lat |
|
1188 | - $data['longitude'] = $line['lng']; // long |
|
1189 | - $data['verticalrate'] = ''; // verticale rate |
|
1190 | - $data['squawk'] = ''; // squawk |
|
1191 | - $data['emergency'] = ''; // emergency |
|
1192 | - //$data['datetime'] = $line['lastupdate']; |
|
1193 | - //$data['last_update'] = $line['lastupdate']; |
|
1194 | - if (isset($value['timezone'])) { |
|
1195 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1196 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1197 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1198 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1199 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1200 | - $data['departure_airport_time'] = $line['deptime']; |
|
1201 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1202 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1203 | - if (isset($line['registration'])) { |
|
1204 | - $data['registration'] = $line['registration']; |
|
1205 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1206 | - } else $data['registration'] = $line['aircraft']; |
|
1207 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1208 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1209 | - if (isset($line['aircraftname'])) { |
|
1177 | + $data = array(); |
|
1178 | + //$data['id'] = $line['id']; // id not usable |
|
1179 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1180 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1181 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1182 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1183 | + $data['ident'] = $line['flightnum']; // ident |
|
1184 | + $data['altitude'] = $line['alt']; // altitude |
|
1185 | + $data['speed'] = $line['gs']; // speed |
|
1186 | + $data['heading'] = $line['heading']; // heading |
|
1187 | + $data['latitude'] = $line['lat']; // lat |
|
1188 | + $data['longitude'] = $line['lng']; // long |
|
1189 | + $data['verticalrate'] = ''; // verticale rate |
|
1190 | + $data['squawk'] = ''; // squawk |
|
1191 | + $data['emergency'] = ''; // emergency |
|
1192 | + //$data['datetime'] = $line['lastupdate']; |
|
1193 | + //$data['last_update'] = $line['lastupdate']; |
|
1194 | + if (isset($value['timezone'])) { |
|
1195 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1196 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1197 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1198 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1199 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1200 | + $data['departure_airport_time'] = $line['deptime']; |
|
1201 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1202 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1203 | + if (isset($line['registration'])) { |
|
1204 | + $data['registration'] = $line['registration']; |
|
1205 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1206 | + } else $data['registration'] = $line['aircraft']; |
|
1207 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1208 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1209 | + if (isset($line['aircraftname'])) { |
|
1210 | 1210 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1211 | 1211 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1212 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1213 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1214 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1215 | - else { |
|
1216 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1217 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1218 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1219 | - } |
|
1220 | - } |
|
1221 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1222 | - $data['id_source'] = $id_source; |
|
1223 | - $data['format_source'] = 'phpvmacars'; |
|
1224 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1225 | - $SI->add($data); |
|
1226 | - unset($data); |
|
1212 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1213 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1214 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1215 | + else { |
|
1216 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1217 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1218 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1219 | + } |
|
1220 | + } |
|
1221 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1222 | + $data['id_source'] = $id_source; |
|
1223 | + $data['format_source'] = 'phpvmacars'; |
|
1224 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1225 | + $SI->add($data); |
|
1226 | + unset($data); |
|
1227 | 1227 | } |
1228 | 1228 | if ($globalDebug) echo 'No more data...'."\n"; |
1229 | 1229 | unset($buffer); |
1230 | 1230 | unset($all_data); |
1231 | - } |
|
1232 | - //$last_exec['phpvmacars'] = time(); |
|
1233 | - $last_exec[$id]['last'] = time(); |
|
1231 | + } |
|
1232 | + //$last_exec['phpvmacars'] = time(); |
|
1233 | + $last_exec[$id]['last'] = time(); |
|
1234 | 1234 | } elseif ($value['format'] == 'vaos' && |
1235 | - ( |
|
1235 | + ( |
|
1236 | 1236 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1237 | 1237 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1238 | - ) |
|
1238 | + ) |
|
1239 | 1239 | ) { |
1240 | - //$buffer = $Common->getData($hosts[$id]); |
|
1241 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1242 | - $buffer = $Common->getData($value['host']); |
|
1243 | - $all_data = json_decode($buffer,true); |
|
1244 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1240 | + //$buffer = $Common->getData($hosts[$id]); |
|
1241 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1242 | + $buffer = $Common->getData($value['host']); |
|
1243 | + $all_data = json_decode($buffer,true); |
|
1244 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1245 | 1245 | $reset = 0; |
1246 | 1246 | foreach ($all_data['ACARSData'] as $line) { |
1247 | - //print_r($line); |
|
1248 | - $data = array(); |
|
1249 | - //$data['id'] = $line['id']; // id not usable |
|
1250 | - $data['id'] = $line['id']; |
|
1251 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1252 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1253 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1254 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1255 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1256 | - $data['altitude'] = $line['altitude']; // altitude |
|
1257 | - $data['speed'] = $line['groundspeed']; // speed |
|
1258 | - $data['heading'] = $line['heading']; // heading |
|
1259 | - $data['latitude'] = $line['lat']; // lat |
|
1260 | - $data['longitude'] = $line['lon']; // long |
|
1261 | - //$data['verticalrate'] = ''; // verticale rate |
|
1262 | - //$data['squawk'] = ''; // squawk |
|
1263 | - //$data['emergency'] = ''; // emergency |
|
1264 | - if (isset($value['timezone'])) { |
|
1265 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1266 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1267 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1268 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1247 | + //print_r($line); |
|
1248 | + $data = array(); |
|
1249 | + //$data['id'] = $line['id']; // id not usable |
|
1250 | + $data['id'] = $line['id']; |
|
1251 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1252 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1253 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1254 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1255 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1256 | + $data['altitude'] = $line['altitude']; // altitude |
|
1257 | + $data['speed'] = $line['groundspeed']; // speed |
|
1258 | + $data['heading'] = $line['heading']; // heading |
|
1259 | + $data['latitude'] = $line['lat']; // lat |
|
1260 | + $data['longitude'] = $line['lon']; // long |
|
1261 | + //$data['verticalrate'] = ''; // verticale rate |
|
1262 | + //$data['squawk'] = ''; // squawk |
|
1263 | + //$data['emergency'] = ''; // emergency |
|
1264 | + if (isset($value['timezone'])) { |
|
1265 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1266 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1267 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1268 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1269 | 1269 | |
1270 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1271 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1272 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1273 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1274 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1270 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1271 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1272 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1273 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1274 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1275 | 1275 | |
1276 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1277 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1278 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1276 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1277 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1278 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1279 | 1279 | |
1280 | - $data['id_source'] = $id_source; |
|
1281 | - $data['format_source'] = 'vaos'; |
|
1282 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1283 | - $SI->add($data); |
|
1284 | - unset($data); |
|
1280 | + $data['id_source'] = $id_source; |
|
1281 | + $data['format_source'] = 'vaos'; |
|
1282 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1283 | + $SI->add($data); |
|
1284 | + unset($data); |
|
1285 | 1285 | } |
1286 | 1286 | if ($globalDebug) echo 'No more data...'."\n"; |
1287 | 1287 | unset($buffer); |
1288 | 1288 | unset($all_data); |
1289 | - } |
|
1290 | - //$last_exec['phpvmacars'] = time(); |
|
1291 | - $last_exec[$id]['last'] = time(); |
|
1289 | + } |
|
1290 | + //$last_exec['phpvmacars'] = time(); |
|
1291 | + $last_exec[$id]['last'] = time(); |
|
1292 | 1292 | } elseif ($value['format'] == 'vam' && |
1293 | - ( |
|
1293 | + ( |
|
1294 | 1294 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1295 | 1295 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1296 | - ) |
|
1296 | + ) |
|
1297 | 1297 | ) { |
1298 | - //$buffer = $Common->getData($hosts[$id]); |
|
1299 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1300 | - $buffer = $Common->getData($value['host']); |
|
1301 | - $all_data = json_decode($buffer,true); |
|
1302 | - if ($buffer != '' && is_array($all_data)) { |
|
1298 | + //$buffer = $Common->getData($hosts[$id]); |
|
1299 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1300 | + $buffer = $Common->getData($value['host']); |
|
1301 | + $all_data = json_decode($buffer,true); |
|
1302 | + if ($buffer != '' && is_array($all_data)) { |
|
1303 | 1303 | $reset = 0; |
1304 | 1304 | foreach ($all_data as $line) { |
1305 | - $data = array(); |
|
1306 | - //$data['id'] = $line['id']; // id not usable |
|
1307 | - $data['id'] = trim($line['flight_id']); |
|
1308 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1309 | - $data['pilot_name'] = $line['pilot_name']; |
|
1310 | - $data['pilot_id'] = $line['pilot_id']; |
|
1311 | - $data['ident'] = trim($line['callsign']); // ident |
|
1312 | - $data['altitude'] = $line['altitude']; // altitude |
|
1313 | - $data['speed'] = $line['gs']; // speed |
|
1314 | - $data['heading'] = $line['heading']; // heading |
|
1315 | - $data['latitude'] = $line['latitude']; // lat |
|
1316 | - $data['longitude'] = $line['longitude']; // long |
|
1317 | - $data['verticalrate'] = ''; // verticale rate |
|
1318 | - $data['squawk'] = ''; // squawk |
|
1319 | - $data['emergency'] = ''; // emergency |
|
1320 | - //$data['datetime'] = $line['lastupdate']; |
|
1321 | - $data['last_update'] = $line['last_update']; |
|
1322 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1323 | - $data['departure_airport_icao'] = $line['departure']; |
|
1324 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1325 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1326 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1327 | - //$data['registration'] = $line['aircraft']; |
|
1328 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1329 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1330 | - $data['id_source'] = $id_source; |
|
1331 | - $data['format_source'] = 'vam'; |
|
1332 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1333 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1334 | - $SI->add($data); |
|
1335 | - unset($data); |
|
1305 | + $data = array(); |
|
1306 | + //$data['id'] = $line['id']; // id not usable |
|
1307 | + $data['id'] = trim($line['flight_id']); |
|
1308 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1309 | + $data['pilot_name'] = $line['pilot_name']; |
|
1310 | + $data['pilot_id'] = $line['pilot_id']; |
|
1311 | + $data['ident'] = trim($line['callsign']); // ident |
|
1312 | + $data['altitude'] = $line['altitude']; // altitude |
|
1313 | + $data['speed'] = $line['gs']; // speed |
|
1314 | + $data['heading'] = $line['heading']; // heading |
|
1315 | + $data['latitude'] = $line['latitude']; // lat |
|
1316 | + $data['longitude'] = $line['longitude']; // long |
|
1317 | + $data['verticalrate'] = ''; // verticale rate |
|
1318 | + $data['squawk'] = ''; // squawk |
|
1319 | + $data['emergency'] = ''; // emergency |
|
1320 | + //$data['datetime'] = $line['lastupdate']; |
|
1321 | + $data['last_update'] = $line['last_update']; |
|
1322 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1323 | + $data['departure_airport_icao'] = $line['departure']; |
|
1324 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1325 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1326 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1327 | + //$data['registration'] = $line['aircraft']; |
|
1328 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1329 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1330 | + $data['id_source'] = $id_source; |
|
1331 | + $data['format_source'] = 'vam'; |
|
1332 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1333 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1334 | + $SI->add($data); |
|
1335 | + unset($data); |
|
1336 | 1336 | } |
1337 | 1337 | if ($globalDebug) echo 'No more data...'."\n"; |
1338 | 1338 | unset($buffer); |
1339 | 1339 | unset($all_data); |
1340 | - } |
|
1341 | - //$last_exec['phpvmacars'] = time(); |
|
1342 | - $last_exec[$id]['last'] = time(); |
|
1340 | + } |
|
1341 | + //$last_exec['phpvmacars'] = time(); |
|
1342 | + $last_exec[$id]['last'] = time(); |
|
1343 | 1343 | } elseif ($value['format'] == 'blitzortung' && |
1344 | - ( |
|
1344 | + ( |
|
1345 | 1345 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1346 | 1346 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1347 | - ) |
|
1347 | + ) |
|
1348 | 1348 | ) { |
1349 | - //$buffer = $Common->getData($hosts[$id]); |
|
1350 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1351 | - $buffer = $Common->getData($value['host']); |
|
1352 | - $all_data = json_decode($buffer,true); |
|
1353 | - if ($buffer != '') { |
|
1349 | + //$buffer = $Common->getData($hosts[$id]); |
|
1350 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1351 | + $buffer = $Common->getData($value['host']); |
|
1352 | + $all_data = json_decode($buffer,true); |
|
1353 | + if ($buffer != '') { |
|
1354 | 1354 | $Source->deleteLocationBySource('blitzortung'); |
1355 | 1355 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1356 | 1356 | $buffer = explode('\n',$buffer); |
1357 | 1357 | foreach ($buffer as $buffer_line) { |
1358 | - $line = json_decode($buffer_line,true); |
|
1359 | - if (isset($line['time'])) { |
|
1358 | + $line = json_decode($buffer_line,true); |
|
1359 | + if (isset($line['time'])) { |
|
1360 | 1360 | $data = array(); |
1361 | 1361 | $data['altitude'] = $line['alt']; // altitude |
1362 | 1362 | $data['latitude'] = $line['lat']; // lat |
@@ -1368,96 +1368,96 @@ discard block |
||
1368 | 1368 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1369 | 1369 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1370 | 1370 | unset($data); |
1371 | - } |
|
1371 | + } |
|
1372 | 1372 | } |
1373 | 1373 | if ($globalDebug) echo 'No more data...'."\n"; |
1374 | 1374 | unset($buffer); |
1375 | - } |
|
1376 | - $last_exec[$id]['last'] = time(); |
|
1375 | + } |
|
1376 | + $last_exec[$id]['last'] = time(); |
|
1377 | 1377 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1378 | 1378 | } 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') { |
1379 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1380 | - //$last_exec[$id]['last'] = time(); |
|
1379 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1380 | + //$last_exec[$id]['last'] = time(); |
|
1381 | 1381 | |
1382 | - //$read = array( $sockets[$id] ); |
|
1383 | - $read = $sockets; |
|
1384 | - $write = NULL; |
|
1385 | - $e = NULL; |
|
1386 | - $n = socket_select($read, $write, $e, $timeout); |
|
1387 | - if ($e != NULL) var_dump($e); |
|
1388 | - if ($n > 0) { |
|
1382 | + //$read = array( $sockets[$id] ); |
|
1383 | + $read = $sockets; |
|
1384 | + $write = NULL; |
|
1385 | + $e = NULL; |
|
1386 | + $n = socket_select($read, $write, $e, $timeout); |
|
1387 | + if ($e != NULL) var_dump($e); |
|
1388 | + if ($n > 0) { |
|
1389 | 1389 | $reset = 0; |
1390 | 1390 | foreach ($read as $nb => $r) { |
1391 | - //$value = $formats[$nb]; |
|
1392 | - $format = $globalSources[$nb]['format']; |
|
1393 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1391 | + //$value = $formats[$nb]; |
|
1392 | + $format = $globalSources[$nb]['format']; |
|
1393 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1394 | 1394 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1395 | - } elseif ($format == 'vrstcp') { |
|
1395 | + } elseif ($format == 'vrstcp') { |
|
1396 | 1396 | $buffer = @socket_read($r, 6000); |
1397 | - } else { |
|
1397 | + } else { |
|
1398 | 1398 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1399 | - } |
|
1400 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1401 | - //echo $buffer."\n"; |
|
1402 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1403 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1404 | - $error = false; |
|
1405 | - //$SI::del(); |
|
1406 | - if ($buffer !== FALSE) { |
|
1399 | + } |
|
1400 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1401 | + //echo $buffer."\n"; |
|
1402 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1403 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1404 | + $error = false; |
|
1405 | + //$SI::del(); |
|
1406 | + if ($buffer !== FALSE) { |
|
1407 | 1407 | if ($format == 'vrstcp') { |
1408 | - $buffer = explode('},{',$buffer); |
|
1408 | + $buffer = explode('},{',$buffer); |
|
1409 | 1409 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
1410 | - } |
|
1411 | - // SBS format is CSV format |
|
1412 | - if ($buffer !== FALSE && $buffer !== '') { |
|
1410 | + } |
|
1411 | + // SBS format is CSV format |
|
1412 | + if ($buffer !== FALSE && $buffer !== '') { |
|
1413 | 1413 | $tt[$format] = 0; |
1414 | 1414 | if ($format == 'acarssbs3') { |
1415 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1416 | - $ACARS->add(trim($buffer)); |
|
1417 | - $ACARS->deleteLiveAcarsData(); |
|
1415 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1416 | + $ACARS->add(trim($buffer)); |
|
1417 | + $ACARS->deleteLiveAcarsData(); |
|
1418 | 1418 | } elseif ($format == 'raw') { |
1419 | - // AVR format |
|
1420 | - $data = $SBS->parse($buffer); |
|
1421 | - if (is_array($data)) { |
|
1419 | + // AVR format |
|
1420 | + $data = $SBS->parse($buffer); |
|
1421 | + if (is_array($data)) { |
|
1422 | 1422 | $data['datetime'] = date('Y-m-d H:i:s'); |
1423 | 1423 | $data['format_source'] = 'raw'; |
1424 | 1424 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1425 | 1425 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1426 | 1426 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1427 | 1427 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1428 | - } |
|
1428 | + } |
|
1429 | 1429 | } elseif ($format == 'ais') { |
1430 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1431 | - $data = array(); |
|
1432 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1433 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1434 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1435 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1436 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1437 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1438 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1439 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1440 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1441 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1442 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1443 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1444 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1445 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1446 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1447 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1430 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1431 | + $data = array(); |
|
1432 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1433 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1434 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1435 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1436 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1437 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1438 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1439 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1440 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1441 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1442 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1443 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1444 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1445 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1446 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1447 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1448 | 1448 | |
1449 | - if (isset($ais_data['timestamp'])) { |
|
1449 | + if (isset($ais_data['timestamp'])) { |
|
1450 | 1450 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1451 | - } else { |
|
1451 | + } else { |
|
1452 | 1452 | $data['datetime'] = date('Y-m-d H:i:s'); |
1453 | - } |
|
1454 | - $data['format_source'] = 'aisnmea'; |
|
1455 | - $data['id_source'] = $id_source; |
|
1456 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1457 | - unset($data); |
|
1458 | - } elseif ($format == 'flightgearsp') { |
|
1459 | - //echo $buffer."\n"; |
|
1460 | - if (strlen($buffer) > 5) { |
|
1453 | + } |
|
1454 | + $data['format_source'] = 'aisnmea'; |
|
1455 | + $data['id_source'] = $id_source; |
|
1456 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1457 | + unset($data); |
|
1458 | + } elseif ($format == 'flightgearsp') { |
|
1459 | + //echo $buffer."\n"; |
|
1460 | + if (strlen($buffer) > 5) { |
|
1461 | 1461 | $line = explode(',',$buffer); |
1462 | 1462 | $data = array(); |
1463 | 1463 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1474,38 +1474,38 @@ discard block |
||
1474 | 1474 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1475 | 1475 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1476 | 1476 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1477 | - } |
|
1478 | - } elseif ($format == 'acars') { |
|
1479 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1480 | - $ACARS->add(trim($buffer)); |
|
1481 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1482 | - $ACARS->deleteLiveAcarsData(); |
|
1477 | + } |
|
1478 | + } elseif ($format == 'acars') { |
|
1479 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1480 | + $ACARS->add(trim($buffer)); |
|
1481 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1482 | + $ACARS->deleteLiveAcarsData(); |
|
1483 | 1483 | } elseif ($format == 'flightgearmp') { |
1484 | - if (substr($buffer,0,1) != '#') { |
|
1484 | + if (substr($buffer,0,1) != '#') { |
|
1485 | 1485 | $data = array(); |
1486 | 1486 | //echo $buffer."\n"; |
1487 | 1487 | $line = explode(' ',$buffer); |
1488 | 1488 | if (count($line) == 11) { |
1489 | - $userserver = explode('@',$line[0]); |
|
1490 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1491 | - $data['ident'] = $userserver[0]; |
|
1492 | - $data['registration'] = $userserver[0]; |
|
1493 | - $data['latitude'] = $line[4]; |
|
1494 | - $data['longitude'] = $line[5]; |
|
1495 | - $data['altitude'] = $line[6]; |
|
1496 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1497 | - $aircraft_type = $line[10]; |
|
1498 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1499 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1500 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1501 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1489 | + $userserver = explode('@',$line[0]); |
|
1490 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1491 | + $data['ident'] = $userserver[0]; |
|
1492 | + $data['registration'] = $userserver[0]; |
|
1493 | + $data['latitude'] = $line[4]; |
|
1494 | + $data['longitude'] = $line[5]; |
|
1495 | + $data['altitude'] = $line[6]; |
|
1496 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1497 | + $aircraft_type = $line[10]; |
|
1498 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1499 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1500 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1501 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1502 | + } |
|
1502 | 1503 | } |
1503 | - } |
|
1504 | 1504 | } elseif ($format == 'beast') { |
1505 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1506 | - die; |
|
1505 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1506 | + die; |
|
1507 | 1507 | } elseif ($format == 'vrstcp') { |
1508 | - foreach($buffer as $all_data) { |
|
1508 | + foreach($buffer as $all_data) { |
|
1509 | 1509 | $line = json_decode('{'.$all_data.'}',true); |
1510 | 1510 | $data = array(); |
1511 | 1511 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1525,153 +1525,153 @@ discard block |
||
1525 | 1525 | */ |
1526 | 1526 | $data['datetime'] = date('Y-m-d H:i:s'); |
1527 | 1527 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1528 | - $data['format_source'] = 'vrstcp'; |
|
1528 | + $data['format_source'] = 'vrstcp'; |
|
1529 | 1529 | $data['id_source'] = $id_source; |
1530 | 1530 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1531 | 1531 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1532 | 1532 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1533 | 1533 | unset($data); |
1534 | - } |
|
1534 | + } |
|
1535 | 1535 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1536 | - $line = explode("\t", $buffer); |
|
1537 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1536 | + $line = explode("\t", $buffer); |
|
1537 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1538 | 1538 | $key = $line[$k]; |
1539 | - $lined[$key] = $line[$k+1]; |
|
1540 | - } |
|
1541 | - if (count($lined) > 3) { |
|
1542 | - $data['hex'] = $lined['hexid']; |
|
1543 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1544 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1545 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1546 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1547 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1548 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1549 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1550 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1551 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1552 | - $data['id_source'] = $id_source; |
|
1553 | - $data['format_source'] = 'tsv'; |
|
1554 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1555 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1539 | + $lined[$key] = $line[$k+1]; |
|
1540 | + } |
|
1541 | + if (count($lined) > 3) { |
|
1542 | + $data['hex'] = $lined['hexid']; |
|
1543 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1544 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1545 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1546 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1547 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1548 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1549 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1550 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1551 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1552 | + $data['id_source'] = $id_source; |
|
1553 | + $data['format_source'] = 'tsv'; |
|
1554 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1555 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1556 | 1556 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1557 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1558 | - unset($lined); |
|
1559 | - unset($data); |
|
1560 | - } else $error = true; |
|
1557 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1558 | + unset($lined); |
|
1559 | + unset($data); |
|
1560 | + } else $error = true; |
|
1561 | 1561 | } elseif ($format == 'aprs' && $use_aprs) { |
1562 | - if ($aprs_connect == 0) { |
|
1562 | + if ($aprs_connect == 0) { |
|
1563 | 1563 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1564 | 1564 | $aprs_connect = 1; |
1565 | - } |
|
1565 | + } |
|
1566 | 1566 | |
1567 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1567 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1568 | 1568 | $aprs_last_tx = time(); |
1569 | 1569 | $data_aprs = "# Keep alive"; |
1570 | 1570 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1571 | - } |
|
1571 | + } |
|
1572 | 1572 | |
1573 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1574 | - //echo 'APRS data : '.$buffer."\n"; |
|
1575 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1576 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1577 | - //echo $buffer."\n"; |
|
1578 | - date_default_timezone_set('UTC'); |
|
1579 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1573 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1574 | + //echo 'APRS data : '.$buffer."\n"; |
|
1575 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1576 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1577 | + //echo $buffer."\n"; |
|
1578 | + date_default_timezone_set('UTC'); |
|
1579 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1580 | 1580 | $line = $APRS->parse($buffer); |
1581 | 1581 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1582 | 1582 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1583 | - $aprs_last_tx = time(); |
|
1584 | - $data = array(); |
|
1585 | - //print_r($line); |
|
1586 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1587 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1588 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1589 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1590 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1591 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1592 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1593 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1594 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1595 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1596 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1597 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1598 | - $data['latitude'] = $line['latitude']; |
|
1599 | - $data['longitude'] = $line['longitude']; |
|
1600 | - //$data['verticalrate'] = $line[16]; |
|
1601 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1602 | - //else $data['speed'] = 0; |
|
1603 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1604 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1605 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1606 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1583 | + $aprs_last_tx = time(); |
|
1584 | + $data = array(); |
|
1585 | + //print_r($line); |
|
1586 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1587 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1588 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1589 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1590 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1591 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1592 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1593 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1594 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1595 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1596 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1597 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1598 | + $data['latitude'] = $line['latitude']; |
|
1599 | + $data['longitude'] = $line['longitude']; |
|
1600 | + //$data['verticalrate'] = $line[16]; |
|
1601 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1602 | + //else $data['speed'] = 0; |
|
1603 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1604 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1605 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1606 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1607 | 1607 | |
1608 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1609 | - //else echo 'No heading...'."\n"; |
|
1610 | - //else $data['heading'] = 0; |
|
1611 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1612 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1613 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1614 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1615 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1616 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1617 | - $data['id_source'] = $id_source; |
|
1618 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1619 | - else $data['format_source'] = 'aprs'; |
|
1620 | - $data['source_name'] = $line['source']; |
|
1621 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1622 | - else $data['source_type'] = 'flarm'; |
|
1623 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1624 | - $currentdate = date('Y-m-d H:i:s'); |
|
1625 | - $aprsdate = strtotime($data['datetime']); |
|
1626 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1627 | - // Accept data if time <= system time + 20s |
|
1628 | - //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'])))) { |
|
1629 | - 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'])))) { |
|
1608 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1609 | + //else echo 'No heading...'."\n"; |
|
1610 | + //else $data['heading'] = 0; |
|
1611 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1612 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1613 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1614 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1615 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1616 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1617 | + $data['id_source'] = $id_source; |
|
1618 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1619 | + else $data['format_source'] = 'aprs'; |
|
1620 | + $data['source_name'] = $line['source']; |
|
1621 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1622 | + else $data['source_type'] = 'flarm'; |
|
1623 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1624 | + $currentdate = date('Y-m-d H:i:s'); |
|
1625 | + $aprsdate = strtotime($data['datetime']); |
|
1626 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1627 | + // Accept data if time <= system time + 20s |
|
1628 | + //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'])))) { |
|
1629 | + 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'])))) { |
|
1630 | 1630 | $send = $SI->add($data); |
1631 | - } elseif ($data['source_type'] == 'ais') { |
|
1631 | + } elseif ($data['source_type'] == 'ais') { |
|
1632 | 1632 | $data['type'] = ''; |
1633 | 1633 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1634 | - } elseif (isset($line['stealth'])) { |
|
1634 | + } elseif (isset($line['stealth'])) { |
|
1635 | 1635 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1636 | 1636 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1637 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1638 | - //$line['symbol'] == 'Balloon' || |
|
1639 | - $line['symbol'] == 'Glider' || |
|
1640 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1641 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1642 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1643 | - $send = $SI->add($data); |
|
1644 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1645 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1646 | - $line['symbol'] == 'Ship (Power Boat)')) { |
|
1647 | - $send = $MI->add($data); |
|
1648 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1649 | - $line['symbol'] == 'Car' || |
|
1650 | - $line['symbol'] == 'Ambulance' || |
|
1651 | - $line['symbol'] == 'Van' || |
|
1652 | - $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1653 | - $line['symbol'] == 'Motorcycle' || |
|
1654 | - $line['symbol'] == 'Tractor' || |
|
1655 | - $line['symbol'] == 'Police' || |
|
1656 | - $line['symbol'] == 'Bike' || |
|
1657 | - $line['symbol'] == 'Jogger' || |
|
1658 | - $line['symbol'] == 'Horse' || |
|
1659 | - $line['symbol'] == 'Bus' || |
|
1660 | - $line['symbol'] == 'Jeep' || |
|
1661 | - $line['symbol'] == 'Recreational Vehicle' || |
|
1662 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1663 | - $line['symbol'] == 'Ship (Power Boat)' || |
|
1664 | - $line['symbol'] == 'Firetruck' || |
|
1665 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1666 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1667 | - $line['symbol'] == 'SUV' || |
|
1668 | - $line['symbol'] == 'Snowmobile' || |
|
1669 | - $line['symbol'] == 'Mobile Satellite Station')) { |
|
1670 | - //} 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') { |
|
1637 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1638 | + //$line['symbol'] == 'Balloon' || |
|
1639 | + $line['symbol'] == 'Glider' || |
|
1640 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1641 | + if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1642 | + if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1643 | + $send = $SI->add($data); |
|
1644 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1645 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1646 | + $line['symbol'] == 'Ship (Power Boat)')) { |
|
1647 | + $send = $MI->add($data); |
|
1648 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1649 | + $line['symbol'] == 'Car' || |
|
1650 | + $line['symbol'] == 'Ambulance' || |
|
1651 | + $line['symbol'] == 'Van' || |
|
1652 | + $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1653 | + $line['symbol'] == 'Motorcycle' || |
|
1654 | + $line['symbol'] == 'Tractor' || |
|
1655 | + $line['symbol'] == 'Police' || |
|
1656 | + $line['symbol'] == 'Bike' || |
|
1657 | + $line['symbol'] == 'Jogger' || |
|
1658 | + $line['symbol'] == 'Horse' || |
|
1659 | + $line['symbol'] == 'Bus' || |
|
1660 | + $line['symbol'] == 'Jeep' || |
|
1661 | + $line['symbol'] == 'Recreational Vehicle' || |
|
1662 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1663 | + $line['symbol'] == 'Ship (Power Boat)' || |
|
1664 | + $line['symbol'] == 'Firetruck' || |
|
1665 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1666 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1667 | + $line['symbol'] == 'SUV' || |
|
1668 | + $line['symbol'] == 'Snowmobile' || |
|
1669 | + $line['symbol'] == 'Mobile Satellite Station')) { |
|
1670 | + //} 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') { |
|
1671 | 1671 | // } 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') { |
1672 | 1672 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1673 | 1673 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1674 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1674 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1675 | 1675 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1676 | 1676 | $Source->deleteOldLocationByType('gs'); |
1677 | 1677 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1679,7 +1679,7 @@ discard block |
||
1679 | 1679 | } else { |
1680 | 1680 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1681 | 1681 | } |
1682 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1682 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1683 | 1683 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1684 | 1684 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1685 | 1685 | $Source->deleteOldLocationByType('wx'); |
@@ -1689,7 +1689,7 @@ discard block |
||
1689 | 1689 | } else { |
1690 | 1690 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1691 | 1691 | } |
1692 | - } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
|
1692 | + } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
|
1693 | 1693 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1694 | 1694 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1695 | 1695 | $Source->deleteOldLocationByType('lightning'); |
@@ -1698,11 +1698,11 @@ discard block |
||
1698 | 1698 | } else { |
1699 | 1699 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1700 | 1700 | } |
1701 | - } elseif ($globalDebug) { |
|
1702 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1703 | - print_r($line); |
|
1704 | - } |
|
1705 | - unset($data); |
|
1701 | + } elseif ($globalDebug) { |
|
1702 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1703 | + print_r($line); |
|
1704 | + } |
|
1705 | + unset($data); |
|
1706 | 1706 | } |
1707 | 1707 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1708 | 1708 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1721,12 +1721,12 @@ discard block |
||
1721 | 1721 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1722 | 1722 | $globalSources[$nb]['last_weather_clean'] = time(); |
1723 | 1723 | } |
1724 | - } |
|
1724 | + } |
|
1725 | 1725 | } else { |
1726 | - $line = explode(',', $buffer); |
|
1727 | - if (count($line) > 20) { |
|
1728 | - $data['hex'] = $line[4]; |
|
1729 | - /* |
|
1726 | + $line = explode(',', $buffer); |
|
1727 | + if (count($line) > 20) { |
|
1728 | + $data['hex'] = $line[4]; |
|
1729 | + /* |
|
1730 | 1730 | $data['datetime'] = $line[6].' '.$line[7]; |
1731 | 1731 | date_default_timezone_set($globalTimezone); |
1732 | 1732 | $datetime = new DateTime($data['datetime']); |
@@ -1734,30 +1734,30 @@ discard block |
||
1734 | 1734 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1735 | 1735 | date_default_timezone_set('UTC'); |
1736 | 1736 | */ |
1737 | - // Force datetime to current UTC datetime |
|
1738 | - date_default_timezone_set('UTC'); |
|
1739 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1740 | - $data['ident'] = trim($line[10]); |
|
1741 | - $data['latitude'] = $line[14]; |
|
1742 | - $data['longitude'] = $line[15]; |
|
1743 | - $data['verticalrate'] = $line[16]; |
|
1744 | - $data['emergency'] = $line[20]; |
|
1745 | - $data['speed'] = $line[12]; |
|
1746 | - $data['squawk'] = $line[17]; |
|
1747 | - $data['altitude'] = $line[11]; |
|
1748 | - $data['heading'] = $line[13]; |
|
1749 | - $data['ground'] = $line[21]; |
|
1750 | - $data['emergency'] = $line[19]; |
|
1751 | - $data['format_source'] = 'sbs'; |
|
1737 | + // Force datetime to current UTC datetime |
|
1738 | + date_default_timezone_set('UTC'); |
|
1739 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1740 | + $data['ident'] = trim($line[10]); |
|
1741 | + $data['latitude'] = $line[14]; |
|
1742 | + $data['longitude'] = $line[15]; |
|
1743 | + $data['verticalrate'] = $line[16]; |
|
1744 | + $data['emergency'] = $line[20]; |
|
1745 | + $data['speed'] = $line[12]; |
|
1746 | + $data['squawk'] = $line[17]; |
|
1747 | + $data['altitude'] = $line[11]; |
|
1748 | + $data['heading'] = $line[13]; |
|
1749 | + $data['ground'] = $line[21]; |
|
1750 | + $data['emergency'] = $line[19]; |
|
1751 | + $data['format_source'] = 'sbs'; |
|
1752 | 1752 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1753 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1753 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1754 | 1754 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1755 | - $data['id_source'] = $id_source; |
|
1756 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1757 | - else $error = true; |
|
1758 | - unset($data); |
|
1759 | - } else $error = true; |
|
1760 | - if ($error) { |
|
1755 | + $data['id_source'] = $id_source; |
|
1756 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1757 | + else $error = true; |
|
1758 | + unset($data); |
|
1759 | + } else $error = true; |
|
1760 | + if ($error) { |
|
1761 | 1761 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1762 | 1762 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1763 | 1763 | } else { |
@@ -1773,13 +1773,13 @@ discard block |
||
1773 | 1773 | connect_all($sourceer); |
1774 | 1774 | $sourceer = array(); |
1775 | 1775 | } |
1776 | - } |
|
1776 | + } |
|
1777 | 1777 | } |
1778 | 1778 | // Sleep for xxx microseconds |
1779 | 1779 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1780 | - } else { |
|
1780 | + } else { |
|
1781 | 1781 | if ($format == 'flightgearmp') { |
1782 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1782 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1783 | 1783 | //@socket_close($r); |
1784 | 1784 | sleep($globalMinFetch); |
1785 | 1785 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1788,9 +1788,9 @@ discard block |
||
1788 | 1788 | break; |
1789 | 1789 | |
1790 | 1790 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1791 | - if (isset($tt[$format])) $tt[$format]++; |
|
1792 | - else $tt[$format] = 0; |
|
1793 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1791 | + if (isset($tt[$format])) $tt[$format]++; |
|
1792 | + else $tt[$format] = 0; |
|
1793 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1794 | 1794 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1795 | 1795 | //@socket_close($r); |
1796 | 1796 | sleep(2); |
@@ -1801,24 +1801,24 @@ discard block |
||
1801 | 1801 | //connect_all($globalSources); |
1802 | 1802 | $tt[$format]=0; |
1803 | 1803 | break; |
1804 | - } |
|
1805 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1804 | + } |
|
1805 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1806 | + } |
|
1806 | 1807 | } |
1807 | - } |
|
1808 | 1808 | } |
1809 | - } else { |
|
1809 | + } else { |
|
1810 | 1810 | $error = socket_strerror(socket_last_error()); |
1811 | 1811 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1812 | 1812 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1813 | 1813 | if (isset($globalDebug)) echo "Restarting...\n"; |
1814 | 1814 | // Restart the script if possible |
1815 | 1815 | if (is_array($sockets)) { |
1816 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1816 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1817 | 1817 | |
1818 | - foreach ($sockets as $sock) { |
|
1818 | + foreach ($sockets as $sock) { |
|
1819 | 1819 | @socket_shutdown($sock,2); |
1820 | 1820 | @socket_close($sock); |
1821 | - } |
|
1821 | + } |
|
1822 | 1822 | |
1823 | 1823 | } |
1824 | 1824 | if ($globalDebug) echo "Waiting..."; |
@@ -1833,15 +1833,15 @@ discard block |
||
1833 | 1833 | if ($globalDebug) echo "Restart all connections..."; |
1834 | 1834 | connect_all($globalSources); |
1835 | 1835 | } |
1836 | - } |
|
1836 | + } |
|
1837 | 1837 | } |
1838 | 1838 | if ($globalDaemon === false) { |
1839 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1840 | - if (isset($SI)) $SI->checkAll(); |
|
1841 | - if (isset($TI)) $TI->checkAll(); |
|
1842 | - if (isset($MI)) $MI->checkAll(); |
|
1839 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1840 | + if (isset($SI)) $SI->checkAll(); |
|
1841 | + if (isset($TI)) $TI->checkAll(); |
|
1842 | + if (isset($MI)) $MI->checkAll(); |
|
1843 | + } |
|
1843 | 1844 | } |
1844 | - } |
|
1845 | 1845 | } |
1846 | 1846 | |
1847 | 1847 | ?> |
@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Stats.php'); |
10 | 10 | require_once(dirname(__FILE__).'/class.Source.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 MarineImport { |
16 | - private $all_tracked = 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_tracked = 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, $APRSMarine, $globalNoDB; |
27 | 27 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
28 | - $Connection = new Connection($dbc); |
|
29 | - $this->db = $Connection->db(); |
|
30 | - date_default_timezone_set('UTC'); |
|
28 | + $Connection = new Connection($dbc); |
|
29 | + $this->db = $Connection->db(); |
|
30 | + date_default_timezone_set('UTC'); |
|
31 | 31 | } |
32 | 32 | // Get previous source stats |
33 | 33 | /* |
@@ -46,57 +46,57 @@ discard block |
||
46 | 46 | } |
47 | 47 | */ |
48 | 48 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
49 | - $APRSMarine = new APRSMarine(); |
|
50 | - //$APRSSpotter->connect(); |
|
49 | + $APRSMarine = new APRSMarine(); |
|
50 | + //$APRSSpotter->connect(); |
|
51 | + } |
|
51 | 52 | } |
52 | - } |
|
53 | 53 | |
54 | - public function checkAll() { |
|
54 | + public function checkAll() { |
|
55 | 55 | global $globalDebug, $globalNoDB; |
56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
58 | - foreach ($this->all_tracked as $key => $flight) { |
|
57 | + if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
58 | + foreach ($this->all_tracked as $key => $flight) { |
|
59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
60 | - //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
61 | - $Marine = new Marine($this->db); |
|
62 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
60 | + //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
61 | + $Marine = new Marine($this->db); |
|
62 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
63 | + } |
|
63 | 64 | } |
64 | - } |
|
65 | 65 | } |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | - public function del() { |
|
68 | + public function del() { |
|
69 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 70 | // Delete old infos |
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | - if (isset($flight['lastupdate'])) { |
|
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
75 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
76 | - if (isset($this->all_tracked[$key]['id'])) { |
|
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
78 | - /* |
|
73 | + if (isset($flight['lastupdate'])) { |
|
74 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
75 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
76 | + if (isset($this->all_tracked[$key]['id'])) { |
|
77 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
78 | + /* |
|
79 | 79 | $MarineLive = new MarineLive(); |
80 | 80 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
81 | 81 | $MarineLive->db = null; |
82 | 82 | */ |
83 | - //$real_arrival = $this->arrival($key); |
|
84 | - $Marine = new Marine($this->db); |
|
85 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
83 | + //$real_arrival = $this->arrival($key); |
|
84 | + $Marine = new Marine($this->db); |
|
85 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
86 | 86 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
88 | - } |
|
89 | - // Put in archive |
|
88 | + } |
|
89 | + // Put in archive |
|
90 | 90 | // $Marine->db = null; |
91 | 91 | } |
92 | - } |
|
93 | - unset($this->all_tracked[$key]); |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
97 | - } |
|
92 | + } |
|
93 | + unset($this->all_tracked[$key]); |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | + } |
|
98 | 98 | |
99 | - public function add($line) { |
|
99 | + public function add($line) { |
|
100 | 100 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
@@ -105,104 +105,104 @@ discard block |
||
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | 107 | if(is_array($line) && isset($line['mmsi'])) { |
108 | - //print_r($line); |
|
109 | - if (isset($line['mmsi'])) { |
|
108 | + //print_r($line); |
|
109 | + if (isset($line['mmsi'])) { |
|
110 | 110 | |
111 | 111 | |
112 | 112 | // Increment message number |
113 | 113 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | - $current_date = date('Y-m-d'); |
|
115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | - else $source = ''; |
|
117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
118 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
119 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
120 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
114 | + $current_date = date('Y-m-d'); |
|
115 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | + else $source = ''; |
|
117 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
118 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
119 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
120 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
121 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | |
125 | 125 | $Common = new Common(); |
126 | 126 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
127 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | + else $id = trim($line['id']); |
|
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | - $this->all_tracked[$id] = array(); |
|
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
135 | - if (!isset($line['id'])) { |
|
131 | + $this->all_tracked[$id] = array(); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
135 | + if (!isset($line['id'])) { |
|
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
137 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
144 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
144 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
145 | 145 | $Marine = new Marine($this->db); |
146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
147 | 147 | if (!empty($identity)) { |
148 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
148 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
151 | 151 | } |
152 | 152 | //print_r($identity); |
153 | 153 | unset($Marine); |
154 | 154 | //$dataFound = true; |
155 | - } |
|
155 | + } |
|
156 | 156 | } |
157 | 157 | if (isset($line['type_id'])) { |
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
160 | 160 | } |
161 | 161 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
162 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
162 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
164 | 164 | } |
165 | 165 | if (isset($line['status']) && $line['status'] != '') { |
166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
167 | 167 | } |
168 | 168 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
170 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
170 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
171 | 171 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
172 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
172 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
173 | 173 | $Marine = new Marine($this->db); |
174 | 174 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
175 | 175 | unset($Marine); |
176 | - } |
|
176 | + } |
|
177 | + } |
|
177 | 178 | } |
178 | - } |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
182 | 182 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
183 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
183 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
184 | 184 | } |
185 | 185 | if (isset($line['imo']) && $line['imo'] != '') { |
186 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
186 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
187 | 187 | } |
188 | 188 | if (isset($line['callsign']) && $line['callsign'] != '') { |
189 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
189 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
190 | 190 | } |
191 | 191 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
192 | - if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
192 | + if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
193 | 193 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
194 | 194 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
195 | 195 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
196 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
196 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
197 | 197 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
198 | - $Marine = new Marine($this->db); |
|
199 | - $fromsource = NULL; |
|
200 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
201 | - $Marine->db = null; |
|
198 | + $Marine = new Marine($this->db); |
|
199 | + $fromsource = NULL; |
|
200 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
201 | + $Marine->db = null; |
|
202 | + } |
|
202 | 203 | } |
203 | - } |
|
204 | 204 | } |
205 | - } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
205 | + } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
206 | 206 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
207 | 207 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
208 | 208 | if (!isset($line['id'])) { |
@@ -210,26 +210,26 @@ discard block |
||
210 | 210 | $this->all_tracked[$id]['forcenew'] = 1; |
211 | 211 | $this->all_tracked[$id]['addedMarine'] = 0; |
212 | 212 | } |
213 | - } |
|
213 | + } |
|
214 | 214 | } |
215 | 215 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
216 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
216 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
220 | 220 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
221 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
221 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
222 | 222 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
223 | - $timeelapsed = microtime(true); |
|
224 | - $Marine = new Marine($this->db); |
|
225 | - $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
226 | - $Marine->db = null; |
|
223 | + $timeelapsed = microtime(true); |
|
224 | + $Marine = new Marine($this->db); |
|
225 | + $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
226 | + $Marine->db = null; |
|
227 | + } |
|
227 | 228 | } |
228 | - } |
|
229 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
230 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
229 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
230 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
231 | 231 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
232 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
232 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
233 | 233 | $timeelapsed = microtime(true); |
234 | 234 | $Marine = new Marine($this->db); |
235 | 235 | $fromsource = NULL; |
@@ -237,20 +237,20 @@ discard block |
||
237 | 237 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
238 | 238 | $Marine->db = null; |
239 | 239 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
240 | - } |
|
240 | + } |
|
241 | + } |
|
241 | 242 | } |
242 | - } |
|
243 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
243 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
247 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
247 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
248 | 248 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
249 | - } else { |
|
249 | + } else { |
|
250 | 250 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
251 | 251 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
252 | 252 | return ''; |
253 | - } |
|
253 | + } |
|
254 | 254 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
255 | 255 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
256 | 256 | return ''; |
@@ -267,24 +267,24 @@ discard block |
||
267 | 267 | |
268 | 268 | |
269 | 269 | if (isset($line['speed'])) { |
270 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
271 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
270 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
271 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
272 | 272 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
273 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
274 | - if ($distance > 1000 && $distance < 10000) { |
|
273 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
274 | + if ($distance > 1000 && $distance < 10000) { |
|
275 | 275 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
276 | 276 | $speed = $speed*3.6; |
277 | 277 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
278 | 278 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
279 | - } |
|
279 | + } |
|
280 | 280 | } |
281 | 281 | |
282 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
283 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
284 | - else unset($timediff); |
|
285 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
282 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
283 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
284 | + else unset($timediff); |
|
285 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
286 | 286 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
287 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
287 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
288 | 288 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
289 | 289 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
290 | 290 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -292,195 +292,195 @@ discard block |
||
292 | 292 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
293 | 293 | $timeelapsed = microtime(true); |
294 | 294 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
295 | - $Marine = new Marine($this->db); |
|
296 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
297 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
298 | - $Marine->db = null; |
|
299 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
295 | + $Marine = new Marine($this->db); |
|
296 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
297 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
298 | + $Marine->db = null; |
|
299 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
300 | 300 | } |
301 | 301 | $this->tmd = 0; |
302 | 302 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
303 | - } |
|
303 | + } |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
307 | 307 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
308 | 308 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
309 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
310 | - $dataFound = true; |
|
311 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
309 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
310 | + $dataFound = true; |
|
311 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
312 | 312 | } |
313 | 313 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
314 | 314 | } |
315 | 315 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
316 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
316 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
317 | 317 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
318 | 318 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
319 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
320 | - $dataFound = true; |
|
321 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
319 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
320 | + $dataFound = true; |
|
321 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
322 | 322 | } |
323 | 323 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
324 | 324 | } |
325 | 325 | |
326 | - } else if ($globalDebug && $timediff > 20) { |
|
326 | + } else if ($globalDebug && $timediff > 20) { |
|
327 | 327 | $this->tmd = $this->tmd + 1; |
328 | 328 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
329 | 329 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
330 | 330 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
331 | 331 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
332 | - } |
|
332 | + } |
|
333 | 333 | } |
334 | 334 | if (isset($line['last_update']) && $line['last_update'] != '') { |
335 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
336 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
335 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
336 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
337 | 337 | } |
338 | 338 | if (isset($line['format_source']) && $line['format_source'] != '') { |
339 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
339 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
340 | 340 | } |
341 | 341 | if (isset($line['source_name']) && $line['source_name'] != '') { |
342 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
342 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
343 | 343 | } |
344 | 344 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
345 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
345 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | if (isset($line['heading']) && $line['heading'] != '') { |
349 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
350 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
351 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
352 | - //$dataFound = true; |
|
349 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
350 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
351 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
352 | + //$dataFound = true; |
|
353 | 353 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
354 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
355 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
356 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
357 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
354 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
355 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
356 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
357 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
358 | 358 | } |
359 | 359 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
360 | 360 | |
361 | 361 | |
362 | 362 | |
363 | 363 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
364 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
365 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
366 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
367 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
364 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
365 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
366 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
367 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
368 | 368 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
369 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
370 | - $timeelapsed = microtime(true); |
|
371 | - $MarineLive = new MarineLive($this->db); |
|
372 | - if (isset($line['id'])) { |
|
369 | + if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
370 | + $timeelapsed = microtime(true); |
|
371 | + $MarineLive = new MarineLive($this->db); |
|
372 | + if (isset($line['id'])) { |
|
373 | 373 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
374 | 374 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
375 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
375 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
376 | 376 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
377 | 377 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
378 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
378 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
379 | 379 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
380 | 380 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
381 | - } else $recent_ident = ''; |
|
382 | - $MarineLive->db=null; |
|
383 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
384 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
381 | + } else $recent_ident = ''; |
|
382 | + $MarineLive->db=null; |
|
383 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
384 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
385 | 385 | } else $recent_ident = ''; |
386 | - } else { |
|
386 | + } else { |
|
387 | 387 | $recent_ident = ''; |
388 | 388 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
389 | - } |
|
390 | - //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
391 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
392 | - { |
|
389 | + } |
|
390 | + //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
391 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
392 | + { |
|
393 | 393 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
394 | 394 | //adds the spotter data for the archive |
395 | - $highlight = ''; |
|
396 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
397 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
395 | + $highlight = ''; |
|
396 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
397 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
398 | 398 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
399 | - $timeelapsed = microtime(true); |
|
400 | - $Marine = new Marine($this->db); |
|
401 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
402 | - $Marine->db = null; |
|
403 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
404 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
399 | + $timeelapsed = microtime(true); |
|
400 | + $Marine = new Marine($this->db); |
|
401 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
402 | + $Marine->db = null; |
|
403 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
404 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
405 | + } |
|
405 | 406 | } |
406 | - } |
|
407 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
407 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
408 | 408 | // Add source stat in DB |
409 | 409 | $Stats = new Stats($this->db); |
410 | 410 | if (!empty($this->stats)) { |
411 | - if ($globalDebug) echo 'Add source stats : '; |
|
412 | - foreach($this->stats as $date => $data) { |
|
411 | + if ($globalDebug) echo 'Add source stats : '; |
|
412 | + foreach($this->stats as $date => $data) { |
|
413 | 413 | foreach($data as $source => $sourced) { |
414 | - //print_r($sourced); |
|
415 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
416 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
417 | - if (isset($sourced['msg'])) { |
|
418 | - if (time() - $sourced['msg']['date'] > 10) { |
|
419 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
420 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
421 | - unset($this->stats[$date][$source]['msg']); |
|
422 | - } |
|
423 | - } |
|
424 | - } |
|
425 | - if ($date != date('Y-m-d')) { |
|
426 | - unset($this->stats[$date]); |
|
427 | - } |
|
428 | - } |
|
429 | - if ($globalDebug) echo 'Done'."\n"; |
|
414 | + //print_r($sourced); |
|
415 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
416 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
417 | + if (isset($sourced['msg'])) { |
|
418 | + if (time() - $sourced['msg']['date'] > 10) { |
|
419 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
420 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
421 | + unset($this->stats[$date][$source]['msg']); |
|
422 | + } |
|
423 | + } |
|
424 | + } |
|
425 | + if ($date != date('Y-m-d')) { |
|
426 | + unset($this->stats[$date]); |
|
427 | + } |
|
428 | + } |
|
429 | + if ($globalDebug) echo 'Done'."\n"; |
|
430 | 430 | } |
431 | 431 | $Stats->db = null; |
432 | - } |
|
432 | + } |
|
433 | 433 | |
434 | - $this->del(); |
|
434 | + $this->del(); |
|
435 | 435 | //$ignoreImport = false; |
436 | 436 | $this->all_tracked[$id]['addedMarine'] = 1; |
437 | 437 | //print_r($this->all_tracked[$id]); |
438 | 438 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
439 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
440 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
441 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
439 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
440 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
441 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
442 | 442 | $MarineLive = new MarineLive($this->db); |
443 | 443 | $MarineLive->deleteLiveMarineData(); |
444 | 444 | $MarineLive->db=null; |
445 | 445 | if ($globalDebug) echo " Done\n"; |
446 | - } |
|
447 | - $this->last_delete = time(); |
|
446 | + } |
|
447 | + $this->last_delete = time(); |
|
448 | 448 | } |
449 | - } elseif ($recent_ident != '') { |
|
449 | + } elseif ($recent_ident != '') { |
|
450 | 450 | $this->all_tracked[$id]['id'] = $recent_ident; |
451 | 451 | $this->all_tracked[$id]['addedMarine'] = 1; |
452 | 452 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
453 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
453 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
454 | 454 | $Marine = new Marine($this->db); |
455 | 455 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
456 | 456 | $Marine->db = null; |
457 | - } |
|
457 | + } |
|
458 | 458 | } |
459 | 459 | |
460 | - } |
|
460 | + } |
|
461 | 461 | } |
462 | - } |
|
463 | - //adds the spotter LIVE data |
|
464 | - if ($globalDebug) { |
|
462 | + } |
|
463 | + //adds the spotter LIVE data |
|
464 | + if ($globalDebug) { |
|
465 | 465 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
466 | - } |
|
467 | - $ignoreImport = false; |
|
466 | + } |
|
467 | + $ignoreImport = false; |
|
468 | 468 | |
469 | - if (!$ignoreImport) { |
|
469 | + if (!$ignoreImport) { |
|
470 | 470 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
471 | 471 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
472 | 472 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
473 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
473 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
474 | 474 | $timeelapsed = microtime(true); |
475 | 475 | $MarineLive = new MarineLive($this->db); |
476 | 476 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
477 | 477 | $MarineLive->db = null; |
478 | 478 | if ($globalDebug) echo $result."\n"; |
479 | 479 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
480 | - } |
|
480 | + } |
|
481 | 481 | } |
482 | 482 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
483 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
483 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
484 | 484 | } |
485 | 485 | $this->all_tracked[$id]['putinarchive'] = false; |
486 | 486 | |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | if ($stats_heading == 16) $stats_heading = 0; |
513 | 513 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
514 | 514 | for ($i=0;$i<=15;$i++) { |
515 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
515 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
516 | 516 | } |
517 | 517 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
518 | 518 | } else { |
@@ -525,11 +525,11 @@ discard block |
||
525 | 525 | //var_dump($this->stats); |
526 | 526 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
527 | 527 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
528 | - end($this->stats[$current_date][$source]['hist']); |
|
529 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
528 | + end($this->stats[$current_date][$source]['hist']); |
|
529 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
530 | 530 | } else $mini = 0; |
531 | 531 | for ($i=$mini;$i<=$distance;$i+=10) { |
532 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
532 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
533 | 533 | } |
534 | 534 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
535 | 535 | } else { |
@@ -545,24 +545,24 @@ discard block |
||
545 | 545 | |
546 | 546 | |
547 | 547 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
548 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
548 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
549 | 549 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
550 | 550 | $MarineLive = new MarineLive($this->db); |
551 | 551 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
552 | 552 | $MarineLive->db = null; |
553 | 553 | //MarineLive->deleteLiveMarineData(); |
554 | 554 | if ($globalDebug) echo " Done\n"; |
555 | - } |
|
556 | - $this->last_delete_hourly = time(); |
|
555 | + } |
|
556 | + $this->last_delete_hourly = time(); |
|
557 | 557 | } |
558 | 558 | |
559 | - } |
|
560 | - //$ignoreImport = false; |
|
559 | + } |
|
560 | + //$ignoreImport = false; |
|
561 | 561 | } |
562 | 562 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
563 | 563 | if ($send) return $this->all_tracked[$id]; |
564 | - } |
|
564 | + } |
|
565 | + } |
|
565 | 566 | } |
566 | - } |
|
567 | 567 | } |
568 | 568 | ?> |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | /** |
16 | - * Get SQL query part for filter used |
|
17 | - * @param Array $filter the filter |
|
18 | - * @return Array the SQL part |
|
19 | - */ |
|
16 | + * Get SQL query part for filter used |
|
17 | + * @param Array $filter the filter |
|
18 | + * @return Array the SQL part |
|
19 | + */ |
|
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | - * Gets all the spotter information based on the latest data entry |
|
137 | - * |
|
138 | - * @return Array the spotter information |
|
139 | - * |
|
140 | - */ |
|
136 | + * Gets all the spotter information based on the latest data entry |
|
137 | + * |
|
138 | + * @return Array the spotter information |
|
139 | + * |
|
140 | + */ |
|
141 | 141 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
142 | 142 | { |
143 | 143 | global $globalDBdriver, $globalLiveInterval; |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
183 | - * Gets Minimal Live Spotter data |
|
184 | - * |
|
185 | - * @return Array the spotter information |
|
186 | - * |
|
187 | - */ |
|
183 | + * Gets Minimal Live Spotter data |
|
184 | + * |
|
185 | + * @return Array the spotter information |
|
186 | + * |
|
187 | + */ |
|
188 | 188 | public function getMinLiveSpotterData($filter = array()) |
189 | 189 | { |
190 | 190 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
224 | - * Gets Minimal Live Spotter data since xx seconds |
|
225 | - * |
|
226 | - * @return Array the spotter information |
|
227 | - * |
|
228 | - */ |
|
224 | + * Gets Minimal Live Spotter data since xx seconds |
|
225 | + * |
|
226 | + * @return Array the spotter information |
|
227 | + * |
|
228 | + */ |
|
229 | 229 | public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false) |
230 | 230 | { |
231 | 231 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
311 | - * Gets number of latest data entry |
|
312 | - * |
|
313 | - * @return String number of entry |
|
314 | - * |
|
315 | - */ |
|
311 | + * Gets number of latest data entry |
|
312 | + * |
|
313 | + * @return String number of entry |
|
314 | + * |
|
315 | + */ |
|
316 | 316 | public function getLiveSpotterCount($filter = array()) |
317 | 317 | { |
318 | 318 | global $globalDBdriver, $globalLiveInterval; |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
342 | - * Gets all the spotter information based on the latest data entry and coord |
|
343 | - * |
|
344 | - * @return Array the spotter information |
|
345 | - * |
|
346 | - */ |
|
342 | + * Gets all the spotter information based on the latest data entry and coord |
|
343 | + * |
|
344 | + * @return Array the spotter information |
|
345 | + * |
|
346 | + */ |
|
347 | 347 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
348 | 348 | { |
349 | 349 | global $globalDBdriver, $globalLiveInterval; |
@@ -368,11 +368,11 @@ discard block |
||
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
371 | - * Gets all the spotter information based on the latest data entry and coord |
|
372 | - * |
|
373 | - * @return Array the spotter information |
|
374 | - * |
|
375 | - */ |
|
371 | + * Gets all the spotter information based on the latest data entry and coord |
|
372 | + * |
|
373 | + * @return Array the spotter information |
|
374 | + * |
|
375 | + */ |
|
376 | 376 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
377 | 377 | { |
378 | 378 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -437,11 +437,11 @@ discard block |
||
437 | 437 | } |
438 | 438 | |
439 | 439 | /** |
440 | - * Gets all the spotter information based on a user's latitude and longitude |
|
441 | - * |
|
442 | - * @return Array the spotter information |
|
443 | - * |
|
444 | - */ |
|
440 | + * Gets all the spotter information based on a user's latitude and longitude |
|
441 | + * |
|
442 | + * @return Array the spotter information |
|
443 | + * |
|
444 | + */ |
|
445 | 445 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
446 | 446 | { |
447 | 447 | $Spotter = new Spotter($this->db); |
@@ -451,98 +451,98 @@ discard block |
||
451 | 451 | return false; |
452 | 452 | } |
453 | 453 | } |
454 | - if ($lng != '') |
|
455 | - { |
|
456 | - if (!is_numeric($lng)) |
|
457 | - { |
|
458 | - return false; |
|
459 | - } |
|
460 | - } |
|
461 | - |
|
462 | - if ($radius != '') |
|
463 | - { |
|
464 | - if (!is_numeric($radius)) |
|
465 | - { |
|
466 | - return false; |
|
467 | - } |
|
468 | - } |
|
454 | + if ($lng != '') |
|
455 | + { |
|
456 | + if (!is_numeric($lng)) |
|
457 | + { |
|
458 | + return false; |
|
459 | + } |
|
460 | + } |
|
461 | + |
|
462 | + if ($radius != '') |
|
463 | + { |
|
464 | + if (!is_numeric($radius)) |
|
465 | + { |
|
466 | + return false; |
|
467 | + } |
|
468 | + } |
|
469 | 469 | $additional_query = ''; |
470 | - if ($interval != '') |
|
471 | - { |
|
472 | - if (!is_string($interval)) |
|
473 | - { |
|
474 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
475 | - return false; |
|
476 | - } else { |
|
477 | - if ($interval == '1m') |
|
478 | - { |
|
479 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
480 | - } else if ($interval == '15m'){ |
|
481 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
482 | - } |
|
483 | - } |
|
484 | - } else { |
|
485 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
486 | - } |
|
487 | - |
|
488 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
470 | + if ($interval != '') |
|
471 | + { |
|
472 | + if (!is_string($interval)) |
|
473 | + { |
|
474 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
475 | + return false; |
|
476 | + } else { |
|
477 | + if ($interval == '1m') |
|
478 | + { |
|
479 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
480 | + } else if ($interval == '15m'){ |
|
481 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
482 | + } |
|
483 | + } |
|
484 | + } else { |
|
485 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
486 | + } |
|
487 | + |
|
488 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
489 | 489 | WHERE spotter_live.latitude <> '' |
490 | 490 | AND spotter_live.longitude <> '' |
491 | 491 | ".$additional_query." |
492 | 492 | HAVING distance < :radius |
493 | 493 | ORDER BY distance"; |
494 | 494 | |
495 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
495 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
496 | 496 | |
497 | - return $spotter_array; |
|
498 | - } |
|
497 | + return $spotter_array; |
|
498 | + } |
|
499 | 499 | |
500 | 500 | |
501 | - /** |
|
502 | - * Gets all the spotter information based on a particular callsign |
|
503 | - * |
|
504 | - * @return Array the spotter information |
|
505 | - * |
|
506 | - */ |
|
501 | + /** |
|
502 | + * Gets all the spotter information based on a particular callsign |
|
503 | + * |
|
504 | + * @return Array the spotter information |
|
505 | + * |
|
506 | + */ |
|
507 | 507 | public function getLastLiveSpotterDataByIdent($ident) |
508 | 508 | { |
509 | 509 | $Spotter = new Spotter($this->db); |
510 | 510 | date_default_timezone_set('UTC'); |
511 | 511 | |
512 | 512 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
513 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
513 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
514 | 514 | |
515 | 515 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
516 | 516 | |
517 | 517 | return $spotter_array; |
518 | 518 | } |
519 | 519 | |
520 | - /** |
|
521 | - * Gets all the spotter information based on a particular callsign |
|
522 | - * |
|
523 | - * @return Array the spotter information |
|
524 | - * |
|
525 | - */ |
|
520 | + /** |
|
521 | + * Gets all the spotter information based on a particular callsign |
|
522 | + * |
|
523 | + * @return Array the spotter information |
|
524 | + * |
|
525 | + */ |
|
526 | 526 | public function getDateLiveSpotterDataByIdent($ident,$date) |
527 | 527 | { |
528 | 528 | $Spotter = new Spotter($this->db); |
529 | 529 | date_default_timezone_set('UTC'); |
530 | 530 | |
531 | 531 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
532 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
532 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
533 | 533 | |
534 | - $date = date('c',$date); |
|
534 | + $date = date('c',$date); |
|
535 | 535 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
536 | 536 | |
537 | 537 | return $spotter_array; |
538 | 538 | } |
539 | 539 | |
540 | - /** |
|
541 | - * Gets last spotter information based on a particular callsign |
|
542 | - * |
|
543 | - * @return Array the spotter information |
|
544 | - * |
|
545 | - */ |
|
540 | + /** |
|
541 | + * Gets last spotter information based on a particular callsign |
|
542 | + * |
|
543 | + * @return Array the spotter information |
|
544 | + * |
|
545 | + */ |
|
546 | 546 | public function getLastLiveSpotterDataById($id) |
547 | 547 | { |
548 | 548 | $Spotter = new Spotter($this->db); |
@@ -553,12 +553,12 @@ discard block |
||
553 | 553 | return $spotter_array; |
554 | 554 | } |
555 | 555 | |
556 | - /** |
|
557 | - * Gets last spotter information based on a particular callsign |
|
558 | - * |
|
559 | - * @return Array the spotter information |
|
560 | - * |
|
561 | - */ |
|
556 | + /** |
|
557 | + * Gets last spotter information based on a particular callsign |
|
558 | + * |
|
559 | + * @return Array the spotter information |
|
560 | + * |
|
561 | + */ |
|
562 | 562 | public function getDateLiveSpotterDataById($id,$date) |
563 | 563 | { |
564 | 564 | $Spotter = new Spotter($this->db); |
@@ -571,21 +571,21 @@ discard block |
||
571 | 571 | return $spotter_array; |
572 | 572 | } |
573 | 573 | |
574 | - /** |
|
575 | - * Gets altitude information based on a particular callsign |
|
576 | - * |
|
577 | - * @return Array the spotter information |
|
578 | - * |
|
579 | - */ |
|
574 | + /** |
|
575 | + * Gets altitude information based on a particular callsign |
|
576 | + * |
|
577 | + * @return Array the spotter information |
|
578 | + * |
|
579 | + */ |
|
580 | 580 | public function getAltitudeLiveSpotterDataByIdent($ident) |
581 | 581 | { |
582 | 582 | |
583 | 583 | date_default_timezone_set('UTC'); |
584 | 584 | |
585 | 585 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
586 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
586 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
587 | 587 | |
588 | - try { |
|
588 | + try { |
|
589 | 589 | |
590 | 590 | $sth = $this->db->prepare($query); |
591 | 591 | $sth->execute(array(':ident' => $ident)); |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | return $spotter_array; |
599 | 599 | } |
600 | 600 | |
601 | - /** |
|
602 | - * Gets all the spotter information based on a particular id |
|
603 | - * |
|
604 | - * @return Array the spotter information |
|
605 | - * |
|
606 | - */ |
|
601 | + /** |
|
602 | + * Gets all the spotter information based on a particular id |
|
603 | + * |
|
604 | + * @return Array the spotter information |
|
605 | + * |
|
606 | + */ |
|
607 | 607 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
608 | 608 | { |
609 | 609 | global $globalDBdriver, $globalLiveInterval; |
@@ -631,18 +631,18 @@ discard block |
||
631 | 631 | return $spotter_array; |
632 | 632 | } |
633 | 633 | |
634 | - /** |
|
635 | - * Gets all the spotter information based on a particular ident |
|
636 | - * |
|
637 | - * @return Array the spotter information |
|
638 | - * |
|
639 | - */ |
|
634 | + /** |
|
635 | + * Gets all the spotter information based on a particular ident |
|
636 | + * |
|
637 | + * @return Array the spotter information |
|
638 | + * |
|
639 | + */ |
|
640 | 640 | public function getAllLiveSpotterDataByIdent($ident) |
641 | 641 | { |
642 | 642 | date_default_timezone_set('UTC'); |
643 | 643 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
644 | 644 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
645 | - try { |
|
645 | + try { |
|
646 | 646 | |
647 | 647 | $sth = $this->db->prepare($query); |
648 | 648 | $sth->execute(array(':ident' => $ident)); |
@@ -656,23 +656,23 @@ discard block |
||
656 | 656 | |
657 | 657 | |
658 | 658 | /** |
659 | - * Deletes all info in the table |
|
660 | - * |
|
661 | - * @return String success or false |
|
662 | - * |
|
663 | - */ |
|
659 | + * Deletes all info in the table |
|
660 | + * |
|
661 | + * @return String success or false |
|
662 | + * |
|
663 | + */ |
|
664 | 664 | public function deleteLiveSpotterData() |
665 | 665 | { |
666 | 666 | global $globalDBdriver; |
667 | 667 | if ($globalDBdriver == 'mysql') { |
668 | 668 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
669 | 669 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
670 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
670 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
671 | 671 | } else { |
672 | 672 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
673 | 673 | } |
674 | 674 | |
675 | - try { |
|
675 | + try { |
|
676 | 676 | |
677 | 677 | $sth = $this->db->prepare($query); |
678 | 678 | $sth->execute(); |
@@ -684,18 +684,18 @@ discard block |
||
684 | 684 | } |
685 | 685 | |
686 | 686 | /** |
687 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
688 | - * |
|
689 | - * @return String success or false |
|
690 | - * |
|
691 | - */ |
|
687 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
688 | + * |
|
689 | + * @return String success or false |
|
690 | + * |
|
691 | + */ |
|
692 | 692 | public function deleteLiveSpotterDataNotUpdated() |
693 | 693 | { |
694 | 694 | global $globalDBdriver, $globalDebug; |
695 | 695 | if ($globalDBdriver == 'mysql') { |
696 | 696 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
697 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
698 | - try { |
|
697 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
698 | + try { |
|
699 | 699 | |
700 | 700 | $sth = $this->db->prepare($query); |
701 | 701 | $sth->execute(); |
@@ -703,8 +703,8 @@ discard block |
||
703 | 703 | return "error"; |
704 | 704 | } |
705 | 705 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
706 | - $i = 0; |
|
707 | - $j =0; |
|
706 | + $i = 0; |
|
707 | + $j =0; |
|
708 | 708 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
709 | 709 | foreach($all as $row) |
710 | 710 | { |
@@ -712,20 +712,20 @@ discard block |
||
712 | 712 | $j++; |
713 | 713 | if ($j == 30) { |
714 | 714 | if ($globalDebug) echo "."; |
715 | - try { |
|
715 | + try { |
|
716 | 716 | |
717 | 717 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
718 | 718 | $sth->execute(); |
719 | 719 | } catch(PDOException $e) { |
720 | 720 | return "error"; |
721 | 721 | } |
722 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
723 | - $j = 0; |
|
722 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
723 | + $j = 0; |
|
724 | 724 | } |
725 | 725 | $query_delete .= "'".$row['flightaware_id']."',"; |
726 | 726 | } |
727 | 727 | if ($i > 0) { |
728 | - try { |
|
728 | + try { |
|
729 | 729 | |
730 | 730 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
731 | 731 | $sth->execute(); |
@@ -736,9 +736,9 @@ discard block |
||
736 | 736 | return "success"; |
737 | 737 | } elseif ($globalDBdriver == 'pgsql') { |
738 | 738 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
739 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
740 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
741 | - try { |
|
739 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
740 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
741 | + try { |
|
742 | 742 | |
743 | 743 | $sth = $this->db->prepare($query); |
744 | 744 | $sth->execute(); |
@@ -782,17 +782,17 @@ discard block |
||
782 | 782 | } |
783 | 783 | |
784 | 784 | /** |
785 | - * Deletes all info in the table for an ident |
|
786 | - * |
|
787 | - * @return String success or false |
|
788 | - * |
|
789 | - */ |
|
785 | + * Deletes all info in the table for an ident |
|
786 | + * |
|
787 | + * @return String success or false |
|
788 | + * |
|
789 | + */ |
|
790 | 790 | public function deleteLiveSpotterDataByIdent($ident) |
791 | 791 | { |
792 | 792 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
793 | 793 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
794 | 794 | |
795 | - try { |
|
795 | + try { |
|
796 | 796 | |
797 | 797 | $sth = $this->db->prepare($query); |
798 | 798 | $sth->execute(array(':ident' => $ident)); |
@@ -804,17 +804,17 @@ discard block |
||
804 | 804 | } |
805 | 805 | |
806 | 806 | /** |
807 | - * Deletes all info in the table for an id |
|
808 | - * |
|
809 | - * @return String success or false |
|
810 | - * |
|
811 | - */ |
|
807 | + * Deletes all info in the table for an id |
|
808 | + * |
|
809 | + * @return String success or false |
|
810 | + * |
|
811 | + */ |
|
812 | 812 | public function deleteLiveSpotterDataById($id) |
813 | 813 | { |
814 | 814 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
815 | 815 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
816 | 816 | |
817 | - try { |
|
817 | + try { |
|
818 | 818 | |
819 | 819 | $sth = $this->db->prepare($query); |
820 | 820 | $sth->execute(array(':id' => $id)); |
@@ -827,11 +827,11 @@ discard block |
||
827 | 827 | |
828 | 828 | |
829 | 829 | /** |
830 | - * Gets the aircraft ident within the last hour |
|
831 | - * |
|
832 | - * @return String the ident |
|
833 | - * |
|
834 | - */ |
|
830 | + * Gets the aircraft ident within the last hour |
|
831 | + * |
|
832 | + * @return String the ident |
|
833 | + * |
|
834 | + */ |
|
835 | 835 | public function getIdentFromLastHour($ident) |
836 | 836 | { |
837 | 837 | global $globalDBdriver, $globalTimezone; |
@@ -857,14 +857,14 @@ discard block |
||
857 | 857 | $ident_result = $row['ident']; |
858 | 858 | } |
859 | 859 | return $ident_result; |
860 | - } |
|
860 | + } |
|
861 | 861 | |
862 | 862 | /** |
863 | - * Check recent aircraft |
|
864 | - * |
|
865 | - * @return String the ident |
|
866 | - * |
|
867 | - */ |
|
863 | + * Check recent aircraft |
|
864 | + * |
|
865 | + * @return String the ident |
|
866 | + * |
|
867 | + */ |
|
868 | 868 | public function checkIdentRecent($ident) |
869 | 869 | { |
870 | 870 | global $globalDBdriver, $globalTimezone; |
@@ -890,14 +890,14 @@ discard block |
||
890 | 890 | $ident_result = $row['flightaware_id']; |
891 | 891 | } |
892 | 892 | return $ident_result; |
893 | - } |
|
893 | + } |
|
894 | 894 | |
895 | 895 | /** |
896 | - * Check recent aircraft by id |
|
897 | - * |
|
898 | - * @return String the ident |
|
899 | - * |
|
900 | - */ |
|
896 | + * Check recent aircraft by id |
|
897 | + * |
|
898 | + * @return String the ident |
|
899 | + * |
|
900 | + */ |
|
901 | 901 | public function checkIdRecent($id) |
902 | 902 | { |
903 | 903 | global $globalDBdriver, $globalTimezone; |
@@ -923,14 +923,14 @@ discard block |
||
923 | 923 | $ident_result = $row['flightaware_id']; |
924 | 924 | } |
925 | 925 | return $ident_result; |
926 | - } |
|
926 | + } |
|
927 | 927 | |
928 | 928 | /** |
929 | - * Check recent aircraft by ModeS |
|
930 | - * |
|
931 | - * @return String the ModeS |
|
932 | - * |
|
933 | - */ |
|
929 | + * Check recent aircraft by ModeS |
|
930 | + * |
|
931 | + * @return String the ModeS |
|
932 | + * |
|
933 | + */ |
|
934 | 934 | public function checkModeSRecent($modes) |
935 | 935 | { |
936 | 936 | global $globalDBdriver, $globalTimezone; |
@@ -960,11 +960,11 @@ discard block |
||
960 | 960 | } |
961 | 961 | |
962 | 962 | /** |
963 | - * Gets the aircraft data from the last 20 seconds |
|
964 | - * |
|
965 | - * @return Array the spotter data |
|
966 | - * |
|
967 | - */ |
|
963 | + * Gets the aircraft data from the last 20 seconds |
|
964 | + * |
|
965 | + * @return Array the spotter data |
|
966 | + * |
|
967 | + */ |
|
968 | 968 | public function getRealTimeData($q = '') |
969 | 969 | { |
970 | 970 | global $globalDBdriver; |
@@ -1006,16 +1006,16 @@ discard block |
||
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | /** |
1009 | - * Adds a new spotter data |
|
1010 | - * |
|
1011 | - * @param String $flightaware_id the ID from flightaware |
|
1012 | - * @param String $ident the flight ident |
|
1013 | - * @param String $aircraft_icao the aircraft type |
|
1014 | - * @param String $departure_airport_icao the departure airport |
|
1015 | - * @param String $arrival_airport_icao the arrival airport |
|
1016 | - * @return String success or false |
|
1017 | - * |
|
1018 | - */ |
|
1009 | + * Adds a new spotter data |
|
1010 | + * |
|
1011 | + * @param String $flightaware_id the ID from flightaware |
|
1012 | + * @param String $ident the flight ident |
|
1013 | + * @param String $aircraft_icao the aircraft type |
|
1014 | + * @param String $departure_airport_icao the departure airport |
|
1015 | + * @param String $arrival_airport_icao the arrival airport |
|
1016 | + * @return String success or false |
|
1017 | + * |
|
1018 | + */ |
|
1019 | 1019 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
1020 | 1020 | { |
1021 | 1021 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1158,10 +1158,10 @@ discard block |
||
1158 | 1158 | $arrival_airport_country = ''; |
1159 | 1159 | |
1160 | 1160 | |
1161 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1162 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1163 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1164 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1161 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1162 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1163 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1164 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1165 | 1165 | |
1166 | 1166 | $query = ''; |
1167 | 1167 | if ($globalArchive) { |
@@ -1182,10 +1182,10 @@ discard block |
||
1182 | 1182 | return "error : ".$e->getMessage(); |
1183 | 1183 | } |
1184 | 1184 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1185 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1186 | - $SpotterArchive = new SpotterArchive($this->db); |
|
1187 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1188 | - if ($globalDebug) echo $result.')'; |
|
1185 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
1186 | + $SpotterArchive = new SpotterArchive($this->db); |
|
1187 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1188 | + if ($globalDebug) echo $result.')'; |
|
1189 | 1189 | } elseif ($globalDebug && $putinarchive !== true) { |
1190 | 1190 | echo '(Not adding to archive)'; |
1191 | 1191 | } elseif ($globalDebug && $noarchive === true) { |
@@ -868,7 +868,6 @@ discard block |
||
868 | 868 | * This tells SimplePie to ignore any file errors and fall back to cache |
869 | 869 | * instead. This only works if caching is enabled and cached content |
870 | 870 | * still exists. |
871 | - |
|
872 | 871 | * @param bool $enable Force use of cache on fail. |
873 | 872 | */ |
874 | 873 | public function force_cache_fallback($enable = false) |
@@ -1663,7 +1662,7 @@ discard block |
||
1663 | 1662 | // Now also do feed discovery, but if microformats were found don't |
1664 | 1663 | // overwrite the current value of file. |
1665 | 1664 | $discovered = $locate->find($this->autodiscovery, |
1666 | - $this->all_discovered_feeds); |
|
1665 | + $this->all_discovered_feeds); |
|
1667 | 1666 | if ($microformats) |
1668 | 1667 | { |
1669 | 1668 | if ($hub = $locate->get_rel_link('hub')) |
@@ -1928,8 +1927,8 @@ discard block |
||
1928 | 1927 | { |
1929 | 1928 | // sanitize encodes ampersands which are required when used in a url. |
1930 | 1929 | return str_replace('&', '&', |
1931 | - $this->sanitize($this->permanent_url, |
|
1932 | - SIMPLEPIE_CONSTRUCT_IRI)); |
|
1930 | + $this->sanitize($this->permanent_url, |
|
1931 | + SIMPLEPIE_CONSTRUCT_IRI)); |
|
1933 | 1932 | } |
1934 | 1933 | } |
1935 | 1934 | else |
@@ -1937,8 +1936,8 @@ discard block |
||
1937 | 1936 | if ($this->feed_url !== null) |
1938 | 1937 | { |
1939 | 1938 | return str_replace('&', '&', |
1940 | - $this->sanitize($this->feed_url, |
|
1941 | - SIMPLEPIE_CONSTRUCT_IRI)); |
|
1939 | + $this->sanitize($this->feed_url, |
|
1940 | + SIMPLEPIE_CONSTRUCT_IRI)); |
|
1942 | 1941 | } |
1943 | 1942 | } |
1944 | 1943 | return null; |
@@ -2597,8 +2596,8 @@ discard block |
||
2597 | 2596 | } |
2598 | 2597 | |
2599 | 2598 | if (isset($this->data['headers']['link']) && |
2600 | - preg_match('/<([^>]+)>; rel='.preg_quote($rel).'/', |
|
2601 | - $this->data['headers']['link'], $match)) |
|
2599 | + preg_match('/<([^>]+)>; rel='.preg_quote($rel).'/', |
|
2600 | + $this->data['headers']['link'], $match)) |
|
2602 | 2601 | { |
2603 | 2602 | return array($match[1]); |
2604 | 2603 | } |
@@ -3937,112 +3936,112 @@ discard block |
||
3937 | 3936 | */ |
3938 | 3937 | class SimplePie_Cache_Memcached implements SimplePie_Cache_Base |
3939 | 3938 | { |
3940 | - /** |
|
3941 | - * Memcached instance |
|
3942 | - * @var Memcached |
|
3943 | - */ |
|
3944 | - protected $cache; |
|
3945 | - |
|
3946 | - /** |
|
3947 | - * Options |
|
3948 | - * @var array |
|
3949 | - */ |
|
3950 | - protected $options; |
|
3951 | - |
|
3952 | - /** |
|
3953 | - * Cache name |
|
3954 | - * @var string |
|
3955 | - */ |
|
3956 | - protected $name; |
|
3957 | - |
|
3958 | - /** |
|
3959 | - * Create a new cache object |
|
3960 | - * @param string $location Location string (from SimplePie::$cache_location) |
|
3961 | - * @param string $name Unique ID for the cache |
|
3962 | - * @param string $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data |
|
3963 | - */ |
|
3964 | - public function __construct($location, $name, $type) { |
|
3965 | - $this->options = array( |
|
3966 | - 'host' => '127.0.0.1', |
|
3967 | - 'port' => 11211, |
|
3968 | - 'extras' => array( |
|
3969 | - 'timeout' => 3600, // one hour |
|
3970 | - 'prefix' => 'simplepie_', |
|
3971 | - ), |
|
3972 | - ); |
|
3973 | - $this->options = SimplePie_Misc::array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location)); |
|
3974 | - |
|
3975 | - $this->name = $this->options['extras']['prefix'] . md5("$name:$type"); |
|
3976 | - |
|
3977 | - $this->cache = new Memcached(); |
|
3978 | - $this->cache->addServer($this->options['host'], (int)$this->options['port']); |
|
3979 | - } |
|
3980 | - |
|
3981 | - /** |
|
3982 | - * Save data to the cache |
|
3983 | - * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property |
|
3984 | - * @return bool Successfulness |
|
3985 | - */ |
|
3986 | - public function save($data) { |
|
3987 | - if ($data instanceof SimplePie) { |
|
3988 | - $data = $data->data; |
|
3989 | - } |
|
3990 | - |
|
3991 | - return $this->setData(serialize($data)); |
|
3992 | - } |
|
3993 | - |
|
3994 | - /** |
|
3995 | - * Retrieve the data saved to the cache |
|
3996 | - * @return array Data for SimplePie::$data |
|
3997 | - */ |
|
3998 | - public function load() { |
|
3999 | - $data = $this->cache->get($this->name); |
|
4000 | - |
|
4001 | - if ($data !== false) { |
|
4002 | - return unserialize($data); |
|
4003 | - } |
|
4004 | - return false; |
|
4005 | - } |
|
4006 | - |
|
4007 | - /** |
|
4008 | - * Retrieve the last modified time for the cache |
|
4009 | - * @return int Timestamp |
|
4010 | - */ |
|
4011 | - public function mtime() { |
|
4012 | - $data = $this->cache->get($this->name . '_mtime'); |
|
4013 | - return (int) $data; |
|
4014 | - } |
|
4015 | - |
|
4016 | - /** |
|
4017 | - * Set the last modified time to the current time |
|
4018 | - * @return bool Success status |
|
4019 | - */ |
|
4020 | - public function touch() { |
|
4021 | - $data = $this->cache->get($this->name); |
|
4022 | - return $this->setData($data); |
|
4023 | - } |
|
4024 | - |
|
4025 | - /** |
|
4026 | - * Remove the cache |
|
4027 | - * @return bool Success status |
|
4028 | - */ |
|
4029 | - public function unlink() { |
|
4030 | - return $this->cache->delete($this->name, 0); |
|
4031 | - } |
|
4032 | - |
|
4033 | - /** |
|
4034 | - * Set the last modified time and data to Memcached |
|
4035 | - * @return bool Success status |
|
4036 | - */ |
|
4037 | - private function setData($data) { |
|
4038 | - |
|
4039 | - if ($data !== false) { |
|
4040 | - $this->cache->set($this->name . '_mtime', time(), (int)$this->options['extras']['timeout']); |
|
4041 | - return $this->cache->set($this->name, $data, (int)$this->options['extras']['timeout']); |
|
4042 | - } |
|
4043 | - |
|
4044 | - return false; |
|
4045 | - } |
|
3939 | + /** |
|
3940 | + * Memcached instance |
|
3941 | + * @var Memcached |
|
3942 | + */ |
|
3943 | + protected $cache; |
|
3944 | + |
|
3945 | + /** |
|
3946 | + * Options |
|
3947 | + * @var array |
|
3948 | + */ |
|
3949 | + protected $options; |
|
3950 | + |
|
3951 | + /** |
|
3952 | + * Cache name |
|
3953 | + * @var string |
|
3954 | + */ |
|
3955 | + protected $name; |
|
3956 | + |
|
3957 | + /** |
|
3958 | + * Create a new cache object |
|
3959 | + * @param string $location Location string (from SimplePie::$cache_location) |
|
3960 | + * @param string $name Unique ID for the cache |
|
3961 | + * @param string $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data |
|
3962 | + */ |
|
3963 | + public function __construct($location, $name, $type) { |
|
3964 | + $this->options = array( |
|
3965 | + 'host' => '127.0.0.1', |
|
3966 | + 'port' => 11211, |
|
3967 | + 'extras' => array( |
|
3968 | + 'timeout' => 3600, // one hour |
|
3969 | + 'prefix' => 'simplepie_', |
|
3970 | + ), |
|
3971 | + ); |
|
3972 | + $this->options = SimplePie_Misc::array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location)); |
|
3973 | + |
|
3974 | + $this->name = $this->options['extras']['prefix'] . md5("$name:$type"); |
|
3975 | + |
|
3976 | + $this->cache = new Memcached(); |
|
3977 | + $this->cache->addServer($this->options['host'], (int)$this->options['port']); |
|
3978 | + } |
|
3979 | + |
|
3980 | + /** |
|
3981 | + * Save data to the cache |
|
3982 | + * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property |
|
3983 | + * @return bool Successfulness |
|
3984 | + */ |
|
3985 | + public function save($data) { |
|
3986 | + if ($data instanceof SimplePie) { |
|
3987 | + $data = $data->data; |
|
3988 | + } |
|
3989 | + |
|
3990 | + return $this->setData(serialize($data)); |
|
3991 | + } |
|
3992 | + |
|
3993 | + /** |
|
3994 | + * Retrieve the data saved to the cache |
|
3995 | + * @return array Data for SimplePie::$data |
|
3996 | + */ |
|
3997 | + public function load() { |
|
3998 | + $data = $this->cache->get($this->name); |
|
3999 | + |
|
4000 | + if ($data !== false) { |
|
4001 | + return unserialize($data); |
|
4002 | + } |
|
4003 | + return false; |
|
4004 | + } |
|
4005 | + |
|
4006 | + /** |
|
4007 | + * Retrieve the last modified time for the cache |
|
4008 | + * @return int Timestamp |
|
4009 | + */ |
|
4010 | + public function mtime() { |
|
4011 | + $data = $this->cache->get($this->name . '_mtime'); |
|
4012 | + return (int) $data; |
|
4013 | + } |
|
4014 | + |
|
4015 | + /** |
|
4016 | + * Set the last modified time to the current time |
|
4017 | + * @return bool Success status |
|
4018 | + */ |
|
4019 | + public function touch() { |
|
4020 | + $data = $this->cache->get($this->name); |
|
4021 | + return $this->setData($data); |
|
4022 | + } |
|
4023 | + |
|
4024 | + /** |
|
4025 | + * Remove the cache |
|
4026 | + * @return bool Success status |
|
4027 | + */ |
|
4028 | + public function unlink() { |
|
4029 | + return $this->cache->delete($this->name, 0); |
|
4030 | + } |
|
4031 | + |
|
4032 | + /** |
|
4033 | + * Set the last modified time and data to Memcached |
|
4034 | + * @return bool Success status |
|
4035 | + */ |
|
4036 | + private function setData($data) { |
|
4037 | + |
|
4038 | + if ($data !== false) { |
|
4039 | + $this->cache->set($this->name . '_mtime', time(), (int)$this->options['extras']['timeout']); |
|
4040 | + return $this->cache->set($this->name, $data, (int)$this->options['extras']['timeout']); |
|
4041 | + } |
|
4042 | + |
|
4043 | + return false; |
|
4044 | + } |
|
4046 | 4045 | } |
4047 | 4046 | |
4048 | 4047 | /** |
@@ -4471,143 +4470,143 @@ discard block |
||
4471 | 4470 | * @uses Redis |
4472 | 4471 | */ |
4473 | 4472 | class SimplePie_Cache_Redis implements SimplePie_Cache_Base { |
4474 | - /** |
|
4475 | - * Redis instance |
|
4476 | - * |
|
4477 | - * @var \Redis |
|
4478 | - */ |
|
4479 | - protected $cache; |
|
4480 | - |
|
4481 | - /** |
|
4482 | - * Options |
|
4483 | - * |
|
4484 | - * @var array |
|
4485 | - */ |
|
4486 | - protected $options; |
|
4487 | - |
|
4488 | - /** |
|
4489 | - * Cache name |
|
4490 | - * |
|
4491 | - * @var string |
|
4492 | - */ |
|
4493 | - protected $name; |
|
4494 | - |
|
4495 | - /** |
|
4496 | - * Cache Data |
|
4497 | - * |
|
4498 | - * @var type |
|
4499 | - */ |
|
4500 | - protected $data; |
|
4501 | - |
|
4502 | - /** |
|
4503 | - * Create a new cache object |
|
4504 | - * |
|
4505 | - * @param string $location Location string (from SimplePie::$cache_location) |
|
4506 | - * @param string $name Unique ID for the cache |
|
4507 | - * @param string $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data |
|
4508 | - */ |
|
4509 | - public function __construct($location, $name, $options = null) { |
|
4510 | - //$this->cache = \flow\simple\cache\Redis::getRedisClientInstance(); |
|
4511 | - $parsed = SimplePie_Cache::parse_URL($location); |
|
4512 | - $redis = new Redis(); |
|
4513 | - $redis->connect($parsed['host'], $parsed['port']); |
|
4514 | - $this->cache = $redis; |
|
4515 | - |
|
4516 | - if (!is_null($options) && is_array($options)) { |
|
4517 | - $this->options = $options; |
|
4518 | - } else { |
|
4519 | - $this->options = array ( |
|
4520 | - 'prefix' => 'rss:simple_primary:', |
|
4521 | - 'expire' => 0, |
|
4522 | - ); |
|
4523 | - } |
|
4524 | - |
|
4525 | - $this->name = $this->options['prefix'] . $name; |
|
4526 | - } |
|
4527 | - |
|
4528 | - /** |
|
4529 | - * @param \Redis $cache |
|
4530 | - */ |
|
4531 | - public function setRedisClient(\Redis $cache) { |
|
4532 | - $this->cache = $cache; |
|
4533 | - } |
|
4534 | - |
|
4535 | - /** |
|
4536 | - * Save data to the cache |
|
4537 | - * |
|
4538 | - * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property |
|
4539 | - * @return bool Successfulness |
|
4540 | - */ |
|
4541 | - public function save($data) { |
|
4542 | - if ($data instanceof SimplePie) { |
|
4543 | - $data = $data->data; |
|
4544 | - } |
|
4545 | - $response = $this->cache->set($this->name, serialize($data)); |
|
4546 | - if ($this->options['expire']) { |
|
4547 | - $this->cache->expire($this->name, $this->options['expire']); |
|
4548 | - } |
|
4549 | - |
|
4550 | - return $response; |
|
4551 | - } |
|
4552 | - |
|
4553 | - /** |
|
4554 | - * Retrieve the data saved to the cache |
|
4555 | - * |
|
4556 | - * @return array Data for SimplePie::$data |
|
4557 | - */ |
|
4558 | - public function load() { |
|
4559 | - $data = $this->cache->get($this->name); |
|
4560 | - |
|
4561 | - if ($data !== false) { |
|
4562 | - return unserialize($data); |
|
4563 | - } |
|
4564 | - return false; |
|
4565 | - } |
|
4566 | - |
|
4567 | - /** |
|
4568 | - * Retrieve the last modified time for the cache |
|
4569 | - * |
|
4570 | - * @return int Timestamp |
|
4571 | - */ |
|
4572 | - public function mtime() { |
|
4573 | - |
|
4574 | - $data = $this->cache->get($this->name); |
|
4575 | - |
|
4576 | - if ($data !== false) { |
|
4577 | - return time(); |
|
4578 | - } |
|
4579 | - |
|
4580 | - return false; |
|
4581 | - } |
|
4582 | - |
|
4583 | - /** |
|
4584 | - * Set the last modified time to the current time |
|
4585 | - * |
|
4586 | - * @return bool Success status |
|
4587 | - */ |
|
4588 | - public function touch() { |
|
4589 | - |
|
4590 | - $data = $this->cache->get($this->name); |
|
4591 | - |
|
4592 | - if ($data !== false) { |
|
4593 | - $return = $this->cache->set($this->name, $data); |
|
4594 | - if ($this->options['expire']) { |
|
4595 | - return $this->cache->expire($this->name, $this->ttl); |
|
4596 | - } |
|
4597 | - return $return; |
|
4598 | - } |
|
4599 | - |
|
4600 | - return false; |
|
4601 | - } |
|
4602 | - |
|
4603 | - /** |
|
4604 | - * Remove the cache |
|
4605 | - * |
|
4606 | - * @return bool Success status |
|
4607 | - */ |
|
4608 | - public function unlink() { |
|
4609 | - return $this->cache->set($this->name, null); |
|
4610 | - } |
|
4473 | + /** |
|
4474 | + * Redis instance |
|
4475 | + * |
|
4476 | + * @var \Redis |
|
4477 | + */ |
|
4478 | + protected $cache; |
|
4479 | + |
|
4480 | + /** |
|
4481 | + * Options |
|
4482 | + * |
|
4483 | + * @var array |
|
4484 | + */ |
|
4485 | + protected $options; |
|
4486 | + |
|
4487 | + /** |
|
4488 | + * Cache name |
|
4489 | + * |
|
4490 | + * @var string |
|
4491 | + */ |
|
4492 | + protected $name; |
|
4493 | + |
|
4494 | + /** |
|
4495 | + * Cache Data |
|
4496 | + * |
|
4497 | + * @var type |
|
4498 | + */ |
|
4499 | + protected $data; |
|
4500 | + |
|
4501 | + /** |
|
4502 | + * Create a new cache object |
|
4503 | + * |
|
4504 | + * @param string $location Location string (from SimplePie::$cache_location) |
|
4505 | + * @param string $name Unique ID for the cache |
|
4506 | + * @param string $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data |
|
4507 | + */ |
|
4508 | + public function __construct($location, $name, $options = null) { |
|
4509 | + //$this->cache = \flow\simple\cache\Redis::getRedisClientInstance(); |
|
4510 | + $parsed = SimplePie_Cache::parse_URL($location); |
|
4511 | + $redis = new Redis(); |
|
4512 | + $redis->connect($parsed['host'], $parsed['port']); |
|
4513 | + $this->cache = $redis; |
|
4514 | + |
|
4515 | + if (!is_null($options) && is_array($options)) { |
|
4516 | + $this->options = $options; |
|
4517 | + } else { |
|
4518 | + $this->options = array ( |
|
4519 | + 'prefix' => 'rss:simple_primary:', |
|
4520 | + 'expire' => 0, |
|
4521 | + ); |
|
4522 | + } |
|
4523 | + |
|
4524 | + $this->name = $this->options['prefix'] . $name; |
|
4525 | + } |
|
4526 | + |
|
4527 | + /** |
|
4528 | + * @param \Redis $cache |
|
4529 | + */ |
|
4530 | + public function setRedisClient(\Redis $cache) { |
|
4531 | + $this->cache = $cache; |
|
4532 | + } |
|
4533 | + |
|
4534 | + /** |
|
4535 | + * Save data to the cache |
|
4536 | + * |
|
4537 | + * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property |
|
4538 | + * @return bool Successfulness |
|
4539 | + */ |
|
4540 | + public function save($data) { |
|
4541 | + if ($data instanceof SimplePie) { |
|
4542 | + $data = $data->data; |
|
4543 | + } |
|
4544 | + $response = $this->cache->set($this->name, serialize($data)); |
|
4545 | + if ($this->options['expire']) { |
|
4546 | + $this->cache->expire($this->name, $this->options['expire']); |
|
4547 | + } |
|
4548 | + |
|
4549 | + return $response; |
|
4550 | + } |
|
4551 | + |
|
4552 | + /** |
|
4553 | + * Retrieve the data saved to the cache |
|
4554 | + * |
|
4555 | + * @return array Data for SimplePie::$data |
|
4556 | + */ |
|
4557 | + public function load() { |
|
4558 | + $data = $this->cache->get($this->name); |
|
4559 | + |
|
4560 | + if ($data !== false) { |
|
4561 | + return unserialize($data); |
|
4562 | + } |
|
4563 | + return false; |
|
4564 | + } |
|
4565 | + |
|
4566 | + /** |
|
4567 | + * Retrieve the last modified time for the cache |
|
4568 | + * |
|
4569 | + * @return int Timestamp |
|
4570 | + */ |
|
4571 | + public function mtime() { |
|
4572 | + |
|
4573 | + $data = $this->cache->get($this->name); |
|
4574 | + |
|
4575 | + if ($data !== false) { |
|
4576 | + return time(); |
|
4577 | + } |
|
4578 | + |
|
4579 | + return false; |
|
4580 | + } |
|
4581 | + |
|
4582 | + /** |
|
4583 | + * Set the last modified time to the current time |
|
4584 | + * |
|
4585 | + * @return bool Success status |
|
4586 | + */ |
|
4587 | + public function touch() { |
|
4588 | + |
|
4589 | + $data = $this->cache->get($this->name); |
|
4590 | + |
|
4591 | + if ($data !== false) { |
|
4592 | + $return = $this->cache->set($this->name, $data); |
|
4593 | + if ($this->options['expire']) { |
|
4594 | + return $this->cache->expire($this->name, $this->ttl); |
|
4595 | + } |
|
4596 | + return $return; |
|
4597 | + } |
|
4598 | + |
|
4599 | + return false; |
|
4600 | + } |
|
4601 | + |
|
4602 | + /** |
|
4603 | + * Remove the cache |
|
4604 | + * |
|
4605 | + * @return bool Success status |
|
4606 | + */ |
|
4607 | + public function unlink() { |
|
4608 | + return $this->cache->set($this->name, null); |
|
4609 | + } |
|
4611 | 4610 | |
4612 | 4611 | } |
4613 | 4612 | |
@@ -8269,9 +8268,9 @@ discard block |
||
8269 | 8268 | * Clean up |
8270 | 8269 | */ |
8271 | 8270 | public function __destruct() { |
8272 | - $this->set_iri(null, true); |
|
8273 | - $this->set_path(null, true); |
|
8274 | - $this->set_authority(null, true); |
|
8271 | + $this->set_iri(null, true); |
|
8272 | + $this->set_path(null, true); |
|
8273 | + $this->set_authority(null, true); |
|
8275 | 8274 | } |
8276 | 8275 | |
8277 | 8276 | /** |
@@ -8794,9 +8793,9 @@ discard block |
||
8794 | 8793 | // Relative urls cannot have a colon in the first path segment (and the |
8795 | 8794 | // slashes themselves are not included so skip the first character). |
8796 | 8795 | if (!$this->scheme && !$isauthority && |
8797 | - strpos($this->ipath, ':') !== false && |
|
8798 | - strpos($this->ipath, '/', 1) !== false && |
|
8799 | - strpos($this->ipath, ':') < strpos($this->ipath, '/', 1)) return false; |
|
8796 | + strpos($this->ipath, ':') !== false && |
|
8797 | + strpos($this->ipath, '/', 1) !== false && |
|
8798 | + strpos($this->ipath, ':') < strpos($this->ipath, '/', 1)) return false; |
|
8800 | 8799 | |
8801 | 8800 | return true; |
8802 | 8801 | } |
@@ -9469,7 +9468,7 @@ discard block |
||
9469 | 9468 | $fn = 'md5'; |
9470 | 9469 | } |
9471 | 9470 | return call_user_func($fn, |
9472 | - $this->get_permalink().$this->get_title().$this->get_content()); |
|
9471 | + $this->get_permalink().$this->get_title().$this->get_content()); |
|
9473 | 9472 | } |
9474 | 9473 | |
9475 | 9474 | /** |
@@ -9538,47 +9537,47 @@ discard block |
||
9538 | 9537 | public function get_description($description_only = false) |
9539 | 9538 | { |
9540 | 9539 | if (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) && |
9541 | - ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) |
|
9540 | + ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) |
|
9542 | 9541 | { |
9543 | 9542 | return $return; |
9544 | 9543 | } |
9545 | 9544 | elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) && |
9546 | - ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) |
|
9545 | + ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) |
|
9547 | 9546 | { |
9548 | 9547 | return $return; |
9549 | 9548 | } |
9550 | 9549 | elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) && |
9551 | - ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($tags[0])))) |
|
9550 | + ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($tags[0])))) |
|
9552 | 9551 | { |
9553 | 9552 | return $return; |
9554 | 9553 | } |
9555 | 9554 | elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) && |
9556 | - ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0])))) |
|
9555 | + ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0])))) |
|
9557 | 9556 | { |
9558 | 9557 | return $return; |
9559 | 9558 | } |
9560 | 9559 | elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) && |
9561 | - ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT))) |
|
9560 | + ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT))) |
|
9562 | 9561 | { |
9563 | 9562 | return $return; |
9564 | 9563 | } |
9565 | 9564 | elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) && |
9566 | - ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT))) |
|
9565 | + ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT))) |
|
9567 | 9566 | { |
9568 | 9567 | return $return; |
9569 | 9568 | } |
9570 | 9569 | elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) && |
9571 | - ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0])))) |
|
9570 | + ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0])))) |
|
9572 | 9571 | { |
9573 | 9572 | return $return; |
9574 | 9573 | } |
9575 | 9574 | elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) && |
9576 | - ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT))) |
|
9575 | + ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT))) |
|
9577 | 9576 | { |
9578 | 9577 | return $return; |
9579 | 9578 | } |
9580 | 9579 | elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) && |
9581 | - ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML))) |
|
9580 | + ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML))) |
|
9582 | 9581 | { |
9583 | 9582 | return $return; |
9584 | 9583 | } |
@@ -9610,17 +9609,17 @@ discard block |
||
9610 | 9609 | public function get_content($content_only = false) |
9611 | 9610 | { |
9612 | 9611 | if (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) && |
9613 | - ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) |
|
9612 | + ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) |
|
9614 | 9613 | { |
9615 | 9614 | return $return; |
9616 | 9615 | } |
9617 | 9616 | elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) && |
9618 | - ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) |
|
9617 | + ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) |
|
9619 | 9618 | { |
9620 | 9619 | return $return; |
9621 | 9620 | } |
9622 | 9621 | elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) && |
9623 | - ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0])))) |
|
9622 | + ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0])))) |
|
9624 | 9623 | { |
9625 | 9624 | return $return; |
9626 | 9625 | } |
@@ -12335,8 +12334,8 @@ discard block |
||
12335 | 12334 | $sniffer = $this->registry->create('Content_Type_Sniffer', array($file)); |
12336 | 12335 | $sniffed = $sniffer->get_type(); |
12337 | 12336 | $mime_types = array('application/rss+xml', 'application/rdf+xml', |
12338 | - 'text/rdf', 'application/atom+xml', 'text/xml', |
|
12339 | - 'application/xml', 'application/x-rss+xml'); |
|
12337 | + 'text/rdf', 'application/atom+xml', 'text/xml', |
|
12338 | + 'application/xml', 'application/x-rss+xml'); |
|
12340 | 12339 | if ($check_html) |
12341 | 12340 | { |
12342 | 12341 | $mime_types[] = 'text/html'; |
@@ -12510,12 +12509,12 @@ discard block |
||
12510 | 12509 | if ($this->dom === null) |
12511 | 12510 | { |
12512 | 12511 | throw new SimplePie_Exception('DOMDocument not found, unable to use '. |
12513 | - 'locator'); |
|
12512 | + 'locator'); |
|
12514 | 12513 | } |
12515 | 12514 | if (!class_exists('DOMXpath')) |
12516 | 12515 | { |
12517 | 12516 | throw new SimplePie_Exception('DOMXpath not found, unable to use '. |
12518 | - 'get_rel_link'); |
|
12517 | + 'get_rel_link'); |
|
12519 | 12518 | } |
12520 | 12519 | |
12521 | 12520 | $xpath = new DOMXpath($this->dom); |
@@ -12525,22 +12524,22 @@ discard block |
||
12525 | 12524 | $href = trim($link->getAttribute('href')); |
12526 | 12525 | $parsed = $this->registry->call('Misc', 'parse_url', array($href)); |
12527 | 12526 | if ($parsed['scheme'] === '' || |
12528 | - preg_match('/^https?$/i', $parsed['scheme'])) |
|
12527 | + preg_match('/^https?$/i', $parsed['scheme'])) |
|
12529 | 12528 | { |
12530 | 12529 | if (method_exists($link, 'getLineNo') && |
12531 | - $this->base_location < $link->getLineNo()) |
|
12530 | + $this->base_location < $link->getLineNo()) |
|
12532 | 12531 | { |
12533 | 12532 | $href = |
12534 | 12533 | $this->registry->call('Misc', 'absolutize_url', |
12535 | - array(trim($link->getAttribute('href')), |
|
12536 | - $this->base)); |
|
12534 | + array(trim($link->getAttribute('href')), |
|
12535 | + $this->base)); |
|
12537 | 12536 | } |
12538 | 12537 | else |
12539 | 12538 | { |
12540 | 12539 | $href = |
12541 | 12540 | $this->registry->call('Misc', 'absolutize_url', |
12542 | - array(trim($link->getAttribute('href')), |
|
12543 | - $this->http_base)); |
|
12541 | + array(trim($link->getAttribute('href')), |
|
12542 | + $this->http_base)); |
|
12544 | 12543 | } |
12545 | 12544 | if ($href === false) |
12546 | 12545 | { |
@@ -16630,9 +16629,9 @@ discard block |
||
16630 | 16629 | } |
16631 | 16630 | $channel = array('channel' => array(array('child' => array('' => |
16632 | 16631 | array('link' => $link, 'image' => $image, 'title' => $feed_title, |
16633 | - 'item' => $items))))); |
|
16632 | + 'item' => $items))))); |
|
16634 | 16633 | $rss = array(array('attribs' => array('' => array('version' => '2.0')), |
16635 | - 'child' => array('' => $channel))); |
|
16634 | + 'child' => array('' => $channel))); |
|
16636 | 16635 | $this->data = array('child' => array('' => array('rss' => $rss))); |
16637 | 16636 | return true; |
16638 | 16637 | } |
@@ -345,14 +345,14 @@ discard block |
||
345 | 345 | </tr> |
346 | 346 | <!-- |
347 | 347 | <?php |
348 | - if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') { |
|
349 | - require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
350 | - $Connection = new Connection(); |
|
348 | + if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') { |
|
349 | + require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
350 | + $Connection = new Connection(); |
|
351 | 351 | ?> |
352 | 352 | --> |
353 | 353 | <?php |
354 | 354 | if ($Connection->db != NULL) { |
355 | - if ($Connection->tableExists('source_location')) { |
|
355 | + if ($Connection->tableExists('source_location')) { |
|
356 | 356 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
357 | 357 | $Source = new Source(); |
358 | 358 | //$alllocations = $Source->getAllLocationInfo(); |
@@ -372,9 +372,9 @@ discard block |
||
372 | 372 | |
373 | 373 | <?php |
374 | 374 | } |
375 | - } |
|
375 | + } |
|
376 | + } |
|
376 | 377 | } |
377 | - } |
|
378 | 378 | ?> |
379 | 379 | |
380 | 380 | <tr> |
@@ -484,12 +484,12 @@ discard block |
||
484 | 484 | ?> |
485 | 485 | <tr> |
486 | 486 | <?php |
487 | - if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
487 | + if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
488 | 488 | ?> |
489 | 489 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
490 | 490 | <td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td> |
491 | 491 | <?php |
492 | - } else { |
|
492 | + } else { |
|
493 | 493 | $hostport = explode(':',$source['host']); |
494 | 494 | if (isset($hostport[1])) { |
495 | 495 | $host = $hostport[0]; |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | <td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td> |
503 | 503 | <td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php print $port; ?>" /></td> |
504 | 504 | <?php |
505 | - } |
|
505 | + } |
|
506 | 506 | ?> |
507 | 507 | <td> |
508 | 508 | <select name="format[]" id="format"> |
@@ -639,9 +639,9 @@ discard block |
||
639 | 639 | </thead> |
640 | 640 | <tbody> |
641 | 641 | <?php |
642 | - if (isset($globalNewsFeeds) && !empty($globalNewsFeeds)) { |
|
642 | + if (isset($globalNewsFeeds) && !empty($globalNewsFeeds)) { |
|
643 | 643 | foreach ($globalNewsFeeds as $type => $feedslng) { |
644 | - foreach ($feedslng as $lng => $feeds) { |
|
644 | + foreach ($feedslng as $lng => $feeds) { |
|
645 | 645 | foreach ($feeds as $feed) { |
646 | 646 | ?> |
647 | 647 | <tr> |
@@ -666,9 +666,9 @@ discard block |
||
666 | 666 | |
667 | 667 | <?php |
668 | 668 | } |
669 | - } |
|
669 | + } |
|
670 | + } |
|
670 | 671 | } |
671 | - } |
|
672 | 672 | ?> |
673 | 673 | <tr> |
674 | 674 | <td><input type="url" name="newsurl[]" /></td> |
@@ -1009,7 +1009,7 @@ discard block |
||
1009 | 1009 | <br /> |
1010 | 1010 | <p> |
1011 | 1011 | <?php |
1012 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
1012 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
1013 | 1013 | ?> |
1014 | 1014 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
1015 | 1015 | <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
@@ -1019,11 +1019,11 @@ discard block |
||
1019 | 1019 | <b>The directory cache is not writable, aircraft icon will not be cached</b> |
1020 | 1020 | <?php |
1021 | 1021 | } |
1022 | - } else { |
|
1022 | + } else { |
|
1023 | 1023 | ?> |
1024 | 1024 | <b>PHP GD is not installed, you can't change color of aircraft icon on map</b> |
1025 | 1025 | <?php |
1026 | - } |
|
1026 | + } |
|
1027 | 1027 | ?> |
1028 | 1028 | </p> |
1029 | 1029 | <br /> |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | </p> |
1048 | 1048 | <?php |
1049 | 1049 | require('../footer.php'); |
1050 | - exit; |
|
1050 | + exit; |
|
1051 | 1051 | } |
1052 | 1052 | // ' |
1053 | 1053 | $settings = array(); |
@@ -1138,8 +1138,8 @@ discard block |
||
1138 | 1138 | |
1139 | 1139 | $sources = array(); |
1140 | 1140 | foreach ($source_name as $keys => $name) { |
1141 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1142 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1141 | + if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1142 | + else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1143 | 1143 | } |
1144 | 1144 | if (count($sources) > 0) $_SESSION['sources'] = $sources; |
1145 | 1145 | |
@@ -1149,13 +1149,13 @@ discard block |
||
1149 | 1149 | |
1150 | 1150 | $newsfeeds = array(); |
1151 | 1151 | foreach($newsurl as $newskey => $url) { |
1152 | - if ($url != '') { |
|
1152 | + if ($url != '') { |
|
1153 | 1153 | $type = $newstype[$newskey]; |
1154 | 1154 | $lng = $newslng[$newskey]; |
1155 | 1155 | if (isset($newsfeeds[$type][$lng])) { |
1156 | - $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url)); |
|
1156 | + $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url)); |
|
1157 | 1157 | } else $newsfeeds[$type][$lng] = array($url); |
1158 | - } |
|
1158 | + } |
|
1159 | 1159 | } |
1160 | 1160 | $settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds)); |
1161 | 1161 | |
@@ -1567,14 +1567,14 @@ discard block |
||
1567 | 1567 | |
1568 | 1568 | // Set some defaults values... |
1569 | 1569 | if (!isset($globalAircraftImageSources)) { |
1570 | - $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1571 | - $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1570 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1571 | + $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1572 | 1572 | } |
1573 | 1573 | |
1574 | 1574 | if (!isset($globalSchedulesSources)) { |
1575 | - $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1576 | - $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1577 | - } |
|
1575 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1576 | + $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1577 | + } |
|
1578 | 1578 | |
1579 | 1579 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
1580 | 1580 | |
@@ -1622,21 +1622,21 @@ discard block |
||
1622 | 1622 | $popi = false; |
1623 | 1623 | $popw = false; |
1624 | 1624 | foreach ($_SESSION['done'] as $done) { |
1625 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1626 | - if ($done == 'Create database') $pop = true; |
|
1627 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1628 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1629 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1625 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1626 | + if ($done == 'Create database') $pop = true; |
|
1627 | + if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1628 | + if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1629 | + if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1630 | 1630 | } |
1631 | 1631 | if ($pop) { |
1632 | - sleep(5); |
|
1633 | - print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1632 | + sleep(5); |
|
1633 | + print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1634 | 1634 | } else if ($popi) { |
1635 | - sleep(5); |
|
1636 | - print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1635 | + sleep(5); |
|
1636 | + print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1637 | 1637 | } else if ($popw) { |
1638 | - sleep(5); |
|
1639 | - print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
1638 | + sleep(5); |
|
1639 | + print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
1640 | 1640 | } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
1641 | 1641 | print '</div></ul>'; |
1642 | 1642 | print '<div id="error"></div>'; |
@@ -1702,7 +1702,7 @@ discard block |
||
1702 | 1702 | unset($_COOKIE['install']); |
1703 | 1703 | print '<div class="info column"><ul>'; |
1704 | 1704 | foreach ($_SESSION['done'] as $done) { |
1705 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1705 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1706 | 1706 | } |
1707 | 1707 | print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>'; |
1708 | 1708 | print '</ul></div>'; |