@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | print '<h1>'._("Aircrafts Types").'</h1>'; |
17 | 17 | |
18 | 18 | $aircraft_types = $Stats->getAllAircraftTypes(); |
19 | - if (empty($aircraft_types) || $aircraft_types[0]['aircraft_manufacturer'] == '') $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
19 | + if (empty($aircraft_types) || $aircraft_types[0]['aircraft_manufacturer'] == '') { |
|
20 | + $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
21 | + } |
|
20 | 22 | $previous = null; |
21 | 23 | print '<div class="alphabet-legend">'; |
22 | 24 | foreach($aircraft_types as $value) { |
@@ -24,7 +26,9 @@ discard block |
||
24 | 26 | $firstLetter = substr($value['aircraft_manufacturer'], 0, 1); |
25 | 27 | if($previous !== $firstLetter) |
26 | 28 | { |
27 | - if ($previous !== null) print ' | '; |
|
29 | + if ($previous !== null) { |
|
30 | + print ' | '; |
|
31 | + } |
|
28 | 32 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
29 | 33 | } |
30 | 34 | $previous = $firstLetter; |
@@ -38,7 +42,9 @@ discard block |
||
38 | 42 | { |
39 | 43 | if($previous !== $firstLetter) |
40 | 44 | { |
41 | - if ($previous !== null) print '</div>'; |
|
45 | + if ($previous !== null) { |
|
46 | + print '</div>'; |
|
47 | + } |
|
42 | 48 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
43 | 49 | } |
44 | 50 | $previous = $firstLetter; |
@@ -339,7 +339,9 @@ discard block |
||
339 | 339 | if (isset($globalTimezone)) |
340 | 340 | { |
341 | 341 | date_default_timezone_set($globalTimezone); |
342 | - } else date_default_timezone_set('UTC'); |
|
342 | + } else { |
|
343 | + date_default_timezone_set('UTC'); |
|
344 | + } |
|
343 | 345 | if ($showSpecial === true) |
344 | 346 | { |
345 | 347 | print '<tr class="special">'."\n"; |
@@ -358,8 +360,9 @@ discard block |
||
358 | 360 | print '<td class="aircraft_thumbnail">'."\n"; |
359 | 361 | |
360 | 362 | if ($spotter_item['image_source'] == 'planespotters') { |
361 | - if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website']; |
|
362 | - else { |
|
363 | + if ($spotter_item['image_source_website'] != '') { |
|
364 | + $image_src = $spotter_item['image_source_website']; |
|
365 | + } else { |
|
363 | 366 | $planespotter_url_array = explode("_", $spotter_item['image']); |
364 | 367 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
365 | 368 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
@@ -372,7 +375,9 @@ discard block |
||
372 | 375 | } else { |
373 | 376 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
374 | 377 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
375 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
378 | + } else { |
|
379 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
380 | + } |
|
376 | 381 | if (isset($spotter_item['airline_name'])) { |
377 | 382 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
378 | 383 | } else { |
@@ -395,8 +400,9 @@ discard block |
||
395 | 400 | print '<td class="aircraft_thumbnail">'."\n"; |
396 | 401 | //print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>'; |
397 | 402 | if ($spotter_item['image_source'] == 'planespotters') { |
398 | - if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website']; |
|
399 | - else { |
|
403 | + if ($spotter_item['image_source_website'] != '') { |
|
404 | + $image_src = $spotter_item['image_source_website']; |
|
405 | + } else { |
|
400 | 406 | $planespotter_url_array = explode("_", $spotter_array[0]['image']); |
401 | 407 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
402 | 408 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
@@ -413,7 +419,9 @@ discard block |
||
413 | 419 | } else { |
414 | 420 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
415 | 421 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
416 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
422 | + } else { |
|
423 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
424 | + } |
|
417 | 425 | if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) { |
418 | 426 | print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
419 | 427 | } elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) { |
@@ -494,15 +502,21 @@ discard block |
||
494 | 502 | if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) { |
495 | 503 | if ($spotter_item['departure_airport_time'] > 2460) { |
496 | 504 | $departure_airport_time = date('H:m',$spotter_item['departure_airport_time']); |
497 | - } else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
505 | + } else { |
|
506 | + $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
507 | + } |
|
498 | 508 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
499 | 509 | $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
500 | - } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
510 | + } else { |
|
511 | + $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
512 | + } |
|
501 | 513 | print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n"; |
502 | 514 | } elseif (isset($spotter_item['real_departure_airport_time'])) { |
503 | 515 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
504 | 516 | $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
505 | - } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
517 | + } else { |
|
518 | + $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
519 | + } |
|
506 | 520 | print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n"; |
507 | 521 | } elseif (isset($spotter_item['departure_airport_time'])) { |
508 | 522 | if ($spotter_item['departure_airport_time'] > 2460) { |
@@ -524,7 +538,9 @@ discard block |
||
524 | 538 | $longitude = $spotter_item['longitude']; |
525 | 539 | } |
526 | 540 | $distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude); |
527 | - } else $distance = ''; |
|
541 | + } else { |
|
542 | + $distance = ''; |
|
543 | + } |
|
528 | 544 | if ($distance != '') { |
529 | 545 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
530 | 546 | echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |
@@ -549,7 +565,9 @@ discard block |
||
549 | 565 | } else { |
550 | 566 | if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) { |
551 | 567 | print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n"; |
552 | - if (!isset($Spotter)) $Spotter = new Spotter(); |
|
568 | + if (!isset($Spotter)) { |
|
569 | + $Spotter = new Spotter(); |
|
570 | + } |
|
553 | 571 | $arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
554 | 572 | print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n"; |
555 | 573 | print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n"; |
@@ -565,20 +583,28 @@ discard block |
||
565 | 583 | if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) { |
566 | 584 | if ($spotter_item['arrival_airport_time'] > 2460) { |
567 | 585 | $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
568 | - } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
586 | + } else { |
|
587 | + $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
588 | + } |
|
569 | 589 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
570 | 590 | $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
571 | - } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
591 | + } else { |
|
592 | + $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
593 | + } |
|
572 | 594 | print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n"; |
573 | 595 | } elseif (isset($spotter_item['real_arrival_airport_time'])) { |
574 | 596 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
575 | 597 | $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
576 | - } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
598 | + } else { |
|
599 | + $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
600 | + } |
|
577 | 601 | print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n"; |
578 | 602 | } elseif (isset($spotter_item['arrival_airport_time'])) { |
579 | 603 | if ($spotter_item['arrival_airport_time'] > 2460) { |
580 | 604 | $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
581 | - } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
605 | + } else { |
|
606 | + $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
607 | + } |
|
582 | 608 | print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n"; |
583 | 609 | } |
584 | 610 | if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
@@ -591,7 +617,9 @@ discard block |
||
591 | 617 | $longitude = $spotter_item['longitude']; |
592 | 618 | } |
593 | 619 | $distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude); |
594 | - } else $distance = ''; |
|
620 | + } else { |
|
621 | + $distance = ''; |
|
622 | + } |
|
595 | 623 | if ($distance != '') { |
596 | 624 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
597 | 625 | echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |
@@ -9,7 +9,10 @@ |
||
9 | 9 | <?php |
10 | 10 | } |
11 | 11 | ?> |
12 | - <span>Developed in Barrie by <a href="http://mtru.nz/" target="_blank">Mario Trunz</a> & at <a href="http://www.zugaina.com" target="_blank">Zugaina</a> by Ycarus</span> - <span><a href="<?php if (isset($globalURL)) print $globalURL; ?>/about#source">Source & Credits</a></span> - <span><a href="https://github.com/Ysurac/FlightAirMap/issues" target="_blank">Report any issues</a></span> |
|
12 | + <span>Developed in Barrie by <a href="http://mtru.nz/" target="_blank">Mario Trunz</a> & at <a href="http://www.zugaina.com" target="_blank">Zugaina</a> by Ycarus</span> - <span><a href="<?php if (isset($globalURL)) { |
|
13 | + print $globalURL; |
|
14 | +} |
|
15 | +?>/about#source">Source & Credits</a></span> - <span><a href="https://github.com/Ysurac/FlightAirMap/issues" target="_blank">Report any issues</a></span> |
|
13 | 16 | </footer> |
14 | 17 | |
15 | 18 | <div class="notifications bottom-left"></div> |
@@ -258,7 +258,9 @@ discard block |
||
258 | 258 | // Update table countries |
259 | 259 | if ($Connection->tableExists('airspace')) { |
260 | 260 | $error .= update_db::update_countries(); |
261 | - if ($error != '') return $error; |
|
261 | + if ($error != '') { |
|
262 | + return $error; |
|
263 | + } |
|
262 | 264 | } |
263 | 265 | // Update schema_version to 7 |
264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
@@ -314,7 +316,9 @@ discard block |
||
314 | 316 | $error = ''; |
315 | 317 | // Update table aircraft |
316 | 318 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | - if ($error != '') return $error; |
|
319 | + if ($error != '') { |
|
320 | + return $error; |
|
321 | + } |
|
318 | 322 | // Update schema_version to 6 |
319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | 324 | try { |
@@ -331,7 +335,9 @@ discard block |
||
331 | 335 | $error = ''; |
332 | 336 | // Update table aircraft |
333 | 337 | $error .= create_db::import_file('../db/notam.sql'); |
334 | - if ($error != '') return $error; |
|
338 | + if ($error != '') { |
|
339 | + return $error; |
|
340 | + } |
|
335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 342 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
@@ -365,7 +371,9 @@ discard block |
||
365 | 371 | $error = ''; |
366 | 372 | // Update table atc |
367 | 373 | $error .= create_db::import_file('../db/atc.sql'); |
368 | - if ($error != '') return $error; |
|
374 | + if ($error != '') { |
|
375 | + return $error; |
|
376 | + } |
|
369 | 377 | |
370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | 379 | try { |
@@ -389,13 +397,21 @@ discard block |
||
389 | 397 | $error = ''; |
390 | 398 | // Add tables |
391 | 399 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | - if ($error != '') return $error; |
|
400 | + if ($error != '') { |
|
401 | + return $error; |
|
402 | + } |
|
393 | 403 | $error .= create_db::import_file('../db/metar.sql'); |
394 | - if ($error != '') return $error; |
|
404 | + if ($error != '') { |
|
405 | + return $error; |
|
406 | + } |
|
395 | 407 | $error .= create_db::import_file('../db/taf.sql'); |
396 | - if ($error != '') return $error; |
|
408 | + if ($error != '') { |
|
409 | + return $error; |
|
410 | + } |
|
397 | 411 | $error .= create_db::import_file('../db/airport.sql'); |
398 | - if ($error != '') return $error; |
|
412 | + if ($error != '') { |
|
413 | + return $error; |
|
414 | + } |
|
399 | 415 | |
400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | 417 | try { |
@@ -469,19 +485,33 @@ discard block |
||
469 | 485 | $error = ''; |
470 | 486 | // Add tables |
471 | 487 | $error .= create_db::import_file('../db/stats.sql'); |
472 | - if ($error != '') return $error; |
|
488 | + if ($error != '') { |
|
489 | + return $error; |
|
490 | + } |
|
473 | 491 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
474 | - if ($error != '') return $error; |
|
492 | + if ($error != '') { |
|
493 | + return $error; |
|
494 | + } |
|
475 | 495 | $error .= create_db::import_file('../db/stats_airline.sql'); |
476 | - if ($error != '') return $error; |
|
496 | + if ($error != '') { |
|
497 | + return $error; |
|
498 | + } |
|
477 | 499 | $error .= create_db::import_file('../db/stats_airport.sql'); |
478 | - if ($error != '') return $error; |
|
500 | + if ($error != '') { |
|
501 | + return $error; |
|
502 | + } |
|
479 | 503 | $error .= create_db::import_file('../db/stats_owner.sql'); |
480 | - if ($error != '') return $error; |
|
504 | + if ($error != '') { |
|
505 | + return $error; |
|
506 | + } |
|
481 | 507 | $error .= create_db::import_file('../db/stats_pilot.sql'); |
482 | - if ($error != '') return $error; |
|
508 | + if ($error != '') { |
|
509 | + return $error; |
|
510 | + } |
|
483 | 511 | $error .= create_db::import_file('../db/spotter_archive_output.sql'); |
484 | - if ($error != '') return $error; |
|
512 | + if ($error != '') { |
|
513 | + return $error; |
|
514 | + } |
|
485 | 515 | |
486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | 517 | try { |
@@ -521,7 +551,9 @@ discard block |
||
521 | 551 | // Add tables |
522 | 552 | if (!$Connection->tableExists('stats_flight')) { |
523 | 553 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | - if ($error != '') return $error; |
|
554 | + if ($error != '') { |
|
555 | + return $error; |
|
556 | + } |
|
525 | 557 | } |
526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | 559 | try { |
@@ -545,7 +577,9 @@ discard block |
||
545 | 577 | } catch(PDOException $e) { |
546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 579 | } |
548 | - if ($error != '') return $error; |
|
580 | + if ($error != '') { |
|
581 | + return $error; |
|
582 | + } |
|
549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | 584 | try { |
551 | 585 | $sth = $Connection->db->prepare($query); |
@@ -566,7 +600,9 @@ discard block |
||
566 | 600 | if (!$Connection->tableExists('stats_callsign')) { |
567 | 601 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 602 | } |
569 | - if ($error != '') return $error; |
|
603 | + if ($error != '') { |
|
604 | + return $error; |
|
605 | + } |
|
570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | 607 | try { |
572 | 608 | $sth = $Connection->db->prepare($query); |
@@ -584,7 +620,9 @@ discard block |
||
584 | 620 | if (!$Connection->tableExists('stats_country')) { |
585 | 621 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 622 | } |
587 | - if ($error != '') return $error; |
|
623 | + if ($error != '') { |
|
624 | + return $error; |
|
625 | + } |
|
588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | 627 | try { |
590 | 628 | $sth = $Connection->db->prepare($query); |
@@ -607,7 +645,9 @@ discard block |
||
607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 646 | } |
609 | 647 | } |
610 | - if ($error != '') return $error; |
|
648 | + if ($error != '') { |
|
649 | + return $error; |
|
650 | + } |
|
611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | 652 | try { |
613 | 653 | $sth = $Connection->db->prepare($query); |
@@ -623,7 +663,9 @@ discard block |
||
623 | 663 | $error = ''; |
624 | 664 | // Update airport table |
625 | 665 | $error .= create_db::import_file('../db/airport.sql'); |
626 | - if ($error != '') return 'Import airport.sql : '.$error; |
|
666 | + if ($error != '') { |
|
667 | + return 'Import airport.sql : '.$error; |
|
668 | + } |
|
627 | 669 | // Remove primary key on Spotter_Archive |
628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | 671 | try { |
@@ -699,7 +741,9 @@ discard block |
||
699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 742 | } |
701 | 743 | } |
702 | - if ($error != '') return $error; |
|
744 | + if ($error != '') { |
|
745 | + return $error; |
|
746 | + } |
|
703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | 748 | try { |
705 | 749 | $sth = $Connection->db->prepare($query); |
@@ -717,7 +761,9 @@ discard block |
||
717 | 761 | // Update airline table |
718 | 762 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
719 | 763 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
764 | + if ($error != '') { |
|
765 | + return 'Import airlines.sql : '.$error; |
|
766 | + } |
|
721 | 767 | } |
722 | 768 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 769 | // Add column over_country |
@@ -729,7 +775,9 @@ discard block |
||
729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 776 | } |
731 | 777 | } |
732 | - if ($error != '') return $error; |
|
778 | + if ($error != '') { |
|
779 | + return $error; |
|
780 | + } |
|
733 | 781 | /* |
734 | 782 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
735 | 783 | // Force update ModeS (this will put type_flight data |
@@ -759,7 +807,9 @@ discard block |
||
759 | 807 | } catch(PDOException $e) { |
760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 809 | } |
762 | - if ($error != '') return $error; |
|
810 | + if ($error != '') { |
|
811 | + return $error; |
|
812 | + } |
|
763 | 813 | } |
764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | 815 | try { |
@@ -782,7 +832,9 @@ discard block |
||
782 | 832 | } else { |
783 | 833 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 834 | } |
785 | - if ($error != '') return $error; |
|
835 | + if ($error != '') { |
|
836 | + return $error; |
|
837 | + } |
|
786 | 838 | } |
787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | 840 | try { |
@@ -804,12 +856,16 @@ discard block |
||
804 | 856 | if ($globalDBdriver == 'mysql') { |
805 | 857 | if (!$Connection->tableExists('tle')) { |
806 | 858 | $error .= create_db::import_file('../db/tle.sql'); |
807 | - if ($error != '') return $error; |
|
859 | + if ($error != '') { |
|
860 | + return $error; |
|
861 | + } |
|
808 | 862 | } |
809 | 863 | } else { |
810 | 864 | if (!$Connection->tableExists('tle')) { |
811 | 865 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
812 | - if ($error != '') return $error; |
|
866 | + if ($error != '') { |
|
867 | + return $error; |
|
868 | + } |
|
813 | 869 | } |
814 | 870 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
815 | 871 | try { |
@@ -849,7 +905,9 @@ discard block |
||
849 | 905 | } else { |
850 | 906 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
851 | 907 | } |
852 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
908 | + if ($error != '') { |
|
909 | + return 'Import airlines.sql : '.$error; |
|
910 | + } |
|
853 | 911 | if (!$Connection->checkColumnName('airlines','forsource')) { |
854 | 912 | // Add forsource to airlines |
855 | 913 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1102,8 +1160,11 @@ discard block |
||
1102 | 1160 | if ($Connection->tableExists('aircraft')) { |
1103 | 1161 | if (!$Connection->tableExists('config')) { |
1104 | 1162 | $version = '1'; |
1105 | - if ($update) return self::update_from_1(); |
|
1106 | - else return $version; |
|
1163 | + if ($update) { |
|
1164 | + return self::update_from_1(); |
|
1165 | + } else { |
|
1166 | + return $version; |
|
1167 | + } |
|
1107 | 1168 | } else { |
1108 | 1169 | $Connection = new Connection(); |
1109 | 1170 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
@@ -1117,106 +1178,183 @@ discard block |
||
1117 | 1178 | if ($update) { |
1118 | 1179 | if ($result['value'] == '2') { |
1119 | 1180 | $error = self::update_from_2(); |
1120 | - if ($error != '') return $error; |
|
1121 | - else return self::check_version(true); |
|
1181 | + if ($error != '') { |
|
1182 | + return $error; |
|
1183 | + } else { |
|
1184 | + return self::check_version(true); |
|
1185 | + } |
|
1122 | 1186 | } elseif ($result['value'] == '3') { |
1123 | 1187 | $error = self::update_from_3(); |
1124 | - if ($error != '') return $error; |
|
1125 | - else return self::check_version(true); |
|
1188 | + if ($error != '') { |
|
1189 | + return $error; |
|
1190 | + } else { |
|
1191 | + return self::check_version(true); |
|
1192 | + } |
|
1126 | 1193 | } elseif ($result['value'] == '4') { |
1127 | 1194 | $error = self::update_from_4(); |
1128 | - if ($error != '') return $error; |
|
1129 | - else return self::check_version(true); |
|
1195 | + if ($error != '') { |
|
1196 | + return $error; |
|
1197 | + } else { |
|
1198 | + return self::check_version(true); |
|
1199 | + } |
|
1130 | 1200 | } elseif ($result['value'] == '5') { |
1131 | 1201 | $error = self::update_from_5(); |
1132 | - if ($error != '') return $error; |
|
1133 | - else return self::check_version(true); |
|
1202 | + if ($error != '') { |
|
1203 | + return $error; |
|
1204 | + } else { |
|
1205 | + return self::check_version(true); |
|
1206 | + } |
|
1134 | 1207 | } elseif ($result['value'] == '6') { |
1135 | 1208 | $error = self::update_from_6(); |
1136 | - if ($error != '') return $error; |
|
1137 | - else return self::check_version(true); |
|
1209 | + if ($error != '') { |
|
1210 | + return $error; |
|
1211 | + } else { |
|
1212 | + return self::check_version(true); |
|
1213 | + } |
|
1138 | 1214 | } elseif ($result['value'] == '7') { |
1139 | 1215 | $error = self::update_from_7(); |
1140 | - if ($error != '') return $error; |
|
1141 | - else return self::check_version(true); |
|
1216 | + if ($error != '') { |
|
1217 | + return $error; |
|
1218 | + } else { |
|
1219 | + return self::check_version(true); |
|
1220 | + } |
|
1142 | 1221 | } elseif ($result['value'] == '8') { |
1143 | 1222 | $error = self::update_from_8(); |
1144 | - if ($error != '') return $error; |
|
1145 | - else return self::check_version(true); |
|
1223 | + if ($error != '') { |
|
1224 | + return $error; |
|
1225 | + } else { |
|
1226 | + return self::check_version(true); |
|
1227 | + } |
|
1146 | 1228 | } elseif ($result['value'] == '9') { |
1147 | 1229 | $error = self::update_from_9(); |
1148 | - if ($error != '') return $error; |
|
1149 | - else return self::check_version(true); |
|
1230 | + if ($error != '') { |
|
1231 | + return $error; |
|
1232 | + } else { |
|
1233 | + return self::check_version(true); |
|
1234 | + } |
|
1150 | 1235 | } elseif ($result['value'] == '10') { |
1151 | 1236 | $error = self::update_from_10(); |
1152 | - if ($error != '') return $error; |
|
1153 | - else return self::check_version(true); |
|
1237 | + if ($error != '') { |
|
1238 | + return $error; |
|
1239 | + } else { |
|
1240 | + return self::check_version(true); |
|
1241 | + } |
|
1154 | 1242 | } elseif ($result['value'] == '11') { |
1155 | 1243 | $error = self::update_from_11(); |
1156 | - if ($error != '') return $error; |
|
1157 | - else return self::check_version(true); |
|
1244 | + if ($error != '') { |
|
1245 | + return $error; |
|
1246 | + } else { |
|
1247 | + return self::check_version(true); |
|
1248 | + } |
|
1158 | 1249 | } elseif ($result['value'] == '12') { |
1159 | 1250 | $error = self::update_from_12(); |
1160 | - if ($error != '') return $error; |
|
1161 | - else return self::check_version(true); |
|
1251 | + if ($error != '') { |
|
1252 | + return $error; |
|
1253 | + } else { |
|
1254 | + return self::check_version(true); |
|
1255 | + } |
|
1162 | 1256 | } elseif ($result['value'] == '13') { |
1163 | 1257 | $error = self::update_from_13(); |
1164 | - if ($error != '') return $error; |
|
1165 | - else return self::check_version(true); |
|
1258 | + if ($error != '') { |
|
1259 | + return $error; |
|
1260 | + } else { |
|
1261 | + return self::check_version(true); |
|
1262 | + } |
|
1166 | 1263 | } elseif ($result['value'] == '14') { |
1167 | 1264 | $error = self::update_from_14(); |
1168 | - if ($error != '') return $error; |
|
1169 | - else return self::check_version(true); |
|
1265 | + if ($error != '') { |
|
1266 | + return $error; |
|
1267 | + } else { |
|
1268 | + return self::check_version(true); |
|
1269 | + } |
|
1170 | 1270 | } elseif ($result['value'] == '15') { |
1171 | 1271 | $error = self::update_from_15(); |
1172 | - if ($error != '') return $error; |
|
1173 | - else return self::check_version(true); |
|
1272 | + if ($error != '') { |
|
1273 | + return $error; |
|
1274 | + } else { |
|
1275 | + return self::check_version(true); |
|
1276 | + } |
|
1174 | 1277 | } elseif ($result['value'] == '16') { |
1175 | 1278 | $error = self::update_from_16(); |
1176 | - if ($error != '') return $error; |
|
1177 | - else return self::check_version(true); |
|
1279 | + if ($error != '') { |
|
1280 | + return $error; |
|
1281 | + } else { |
|
1282 | + return self::check_version(true); |
|
1283 | + } |
|
1178 | 1284 | } elseif ($result['value'] == '17') { |
1179 | 1285 | $error = self::update_from_17(); |
1180 | - if ($error != '') return $error; |
|
1181 | - else return self::check_version(true); |
|
1286 | + if ($error != '') { |
|
1287 | + return $error; |
|
1288 | + } else { |
|
1289 | + return self::check_version(true); |
|
1290 | + } |
|
1182 | 1291 | } elseif ($result['value'] == '18') { |
1183 | 1292 | $error = self::update_from_18(); |
1184 | - if ($error != '') return $error; |
|
1185 | - else return self::check_version(true); |
|
1293 | + if ($error != '') { |
|
1294 | + return $error; |
|
1295 | + } else { |
|
1296 | + return self::check_version(true); |
|
1297 | + } |
|
1186 | 1298 | } elseif ($result['value'] == '19') { |
1187 | 1299 | $error = self::update_from_19(); |
1188 | - if ($error != '') return $error; |
|
1189 | - else return self::check_version(true); |
|
1300 | + if ($error != '') { |
|
1301 | + return $error; |
|
1302 | + } else { |
|
1303 | + return self::check_version(true); |
|
1304 | + } |
|
1190 | 1305 | } elseif ($result['value'] == '20') { |
1191 | 1306 | $error = self::update_from_20(); |
1192 | - if ($error != '') return $error; |
|
1193 | - else return self::check_version(true); |
|
1307 | + if ($error != '') { |
|
1308 | + return $error; |
|
1309 | + } else { |
|
1310 | + return self::check_version(true); |
|
1311 | + } |
|
1194 | 1312 | } elseif ($result['value'] == '21') { |
1195 | 1313 | $error = self::update_from_21(); |
1196 | - if ($error != '') return $error; |
|
1197 | - else return self::check_version(true); |
|
1314 | + if ($error != '') { |
|
1315 | + return $error; |
|
1316 | + } else { |
|
1317 | + return self::check_version(true); |
|
1318 | + } |
|
1198 | 1319 | } elseif ($result['value'] == '22') { |
1199 | 1320 | $error = self::update_from_22(); |
1200 | - if ($error != '') return $error; |
|
1201 | - else return self::check_version(true); |
|
1321 | + if ($error != '') { |
|
1322 | + return $error; |
|
1323 | + } else { |
|
1324 | + return self::check_version(true); |
|
1325 | + } |
|
1202 | 1326 | } elseif ($result['value'] == '23') { |
1203 | 1327 | $error = self::update_from_23(); |
1204 | - if ($error != '') return $error; |
|
1205 | - else return self::check_version(true); |
|
1328 | + if ($error != '') { |
|
1329 | + return $error; |
|
1330 | + } else { |
|
1331 | + return self::check_version(true); |
|
1332 | + } |
|
1206 | 1333 | } elseif ($result['value'] == '24') { |
1207 | 1334 | $error = self::update_from_24(); |
1208 | - if ($error != '') return $error; |
|
1209 | - else return self::check_version(true); |
|
1335 | + if ($error != '') { |
|
1336 | + return $error; |
|
1337 | + } else { |
|
1338 | + return self::check_version(true); |
|
1339 | + } |
|
1210 | 1340 | } elseif ($result['value'] == '25') { |
1211 | 1341 | $error = self::update_from_25(); |
1212 | - if ($error != '') return $error; |
|
1213 | - else return self::check_version(true); |
|
1214 | - } else return ''; |
|
1342 | + if ($error != '') { |
|
1343 | + return $error; |
|
1344 | + } else { |
|
1345 | + return self::check_version(true); |
|
1346 | + } |
|
1347 | + } else { |
|
1348 | + return ''; |
|
1349 | + } |
|
1350 | + } else { |
|
1351 | + return $result['value']; |
|
1215 | 1352 | } |
1216 | - else return $result['value']; |
|
1217 | 1353 | } |
1218 | 1354 | |
1219 | - } else return $version; |
|
1355 | + } else { |
|
1356 | + return $version; |
|
1357 | + } |
|
1220 | 1358 | } |
1221 | 1359 | |
1222 | 1360 | } |
@@ -1015,8 +1015,11 @@ discard block |
||
1015 | 1015 | $data = file_get_contents($filename); |
1016 | 1016 | preg_match_all("/%%(.+?)%%/is", $data, $matches); |
1017 | 1017 | //print_r($matches); |
1018 | - if (isset($matches[1])) return $matches[1]; |
|
1019 | - else return array(); |
|
1018 | + if (isset($matches[1])) { |
|
1019 | + return $matches[1]; |
|
1020 | + } else { |
|
1021 | + return array(); |
|
1022 | + } |
|
1020 | 1023 | } |
1021 | 1024 | public function getAllNOTAMbyScope($scope) { |
1022 | 1025 | global $globalDBdriver; |
@@ -1043,7 +1046,9 @@ discard block |
||
1043 | 1046 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1044 | 1047 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1045 | 1048 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1046 | - } else return array(); |
|
1049 | + } else { |
|
1050 | + return array(); |
|
1051 | + } |
|
1047 | 1052 | if ($globalDBdriver == 'mysql') { |
1048 | 1053 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP()'; |
1049 | 1054 | } else { |
@@ -1067,7 +1072,9 @@ discard block |
||
1067 | 1072 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1068 | 1073 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1069 | 1074 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1070 | - } else return array(); |
|
1075 | + } else { |
|
1076 | + return array(); |
|
1077 | + } |
|
1071 | 1078 | if ($globalDBdriver == 'mysql') { |
1072 | 1079 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope'; |
1073 | 1080 | } else { |
@@ -1094,8 +1101,11 @@ discard block |
||
1094 | 1101 | return "error : ".$e->getMessage(); |
1095 | 1102 | } |
1096 | 1103 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1097 | - if (isset($all[0])) return $all[0]; |
|
1098 | - else return array(); |
|
1104 | + if (isset($all[0])) { |
|
1105 | + return $all[0]; |
|
1106 | + } else { |
|
1107 | + return array(); |
|
1108 | + } |
|
1099 | 1109 | } |
1100 | 1110 | |
1101 | 1111 | public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) { |
@@ -1173,7 +1183,9 @@ discard block |
||
1173 | 1183 | foreach ($alldata as $initial_data) { |
1174 | 1184 | $data = $this->parse($initial_data); |
1175 | 1185 | $notamref = $this->getNOTAMbyRef($data['ref']); |
1176 | - if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1186 | + if (count($notamref) == 0) { |
|
1187 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1188 | + } |
|
1177 | 1189 | } |
1178 | 1190 | } |
1179 | 1191 | } |
@@ -1186,7 +1198,9 @@ discard block |
||
1186 | 1198 | foreach ($alldata as $initial_data) { |
1187 | 1199 | $data = $this->parse($initial_data); |
1188 | 1200 | $notamref = $this->getNOTAMbyRef($data['ref']); |
1189 | - if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1201 | + if (!isset($notamref['notam_id'])) { |
|
1202 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1203 | + } |
|
1190 | 1204 | } |
1191 | 1205 | } |
1192 | 1206 | } |
@@ -1198,11 +1212,15 @@ discard block |
||
1198 | 1212 | foreach (array_chunk($allairports,20) as $airport) { |
1199 | 1213 | $airports_icao = array(); |
1200 | 1214 | foreach($airport as $icao) { |
1201 | - if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; |
|
1215 | + if (isset($icao['icao'])) { |
|
1216 | + $airports_icao[] = $icao['icao']; |
|
1217 | + } |
|
1202 | 1218 | } |
1203 | 1219 | $airport_icao = implode(',',$airports_icao); |
1204 | 1220 | $alldata = $this->downloadNOTAM($airport_icao); |
1205 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
1221 | + if ($globalTransaction) { |
|
1222 | + $this->db->beginTransaction(); |
|
1223 | + } |
|
1206 | 1224 | if (count($alldata) > 0) { |
1207 | 1225 | foreach ($alldata as $initial_data) { |
1208 | 1226 | //print_r($initial_data); |
@@ -1211,14 +1229,23 @@ discard block |
||
1211 | 1229 | if (isset($data['ref'])) { |
1212 | 1230 | $notamref = $this->getNOTAMbyRef($data['ref']); |
1213 | 1231 | if (count($notamref) == 0) { |
1214 | - if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
1215 | - if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
1216 | - elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1232 | + if (isset($data['ref_replaced'])) { |
|
1233 | + $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
1234 | + } |
|
1235 | + if (isset($data['ref_cancelled'])) { |
|
1236 | + $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
1237 | + } elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) { |
|
1238 | + echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1239 | + } |
|
1217 | 1240 | } |
1218 | 1241 | } |
1219 | 1242 | } |
1220 | - } else echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
1221 | - if ($globalTransaction) $this->db->commit(); |
|
1243 | + } else { |
|
1244 | + echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
1245 | + } |
|
1246 | + if ($globalTransaction) { |
|
1247 | + $this->db->commit(); |
|
1248 | + } |
|
1222 | 1249 | sleep(5); |
1223 | 1250 | } |
1224 | 1251 | } |
@@ -1231,8 +1258,11 @@ discard block |
||
1231 | 1258 | $data = $Common->getData($url); |
1232 | 1259 | preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); |
1233 | 1260 | //print_r($matches); |
1234 | - if (isset($matches[1])) return $matches[1]; |
|
1235 | - else return array(); |
|
1261 | + if (isset($matches[1])) { |
|
1262 | + return $matches[1]; |
|
1263 | + } else { |
|
1264 | + return array(); |
|
1265 | + } |
|
1236 | 1266 | } |
1237 | 1267 | |
1238 | 1268 | public function parse($data) { |
@@ -1255,89 +1285,145 @@ discard block |
||
1255 | 1285 | $rules = str_split($matches[3]); |
1256 | 1286 | foreach ($rules as $rule) { |
1257 | 1287 | if ($rule == 'I') { |
1258 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/IFR'; |
|
1259 | - else $result['rules'] = 'IFR'; |
|
1288 | + if (isset($result['rules'])) { |
|
1289 | + $result['rules'] = $result['rules'].'/IFR'; |
|
1290 | + } else { |
|
1291 | + $result['rules'] = 'IFR'; |
|
1292 | + } |
|
1260 | 1293 | } elseif ($rule == 'V') { |
1261 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/VFR'; |
|
1262 | - else $result['rules'] = 'VFR'; |
|
1294 | + if (isset($result['rules'])) { |
|
1295 | + $result['rules'] = $result['rules'].'/VFR'; |
|
1296 | + } else { |
|
1297 | + $result['rules'] = 'VFR'; |
|
1298 | + } |
|
1263 | 1299 | } elseif ($rule == 'K') { |
1264 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/Checklist'; |
|
1265 | - else $result['rules'] = 'Checklist'; |
|
1300 | + if (isset($result['rules'])) { |
|
1301 | + $result['rules'] = $result['rules'].'/Checklist'; |
|
1302 | + } else { |
|
1303 | + $result['rules'] = 'Checklist'; |
|
1304 | + } |
|
1266 | 1305 | } |
1267 | 1306 | } |
1268 | 1307 | $attentions = str_split($matches[4]); |
1269 | 1308 | foreach ($attentions as $attention) { |
1270 | 1309 | if ($attention == 'N') { |
1271 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Immediate attention'; |
|
1272 | - else $result['rules'] = 'Immediate attention'; |
|
1310 | + if (isset($result['attention'])) { |
|
1311 | + $result['attention'] = $result['attention'].' / Immediate attention'; |
|
1312 | + } else { |
|
1313 | + $result['rules'] = 'Immediate attention'; |
|
1314 | + } |
|
1273 | 1315 | } elseif ($attention == 'B') { |
1274 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Operational significance'; |
|
1275 | - else $result['rules'] = 'Operational significance'; |
|
1316 | + if (isset($result['attention'])) { |
|
1317 | + $result['attention'] = $result['attention'].' / Operational significance'; |
|
1318 | + } else { |
|
1319 | + $result['rules'] = 'Operational significance'; |
|
1320 | + } |
|
1276 | 1321 | } elseif ($attention == 'O') { |
1277 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Flight operations'; |
|
1278 | - else $result['rules'] = 'Flight operations'; |
|
1322 | + if (isset($result['attention'])) { |
|
1323 | + $result['attention'] = $result['attention'].' / Flight operations'; |
|
1324 | + } else { |
|
1325 | + $result['rules'] = 'Flight operations'; |
|
1326 | + } |
|
1279 | 1327 | } elseif ($attention == 'M') { |
1280 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Misc'; |
|
1281 | - else $result['rules'] = 'Misc'; |
|
1328 | + if (isset($result['attention'])) { |
|
1329 | + $result['attention'] = $result['attention'].' / Misc'; |
|
1330 | + } else { |
|
1331 | + $result['rules'] = 'Misc'; |
|
1332 | + } |
|
1282 | 1333 | } elseif ($attention == 'K') { |
1283 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Checklist'; |
|
1284 | - else $result['rules'] = 'Checklist'; |
|
1334 | + if (isset($result['attention'])) { |
|
1335 | + $result['attention'] = $result['attention'].' / Checklist'; |
|
1336 | + } else { |
|
1337 | + $result['rules'] = 'Checklist'; |
|
1338 | + } |
|
1285 | 1339 | } |
1286 | 1340 | } |
1287 | - if ($matches[5] == 'A') $result['scope'] = 'Airport warning'; |
|
1288 | - elseif ($matches[5] == 'E') $result['scope'] = 'Enroute warning'; |
|
1289 | - elseif ($matches[5] == 'W') $result['scope'] = 'Navigation warning'; |
|
1290 | - elseif ($matches[5] == 'K') $result['scope'] = 'Checklist'; |
|
1291 | - elseif ($matches[5] == 'AE') $result['scope'] = 'Airport/Enroute warning'; |
|
1292 | - elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; |
|
1341 | + if ($matches[5] == 'A') { |
|
1342 | + $result['scope'] = 'Airport warning'; |
|
1343 | + } elseif ($matches[5] == 'E') { |
|
1344 | + $result['scope'] = 'Enroute warning'; |
|
1345 | + } elseif ($matches[5] == 'W') { |
|
1346 | + $result['scope'] = 'Navigation warning'; |
|
1347 | + } elseif ($matches[5] == 'K') { |
|
1348 | + $result['scope'] = 'Checklist'; |
|
1349 | + } elseif ($matches[5] == 'AE') { |
|
1350 | + $result['scope'] = 'Airport/Enroute warning'; |
|
1351 | + } elseif ($matches[5] == 'AW') { |
|
1352 | + $result['scope'] = 'Airport/Navigation warning'; |
|
1353 | + } |
|
1293 | 1354 | $result['lower_limit'] = $matches[6]; |
1294 | 1355 | $result['upper_limit'] = $matches[7]; |
1295 | 1356 | $latitude = $Common->convertDec($matches[8],'latitude'); |
1296 | - if ($matches[9] == 'S') $latitude = -$latitude; |
|
1357 | + if ($matches[9] == 'S') { |
|
1358 | + $latitude = -$latitude; |
|
1359 | + } |
|
1297 | 1360 | $longitude = $Common->convertDec($matches[10],'longitude'); |
1298 | - if ($matches[11] == 'W') $longitude = -$longitude; |
|
1361 | + if ($matches[11] == 'W') { |
|
1362 | + $longitude = -$longitude; |
|
1363 | + } |
|
1299 | 1364 | $result['latitude'] = $latitude; |
1300 | 1365 | $result['longitude'] = $longitude; |
1301 | 1366 | $result['radius'] = intval($matches[12]); |
1302 | - } else echo 'ERROR : '.$line."\n"; |
|
1303 | - } |
|
1304 | - elseif (preg_match('#A\) (.*)#',$line,$matches)) { |
|
1367 | + } else { |
|
1368 | + echo 'ERROR : '.$line."\n"; |
|
1369 | + } |
|
1370 | + } elseif (preg_match('#A\) (.*)#',$line,$matches)) { |
|
1305 | 1371 | $result['icao'] = $matches[1]; |
1306 | - } |
|
1307 | - elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) { |
|
1308 | - if ($matches[1] > 50) $year = '19'.$matches[1]; |
|
1309 | - else $year = '20'.$matches[1]; |
|
1372 | + } elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) { |
|
1373 | + if ($matches[1] > 50) { |
|
1374 | + $year = '19'.$matches[1]; |
|
1375 | + } else { |
|
1376 | + $year = '20'.$matches[1]; |
|
1377 | + } |
|
1310 | 1378 | $result['date_begin'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
1311 | - } |
|
1312 | - elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) { |
|
1313 | - if ($matches[1] > 50) $year = '19'.$matches[1]; |
|
1314 | - else $year = '20'.$matches[1]; |
|
1379 | + } elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) { |
|
1380 | + if ($matches[1] > 50) { |
|
1381 | + $year = '19'.$matches[1]; |
|
1382 | + } else { |
|
1383 | + $year = '20'.$matches[1]; |
|
1384 | + } |
|
1315 | 1385 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
1316 | 1386 | $result['permanent'] = 0; |
1317 | - } |
|
1318 | - elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) { |
|
1319 | - if ($matches[1] > 50) $year = '19'.$matches[1]; |
|
1320 | - else $year = '20'.$matches[1]; |
|
1387 | + } elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) { |
|
1388 | + if ($matches[1] > 50) { |
|
1389 | + $year = '19'.$matches[1]; |
|
1390 | + } else { |
|
1391 | + $year = '20'.$matches[1]; |
|
1392 | + } |
|
1321 | 1393 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
1322 | - if ($matches[6] == 'EST') $result['estimated'] = 1; |
|
1323 | - else $result['estimated'] = 0; |
|
1324 | - if ($matches[6] == 'PERM') $result['permanent'] = 1; |
|
1325 | - else $result['permanent'] = 0; |
|
1326 | - } |
|
1327 | - elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) { |
|
1394 | + if ($matches[6] == 'EST') { |
|
1395 | + $result['estimated'] = 1; |
|
1396 | + } else { |
|
1397 | + $result['estimated'] = 0; |
|
1398 | + } |
|
1399 | + if ($matches[6] == 'PERM') { |
|
1400 | + $result['permanent'] = 1; |
|
1401 | + } else { |
|
1402 | + $result['permanent'] = 0; |
|
1403 | + } |
|
1404 | + } elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) { |
|
1328 | 1405 | $result['date_end'] = '2030/12/20 12:00'; |
1329 | - if ($matches[1] == 'EST') $result['estimated'] = 1; |
|
1330 | - else $result['estimated'] = 0; |
|
1331 | - if ($matches[1] == 'PERM') $result['permanent'] = 1; |
|
1332 | - else $result['permanent'] = 0; |
|
1333 | - } |
|
1334 | - elseif (preg_match('#E\) (.*)#',$line,$matches)) { |
|
1406 | + if ($matches[1] == 'EST') { |
|
1407 | + $result['estimated'] = 1; |
|
1408 | + } else { |
|
1409 | + $result['estimated'] = 0; |
|
1410 | + } |
|
1411 | + if ($matches[1] == 'PERM') { |
|
1412 | + $result['permanent'] = 1; |
|
1413 | + } else { |
|
1414 | + $result['permanent'] = 0; |
|
1415 | + } |
|
1416 | + } elseif (preg_match('#E\) (.*)#',$line,$matches)) { |
|
1335 | 1417 | $rtext = array(); |
1336 | 1418 | $text = explode(' ',$matches[1]); |
1337 | 1419 | foreach ($text as $word) { |
1338 | - if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); |
|
1339 | - elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
1340 | - else $rtext[] = $word; |
|
1420 | + if (isset($this->abbr[$word])) { |
|
1421 | + $rtext[] = strtoupper($this->abbr[$word]); |
|
1422 | + } elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) { |
|
1423 | + $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
1424 | + } else { |
|
1425 | + $rtext[] = $word; |
|
1426 | + } |
|
1341 | 1427 | } |
1342 | 1428 | $result['text'] = implode(' ',$rtext); |
1343 | 1429 | //} elseif (preg_match('#F\) (.*)#',$line,$matches)) { |
@@ -1345,7 +1431,9 @@ discard block |
||
1345 | 1431 | } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { |
1346 | 1432 | $text = explode(' ',$line); |
1347 | 1433 | $result['ref'] = $text[0]; |
1348 | - if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; |
|
1434 | + if ($matches[1] == 'NOTAMN') { |
|
1435 | + $result['type'] = 'new'; |
|
1436 | + } |
|
1349 | 1437 | if ($matches[1] == 'NOTAMC') { |
1350 | 1438 | $result['type'] = 'cancel'; |
1351 | 1439 | $result['ref_cancelled'] = $text[2]; |
@@ -1367,69 +1455,101 @@ discard block |
||
1367 | 1455 | switch ($code[1]) { |
1368 | 1456 | case 'A': |
1369 | 1457 | $result = 'Airspace organization '; |
1370 | - if (isset($this->code_airspace[$code_fp])) $result .= $this->code_airspace[$code_fp]; |
|
1458 | + if (isset($this->code_airspace[$code_fp])) { |
|
1459 | + $result .= $this->code_airspace[$code_fp]; |
|
1460 | + } |
|
1371 | 1461 | break; |
1372 | 1462 | case 'C': |
1373 | 1463 | $result = 'Communications and radar facilities '; |
1374 | - if (isset($this->code_comradar[$code_fp])) $result .= $this->code_comradar[$code_fp]; |
|
1464 | + if (isset($this->code_comradar[$code_fp])) { |
|
1465 | + $result .= $this->code_comradar[$code_fp]; |
|
1466 | + } |
|
1375 | 1467 | break; |
1376 | 1468 | case 'F': |
1377 | 1469 | $result = 'Facilities and services '; |
1378 | - if (isset($this->code_facilities[$code_fp])) $result .= $this->code_facilities[$code_fp]; |
|
1470 | + if (isset($this->code_facilities[$code_fp])) { |
|
1471 | + $result .= $this->code_facilities[$code_fp]; |
|
1472 | + } |
|
1379 | 1473 | break; |
1380 | 1474 | case 'I': |
1381 | 1475 | $result = 'Instrument and Microwave Landing System '; |
1382 | - if (isset($this->code_instrumentlanding[$code_fp])) $result .= $this->code_instrumentlanding[$code_fp]; |
|
1476 | + if (isset($this->code_instrumentlanding[$code_fp])) { |
|
1477 | + $result .= $this->code_instrumentlanding[$code_fp]; |
|
1478 | + } |
|
1383 | 1479 | break; |
1384 | 1480 | case 'L': |
1385 | 1481 | $result = 'Lighting facilities '; |
1386 | - if (isset($this->code_lightingfacilities[$code_fp])) $result .= $this->code_lightingfacilities[$code_fp]; |
|
1482 | + if (isset($this->code_lightingfacilities[$code_fp])) { |
|
1483 | + $result .= $this->code_lightingfacilities[$code_fp]; |
|
1484 | + } |
|
1387 | 1485 | break; |
1388 | 1486 | case 'M': |
1389 | 1487 | $result = 'Movement and landing areas '; |
1390 | - if (isset($this->code_movementareas[$code_fp])) $result .= $this->code_movementareas[$code_fp]; |
|
1488 | + if (isset($this->code_movementareas[$code_fp])) { |
|
1489 | + $result .= $this->code_movementareas[$code_fp]; |
|
1490 | + } |
|
1391 | 1491 | break; |
1392 | 1492 | case 'N': |
1393 | 1493 | $result = 'Terminal and En Route Navigation Facilities '; |
1394 | - if (isset($this->code_terminalfacilities[$code_fp])) $result .= $this->code_terminalfacilities[$code_fp]; |
|
1494 | + if (isset($this->code_terminalfacilities[$code_fp])) { |
|
1495 | + $result .= $this->code_terminalfacilities[$code_fp]; |
|
1496 | + } |
|
1395 | 1497 | break; |
1396 | 1498 | case 'O': |
1397 | 1499 | $result = 'Other information '; |
1398 | - if (isset($this->code_information[$code_fp])) $result .= $this->code_information[$code_fp]; |
|
1500 | + if (isset($this->code_information[$code_fp])) { |
|
1501 | + $result .= $this->code_information[$code_fp]; |
|
1502 | + } |
|
1399 | 1503 | break; |
1400 | 1504 | case 'P': |
1401 | 1505 | $result = 'Air Traffic procedures '; |
1402 | - if (isset($this->code_airtraffic[$code_fp])) $result .= $this->code_airtraffic[$code_fp]; |
|
1506 | + if (isset($this->code_airtraffic[$code_fp])) { |
|
1507 | + $result .= $this->code_airtraffic[$code_fp]; |
|
1508 | + } |
|
1403 | 1509 | break; |
1404 | 1510 | case 'R': |
1405 | 1511 | $result = 'Navigation Warnings: Airspace Restrictions '; |
1406 | - if (isset($this->code_navigationw[$code_fp])) $result .= $this->code_navigationw[$code_fp]; |
|
1512 | + if (isset($this->code_navigationw[$code_fp])) { |
|
1513 | + $result .= $this->code_navigationw[$code_fp]; |
|
1514 | + } |
|
1407 | 1515 | break; |
1408 | 1516 | case 'S': |
1409 | 1517 | $result = 'Air Traffic and VOLMET Services '; |
1410 | - if (isset($this->code_volmet[$code_fp])) $result .= $this->code_volmet[$code_fp]; |
|
1518 | + if (isset($this->code_volmet[$code_fp])) { |
|
1519 | + $result .= $this->code_volmet[$code_fp]; |
|
1520 | + } |
|
1411 | 1521 | break; |
1412 | 1522 | case 'W': |
1413 | 1523 | $result = 'Navigation Warnings: Warnings '; |
1414 | - if (isset($this->code_warnings[$code_fp])) $result .= $this->code_warnings[$code_fp]; |
|
1524 | + if (isset($this->code_warnings[$code_fp])) { |
|
1525 | + $result .= $this->code_warnings[$code_fp]; |
|
1526 | + } |
|
1415 | 1527 | break; |
1416 | 1528 | } |
1417 | 1529 | switch ($code[3]) { |
1418 | 1530 | case 'A': |
1419 | 1531 | // Availability |
1420 | - if (isset($this->code_sp_availabity[$code_sp])) $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
1532 | + if (isset($this->code_sp_availabity[$code_sp])) { |
|
1533 | + $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
1534 | + } |
|
1421 | 1535 | break; |
1422 | 1536 | case 'C': |
1423 | 1537 | // Changes |
1424 | - if (isset($this->code_sp_changes[$code_sp])) $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
1538 | + if (isset($this->code_sp_changes[$code_sp])) { |
|
1539 | + $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
1540 | + } |
|
1425 | 1541 | break; |
1426 | 1542 | case 'H': |
1427 | 1543 | // Hazardous conditions |
1428 | - if (isset($this->code_sp_hazardous[$code_sp])) $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
1544 | + if (isset($this->code_sp_hazardous[$code_sp])) { |
|
1545 | + $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
1546 | + } |
|
1429 | 1547 | break; |
1430 | 1548 | case 'L': |
1431 | 1549 | // Limitations |
1432 | - if (isset($this->code_sp_limitations[$code_sp])) $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
1550 | + if (isset($this->code_sp_limitations[$code_sp])) { |
|
1551 | + $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
1552 | + } |
|
1433 | 1553 | break; |
1434 | 1554 | case 'X': |
1435 | 1555 | // Other Information |
@@ -25,7 +25,9 @@ discard block |
||
25 | 25 | $airspace = $result[0]; |
26 | 26 | date_default_timezone_set('UTC'); |
27 | 27 | print '<div class="top">'; |
28 | -if (isset($airspace['name'])) $airspace['title'] = $airspace['name']; |
|
28 | +if (isset($airspace['name'])) { |
|
29 | + $airspace['title'] = $airspace['name']; |
|
30 | +} |
|
29 | 31 | print '<div class="right"><div class="callsign-details"><div class="callsign">'.$airspace['title'].'</a></div>'; |
30 | 32 | print '</div>'; |
31 | 33 | print '<div class="details">'; |
@@ -44,13 +46,17 @@ discard block |
||
44 | 46 | print '</div>'; |
45 | 47 | } |
46 | 48 | |
47 | -if (isset($airspace['ceiling'])) $airspace['tops'] = $airspace['ceiling']; |
|
49 | +if (isset($airspace['ceiling'])) { |
|
50 | + $airspace['tops'] = $airspace['ceiling']; |
|
51 | +} |
|
48 | 52 | print '<div>'; |
49 | 53 | print '<span>'._("Tops").'</span>'; |
50 | 54 | print $airspace['tops']; |
51 | 55 | print '</div>'; |
52 | 56 | |
53 | -if (isset($airspace['floor'])) $airspace['base'] = $airspace['floor']; |
|
57 | +if (isset($airspace['floor'])) { |
|
58 | + $airspace['base'] = $airspace['floor']; |
|
59 | +} |
|
54 | 60 | print '<div>'; |
55 | 61 | print '<span>'._("Base").'</span>'; |
56 | 62 | print $airspace['base']; |
@@ -67,12 +67,22 @@ |
||
67 | 67 | } else { |
68 | 68 | $geom = geoPHP::load(stream_get_contents($row['wkb'])); |
69 | 69 | } |
70 | - if (isset($properties['type'])) $properties['type'] = trim($properties['type']); |
|
71 | - elseif (isset($properties['class'])) $properties['type'] = trim($properties['class']); |
|
72 | - if (isset($properties['ogr_fid'])) $properties['id'] = $properties['ogr_fid']; |
|
73 | - elseif (isset($properties['ogc_fid'])) $properties['id'] = $properties['ogc_fid']; |
|
74 | - if (isset($properties['ceiling'])) $properties['tops'] = $properties['ceiling']; |
|
75 | - if (isset($properties['floor'])) $properties['base'] = $properties['floor']; |
|
70 | + if (isset($properties['type'])) { |
|
71 | + $properties['type'] = trim($properties['type']); |
|
72 | + } elseif (isset($properties['class'])) { |
|
73 | + $properties['type'] = trim($properties['class']); |
|
74 | + } |
|
75 | + if (isset($properties['ogr_fid'])) { |
|
76 | + $properties['id'] = $properties['ogr_fid']; |
|
77 | + } elseif (isset($properties['ogc_fid'])) { |
|
78 | + $properties['id'] = $properties['ogc_fid']; |
|
79 | + } |
|
80 | + if (isset($properties['ceiling'])) { |
|
81 | + $properties['tops'] = $properties['ceiling']; |
|
82 | + } |
|
83 | + if (isset($properties['floor'])) { |
|
84 | + $properties['base'] = $properties['floor']; |
|
85 | + } |
|
76 | 86 | if (preg_match('/^FL(\s)*(?<alt>\d+)/',strtoupper($properties['tops']),$matches)) { |
77 | 87 | $properties['upper_limit'] = round($matches['alt']*100*0.38048); |
78 | 88 | } elseif (preg_match('/^(?<alt>\d+)(\s)*(FT|AGL|ALT|MSL)/',strtoupper($properties['tops']),$matches)) { |
@@ -9,7 +9,9 @@ discard block |
||
9 | 9 | if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { |
10 | 10 | exec("ps ux", $output, $result); |
11 | 11 | $j = 0; |
12 | - foreach ($output as $line) if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++; |
|
12 | + foreach ($output as $line) { |
|
13 | + if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++; |
|
14 | + } |
|
13 | 15 | if ($j > 1) { |
14 | 16 | echo "Script is already runnning..."; |
15 | 17 | die(); |
@@ -28,8 +30,10 @@ discard block |
||
28 | 30 | $update_db->update_notam(); |
29 | 31 | } |
30 | 32 | $update_db->insert_last_notam_update(); |
31 | - } elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n"; |
|
32 | -} |
|
33 | + } elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) { |
|
34 | + echo "NOTAM are only updated once a day.\n"; |
|
35 | + } |
|
36 | + } |
|
33 | 37 | |
34 | 38 | if ($update_db->check_last_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
35 | 39 | $update_db->update_all(); |
@@ -37,7 +41,9 @@ discard block |
||
37 | 41 | // $Spotter = new Spotter(); |
38 | 42 | // $Spotter->updateFieldsFromOtherTables(); |
39 | 43 | $update_db->insert_last_update(); |
40 | -} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n"; |
|
44 | +} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) { |
|
45 | + echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n"; |
|
46 | +} |
|
41 | 47 | |
42 | 48 | |
43 | 49 | if (isset($globalMETAR) && isset($globalMETARcycle) && $globalMETAR && $globalMETARcycle) { |
@@ -47,22 +53,28 @@ discard block |
||
47 | 53 | if ($METAR->check_last_update()) { |
48 | 54 | $METAR->addMETARCycle(); |
49 | 55 | $METAR->insert_last_update(); |
50 | - } else echo "METAR are only updated every 30 minutes.\n"; |
|
51 | -} |
|
56 | + } else { |
|
57 | + echo "METAR are only updated every 30 minutes.\n"; |
|
58 | + } |
|
59 | + } |
|
52 | 60 | |
53 | 61 | |
54 | 62 | if (isset($globalOwner) && $globalOwner && $update_db->check_last_owner_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
55 | 63 | echo "Updating private aircraft's owners..."; |
56 | 64 | $update_db->update_owner(); |
57 | 65 | $update_db->insert_last_owner_update(); |
58 | -} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n"; |
|
66 | +} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
|
67 | + echo "Owner are only updated every 15 days.\n"; |
|
68 | +} |
|
59 | 69 | |
60 | 70 | if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
61 | 71 | echo "Updating schedules..."; |
62 | 72 | $update_db->update_oneworld(); |
63 | 73 | $update_db->update_skyteam(); |
64 | 74 | $update_db->insert_last_schedules_update(); |
65 | -} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n"; |
|
75 | +} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
|
76 | + echo "Schedules are only updated every 15 days.\n"; |
|
77 | +} |
|
66 | 78 | |
67 | 79 | if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) { |
68 | 80 | echo "Updating statistics and archive old data..."; |
@@ -14,7 +14,9 @@ discard block |
||
14 | 14 | //foreach ($lines as $line) |
15 | 15 | while (($line = fgets($handle,4096)) !== false) |
16 | 16 | { |
17 | - if (substr($line,0,2) == '--' || $line == '') continue; |
|
17 | + if (substr($line,0,2) == '--' || $line == '') { |
|
18 | + continue; |
|
19 | + } |
|
18 | 20 | $templine .= $line; |
19 | 21 | if (substr(trim($line), -1,1) == ';') |
20 | 22 | { |
@@ -40,7 +42,9 @@ discard block |
||
40 | 42 | //foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename) |
41 | 43 | while(false !== ($filename = readdir($dh))) |
42 | 44 | { |
43 | - if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename); |
|
45 | + if (preg_match('/\.sql$/',$filename)) { |
|
46 | + $error .= create_db::import_file($directory.$filename); |
|
47 | + } |
|
44 | 48 | } |
45 | 49 | return $error; |
46 | 50 | } |
@@ -56,13 +60,17 @@ discard block |
||
56 | 60 | // Dirty hack |
57 | 61 | if ($host != 'localhost' && $host != '127.0.0.1') { |
58 | 62 | $grantright = $_SERVER['SERVER_ADDR']; |
59 | - } else $grantright = 'localhost'; |
|
63 | + } else { |
|
64 | + $grantright = 'localhost'; |
|
65 | + } |
|
60 | 66 | try { |
61 | 67 | $dbh = new PDO($db_type.':host='.$host,$root,$root_pass); |
62 | 68 | $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
63 | 69 | if ($db_type == 'mysql') { |
64 | 70 | $dbh->exec('CREATE DATABASE IF NOT EXISTS `'.$db.'`;GRANT ALL ON `'.$db."`.* TO '".$user."'@'".$grantright."' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;"); |
65 | - if ($grantright == 'localhost') $dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;"); |
|
71 | + if ($grantright == 'localhost') { |
|
72 | + $dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;"); |
|
73 | + } |
|
66 | 74 | } else if ($db_type == 'pgsql') { |
67 | 75 | $dbh->exec("CREATE DATABASE ".$db.";"); |
68 | 76 | $dbh->exec("CREATE USER ".$user." WITH PASSWORD '".$password."'; |