@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
31 | - * Add schedule data to database |
|
32 | - * @param String $ident aircraft ident |
|
33 | - * @param String $departure_airport_icao departure airport icao |
|
34 | - * @param String $departure_airport_time departure airport time |
|
35 | - * @param String $arrival_airport_icao arrival airport icao |
|
36 | - * @param String $arrival_airport_time arrival airport time |
|
31 | + * Add schedule data to database |
|
32 | + * @param String $ident aircraft ident |
|
33 | + * @param String $departure_airport_icao departure airport icao |
|
34 | + * @param String $departure_airport_time departure airport time |
|
35 | + * @param String $arrival_airport_icao arrival airport icao |
|
36 | + * @param String $arrival_airport_time arrival airport time |
|
37 | 37 | / @param String $source source of data |
38 | - */ |
|
38 | + */ |
|
39 | 39 | public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') { |
40 | 40 | date_default_timezone_set('UTC'); |
41 | 41 | $date = date("Y-m-d H:i:s",time()); |
@@ -51,18 +51,18 @@ discard block |
||
51 | 51 | } |
52 | 52 | if ($sth->fetchColumn() > 0) { |
53 | 53 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
54 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
|
55 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
54 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
|
55 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
56 | 56 | } elseif ($arrival_airport_time == '') { |
57 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
|
58 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
57 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
|
58 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
59 | 59 | } elseif ($departure_airport_time == '') { |
60 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
61 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
60 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
61 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
62 | 62 | } else { |
63 | - //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
|
64 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
65 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
63 | + //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
|
64 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
65 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
66 | 66 | } |
67 | 67 | try { |
68 | 68 | $sth = $this->db->prepare($query); |
@@ -149,15 +149,15 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function checkSchedule($ident) { |
151 | 151 | global $globalDBdriver; |
152 | - //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1"; |
|
153 | - if ($globalDBdriver == 'mysql') { |
|
152 | + //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1"; |
|
153 | + if ($globalDBdriver == 'mysql') { |
|
154 | 154 | $query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1"; |
155 | 155 | } else { |
156 | 156 | $query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident |
157 | 157 | AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL) |
158 | 158 | OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1"; |
159 | 159 | } |
160 | - $query_values = array(':ident' => $ident); |
|
160 | + $query_values = array(':ident' => $ident); |
|
161 | 161 | try { |
162 | 162 | $sth = $this->db->prepare($query); |
163 | 163 | $sth->execute($query_values); |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
173 | - * Get flight info from Air France |
|
174 | - * @param String $callsign The callsign |
|
175 | - * @param String $date date we want flight number info |
|
176 | - * @param String $carrier IATA code |
|
177 | - * @return Flight departure and arrival airports and time |
|
178 | - */ |
|
173 | + * Get flight info from Air France |
|
174 | + * @param String $callsign The callsign |
|
175 | + * @param String $date date we want flight number info |
|
176 | + * @param String $carrier IATA code |
|
177 | + * @return Flight departure and arrival airports and time |
|
178 | + */ |
|
179 | 179 | public function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') { |
180 | 180 | $Common = new Common(); |
181 | 181 | $check_date = new Datetime($date); |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
214 | - * Get flight info from EasyJet |
|
215 | - * @param String $callsign The callsign |
|
216 | - * @param String $date date we want flight number info |
|
217 | - * @return Flight departure and arrival airports and time |
|
218 | - */ |
|
214 | + * Get flight info from EasyJet |
|
215 | + * @param String $callsign The callsign |
|
216 | + * @param String $date date we want flight number info |
|
217 | + * @return Flight departure and arrival airports and time |
|
218 | + */ |
|
219 | 219 | private function getEasyJet($callsign, $date = 'NOW') { |
220 | 220 | global $globalTimezone; |
221 | 221 | $Common = new Common(); |
@@ -239,10 +239,10 @@ discard block |
||
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
242 | - * Get flight info from Ryanair |
|
243 | - * @param String $callsign The callsign |
|
244 | - * @return Flight departure and arrival airports and time |
|
245 | - */ |
|
242 | + * Get flight info from Ryanair |
|
243 | + * @param String $callsign The callsign |
|
244 | + * @return Flight departure and arrival airports and time |
|
245 | + */ |
|
246 | 246 | private function getRyanair($callsign) { |
247 | 247 | $Common = new Common(); |
248 | 248 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
268 | - * Get flight info from Swiss |
|
269 | - * @param String $callsign The callsign |
|
270 | - * @return Flight departure and arrival airports and time |
|
271 | - */ |
|
268 | + * Get flight info from Swiss |
|
269 | + * @param String $callsign The callsign |
|
270 | + * @return Flight departure and arrival airports and time |
|
271 | + */ |
|
272 | 272 | private function getSwiss($callsign) { |
273 | 273 | $Common = new Common(); |
274 | 274 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -297,11 +297,11 @@ discard block |
||
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
300 | - * Get flight info from British Airways API |
|
301 | - * @param String $callsign The callsign |
|
302 | - * @param String $date date we want flight number info |
|
303 | - * @return Flight departure and arrival airports and time |
|
304 | - */ |
|
300 | + * Get flight info from British Airways API |
|
301 | + * @param String $callsign The callsign |
|
302 | + * @param String $date date we want flight number info |
|
303 | + * @return Flight departure and arrival airports and time |
|
304 | + */ |
|
305 | 305 | public function getBritishAirways($callsign, $date = 'NOW') { |
306 | 306 | global $globalBritishAirwaysKey; |
307 | 307 | $Common = new Common(); |
@@ -325,11 +325,11 @@ discard block |
||
325 | 325 | } |
326 | 326 | |
327 | 327 | /** |
328 | - * Get flight info from Lutfhansa API |
|
329 | - * @param String $callsign The callsign |
|
330 | - * @param String $date date we want flight number info |
|
331 | - * @return Flight departure and arrival airports and time |
|
332 | - */ |
|
328 | + * Get flight info from Lutfhansa API |
|
329 | + * @param String $callsign The callsign |
|
330 | + * @param String $date date we want flight number info |
|
331 | + * @return Flight departure and arrival airports and time |
|
332 | + */ |
|
333 | 333 | public function getLufthansa($callsign, $date = 'NOW') { |
334 | 334 | global $globalLufthansaKey; |
335 | 335 | $Common = new Common(); |
@@ -359,11 +359,11 @@ discard block |
||
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
362 | - * Get flight info from Transavia API |
|
363 | - * @param String $callsign The callsign |
|
364 | - * @param String $date date we want flight number info |
|
365 | - * @return Flight departure and arrival airports and time |
|
366 | - */ |
|
362 | + * Get flight info from Transavia API |
|
363 | + * @param String $callsign The callsign |
|
364 | + * @param String $date date we want flight number info |
|
365 | + * @return Flight departure and arrival airports and time |
|
366 | + */ |
|
367 | 367 | public function getTransavia($callsign, $date = 'NOW') { |
368 | 368 | global $globalTransaviaKey; |
369 | 369 | $Common = new Common(); |
@@ -389,10 +389,10 @@ discard block |
||
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
392 | - * Get flight info from Tunisair |
|
393 | - * @param String $callsign The callsign |
|
394 | - * @return Flight departure and arrival airports and time |
|
395 | - */ |
|
392 | + * Get flight info from Tunisair |
|
393 | + * @param String $callsign The callsign |
|
394 | + * @return Flight departure and arrival airports and time |
|
395 | + */ |
|
396 | 396 | public function getTunisair($callsign) { |
397 | 397 | $Common = new Common(); |
398 | 398 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -409,10 +409,10 @@ discard block |
||
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
412 | - * Get flight info from Vueling |
|
413 | - * @param String $callsign The callsign |
|
414 | - * @return Flight departure and arrival airports and time |
|
415 | - */ |
|
412 | + * Get flight info from Vueling |
|
413 | + * @param String $callsign The callsign |
|
414 | + * @return Flight departure and arrival airports and time |
|
415 | + */ |
|
416 | 416 | public function getVueling($callsign,$date = 'NOW') { |
417 | 417 | $Common = new Common(); |
418 | 418 | $check_date = new Datetime($date); |
@@ -434,11 +434,11 @@ discard block |
||
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
437 | - * Get flight info from Iberia |
|
438 | - * @param String $callsign The callsign |
|
439 | - * @param String $date date we want flight number info |
|
440 | - * @return Flight departure and arrival airports and time |
|
441 | - */ |
|
437 | + * Get flight info from Iberia |
|
438 | + * @param String $callsign The callsign |
|
439 | + * @param String $date date we want flight number info |
|
440 | + * @return Flight departure and arrival airports and time |
|
441 | + */ |
|
442 | 442 | public function getIberia($callsign, $date = 'NOW') { |
443 | 443 | $Common = new Common(); |
444 | 444 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -468,11 +468,11 @@ discard block |
||
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
471 | - * Get flight info from Star Alliance |
|
472 | - * @param String $callsign The callsign |
|
473 | - * @param String $date date we want flight number info |
|
474 | - * @return Flight departure and arrival airports and time |
|
475 | - */ |
|
471 | + * Get flight info from Star Alliance |
|
472 | + * @param String $callsign The callsign |
|
473 | + * @param String $date date we want flight number info |
|
474 | + * @return Flight departure and arrival airports and time |
|
475 | + */ |
|
476 | 476 | |
477 | 477 | private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') { |
478 | 478 | $Common = new Common(); |
@@ -504,11 +504,11 @@ discard block |
||
504 | 504 | |
505 | 505 | |
506 | 506 | /** |
507 | - * Get flight info from Alitalia |
|
508 | - * @param String $callsign The callsign |
|
509 | - * @param String $date date we want flight number info |
|
510 | - * @return Flight departure and arrival airports and time |
|
511 | - */ |
|
507 | + * Get flight info from Alitalia |
|
508 | + * @param String $callsign The callsign |
|
509 | + * @param String $date date we want flight number info |
|
510 | + * @return Flight departure and arrival airports and time |
|
511 | + */ |
|
512 | 512 | private function getAlitalia($callsign, $date = 'NOW') { |
513 | 513 | $Common = new Common(); |
514 | 514 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -527,11 +527,11 @@ discard block |
||
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
530 | - * Get flight info from Brussels airlines |
|
531 | - * @param String $callsign The callsign |
|
532 | - * @param String $date date we want flight number info |
|
533 | - * @return Flight departure and arrival airports and time |
|
534 | - */ |
|
530 | + * Get flight info from Brussels airlines |
|
531 | + * @param String $callsign The callsign |
|
532 | + * @param String $date date we want flight number info |
|
533 | + * @return Flight departure and arrival airports and time |
|
534 | + */ |
|
535 | 535 | private function getBrussels($callsign, $date = 'NOW') { |
536 | 536 | $Common = new Common(); |
537 | 537 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -541,24 +541,24 @@ discard block |
||
541 | 541 | if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
542 | 542 | $data = $Common->getData($url); |
543 | 543 | if ($data != '') { |
544 | - //echo $data; |
|
545 | - $parsed_json = json_decode($data,true); |
|
546 | - if (isset($parsed_json[0]['FromAirportCode'])) { |
|
544 | + //echo $data; |
|
545 | + $parsed_json = json_decode($data,true); |
|
546 | + if (isset($parsed_json[0]['FromAirportCode'])) { |
|
547 | 547 | $DepartureAirportIata = $parsed_json[0]['FromAirportCode']; |
548 | 548 | $ArrivalAirportIata = $parsed_json[0]['ToAirportCode']; |
549 | 549 | $departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
550 | 550 | $arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
551 | 551 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels'); |
552 | - } |
|
552 | + } |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
557 | - * Get flight info from FlightRadar24 |
|
558 | - * @param String $callsign The callsign |
|
559 | - * @param String $date date we want flight number info |
|
560 | - * @return Flight departure and arrival airports and time |
|
561 | - */ |
|
557 | + * Get flight info from FlightRadar24 |
|
558 | + * @param String $callsign The callsign |
|
559 | + * @param String $date date we want flight number info |
|
560 | + * @return Flight departure and arrival airports and time |
|
561 | + */ |
|
562 | 562 | /* |
563 | 563 | public function getFlightRadar24($callsign, $date = 'NOW') { |
564 | 564 | $Common = new Common(); |
@@ -587,11 +587,11 @@ discard block |
||
587 | 587 | } |
588 | 588 | */ |
589 | 589 | /** |
590 | - * Get flight info from Lufthansa |
|
591 | - * @param String $callsign The callsign |
|
592 | - * @param String $date date we want flight number info |
|
593 | - * @return Flight departure and arrival airports and time |
|
594 | - */ |
|
590 | + * Get flight info from Lufthansa |
|
591 | + * @param String $callsign The callsign |
|
592 | + * @param String $date date we want flight number info |
|
593 | + * @return Flight departure and arrival airports and time |
|
594 | + */ |
|
595 | 595 | |
596 | 596 | /* private function getLufthansa($callsign, $date = 'NOW') { |
597 | 597 | $Common = new Common(); |
@@ -619,10 +619,10 @@ discard block |
||
619 | 619 | } |
620 | 620 | */ |
621 | 621 | /** |
622 | - * Get flight info from flytap |
|
623 | - * @param String $callsign The callsign |
|
624 | - * @return Flight departure and arrival airports and time |
|
625 | - */ |
|
622 | + * Get flight info from flytap |
|
623 | + * @param String $callsign The callsign |
|
624 | + * @return Flight departure and arrival airports and time |
|
625 | + */ |
|
626 | 626 | private function getFlyTap($callsign) { |
627 | 627 | $Common = new Common(); |
628 | 628 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -645,10 +645,10 @@ discard block |
||
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
648 | - * Get flight info from flightmapper |
|
649 | - * @param String $callsign The callsign |
|
650 | - * @return Flight departure and arrival airports and time |
|
651 | - */ |
|
648 | + * Get flight info from flightmapper |
|
649 | + * @param String $callsign The callsign |
|
650 | + * @return Flight departure and arrival airports and time |
|
651 | + */ |
|
652 | 652 | public function getFlightMapper($callsign) { |
653 | 653 | $Common = new Common(); |
654 | 654 | $airline_icao = ''; |
@@ -676,11 +676,11 @@ discard block |
||
676 | 676 | $aarr = ''; |
677 | 677 | $n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr); |
678 | 678 | if ($n == 7) { |
679 | - $departureTime = $dhour; |
|
680 | - $arrivalTime = $ahour; |
|
681 | - $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
682 | - $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
683 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
679 | + $departureTime = $dhour; |
|
680 | + $arrivalTime = $ahour; |
|
681 | + $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
682 | + $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
683 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
684 | 684 | } |
685 | 685 | } |
686 | 686 | } |
@@ -688,10 +688,10 @@ discard block |
||
688 | 688 | } |
689 | 689 | |
690 | 690 | /** |
691 | - * Get flight info from flightaware |
|
692 | - * @param String $callsign The callsign |
|
693 | - * @return Flight departure and arrival airports and time |
|
694 | - */ |
|
691 | + * Get flight info from flightaware |
|
692 | + * @param String $callsign The callsign |
|
693 | + * @return Flight departure and arrival airports and time |
|
694 | + */ |
|
695 | 695 | public function getFlightAware($callsign) { |
696 | 696 | global $globalFlightAwareUsername, $globalFlightAwarePassword; |
697 | 697 | date_default_timezone_set('UTC'); |
@@ -716,11 +716,11 @@ discard block |
||
716 | 716 | $flight = $result['FlightInfoStatusResult']['flights'][0]; |
717 | 717 | if (isset($flight['origin'])) { |
718 | 718 | return array( |
719 | - 'DepartureAirportIATA' => $flight['origin']['alternate_ident'], |
|
720 | - 'DepartureTime' => $flight['filed_departure_time']['time'], |
|
721 | - 'ArrivalAirportIATA' => $flight['destination']['alternate_ident'], |
|
722 | - 'ArrivalTime' => $flight['filed_arrival_time']['time'], |
|
723 | - 'Source' => 'website_flightaware'); |
|
719 | + 'DepartureAirportIATA' => $flight['origin']['alternate_ident'], |
|
720 | + 'DepartureTime' => $flight['filed_departure_time']['time'], |
|
721 | + 'ArrivalAirportIATA' => $flight['destination']['alternate_ident'], |
|
722 | + 'ArrivalTime' => $flight['filed_arrival_time']['time'], |
|
723 | + 'Source' => 'website_flightaware'); |
|
724 | 724 | } |
725 | 725 | } |
726 | 726 | } |
@@ -733,21 +733,21 @@ discard block |
||
733 | 733 | $flight = reset($flights['flights']); |
734 | 734 | if (isset($flight['activityLog']['flights'][0]['origin'])) { |
735 | 735 | return array( |
736 | - 'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'], |
|
737 | - 'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']), |
|
738 | - 'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'], |
|
739 | - 'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']), |
|
740 | - 'Source' => 'website_flightaware'); |
|
736 | + 'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'], |
|
737 | + 'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']), |
|
738 | + 'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'], |
|
739 | + 'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']), |
|
740 | + 'Source' => 'website_flightaware'); |
|
741 | 741 | } |
742 | 742 | } |
743 | 743 | return array(); |
744 | 744 | } |
745 | 745 | |
746 | 746 | /** |
747 | - * Get flight info from CostToTravel |
|
748 | - * @param String $callsign The callsign |
|
749 | - * @return Flight departure and arrival airports and time |
|
750 | - */ |
|
747 | + * Get flight info from CostToTravel |
|
748 | + * @param String $callsign The callsign |
|
749 | + * @return Flight departure and arrival airports and time |
|
750 | + */ |
|
751 | 751 | public function getCostToTravel($callsign) { |
752 | 752 | $Common = new Common(); |
753 | 753 | $url= "http://www.costtotravel.com/flight-number/".$callsign; |
@@ -770,11 +770,11 @@ discard block |
||
770 | 770 | } |
771 | 771 | |
772 | 772 | /** |
773 | - * Get flight info from Air Canada |
|
774 | - * @param String $callsign The callsign |
|
775 | - * @param String $date date we want flight number info |
|
776 | - * @return Flight departure and arrival airports and time |
|
777 | - */ |
|
773 | + * Get flight info from Air Canada |
|
774 | + * @param String $callsign The callsign |
|
775 | + * @param String $date date we want flight number info |
|
776 | + * @return Flight departure and arrival airports and time |
|
777 | + */ |
|
778 | 778 | private function getAirCanada($callsign,$date = 'NOW') { |
779 | 779 | $Common = new Common(); |
780 | 780 | if (class_exists("DomDocument") === FALSE) return array(); |
@@ -799,11 +799,11 @@ discard block |
||
799 | 799 | } |
800 | 800 | |
801 | 801 | /** |
802 | - * Get flight info from Vietnam Airlines |
|
803 | - * @param String $callsign The callsign |
|
804 | - * @param String $date date we want flight number info |
|
805 | - * @return Flight departure and arrival airports and time |
|
806 | - */ |
|
802 | + * Get flight info from Vietnam Airlines |
|
803 | + * @param String $callsign The callsign |
|
804 | + * @param String $date date we want flight number info |
|
805 | + * @return Flight departure and arrival airports and time |
|
806 | + */ |
|
807 | 807 | private function getVietnamAirlines($callsign, $date = 'NOW') { |
808 | 808 | $Common = new Common(); |
809 | 809 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -825,12 +825,12 @@ discard block |
||
825 | 825 | } |
826 | 826 | |
827 | 827 | /** |
828 | - * Get flight info from Air Berlin |
|
829 | - * @param String $callsign The callsign |
|
830 | - * @param String $date date we want flight number info |
|
831 | - * @param String $carrier airline code |
|
832 | - * @return Flight departure and arrival airports and time |
|
833 | - */ |
|
828 | + * Get flight info from Air Berlin |
|
829 | + * @param String $callsign The callsign |
|
830 | + * @param String $date date we want flight number info |
|
831 | + * @param String $carrier airline code |
|
832 | + * @return Flight departure and arrival airports and time |
|
833 | + */ |
|
834 | 834 | private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') { |
835 | 835 | $Common = new Common(); |
836 | 836 | date_default_timezone_set('UTC'); |
@@ -859,11 +859,11 @@ discard block |
||
859 | 859 | $table = $Common->table2array($data); |
860 | 860 | $flight = $table; |
861 | 861 | if (isset($flight[5][4])) { |
862 | - $arrivalTime = $flight[5][4]; |
|
863 | - $arrivalAirport = $flight[5][3]; |
|
862 | + $arrivalTime = $flight[5][4]; |
|
863 | + $arrivalAirport = $flight[5][3]; |
|
864 | 864 | } else { |
865 | - $arrivalTime = ''; |
|
866 | - $arrivalAirport = ''; |
|
865 | + $arrivalTime = ''; |
|
866 | + $arrivalAirport = ''; |
|
867 | 867 | } |
868 | 868 | } else return array(); |
869 | 869 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
@@ -9,20 +9,20 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
10 | 10 | require_once(dirname(__FILE__).'/class.GeoidHeight.php'); |
11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | class SpotterImport { |
16 | - private $all_flights = array(); |
|
17 | - private $last_delete_hourly = 0; |
|
18 | - private $last_delete = 0; |
|
19 | - private $stats = array(); |
|
20 | - private $tmd = 0; |
|
21 | - private $source_location = array(); |
|
22 | - public $db = null; |
|
23 | - public $nb = 0; |
|
16 | + private $all_flights = array(); |
|
17 | + private $last_delete_hourly = 0; |
|
18 | + private $last_delete = 0; |
|
19 | + private $stats = array(); |
|
20 | + private $tmd = 0; |
|
21 | + private $source_location = array(); |
|
22 | + public $db = null; |
|
23 | + public $nb = 0; |
|
24 | 24 | |
25 | - public function __construct($dbc = null) { |
|
25 | + public function __construct($dbc = null) { |
|
26 | 26 | global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid; |
27 | 27 | if (!(isset($globalNoDB) && $globalNoDB)) { |
28 | 28 | $Connection = new Connection($dbc); |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | $currentdate = date('Y-m-d'); |
35 | 35 | $sourcestat = $Stats->getStatsSource($currentdate); |
36 | 36 | if (!empty($sourcestat)) { |
37 | - foreach($sourcestat as $srcst) { |
|
38 | - $type = $srcst['stats_type']; |
|
37 | + foreach($sourcestat as $srcst) { |
|
38 | + $type = $srcst['stats_type']; |
|
39 | 39 | if ($type == 'polar' || $type == 'hist') { |
40 | - $source = $srcst['source_name']; |
|
41 | - $data = $srcst['source_data']; |
|
42 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
43 | - } |
|
44 | - } |
|
40 | + $source = $srcst['source_name']; |
|
41 | + $data = $srcst['source_data']; |
|
42 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
43 | + } |
|
44 | + } |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | $GeoidClass = FALSE; |
57 | 57 | } |
58 | 58 | } |
59 | - } |
|
59 | + } |
|
60 | 60 | |
61 | - public function get_Schedule($id,$ident) { |
|
61 | + public function get_Schedule($id,$ident) { |
|
62 | 62 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
63 | 63 | // Get schedule here, so it's done only one time |
64 | 64 | |
@@ -78,43 +78,43 @@ discard block |
||
78 | 78 | $operator = $Spotter->getOperator($ident); |
79 | 79 | $scheduleexist = false; |
80 | 80 | if ($Schedule->checkSchedule($operator) == 0) { |
81 | - $operator = $Translation->checkTranslation($ident); |
|
82 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
81 | + $operator = $Translation->checkTranslation($ident); |
|
82 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
83 | 83 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 84 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
86 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | - // Should also check if route schedule = route from DB |
|
89 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
85 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
86 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | + // Should also check if route schedule = route from DB |
|
89 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
90 | 90 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
91 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
92 | - if (trim($airport_icao) != '') { |
|
91 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
92 | + if (trim($airport_icao) != '') { |
|
93 | 93 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
94 | 94 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
95 | - } |
|
95 | + } |
|
96 | + } |
|
96 | 97 | } |
97 | - } |
|
98 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
98 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
99 | 99 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
100 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
101 | - if (trim($airport_icao) != '') { |
|
100 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
101 | + if (trim($airport_icao) != '') { |
|
102 | 102 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
103 | 103 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
104 | - } |
|
104 | + } |
|
105 | 105 | } |
106 | - } |
|
107 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
106 | + } |
|
107 | + $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
108 | 108 | } |
109 | - } else $scheduleexist = true; |
|
109 | + } else $scheduleexist = true; |
|
110 | 110 | } else $scheduleexist = true; |
111 | 111 | // close connection, at least one way will work ? |
112 | - if ($scheduleexist) { |
|
112 | + if ($scheduleexist) { |
|
113 | 113 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
114 | - $sch = $Schedule->getSchedule($operator); |
|
114 | + $sch = $Schedule->getSchedule($operator); |
|
115 | 115 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
116 | 116 | if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
117 | - } |
|
117 | + } |
|
118 | 118 | $Spotter->db = null; |
119 | 119 | $Schedule->db = null; |
120 | 120 | $Translation->db = null; |
@@ -129,78 +129,78 @@ discard block |
||
129 | 129 | } |
130 | 130 | */ |
131 | 131 | } |
132 | - } |
|
132 | + } |
|
133 | 133 | |
134 | - public function checkAll() { |
|
134 | + public function checkAll() { |
|
135 | 135 | global $globalDebug, $globalNoImport; |
136 | 136 | if ($globalDebug) echo "Update last seen flights data...\n"; |
137 | 137 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
138 | - foreach ($this->all_flights as $key => $flight) { |
|
138 | + foreach ($this->all_flights as $key => $flight) { |
|
139 | 139 | if (isset($this->all_flights[$key]['id'])) { |
140 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
141 | - $Spotter = new Spotter($this->db); |
|
142 | - $real_arrival = $this->arrival($key); |
|
143 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
144 | - } |
|
145 | - } |
|
140 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
141 | + $Spotter = new Spotter($this->db); |
|
142 | + $real_arrival = $this->arrival($key); |
|
143 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
144 | + } |
|
145 | + } |
|
146 | + } |
|
146 | 147 | } |
147 | - } |
|
148 | 148 | |
149 | - public function arrival($key) { |
|
149 | + public function arrival($key) { |
|
150 | 150 | global $globalClosestMinDist, $globalDebug; |
151 | 151 | if ($globalDebug) echo 'Update arrival...'."\n"; |
152 | 152 | $Spotter = new Spotter($this->db); |
153 | - $airport_icao = ''; |
|
154 | - $airport_time = ''; |
|
155 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
153 | + $airport_icao = ''; |
|
154 | + $airport_time = ''; |
|
155 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
156 | 156 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
157 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
158 | - if (isset($closestAirports[0])) { |
|
159 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
160 | - $airport_icao = $closestAirports[0]['icao']; |
|
161 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
162 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
163 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
164 | - foreach ($closestAirports as $airport) { |
|
165 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
166 | - $airport_icao = $airport['icao']; |
|
167 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
168 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
169 | - break; |
|
170 | - } |
|
171 | - } |
|
172 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
173 | - $airport_icao = $closestAirports[0]['icao']; |
|
174 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
175 | - } else { |
|
176 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
177 | - } |
|
178 | - } else { |
|
179 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
180 | - } |
|
157 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
158 | + if (isset($closestAirports[0])) { |
|
159 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
160 | + $airport_icao = $closestAirports[0]['icao']; |
|
161 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
162 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
163 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
164 | + foreach ($closestAirports as $airport) { |
|
165 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
166 | + $airport_icao = $airport['icao']; |
|
167 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
168 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
169 | + break; |
|
170 | + } |
|
171 | + } |
|
172 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
173 | + $airport_icao = $closestAirports[0]['icao']; |
|
174 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
175 | + } else { |
|
176 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
177 | + } |
|
178 | + } else { |
|
179 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
180 | + } |
|
181 | 181 | |
182 | - } else { |
|
183 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
184 | - } |
|
185 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
186 | - } |
|
182 | + } else { |
|
183 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
184 | + } |
|
185 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
186 | + } |
|
187 | 187 | |
188 | 188 | |
189 | 189 | |
190 | - public function del() { |
|
190 | + public function del() { |
|
191 | 191 | global $globalDebug, $globalNoImport, $globalNoDB; |
192 | 192 | // Delete old infos |
193 | 193 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
194 | 194 | foreach ($this->all_flights as $key => $flight) { |
195 | - if (isset($flight['lastupdate'])) { |
|
195 | + if (isset($flight['lastupdate'])) { |
|
196 | 196 | if ($flight['lastupdate'] < (time()-1800)) { |
197 | - $this->delKey($key); |
|
197 | + $this->delKey($key); |
|
198 | 198 | } |
199 | - } |
|
199 | + } |
|
200 | + } |
|
200 | 201 | } |
201 | - } |
|
202 | 202 | |
203 | - public function delKey($key) { |
|
203 | + public function delKey($key) { |
|
204 | 204 | global $globalDebug, $globalNoImport, $globalNoDB; |
205 | 205 | // Delete old infos |
206 | 206 | if (isset($this->all_flights[$key]['id'])) { |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | } |
216 | 216 | } |
217 | 217 | unset($this->all_flights[$key]); |
218 | - } |
|
218 | + } |
|
219 | 219 | |
220 | - public function add($line) { |
|
220 | + public function add($line) { |
|
221 | 221 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive; |
222 | 222 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
223 | 223 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
@@ -243,20 +243,20 @@ discard block |
||
243 | 243 | |
244 | 244 | // SBS format is CSV format |
245 | 245 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
246 | - //print_r($line); |
|
247 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
248 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
246 | + //print_r($line); |
|
247 | + if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
248 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
249 | 249 | |
250 | 250 | // Increment message number |
251 | 251 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
252 | - $current_date = date('Y-m-d'); |
|
253 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
254 | - else $source = ''; |
|
255 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
256 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
257 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
258 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
259 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
252 | + $current_date = date('Y-m-d'); |
|
253 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
254 | + else $source = ''; |
|
255 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
256 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
257 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
258 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
259 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /* |
@@ -272,54 +272,54 @@ discard block |
||
272 | 272 | //$this->db = $dbc; |
273 | 273 | |
274 | 274 | //$hex = trim($line['hex']); |
275 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
276 | - else $id = trim($line['id']); |
|
275 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
276 | + else $id = trim($line['id']); |
|
277 | 277 | |
278 | 278 | if (!isset($this->all_flights[$id])) { |
279 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
280 | - $this->all_flights[$id] = array(); |
|
281 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
282 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
283 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
284 | - if (!isset($line['id'])) { |
|
279 | + if ($globalDebug) echo 'New flight...'."\n"; |
|
280 | + $this->all_flights[$id] = array(); |
|
281 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
282 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
283 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
284 | + if (!isset($line['id'])) { |
|
285 | 285 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
286 | 286 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
287 | 287 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
288 | 288 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
289 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
290 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
291 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
289 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
290 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
291 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
292 | 292 | } |
293 | 293 | if (isset($line['source_type']) && $line['source_type'] != '') { |
294 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
294 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | //print_r($this->all_flights); |
298 | 298 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
299 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
300 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
299 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
300 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
301 | 301 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
302 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
303 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
302 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
303 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
304 | 304 | $timeelapsed = microtime(true); |
305 | 305 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
306 | - $Spotter = new Spotter($this->db); |
|
307 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
306 | + $Spotter = new Spotter($this->db); |
|
307 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
308 | 308 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
309 | - } else { |
|
309 | + } else { |
|
310 | 310 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
311 | - } |
|
312 | - $Spotter->db = null; |
|
313 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
314 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
311 | + } |
|
312 | + $Spotter->db = null; |
|
313 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
314 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
315 | 315 | } |
316 | - } |
|
317 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
318 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
316 | + } |
|
317 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
318 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
319 | 319 | } |
320 | - if (isset($line['id']) && !isset($line['hex'])) { |
|
321 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
322 | - } |
|
320 | + if (isset($line['id']) && !isset($line['hex'])) { |
|
321 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
322 | + } |
|
323 | 323 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
324 | 324 | $icao = $line['aircraft_icao']; |
325 | 325 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -349,9 +349,9 @@ discard block |
||
349 | 349 | } |
350 | 350 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
351 | 351 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
352 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
352 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
353 | 353 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
354 | - } else { |
|
354 | + } else { |
|
355 | 355 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
356 | 356 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
357 | 357 | /* |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | print_r($line); |
361 | 361 | */ |
362 | 362 | return ''; |
363 | - } |
|
363 | + } |
|
364 | 364 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
365 | 365 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
366 | 366 | return ''; |
@@ -376,21 +376,21 @@ discard block |
||
376 | 376 | } |
377 | 377 | |
378 | 378 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
379 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
379 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
380 | 380 | } |
381 | 381 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
382 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
382 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
383 | 383 | } |
384 | 384 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
385 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
385 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
386 | 386 | } |
387 | 387 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
388 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
388 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
392 | 392 | |
393 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
393 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
394 | 394 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
395 | 395 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
396 | 396 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -399,23 +399,23 @@ discard block |
||
399 | 399 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
400 | 400 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
401 | 401 | } else { |
402 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
403 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
402 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
403 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
404 | 404 | $timeelapsed = microtime(true); |
405 | - $Spotter = new Spotter($this->db); |
|
406 | - $fromsource = NULL; |
|
407 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
408 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
405 | + $Spotter = new Spotter($this->db); |
|
406 | + $fromsource = NULL; |
|
407 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
408 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
409 | 409 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
410 | 410 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
411 | 411 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
412 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
412 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
413 | 413 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
414 | 414 | $Spotter->db = null; |
415 | 415 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
416 | - } |
|
416 | + } |
|
417 | 417 | } |
418 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
418 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
419 | 419 | |
420 | 420 | /* |
421 | 421 | if (!isset($line['id'])) { |
@@ -425,63 +425,63 @@ discard block |
||
425 | 425 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
426 | 426 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
427 | 427 | */ |
428 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
428 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
429 | 429 | |
430 | - //$putinarchive = true; |
|
431 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
430 | + //$putinarchive = true; |
|
431 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
432 | 432 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
433 | - } |
|
434 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
433 | + } |
|
434 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
435 | 435 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
436 | - } |
|
437 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
438 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
439 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
436 | + } |
|
437 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
438 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
439 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
440 | 440 | $timeelapsed = microtime(true); |
441 | 441 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
442 | 442 | $Spotter = new Spotter($this->db); |
443 | 443 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
444 | 444 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
445 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
445 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
446 | 446 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
447 | - } |
|
448 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
447 | + } |
|
448 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
449 | 449 | $timeelapsed = microtime(true); |
450 | 450 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
451 | - $Spotter = new Spotter($this->db); |
|
452 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
453 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
451 | + $Spotter = new Spotter($this->db); |
|
452 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
453 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
454 | 454 | $Translation = new Translation($this->db); |
455 | 455 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
456 | 456 | $route = $Spotter->getRouteInfo($ident); |
457 | 457 | $Translation->db = null; |
458 | - } |
|
459 | - $Spotter->db = null; |
|
460 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
461 | - } |
|
458 | + } |
|
459 | + $Spotter->db = null; |
|
460 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
461 | + } |
|
462 | 462 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
463 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
464 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
463 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
464 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
465 | 465 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
466 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
467 | - } |
|
466 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
467 | + } |
|
468 | 468 | } |
469 | 469 | if (!isset($globalFork)) $globalFork = TRUE; |
470 | 470 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
471 | 471 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
472 | 472 | } |
473 | - } |
|
473 | + } |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
477 | 477 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
478 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
479 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
480 | - //$dataFound = true; |
|
478 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
479 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
480 | + //$dataFound = true; |
|
481 | 481 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
482 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
483 | - if ($distance > 1000 && $distance < 10000) { |
|
484 | - // use datetime |
|
482 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
483 | + if ($distance > 1000 && $distance < 10000) { |
|
484 | + // use datetime |
|
485 | 485 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
486 | 486 | $speed = $speed*3.6; |
487 | 487 | if ($speed < 1000) { |
@@ -490,49 +490,49 @@ discard block |
||
490 | 490 | } else { |
491 | 491 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
492 | 492 | } |
493 | - } |
|
493 | + } |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | |
497 | 497 | |
498 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
499 | - if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
500 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
501 | - return false; |
|
502 | - } |
|
503 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
504 | - else unset($timediff); |
|
505 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
506 | - else unset($timediff_archive); |
|
507 | - if ($this->tmd > 5 |
|
508 | - || (isset($line['format_source']) |
|
509 | - && $line['format_source'] == 'airwhere' |
|
510 | - && ((!isset($this->all_flights[$id]['latitude']) |
|
511 | - || !isset($this->all_flights[$id]['longitude'])) |
|
512 | - || (isset($this->all_flights[$id]['latitude']) |
|
513 | - && isset($this->all_flights[$id]['longitude']) |
|
514 | - && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
515 | - && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
516 | - ) |
|
517 | - ) |
|
518 | - ) |
|
519 | - || (isset($globalVA) && $globalVA) |
|
520 | - || (isset($globalIVAO) && $globalIVAO) |
|
521 | - || (isset($globalVATSIM) && $globalVATSIM) |
|
522 | - || (isset($globalphpVMS) && $globalphpVMS) |
|
523 | - || (isset($globalVAM) && $globalVAM) |
|
524 | - || !isset($timediff) |
|
525 | - || $timediff > $globalLiveInterval |
|
526 | - || $globalArchive |
|
527 | - || ($timediff > 30 |
|
528 | - && isset($this->all_flights[$id]['latitude']) |
|
529 | - && isset($this->all_flights[$id]['longitude']) |
|
530 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
531 | - ) |
|
532 | - ) { |
|
498 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
499 | + if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
500 | + if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
501 | + return false; |
|
502 | + } |
|
503 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
504 | + else unset($timediff); |
|
505 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
506 | + else unset($timediff_archive); |
|
507 | + if ($this->tmd > 5 |
|
508 | + || (isset($line['format_source']) |
|
509 | + && $line['format_source'] == 'airwhere' |
|
510 | + && ((!isset($this->all_flights[$id]['latitude']) |
|
511 | + || !isset($this->all_flights[$id]['longitude'])) |
|
512 | + || (isset($this->all_flights[$id]['latitude']) |
|
513 | + && isset($this->all_flights[$id]['longitude']) |
|
514 | + && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
515 | + && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
516 | + ) |
|
517 | + ) |
|
518 | + ) |
|
519 | + || (isset($globalVA) && $globalVA) |
|
520 | + || (isset($globalIVAO) && $globalIVAO) |
|
521 | + || (isset($globalVATSIM) && $globalVATSIM) |
|
522 | + || (isset($globalphpVMS) && $globalphpVMS) |
|
523 | + || (isset($globalVAM) && $globalVAM) |
|
524 | + || !isset($timediff) |
|
525 | + || $timediff > $globalLiveInterval |
|
526 | + || $globalArchive |
|
527 | + || ($timediff > 30 |
|
528 | + && isset($this->all_flights[$id]['latitude']) |
|
529 | + && isset($this->all_flights[$id]['longitude']) |
|
530 | + && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
531 | + ) |
|
532 | + ) { |
|
533 | 533 | |
534 | 534 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
535 | - if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
535 | + if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
536 | 536 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
537 | 537 | || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
538 | 538 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -540,9 +540,9 @@ discard block |
||
540 | 540 | $this->all_flights[$id]['putinarchive'] = true; |
541 | 541 | $this->tmd = 0; |
542 | 542 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
543 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
544 | - $timeelapsed = microtime(true); |
|
545 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
543 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
544 | + $timeelapsed = microtime(true); |
|
545 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
546 | 546 | $Spotter = new Spotter($this->db); |
547 | 547 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
548 | 548 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
@@ -550,11 +550,11 @@ discard block |
||
550 | 550 | $Spotter->db = null; |
551 | 551 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
552 | 552 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
553 | - } |
|
553 | + } |
|
554 | 554 | } |
555 | 555 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
556 | - } |
|
557 | - /* |
|
556 | + } |
|
557 | + /* |
|
558 | 558 | else { |
559 | 559 | if (!isset($timediff)) echo 'NO TIMEDIFF'; |
560 | 560 | else { |
@@ -568,16 +568,16 @@ discard block |
||
568 | 568 | } |
569 | 569 | |
570 | 570 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
571 | - //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
571 | + //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
572 | 572 | if (!isset($this->all_flights[$id]['archive_latitude'])) { |
573 | 573 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
574 | 574 | $this->all_flights[$id]['time_last_coord'] = time(); |
575 | 575 | } |
576 | 576 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
577 | 577 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
578 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
579 | - $dataFound = true; |
|
580 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
578 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
579 | + $dataFound = true; |
|
580 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
581 | 581 | } |
582 | 582 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
583 | 583 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -588,24 +588,24 @@ discard block |
||
588 | 588 | //$putinarchive = true; |
589 | 589 | } |
590 | 590 | */ |
591 | - /* |
|
591 | + /* |
|
592 | 592 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
593 | 593 | if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n"; |
594 | 594 | } |
595 | 595 | */ |
596 | 596 | } |
597 | 597 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
598 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
599 | - //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
598 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
599 | + //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
600 | 600 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
601 | 601 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
602 | 602 | $this->all_flights[$id]['time_last_coord'] = time(); |
603 | 603 | } |
604 | 604 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
605 | 605 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
606 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
607 | - $dataFound = true; |
|
608 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
606 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
607 | + $dataFound = true; |
|
608 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
609 | 609 | } |
610 | 610 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
611 | 611 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -623,67 +623,67 @@ discard block |
||
623 | 623 | */ |
624 | 624 | } |
625 | 625 | |
626 | - } else if ($globalDebug && $timediff > 30) { |
|
626 | + } else if ($globalDebug && $timediff > 30) { |
|
627 | 627 | $this->tmd = $this->tmd + 1; |
628 | 628 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
629 | 629 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
630 | 630 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
631 | 631 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
632 | - } |
|
632 | + } |
|
633 | 633 | } |
634 | 634 | if (isset($line['last_update']) && $line['last_update'] != '') { |
635 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
636 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
635 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
636 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
637 | 637 | } |
638 | 638 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
639 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
640 | - //$dataFound = true; |
|
639 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
640 | + //$dataFound = true; |
|
641 | 641 | } |
642 | 642 | if (isset($line['format_source']) && $line['format_source'] != '') { |
643 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
643 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
644 | 644 | } |
645 | 645 | if (isset($line['source_name']) && $line['source_name'] != '') { |
646 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
646 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
647 | 647 | } |
648 | 648 | if (isset($line['emergency']) && $line['emergency'] != '') { |
649 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
650 | - //$dataFound = true; |
|
649 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
650 | + //$dataFound = true; |
|
651 | 651 | } |
652 | 652 | if (isset($line['ground']) && $line['ground'] != '') { |
653 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
653 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
654 | 654 | // Here we force archive of flight because after ground it's a new one (or should be) |
655 | 655 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
656 | 656 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
657 | 657 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
658 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
658 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
659 | 659 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
660 | - } |
|
661 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
662 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
663 | - //$dataFound = true; |
|
660 | + } |
|
661 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
662 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
663 | + //$dataFound = true; |
|
664 | 664 | } |
665 | 665 | if (isset($line['squawk']) && $line['squawk'] != '') { |
666 | - if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
667 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
668 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
669 | - $highlight = ''; |
|
670 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
671 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
672 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
673 | - if ($highlight != '') { |
|
666 | + if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
667 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
668 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
669 | + $highlight = ''; |
|
670 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
671 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
672 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
673 | + if ($highlight != '') { |
|
674 | 674 | $timeelapsed = microtime(true); |
675 | 675 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
676 | - $Spotter = new Spotter($this->db); |
|
677 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
678 | - $Spotter->db = null; |
|
679 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
676 | + $Spotter = new Spotter($this->db); |
|
677 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
678 | + $Spotter->db = null; |
|
679 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
680 | 680 | } |
681 | 681 | //$putinarchive = true; |
682 | 682 | //$highlight = ''; |
683 | - } |
|
683 | + } |
|
684 | 684 | |
685 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
686 | - //$dataFound = true; |
|
685 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
686 | + //$dataFound = true; |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | if (isset($line['altitude']) && $line['altitude'] != '') { |
@@ -694,13 +694,13 @@ discard block |
||
694 | 694 | $line['altitude'] = $line['altitude'] - $geoid; |
695 | 695 | } |
696 | 696 | } |
697 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
697 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
698 | 698 | if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
699 | 699 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
700 | 700 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
701 | 701 | //$dataFound = true; |
702 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
703 | - if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
702 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
703 | + if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
704 | 704 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
705 | 705 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
706 | 706 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -709,27 +709,27 @@ discard block |
||
709 | 709 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
710 | 710 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
711 | 711 | } |
712 | - } |
|
713 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
712 | + } |
|
713 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
717 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
717 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | if (isset($line['heading']) && $line['heading'] != '') { |
721 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
722 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
723 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
724 | - //$dataFound = true; |
|
721 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
722 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
723 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
724 | + //$dataFound = true; |
|
725 | 725 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
726 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
727 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
728 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
729 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
726 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
727 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
728 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
729 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
730 | 730 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
731 | - // If not enough messages and ACARS set heading to 0 |
|
732 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
731 | + // If not enough messages and ACARS set heading to 0 |
|
732 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
733 | 733 | } |
734 | 734 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
735 | 735 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -742,125 +742,125 @@ discard block |
||
742 | 742 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
743 | 743 | //if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
744 | 744 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
745 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
746 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
747 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
748 | - //print_r($this->all_flights); |
|
749 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
750 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
751 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
745 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
746 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
747 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
748 | + //print_r($this->all_flights); |
|
749 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
750 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
751 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
752 | 752 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
753 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
754 | - $timeelapsed = microtime(true); |
|
755 | - $SpotterLive = new SpotterLive($this->db); |
|
756 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
753 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
754 | + $timeelapsed = microtime(true); |
|
755 | + $SpotterLive = new SpotterLive($this->db); |
|
756 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
757 | 757 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
758 | 758 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
759 | - } elseif (isset($line['id'])) { |
|
759 | + } elseif (isset($line['id'])) { |
|
760 | 760 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
761 | 761 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
762 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
762 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
763 | 763 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
764 | 764 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
765 | - } else $recent_ident = ''; |
|
766 | - $SpotterLive->db=null; |
|
767 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
768 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
765 | + } else $recent_ident = ''; |
|
766 | + $SpotterLive->db=null; |
|
767 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
768 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
769 | 769 | } else $recent_ident = ''; |
770 | - } else { |
|
770 | + } else { |
|
771 | 771 | $recent_ident = ''; |
772 | 772 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
773 | - } |
|
774 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
775 | - if($recent_ident == "") |
|
776 | - { |
|
773 | + } |
|
774 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
775 | + if($recent_ident == "") |
|
776 | + { |
|
777 | 777 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
778 | 778 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
779 | 779 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
780 | 780 | //adds the spotter data for the archive |
781 | 781 | $ignoreImport = false; |
782 | 782 | foreach($globalAirportIgnore as $airportIgnore) { |
783 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
783 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
784 | 784 | $ignoreImport = true; |
785 | - } |
|
785 | + } |
|
786 | 786 | } |
787 | 787 | if (count($globalAirportAccept) > 0) { |
788 | - $ignoreImport = true; |
|
789 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
788 | + $ignoreImport = true; |
|
789 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
790 | 790 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
791 | - $ignoreImport = false; |
|
791 | + $ignoreImport = false; |
|
792 | + } |
|
792 | 793 | } |
793 | - } |
|
794 | 794 | } |
795 | 795 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
796 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
796 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
797 | 797 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
798 | - $ignoreImport = true; |
|
798 | + $ignoreImport = true; |
|
799 | + } |
|
799 | 800 | } |
800 | - } |
|
801 | 801 | } |
802 | 802 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
803 | - $ignoreImport = true; |
|
804 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
803 | + $ignoreImport = true; |
|
804 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
805 | 805 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
806 | - $ignoreImport = false; |
|
806 | + $ignoreImport = false; |
|
807 | + } |
|
807 | 808 | } |
808 | - } |
|
809 | 809 | } |
810 | 810 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
811 | - $ignoreImport = true; |
|
812 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
811 | + $ignoreImport = true; |
|
812 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
813 | 813 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
814 | - $ignoreImport = false; |
|
814 | + $ignoreImport = false; |
|
815 | + } |
|
815 | 816 | } |
816 | - } |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | if (!$ignoreImport) { |
820 | - $highlight = ''; |
|
821 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
822 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
823 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
824 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
825 | - $timeelapsed = microtime(true); |
|
826 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
820 | + $highlight = ''; |
|
821 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
822 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
823 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
824 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
825 | + $timeelapsed = microtime(true); |
|
826 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
827 | 827 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
828 | - $Spotter = new Spotter($this->db); |
|
829 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
830 | - $Spotter->db = null; |
|
831 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
828 | + $Spotter = new Spotter($this->db); |
|
829 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
830 | + $Spotter->db = null; |
|
831 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
832 | 832 | } |
833 | - } |
|
834 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
835 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
833 | + } |
|
834 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
835 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
836 | 836 | |
837 | - // Add source stat in DB |
|
838 | - $Stats = new Stats($this->db); |
|
839 | - if (!empty($this->stats)) { |
|
837 | + // Add source stat in DB |
|
838 | + $Stats = new Stats($this->db); |
|
839 | + if (!empty($this->stats)) { |
|
840 | 840 | if ($globalDebug) echo 'Add source stats : '; |
841 | - foreach($this->stats as $date => $data) { |
|
842 | - foreach($data as $source => $sourced) { |
|
843 | - //print_r($sourced); |
|
844 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
845 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
846 | - if (isset($sourced['msg'])) { |
|
847 | - if (time() - $sourced['msg']['date'] > 10) { |
|
848 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
849 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
850 | - unset($this->stats[$date][$source]['msg']); |
|
851 | - } |
|
852 | - } |
|
853 | - } |
|
854 | - if ($date != date('Y-m-d')) { |
|
855 | - unset($this->stats[$date]); |
|
856 | - } |
|
857 | - } |
|
858 | - if ($globalDebug) echo 'Done'."\n"; |
|
841 | + foreach($this->stats as $date => $data) { |
|
842 | + foreach($data as $source => $sourced) { |
|
843 | + //print_r($sourced); |
|
844 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
845 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
846 | + if (isset($sourced['msg'])) { |
|
847 | + if (time() - $sourced['msg']['date'] > 10) { |
|
848 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
849 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
850 | + unset($this->stats[$date][$source]['msg']); |
|
851 | + } |
|
852 | + } |
|
853 | + } |
|
854 | + if ($date != date('Y-m-d')) { |
|
855 | + unset($this->stats[$date]); |
|
856 | + } |
|
857 | + } |
|
858 | + if ($globalDebug) echo 'Done'."\n"; |
|
859 | 859 | |
860 | - } |
|
861 | - $Stats->db = null; |
|
862 | - } |
|
863 | - $this->del(); |
|
860 | + } |
|
861 | + $Stats->db = null; |
|
862 | + } |
|
863 | + $this->del(); |
|
864 | 864 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
865 | 865 | //$ignoreImport = false; |
866 | 866 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -878,41 +878,41 @@ discard block |
||
878 | 878 | */ |
879 | 879 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
880 | 880 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
881 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
882 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
883 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
881 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
882 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
883 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
884 | 884 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
885 | - $SpotterLive = new SpotterLive($this->db); |
|
886 | - $SpotterLive->deleteLiveSpotterData(); |
|
887 | - $SpotterLive->db=null; |
|
885 | + $SpotterLive = new SpotterLive($this->db); |
|
886 | + $SpotterLive->deleteLiveSpotterData(); |
|
887 | + $SpotterLive->db=null; |
|
888 | 888 | } |
889 | - } |
|
890 | - if ($globalDebug) echo " Done\n"; |
|
891 | - $this->last_delete = time(); |
|
889 | + } |
|
890 | + if ($globalDebug) echo " Done\n"; |
|
891 | + $this->last_delete = time(); |
|
892 | 892 | } |
893 | - } else { |
|
893 | + } else { |
|
894 | 894 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
895 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
896 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
895 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
896 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
897 | 897 | } |
898 | 898 | if (isset($globalDaemon) && !$globalDaemon) { |
899 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
899 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
900 | 900 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
901 | - $Spotter = new Spotter($this->db); |
|
902 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
903 | - $Spotter->db = null; |
|
901 | + $Spotter = new Spotter($this->db); |
|
902 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
903 | + $Spotter->db = null; |
|
904 | + } |
|
904 | 905 | } |
905 | - } |
|
906 | 906 | } |
907 | 907 | |
908 | - } |
|
908 | + } |
|
909 | 909 | } |
910 | - } |
|
911 | - //adds the spotter LIVE data |
|
912 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
913 | - //echo "\nAdd in Live !! \n"; |
|
914 | - //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
915 | - if ($globalDebug) { |
|
910 | + } |
|
911 | + //adds the spotter LIVE data |
|
912 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
913 | + //echo "\nAdd in Live !! \n"; |
|
914 | + //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
915 | + if ($globalDebug) { |
|
916 | 916 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
917 | 917 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
918 | 918 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
@@ -920,60 +920,60 @@ discard block |
||
920 | 920 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
921 | 921 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
922 | 922 | } |
923 | - } |
|
924 | - $ignoreImport = false; |
|
925 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
926 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
923 | + } |
|
924 | + $ignoreImport = false; |
|
925 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
926 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
927 | 927 | |
928 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
929 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
930 | - $ignoreImport = true; |
|
928 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
929 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
930 | + $ignoreImport = true; |
|
931 | + } |
|
931 | 932 | } |
932 | - } |
|
933 | - if (count($globalAirportAccept) > 0) { |
|
934 | - $ignoreImport = true; |
|
935 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
936 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
933 | + if (count($globalAirportAccept) > 0) { |
|
934 | + $ignoreImport = true; |
|
935 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
936 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
937 | 937 | $ignoreImport = false; |
938 | - } |
|
938 | + } |
|
939 | 939 | } |
940 | - } |
|
941 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
940 | + } |
|
941 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
942 | 942 | foreach($globalAirlineIgnore as $airlineIgnore) { |
943 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
943 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
944 | 944 | $ignoreImport = true; |
945 | - } |
|
945 | + } |
|
946 | 946 | } |
947 | - } |
|
948 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
947 | + } |
|
948 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
949 | 949 | $ignoreImport = true; |
950 | 950 | foreach($globalAirlineAccept as $airlineAccept) { |
951 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
951 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
952 | 952 | $ignoreImport = false; |
953 | - } |
|
953 | + } |
|
954 | + } |
|
954 | 955 | } |
955 | - } |
|
956 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
956 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
957 | 957 | $ignoreImport = true; |
958 | 958 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
959 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
960 | - $ignoreImport = false; |
|
961 | - } |
|
959 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
960 | + $ignoreImport = false; |
|
961 | + } |
|
962 | + } |
|
962 | 963 | } |
963 | - } |
|
964 | 964 | |
965 | - if (!$ignoreImport) { |
|
965 | + if (!$ignoreImport) { |
|
966 | 966 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
967 | 967 | if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
968 | 968 | $timeelapsed = microtime(true); |
969 | 969 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
970 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
970 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
971 | 971 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
972 | 972 | $SpotterLive = new SpotterLive($this->db); |
973 | 973 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
974 | 974 | $SpotterLive->db = null; |
975 | 975 | if ($globalDebug) echo $result."\n"; |
976 | - } |
|
976 | + } |
|
977 | 977 | } |
978 | 978 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
979 | 979 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | //if ($line['format_source'] != 'aprs') { |
986 | 986 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
987 | 987 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
988 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
988 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
989 | 989 | $source = $this->all_flights[$id]['source_name']; |
990 | 990 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
991 | 991 | if (!isset($this->source_location[$source])) { |
@@ -1011,7 +1011,7 @@ discard block |
||
1011 | 1011 | if ($stats_heading == 16) $stats_heading = 0; |
1012 | 1012 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1013 | 1013 | for ($i=0;$i<=15;$i++) { |
1014 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1014 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1015 | 1015 | } |
1016 | 1016 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
1017 | 1017 | } else { |
@@ -1024,17 +1024,17 @@ discard block |
||
1024 | 1024 | //var_dump($this->stats); |
1025 | 1025 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1026 | 1026 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1027 | - end($this->stats[$current_date][$source]['hist']); |
|
1028 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1027 | + end($this->stats[$current_date][$source]['hist']); |
|
1028 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1029 | 1029 | } else $mini = 0; |
1030 | 1030 | for ($i=$mini;$i<=$distance;$i+=10) { |
1031 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1031 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1032 | 1032 | } |
1033 | 1033 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
1034 | 1034 | } else { |
1035 | 1035 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
1036 | 1036 | } |
1037 | - } |
|
1037 | + } |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | //$this->del(); |
1045 | 1045 | |
1046 | 1046 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1047 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1047 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1048 | 1048 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
1049 | 1049 | $SpotterLive = new SpotterLive($this->db); |
1050 | 1050 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -1052,19 +1052,19 @@ discard block |
||
1052 | 1052 | //SpotterLive->deleteLiveSpotterData(); |
1053 | 1053 | if ($globalDebug) echo " Done\n"; |
1054 | 1054 | $this->last_delete_hourly = time(); |
1055 | - } else { |
|
1055 | + } else { |
|
1056 | 1056 | $this->del(); |
1057 | 1057 | $this->last_delete_hourly = time(); |
1058 | - } |
|
1058 | + } |
|
1059 | 1059 | } |
1060 | 1060 | |
1061 | - } |
|
1062 | - //$ignoreImport = false; |
|
1061 | + } |
|
1062 | + //$ignoreImport = false; |
|
1063 | 1063 | } |
1064 | 1064 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1065 | 1065 | if ($send) return $this->all_flights[$id]; |
1066 | - } |
|
1066 | + } |
|
1067 | + } |
|
1067 | 1068 | } |
1068 | - } |
|
1069 | 1069 | } |
1070 | 1070 | ?> |
@@ -14,23 +14,23 @@ discard block |
||
14 | 14 | $usecoord = false; |
15 | 15 | if (isset($_GET['test'])) exit(); |
16 | 16 | if (isset($_GET['tracker'])) { |
17 | - $tracker = true; |
|
17 | + $tracker = true; |
|
18 | 18 | } |
19 | 19 | if (isset($_GET['marine'])) { |
20 | - $marine = true; |
|
20 | + $marine = true; |
|
21 | 21 | } |
22 | 22 | if ($tracker) { |
23 | - require_once('require/class.Tracker.php'); |
|
24 | - require_once('require/class.TrackerLive.php'); |
|
25 | - require_once('require/class.TrackerArchive.php'); |
|
23 | + require_once('require/class.Tracker.php'); |
|
24 | + require_once('require/class.TrackerLive.php'); |
|
25 | + require_once('require/class.TrackerArchive.php'); |
|
26 | 26 | } elseif ($marine) { |
27 | - require_once('require/class.Marine.php'); |
|
28 | - require_once('require/class.MarineLive.php'); |
|
29 | - require_once('require/class.MarineArchive.php'); |
|
27 | + require_once('require/class.Marine.php'); |
|
28 | + require_once('require/class.MarineLive.php'); |
|
29 | + require_once('require/class.MarineArchive.php'); |
|
30 | 30 | } else { |
31 | - require_once('require/class.Spotter.php'); |
|
32 | - require_once('require/class.SpotterLive.php'); |
|
33 | - require_once('require/class.SpotterArchive.php'); |
|
31 | + require_once('require/class.Spotter.php'); |
|
32 | + require_once('require/class.SpotterLive.php'); |
|
33 | + require_once('require/class.SpotterArchive.php'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | $begintime = microtime(true); |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | $Common = new Common(); |
51 | 51 | |
52 | 52 | if (isset($_GET['download'])) { |
53 | - if ($_GET['download'] == "true") |
|
54 | - { |
|
53 | + if ($_GET['download'] == "true") |
|
54 | + { |
|
55 | 55 | header('Content-disposition: attachment; filename="flightairmap.json"'); |
56 | - } |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | header('Content-Type: text/javascript'); |
59 | 59 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $usecoord = true; |
132 | 132 | $coord = explode(',',$_GET['coord']); |
133 | 133 | if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
134 | - && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) { |
|
134 | + && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) { |
|
135 | 135 | if ($tracker) { |
136 | 136 | $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter); |
137 | 137 | } elseif ($marine) { |
@@ -635,17 +635,17 @@ discard block |
||
635 | 635 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
636 | 636 | |
637 | 637 | if ( |
638 | - (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
639 | - || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
638 | + (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
639 | + || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
640 | 640 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
641 | 641 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
642 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
643 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
644 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
645 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
646 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
647 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
648 | - ) { |
|
642 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
643 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
644 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
645 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
646 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
647 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
648 | + ) { |
|
649 | 649 | if ($tracker) { |
650 | 650 | if ($from_archive || $globalArchive) { |
651 | 651 | $spotter_history_array = $TrackerArchive->getAllArchiveTrackerDataById($spotter_item['famtrackid']); |
@@ -653,9 +653,9 @@ discard block |
||
653 | 653 | $spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']); |
654 | 654 | } |
655 | 655 | if (((isset($_COOKIE['mapmatching']) && $_COOKIE['mapmatching'] == 'true') || |
656 | - (!isset($_COOKIE['mapmatching']) && $globalMapMatching === TRUE)) && |
|
657 | - isset($_GET['zoom']) && $_GET['zoom'] > 12 && |
|
658 | - isset($spotter_item['type']) && ( |
|
656 | + (!isset($_COOKIE['mapmatching']) && $globalMapMatching === TRUE)) && |
|
657 | + isset($_GET['zoom']) && $_GET['zoom'] > 12 && |
|
658 | + isset($spotter_item['type']) && ( |
|
659 | 659 | $spotter_item['type'] == 'Firetruck' || |
660 | 660 | $spotter_item['type'] == 'Ambulance' || |
661 | 661 | $spotter_item['type'] == 'Truck (18 Wheeler)' || |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | $spotter_item['type'] == 'Jeep' || |
668 | 668 | $spotter_item['type'] == 'Motorcycle' || |
669 | 669 | $spotter_item['type'] == 'Car' |
670 | - ) |
|
670 | + ) |
|
671 | 671 | ) { |
672 | 672 | require(dirname(__FILE__).'/require/class.MapMatching.php'); |
673 | 673 | $MapMatching = new MapMatching(); |
@@ -770,75 +770,75 @@ discard block |
||
770 | 770 | } |
771 | 771 | |
772 | 772 | if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
773 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
774 | - && (isset($spotter_item['departure_airport']) |
|
775 | - && $spotter_item['departure_airport'] != 'NA' |
|
776 | - && isset($spotter_item['arrival_airport']) |
|
777 | - && $spotter_item['arrival_airport'] != 'NA' |
|
778 | - && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
|
779 | - || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
|
780 | - if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
781 | - else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
782 | - if (isset($spotter_item['departure_airport_latitude'])) { |
|
773 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
774 | + && (isset($spotter_item['departure_airport']) |
|
775 | + && $spotter_item['departure_airport'] != 'NA' |
|
776 | + && isset($spotter_item['arrival_airport']) |
|
777 | + && $spotter_item['arrival_airport'] != 'NA' |
|
778 | + && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
|
779 | + || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
|
780 | + if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
781 | + else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
782 | + if (isset($spotter_item['departure_airport_latitude'])) { |
|
783 | 783 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
784 | - } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
784 | + } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
785 | 785 | $dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']); |
786 | 786 | if (isset($dairport[0]['latitude'])) { |
787 | - $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
787 | + $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
788 | 788 | } |
789 | - } |
|
790 | - if (isset($spotter_item['arrival_airport_latitude'])) { |
|
789 | + } |
|
790 | + if (isset($spotter_item['arrival_airport_latitude'])) { |
|
791 | 791 | $output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].'],'; |
792 | - } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
792 | + } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
793 | 793 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
794 | 794 | if (isset($aairport[0]['latitude'])) { |
795 | - $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],'; |
|
795 | + $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],'; |
|
796 | 796 | } |
797 | - } |
|
798 | - $output_air = substr($output_air, 0, -1); |
|
799 | - $output_air .= ']}},'; |
|
800 | - $output .= $output_air; |
|
801 | - unset($output_air); |
|
797 | + } |
|
798 | + $output_air = substr($output_air, 0, -1); |
|
799 | + $output_air .= ']}},'; |
|
800 | + $output .= $output_air; |
|
801 | + unset($output_air); |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
805 | 805 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
806 | 806 | if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
807 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
808 | - && (isset($spotter_item['arrival_airport']) |
|
809 | - && $spotter_item['arrival_airport'] != 'NA' |
|
810 | - && ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") |
|
811 | - || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) |
|
812 | - || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
|
813 | - $havedata = false; |
|
814 | - if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
815 | - else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
807 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
808 | + && (isset($spotter_item['arrival_airport']) |
|
809 | + && $spotter_item['arrival_airport'] != 'NA' |
|
810 | + && ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") |
|
811 | + || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) |
|
812 | + || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
|
813 | + $havedata = false; |
|
814 | + if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
815 | + else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
816 | 816 | |
817 | - //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
|
818 | - if (isset($spotter_item['arrival_airport_latitude'])) { |
|
817 | + //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
|
818 | + if (isset($spotter_item['arrival_airport_latitude'])) { |
|
819 | 819 | //$output_dest .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']'; |
820 | 820 | $end_lon = $spotter_item['arrival_airport_longitude']; |
821 | 821 | $end_lat = $spotter_item['arrival_airport_latitude']; |
822 | 822 | $havedata = true; |
823 | - } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
823 | + } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
824 | 824 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
825 | 825 | if (isset($aairport[0]['latitude'])) { |
826 | - //$output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
827 | - $end_lon = $aairport[0]['longitude']; |
|
828 | - $end_lat = $aairport[0]['latitude']; |
|
829 | - $havedata = true; |
|
826 | + //$output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
827 | + $end_lon = $aairport[0]['longitude']; |
|
828 | + $end_lat = $aairport[0]['latitude']; |
|
829 | + $havedata = true; |
|
830 | 830 | } |
831 | - } |
|
832 | - if ($havedata) { |
|
831 | + } |
|
832 | + if ($havedata) { |
|
833 | 833 | $line = $Common->greatCircle($spotter_item['latitude'],$spotter_item['longitude'],$end_lat,$end_lon); |
834 | 834 | foreach ($line[0] as $coord) { |
835 | 835 | $output_dest .= '['.$coord[0].','.$coord[1].'],'; |
836 | 836 | } |
837 | 837 | $output_dest = substr($output_dest, 0, -1); |
838 | - } |
|
839 | - $output_dest .= ']}},'; |
|
840 | - if ($havedata) $output .= $output_dest; |
|
841 | - unset($output_dest); |
|
838 | + } |
|
839 | + $output_dest .= ']}},'; |
|
840 | + if ($havedata) $output .= $output_dest; |
|
841 | + unset($output_dest); |
|
842 | 842 | } |
843 | 843 | } |
844 | 844 | $output = substr($output, 0, -1); |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | //protected $cookies = array(); |
8 | 8 | |
9 | 9 | /** |
10 | - * Get data from form result |
|
11 | - * @param String $url form URL |
|
12 | - * @param String $type type of submit form method (get or post) |
|
13 | - * @param String|Array $data values form post method |
|
14 | - * @param Array $headers header to submit with the form |
|
15 | - * @return String the result |
|
16 | - */ |
|
10 | + * Get data from form result |
|
11 | + * @param String $url form URL |
|
12 | + * @param String $type type of submit form method (get or post) |
|
13 | + * @param String|Array $data values form post method |
|
14 | + * @param Array $headers header to submit with the form |
|
15 | + * @return String the result |
|
16 | + */ |
|
17 | 17 | public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false, $async = false) { |
18 | 18 | global $globalProxy, $globalForceIPv4; |
19 | 19 | $ch = curl_init(); |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | - * Convert a HTML table to an array |
|
170 | - * @param String $data HTML page |
|
171 | - * @return Array array of the tables in HTML page |
|
172 | - */ |
|
169 | + * Convert a HTML table to an array |
|
170 | + * @param String $data HTML page |
|
171 | + * @return Array array of the tables in HTML page |
|
172 | + */ |
|
173 | 173 | public function table2array($data) { |
174 | 174 | if (!is_string($data)) return array(); |
175 | 175 | if ($data == '') return array(); |
@@ -203,10 +203,10 @@ discard block |
||
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
206 | - * Convert <p> part of a HTML page to an array |
|
207 | - * @param String $data HTML page |
|
208 | - * @return Array array of the <p> in HTML page |
|
209 | - */ |
|
206 | + * Convert <p> part of a HTML page to an array |
|
207 | + * @param String $data HTML page |
|
208 | + * @return Array array of the <p> in HTML page |
|
209 | + */ |
|
210 | 210 | public function text2array($data) { |
211 | 211 | $html = str_get_html($data); |
212 | 212 | if ($html === false) return array(); |
@@ -221,14 +221,14 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
224 | - * Give distance between 2 coordonnates |
|
225 | - * @param Float $lat latitude of first point |
|
226 | - * @param Float $lon longitude of first point |
|
227 | - * @param Float $latc latitude of second point |
|
228 | - * @param Float $lonc longitude of second point |
|
229 | - * @param String $unit km else no unit used |
|
230 | - * @return Float Distance in $unit |
|
231 | - */ |
|
224 | + * Give distance between 2 coordonnates |
|
225 | + * @param Float $lat latitude of first point |
|
226 | + * @param Float $lon longitude of first point |
|
227 | + * @param Float $latc latitude of second point |
|
228 | + * @param Float $lonc longitude of second point |
|
229 | + * @param String $unit km else no unit used |
|
230 | + * @return Float Distance in $unit |
|
231 | + */ |
|
232 | 232 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
233 | 233 | if ($lat == $latc && $lon == $lonc) return 0; |
234 | 234 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
@@ -246,25 +246,25 @@ discard block |
||
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
249 | - * Give plunge between 2 altitudes and distance |
|
250 | - * @param Float $initial_altitude altitude of first point in m |
|
251 | - * @param Float $final_altitude altitude of second point in m |
|
252 | - * @param String $distance distance between two points in m |
|
253 | - * @return Float plunge |
|
254 | - */ |
|
249 | + * Give plunge between 2 altitudes and distance |
|
250 | + * @param Float $initial_altitude altitude of first point in m |
|
251 | + * @param Float $final_altitude altitude of second point in m |
|
252 | + * @param String $distance distance between two points in m |
|
253 | + * @return Float plunge |
|
254 | + */ |
|
255 | 255 | public function plunge($initial_altitude,$final_altitude,$distance) { |
256 | 256 | $plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance)); |
257 | 257 | return $plunge; |
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
261 | - * Give azimuth between 2 coordonnates |
|
262 | - * @param Float $lat latitude of first point |
|
263 | - * @param Float $lon longitude of first point |
|
264 | - * @param Float $latc latitude of second point |
|
265 | - * @param Float $lonc longitude of second point |
|
266 | - * @return Float Azimuth |
|
267 | - */ |
|
261 | + * Give azimuth between 2 coordonnates |
|
262 | + * @param Float $lat latitude of first point |
|
263 | + * @param Float $lon longitude of first point |
|
264 | + * @param Float $latc latitude of second point |
|
265 | + * @param Float $lonc longitude of second point |
|
266 | + * @return Float Azimuth |
|
267 | + */ |
|
268 | 268 | public function azimuth($lat, $lon, $latc, $lonc) { |
269 | 269 | $dX = $latc - $lat; |
270 | 270 | $dY = $lonc - $lon; |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | |
276 | 276 | |
277 | 277 | /** |
278 | - * Check is distance realistic |
|
279 | - * @param int $timeDifference the time between the reception of both messages |
|
280 | - * @param float $distance distance covered |
|
281 | - * @return whether distance is realistic |
|
282 | - */ |
|
278 | + * Check is distance realistic |
|
279 | + * @param int $timeDifference the time between the reception of both messages |
|
280 | + * @param float $distance distance covered |
|
281 | + * @return whether distance is realistic |
|
282 | + */ |
|
283 | 283 | public function withinThreshold ($timeDifference, $distance) { |
284 | 284 | $x = abs($timeDifference); |
285 | 285 | $d = abs($distance); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | } |
298 | 298 | |
299 | 299 | public function isInteger($input){ |
300 | - return(ctype_digit(strval($input))); |
|
300 | + return(ctype_digit(strval($input))); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
331 | - * Copy folder contents |
|
332 | - * @param string $source Source path |
|
333 | - * @param string $dest Destination path |
|
334 | - * @return bool Returns true on success, false on failure |
|
335 | - */ |
|
331 | + * Copy folder contents |
|
332 | + * @param string $source Source path |
|
333 | + * @param string $dest Destination path |
|
334 | + * @return bool Returns true on success, false on failure |
|
335 | + */ |
|
336 | 336 | public function xcopy($source, $dest) |
337 | 337 | { |
338 | 338 | $files = glob($source.'*.*'); |
@@ -344,20 +344,20 @@ discard block |
||
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
347 | - * Check if an url exist |
|
348 | - * @param String $url url to check |
|
349 | - * @return bool Return true on succes false on failure |
|
350 | - */ |
|
347 | + * Check if an url exist |
|
348 | + * @param String $url url to check |
|
349 | + * @return bool Return true on succes false on failure |
|
350 | + */ |
|
351 | 351 | public function urlexist($url){ |
352 | 352 | $headers=get_headers($url); |
353 | 353 | return stripos($headers[0],"200 OK")?true:false; |
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
357 | - * Convert hexa to string |
|
358 | - * @param String $hex data in hexa |
|
359 | - * @return String Return result |
|
360 | - */ |
|
357 | + * Convert hexa to string |
|
358 | + * @param String $hex data in hexa |
|
359 | + * @return String Return result |
|
360 | + */ |
|
361 | 361 | public function hex2str($hex) { |
362 | 362 | $str = ''; |
363 | 363 | $hexln = strlen($hex); |
@@ -366,10 +366,10 @@ discard block |
||
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
369 | - * Convert hexa color to rgb |
|
370 | - * @param String $hex data in hexa |
|
371 | - * @return String Return result |
|
372 | - */ |
|
369 | + * Convert hexa color to rgb |
|
370 | + * @param String $hex data in hexa |
|
371 | + * @return String Return result |
|
372 | + */ |
|
373 | 373 | public function hex2rgb($hex) { |
374 | 374 | $hex = str_replace('#','',$hex); |
375 | 375 | return sscanf($hex, "%02x%02x%02x"); |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
450 | - * Returns list of available locales |
|
451 | - * |
|
452 | - * @return array |
|
450 | + * Returns list of available locales |
|
451 | + * |
|
452 | + * @return array |
|
453 | 453 | */ |
454 | 454 | public function listLocaleDir() |
455 | 455 | { |
@@ -548,100 +548,100 @@ discard block |
||
548 | 548 | public function remove_accents($string) { |
549 | 549 | if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
550 | 550 | $chars = array( |
551 | - // Decompositions for Latin-1 Supplement |
|
552 | - chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
|
553 | - chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', |
|
554 | - chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', |
|
555 | - chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', |
|
556 | - chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', |
|
557 | - chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', |
|
558 | - chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', |
|
559 | - chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', |
|
560 | - chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', |
|
561 | - chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', |
|
562 | - chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', |
|
563 | - chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', |
|
564 | - chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', |
|
565 | - chr(195).chr(159) => 's', chr(195).chr(160) => 'a', |
|
566 | - chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', |
|
567 | - chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', |
|
568 | - chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', |
|
569 | - chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', |
|
570 | - chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', |
|
571 | - chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', |
|
572 | - chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', |
|
573 | - chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', |
|
574 | - chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', |
|
575 | - chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', |
|
576 | - chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', |
|
577 | - chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', |
|
578 | - chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', |
|
579 | - chr(195).chr(191) => 'y', |
|
580 | - // Decompositions for Latin Extended-A |
|
581 | - chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', |
|
582 | - chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', |
|
583 | - chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', |
|
584 | - chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', |
|
585 | - chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', |
|
586 | - chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', |
|
587 | - chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', |
|
588 | - chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', |
|
589 | - chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', |
|
590 | - chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', |
|
591 | - chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', |
|
592 | - chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', |
|
593 | - chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', |
|
594 | - chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', |
|
595 | - chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', |
|
596 | - chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', |
|
597 | - chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', |
|
598 | - chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', |
|
599 | - chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', |
|
600 | - chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', |
|
601 | - chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', |
|
602 | - chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', |
|
603 | - chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
|
604 | - chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
|
605 | - chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
|
606 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
607 | - chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
|
608 | - chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
|
609 | - chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
|
610 | - chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', |
|
611 | - chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', |
|
612 | - chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', |
|
613 | - chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', |
|
614 | - chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', |
|
615 | - chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', |
|
616 | - chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', |
|
617 | - chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', |
|
618 | - chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', |
|
619 | - chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
|
620 | - chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
|
621 | - chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
|
622 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
623 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
624 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
625 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
626 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
627 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
628 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
629 | - chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
|
630 | - chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
|
631 | - chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
|
632 | - chr(197).chr(166) => 'T', chr(197).chr(167) => 't', |
|
633 | - chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', |
|
634 | - chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', |
|
635 | - chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', |
|
636 | - chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', |
|
637 | - chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', |
|
638 | - chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', |
|
639 | - chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', |
|
640 | - chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', |
|
641 | - chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', |
|
642 | - chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', |
|
643 | - chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', |
|
644 | - chr(197).chr(190) => 'z', chr(197).chr(191) => 's' |
|
551 | + // Decompositions for Latin-1 Supplement |
|
552 | + chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
|
553 | + chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', |
|
554 | + chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', |
|
555 | + chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', |
|
556 | + chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', |
|
557 | + chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', |
|
558 | + chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', |
|
559 | + chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', |
|
560 | + chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', |
|
561 | + chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', |
|
562 | + chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', |
|
563 | + chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', |
|
564 | + chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', |
|
565 | + chr(195).chr(159) => 's', chr(195).chr(160) => 'a', |
|
566 | + chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', |
|
567 | + chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', |
|
568 | + chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', |
|
569 | + chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', |
|
570 | + chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', |
|
571 | + chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', |
|
572 | + chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', |
|
573 | + chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', |
|
574 | + chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', |
|
575 | + chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', |
|
576 | + chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', |
|
577 | + chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', |
|
578 | + chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', |
|
579 | + chr(195).chr(191) => 'y', |
|
580 | + // Decompositions for Latin Extended-A |
|
581 | + chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', |
|
582 | + chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', |
|
583 | + chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', |
|
584 | + chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', |
|
585 | + chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', |
|
586 | + chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', |
|
587 | + chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', |
|
588 | + chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', |
|
589 | + chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', |
|
590 | + chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', |
|
591 | + chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', |
|
592 | + chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', |
|
593 | + chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', |
|
594 | + chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', |
|
595 | + chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', |
|
596 | + chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', |
|
597 | + chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', |
|
598 | + chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', |
|
599 | + chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', |
|
600 | + chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', |
|
601 | + chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', |
|
602 | + chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', |
|
603 | + chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
|
604 | + chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
|
605 | + chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
|
606 | + chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
607 | + chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
|
608 | + chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
|
609 | + chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
|
610 | + chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', |
|
611 | + chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', |
|
612 | + chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', |
|
613 | + chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', |
|
614 | + chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', |
|
615 | + chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', |
|
616 | + chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', |
|
617 | + chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', |
|
618 | + chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', |
|
619 | + chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
|
620 | + chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
|
621 | + chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
|
622 | + chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
623 | + chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
624 | + chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
625 | + chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
626 | + chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
627 | + chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
628 | + chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
629 | + chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
|
630 | + chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
|
631 | + chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
|
632 | + chr(197).chr(166) => 'T', chr(197).chr(167) => 't', |
|
633 | + chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', |
|
634 | + chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', |
|
635 | + chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', |
|
636 | + chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', |
|
637 | + chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', |
|
638 | + chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', |
|
639 | + chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', |
|
640 | + chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', |
|
641 | + chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', |
|
642 | + chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', |
|
643 | + chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', |
|
644 | + chr(197).chr(190) => 'z', chr(197).chr(191) => 's' |
|
645 | 645 | ); |
646 | 646 | $string = strtr($string, $chars); |
647 | 647 | return $string; |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | $dfX = $first_pass[$j][0]; |
783 | 783 | $dfDiffLong = abs($dfX - $dfPrevX); |
784 | 784 | if ($dfDiffLong > $dfDiffSpace && |
785 | - (($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) |
|
785 | + (($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) |
|
786 | 786 | { |
787 | 787 | $bHasBigDiff = true; |
788 | 788 | } else if ($dfDiffLong > $dfMaxSmallDiffLong) { |
@@ -802,8 +802,8 @@ discard block |
||
802 | 802 | $dfX2 = floatval($first_pass[$k][0]); |
803 | 803 | $dfY2 = floatval($first_pass[$k][1]); |
804 | 804 | if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 && |
805 | - $k+1 < count($first_pass) && |
|
806 | - $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX) |
|
805 | + $k+1 < count($first_pass) && |
|
806 | + $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX) |
|
807 | 807 | { |
808 | 808 | $poNewLS[] = array(-180, $first_pass[$k][1]); |
809 | 809 | $k++; |
@@ -811,8 +811,8 @@ discard block |
||
811 | 811 | $poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]); |
812 | 812 | continue; |
813 | 813 | } else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 && |
814 | - $k+1 < $first_pass_ln && |
|
815 | - $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180) |
|
814 | + $k+1 < $first_pass_ln && |
|
815 | + $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180) |
|
816 | 816 | { |
817 | 817 | $poNewLS[] = array(180, $first_pass[$k][1]); |
818 | 818 | $k++; |