@@ -38,8 +38,12 @@ |
||
38 | 38 | if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) { |
39 | 39 | include('table-output.php'); |
40 | 40 | print '<div class="pagination">'; |
41 | - if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
42 | - if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
41 | + if ($limit_previous_1 >= 0) { |
|
42 | + print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
43 | + } |
|
44 | + if ($spotter_array[0]['query_number_rows'] == $absolute_difference) { |
|
45 | + print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
46 | + } |
|
43 | 47 | print '</div>'; |
44 | 48 | } |
45 | 49 | print '</div>'; |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
3 | -if ($date == '') $date = date('Y-m-d'); |
|
3 | +if ($date == '') { |
|
4 | + $date = date('Y-m-d'); |
|
5 | +} |
|
4 | 6 | header('Location: '.$globalURL.'/incident/'.$date); |
5 | 7 | ?> |
6 | 8 | \ No newline at end of file |
@@ -38,8 +38,12 @@ |
||
38 | 38 | if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) { |
39 | 39 | include('table-output.php'); |
40 | 40 | print '<div class="pagination">'; |
41 | - if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
42 | - if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
41 | + if ($limit_previous_1 >= 0) { |
|
42 | + print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
43 | + } |
|
44 | + if ($spotter_array[0]['query_number_rows'] == $absolute_difference) { |
|
45 | + print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
46 | + } |
|
43 | 47 | print '</div>'; |
44 | 48 | } |
45 | 49 | print '</div>'; |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
3 | -if ($date == '') $date = date('Y-m-d'); |
|
3 | +if ($date == '') { |
|
4 | + $date = date('Y-m-d'); |
|
5 | +} |
|
4 | 6 | header('Location: '.$globalURL.'/incident/'.$date); |
5 | 7 | ?> |
6 | 8 | \ No newline at end of file |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
3 | -if ($date == '') $date = date('Y-m-d'); |
|
3 | +if ($date == '') { |
|
4 | + $date = date('Y-m-d'); |
|
5 | +} |
|
4 | 6 | header('Location: '.$globalURL.'/incident/'.$date); |
5 | 7 | ?> |
6 | 8 | \ No newline at end of file |
@@ -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"; |
@@ -1280,8 +1338,11 @@ discard block |
||
1280 | 1338 | if ($Connection->tableExists('aircraft')) { |
1281 | 1339 | if (!$Connection->tableExists('config')) { |
1282 | 1340 | $version = '1'; |
1283 | - if ($update) return self::update_from_1(); |
|
1284 | - else return $version; |
|
1341 | + if ($update) { |
|
1342 | + return self::update_from_1(); |
|
1343 | + } else { |
|
1344 | + return $version; |
|
1345 | + } |
|
1285 | 1346 | } else { |
1286 | 1347 | $Connection = new Connection(); |
1287 | 1348 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
@@ -1295,126 +1356,218 @@ discard block |
||
1295 | 1356 | if ($update) { |
1296 | 1357 | if ($result['value'] == '2') { |
1297 | 1358 | $error = self::update_from_2(); |
1298 | - if ($error != '') return $error; |
|
1299 | - else return self::check_version(true); |
|
1359 | + if ($error != '') { |
|
1360 | + return $error; |
|
1361 | + } else { |
|
1362 | + return self::check_version(true); |
|
1363 | + } |
|
1300 | 1364 | } elseif ($result['value'] == '3') { |
1301 | 1365 | $error = self::update_from_3(); |
1302 | - if ($error != '') return $error; |
|
1303 | - else return self::check_version(true); |
|
1366 | + if ($error != '') { |
|
1367 | + return $error; |
|
1368 | + } else { |
|
1369 | + return self::check_version(true); |
|
1370 | + } |
|
1304 | 1371 | } elseif ($result['value'] == '4') { |
1305 | 1372 | $error = self::update_from_4(); |
1306 | - if ($error != '') return $error; |
|
1307 | - else return self::check_version(true); |
|
1373 | + if ($error != '') { |
|
1374 | + return $error; |
|
1375 | + } else { |
|
1376 | + return self::check_version(true); |
|
1377 | + } |
|
1308 | 1378 | } elseif ($result['value'] == '5') { |
1309 | 1379 | $error = self::update_from_5(); |
1310 | - if ($error != '') return $error; |
|
1311 | - else return self::check_version(true); |
|
1380 | + if ($error != '') { |
|
1381 | + return $error; |
|
1382 | + } else { |
|
1383 | + return self::check_version(true); |
|
1384 | + } |
|
1312 | 1385 | } elseif ($result['value'] == '6') { |
1313 | 1386 | $error = self::update_from_6(); |
1314 | - if ($error != '') return $error; |
|
1315 | - else return self::check_version(true); |
|
1387 | + if ($error != '') { |
|
1388 | + return $error; |
|
1389 | + } else { |
|
1390 | + return self::check_version(true); |
|
1391 | + } |
|
1316 | 1392 | } elseif ($result['value'] == '7') { |
1317 | 1393 | $error = self::update_from_7(); |
1318 | - if ($error != '') return $error; |
|
1319 | - else return self::check_version(true); |
|
1394 | + if ($error != '') { |
|
1395 | + return $error; |
|
1396 | + } else { |
|
1397 | + return self::check_version(true); |
|
1398 | + } |
|
1320 | 1399 | } elseif ($result['value'] == '8') { |
1321 | 1400 | $error = self::update_from_8(); |
1322 | - if ($error != '') return $error; |
|
1323 | - else return self::check_version(true); |
|
1401 | + if ($error != '') { |
|
1402 | + return $error; |
|
1403 | + } else { |
|
1404 | + return self::check_version(true); |
|
1405 | + } |
|
1324 | 1406 | } elseif ($result['value'] == '9') { |
1325 | 1407 | $error = self::update_from_9(); |
1326 | - if ($error != '') return $error; |
|
1327 | - else return self::check_version(true); |
|
1408 | + if ($error != '') { |
|
1409 | + return $error; |
|
1410 | + } else { |
|
1411 | + return self::check_version(true); |
|
1412 | + } |
|
1328 | 1413 | } elseif ($result['value'] == '10') { |
1329 | 1414 | $error = self::update_from_10(); |
1330 | - if ($error != '') return $error; |
|
1331 | - else return self::check_version(true); |
|
1415 | + if ($error != '') { |
|
1416 | + return $error; |
|
1417 | + } else { |
|
1418 | + return self::check_version(true); |
|
1419 | + } |
|
1332 | 1420 | } elseif ($result['value'] == '11') { |
1333 | 1421 | $error = self::update_from_11(); |
1334 | - if ($error != '') return $error; |
|
1335 | - else return self::check_version(true); |
|
1422 | + if ($error != '') { |
|
1423 | + return $error; |
|
1424 | + } else { |
|
1425 | + return self::check_version(true); |
|
1426 | + } |
|
1336 | 1427 | } elseif ($result['value'] == '12') { |
1337 | 1428 | $error = self::update_from_12(); |
1338 | - if ($error != '') return $error; |
|
1339 | - else return self::check_version(true); |
|
1429 | + if ($error != '') { |
|
1430 | + return $error; |
|
1431 | + } else { |
|
1432 | + return self::check_version(true); |
|
1433 | + } |
|
1340 | 1434 | } elseif ($result['value'] == '13') { |
1341 | 1435 | $error = self::update_from_13(); |
1342 | - if ($error != '') return $error; |
|
1343 | - else return self::check_version(true); |
|
1436 | + if ($error != '') { |
|
1437 | + return $error; |
|
1438 | + } else { |
|
1439 | + return self::check_version(true); |
|
1440 | + } |
|
1344 | 1441 | } elseif ($result['value'] == '14') { |
1345 | 1442 | $error = self::update_from_14(); |
1346 | - if ($error != '') return $error; |
|
1347 | - else return self::check_version(true); |
|
1443 | + if ($error != '') { |
|
1444 | + return $error; |
|
1445 | + } else { |
|
1446 | + return self::check_version(true); |
|
1447 | + } |
|
1348 | 1448 | } elseif ($result['value'] == '15') { |
1349 | 1449 | $error = self::update_from_15(); |
1350 | - if ($error != '') return $error; |
|
1351 | - else return self::check_version(true); |
|
1450 | + if ($error != '') { |
|
1451 | + return $error; |
|
1452 | + } else { |
|
1453 | + return self::check_version(true); |
|
1454 | + } |
|
1352 | 1455 | } elseif ($result['value'] == '16') { |
1353 | 1456 | $error = self::update_from_16(); |
1354 | - if ($error != '') return $error; |
|
1355 | - else return self::check_version(true); |
|
1457 | + if ($error != '') { |
|
1458 | + return $error; |
|
1459 | + } else { |
|
1460 | + return self::check_version(true); |
|
1461 | + } |
|
1356 | 1462 | } elseif ($result['value'] == '17') { |
1357 | 1463 | $error = self::update_from_17(); |
1358 | - if ($error != '') return $error; |
|
1359 | - else return self::check_version(true); |
|
1464 | + if ($error != '') { |
|
1465 | + return $error; |
|
1466 | + } else { |
|
1467 | + return self::check_version(true); |
|
1468 | + } |
|
1360 | 1469 | } elseif ($result['value'] == '18') { |
1361 | 1470 | $error = self::update_from_18(); |
1362 | - if ($error != '') return $error; |
|
1363 | - else return self::check_version(true); |
|
1471 | + if ($error != '') { |
|
1472 | + return $error; |
|
1473 | + } else { |
|
1474 | + return self::check_version(true); |
|
1475 | + } |
|
1364 | 1476 | } elseif ($result['value'] == '19') { |
1365 | 1477 | $error = self::update_from_19(); |
1366 | - if ($error != '') return $error; |
|
1367 | - else return self::check_version(true); |
|
1478 | + if ($error != '') { |
|
1479 | + return $error; |
|
1480 | + } else { |
|
1481 | + return self::check_version(true); |
|
1482 | + } |
|
1368 | 1483 | } elseif ($result['value'] == '20') { |
1369 | 1484 | $error = self::update_from_20(); |
1370 | - if ($error != '') return $error; |
|
1371 | - else return self::check_version(true); |
|
1485 | + if ($error != '') { |
|
1486 | + return $error; |
|
1487 | + } else { |
|
1488 | + return self::check_version(true); |
|
1489 | + } |
|
1372 | 1490 | } elseif ($result['value'] == '21') { |
1373 | 1491 | $error = self::update_from_21(); |
1374 | - if ($error != '') return $error; |
|
1375 | - else return self::check_version(true); |
|
1492 | + if ($error != '') { |
|
1493 | + return $error; |
|
1494 | + } else { |
|
1495 | + return self::check_version(true); |
|
1496 | + } |
|
1376 | 1497 | } elseif ($result['value'] == '22') { |
1377 | 1498 | $error = self::update_from_22(); |
1378 | - if ($error != '') return $error; |
|
1379 | - else return self::check_version(true); |
|
1499 | + if ($error != '') { |
|
1500 | + return $error; |
|
1501 | + } else { |
|
1502 | + return self::check_version(true); |
|
1503 | + } |
|
1380 | 1504 | } elseif ($result['value'] == '23') { |
1381 | 1505 | $error = self::update_from_23(); |
1382 | - if ($error != '') return $error; |
|
1383 | - else return self::check_version(true); |
|
1506 | + if ($error != '') { |
|
1507 | + return $error; |
|
1508 | + } else { |
|
1509 | + return self::check_version(true); |
|
1510 | + } |
|
1384 | 1511 | } elseif ($result['value'] == '24') { |
1385 | 1512 | $error = self::update_from_24(); |
1386 | - if ($error != '') return $error; |
|
1387 | - else return self::check_version(true); |
|
1513 | + if ($error != '') { |
|
1514 | + return $error; |
|
1515 | + } else { |
|
1516 | + return self::check_version(true); |
|
1517 | + } |
|
1388 | 1518 | } elseif ($result['value'] == '25') { |
1389 | 1519 | $error = self::update_from_25(); |
1390 | - if ($error != '') return $error; |
|
1391 | - else return self::check_version(true); |
|
1520 | + if ($error != '') { |
|
1521 | + return $error; |
|
1522 | + } else { |
|
1523 | + return self::check_version(true); |
|
1524 | + } |
|
1392 | 1525 | } elseif ($result['value'] == '26') { |
1393 | 1526 | $error = self::update_from_26(); |
1394 | - if ($error != '') return $error; |
|
1395 | - else return self::check_version(true); |
|
1527 | + if ($error != '') { |
|
1528 | + return $error; |
|
1529 | + } else { |
|
1530 | + return self::check_version(true); |
|
1531 | + } |
|
1396 | 1532 | } elseif ($result['value'] == '27') { |
1397 | 1533 | $error = self::update_from_27(); |
1398 | - if ($error != '') return $error; |
|
1399 | - else return self::check_version(true); |
|
1534 | + if ($error != '') { |
|
1535 | + return $error; |
|
1536 | + } else { |
|
1537 | + return self::check_version(true); |
|
1538 | + } |
|
1400 | 1539 | } elseif ($result['value'] == '28') { |
1401 | 1540 | $error = self::update_from_28(); |
1402 | - if ($error != '') return $error; |
|
1403 | - else return self::check_version(true); |
|
1541 | + if ($error != '') { |
|
1542 | + return $error; |
|
1543 | + } else { |
|
1544 | + return self::check_version(true); |
|
1545 | + } |
|
1404 | 1546 | } elseif ($result['value'] == '29') { |
1405 | 1547 | $error = self::update_from_29(); |
1406 | - if ($error != '') return $error; |
|
1407 | - else return self::check_version(true); |
|
1548 | + if ($error != '') { |
|
1549 | + return $error; |
|
1550 | + } else { |
|
1551 | + return self::check_version(true); |
|
1552 | + } |
|
1408 | 1553 | } elseif ($result['value'] == '30') { |
1409 | 1554 | $error = self::update_from_30(); |
1410 | - if ($error != '') return $error; |
|
1411 | - else return self::check_version(true); |
|
1412 | - } else return ''; |
|
1555 | + if ($error != '') { |
|
1556 | + return $error; |
|
1557 | + } else { |
|
1558 | + return self::check_version(true); |
|
1559 | + } |
|
1560 | + } else { |
|
1561 | + return ''; |
|
1562 | + } |
|
1563 | + } else { |
|
1564 | + return $result['value']; |
|
1413 | 1565 | } |
1414 | - else return $result['value']; |
|
1415 | 1566 | } |
1416 | 1567 | |
1417 | - } else return $version; |
|
1568 | + } else { |
|
1569 | + return $version; |
|
1570 | + } |
|
1418 | 1571 | } |
1419 | 1572 | |
1420 | 1573 | } |
@@ -85,8 +85,11 @@ discard block |
||
85 | 85 | $data = array(); |
86 | 86 | if ($row['registration'] != '') { |
87 | 87 | $image_array = $Image->getSpotterImage($row['registration']); |
88 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
89 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
88 | + if (count($image_array) > 0) { |
|
89 | + $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
90 | + } else { |
|
91 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
92 | + } |
|
90 | 93 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
91 | 94 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
92 | 95 | if (!empty($aircraft_info)) { |
@@ -102,32 +105,50 @@ discard block |
||
102 | 105 | $data['aircraft_base'] = $owner_data['base']; |
103 | 106 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
104 | 107 | } |
105 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
106 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
107 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
108 | + } else { |
|
109 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
110 | + } |
|
111 | + if ($row['registration'] == '') { |
|
112 | + $row['registration'] = 'NA'; |
|
113 | + } |
|
114 | + if ($row['ident'] == '') { |
|
115 | + $row['ident'] = 'NA'; |
|
116 | + } |
|
108 | 117 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
109 | 118 | if (isset($identicao[0])) { |
110 | 119 | if (substr($row['ident'],0,2) == 'AF') { |
111 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
112 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
113 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
120 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
121 | + $icao = $row['ident']; |
|
122 | + } else { |
|
123 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
124 | + } |
|
125 | + } else { |
|
126 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
127 | + } |
|
114 | 128 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
115 | - } else $icao = $row['ident']; |
|
129 | + } else { |
|
130 | + $icao = $row['ident']; |
|
131 | + } |
|
116 | 132 | $icao = $Translation->checkTranslation($icao,false); |
117 | 133 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
118 | 134 | $data = array_merge($row,$data); |
119 | - if ($data['ident'] == null) $data['ident'] = $icao; |
|
135 | + if ($data['ident'] == null) { |
|
136 | + $data['ident'] = $icao; |
|
137 | + } |
|
120 | 138 | if ($data['title'] == null) { |
121 | 139 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
122 | - } else $data['message'] = strtolower($data['title']); |
|
140 | + } else { |
|
141 | + $data['message'] = strtolower($data['title']); |
|
142 | + } |
|
123 | 143 | $result[] = $data; |
124 | 144 | $i++; |
125 | 145 | } |
126 | 146 | if (isset($result)) { |
127 | 147 | $result[0]['query_number_rows'] = $i; |
128 | 148 | return $result; |
149 | + } else { |
|
150 | + return array(); |
|
129 | 151 | } |
130 | - else return array(); |
|
131 | 152 | } |
132 | 153 | |
133 | 154 | |
@@ -137,7 +158,9 @@ discard block |
||
137 | 158 | */ |
138 | 159 | public function import($file) { |
139 | 160 | global $globalTransaction, $globalDebug; |
140 | - if ($globalDebug) echo 'Import '.$file."\n"; |
|
161 | + if ($globalDebug) { |
|
162 | + echo 'Import '.$file."\n"; |
|
163 | + } |
|
141 | 164 | $result = array(); |
142 | 165 | if (file_exists($file)) { |
143 | 166 | if (($handle = fopen($file,'r')) !== FALSE) { |
@@ -148,8 +171,11 @@ discard block |
||
148 | 171 | } |
149 | 172 | fclose($handle); |
150 | 173 | } |
151 | - if (!empty($result)) $this->add($result,true); |
|
152 | - elseif ($globalDebug) echo 'Nothing to import'; |
|
174 | + if (!empty($result)) { |
|
175 | + $this->add($result,true); |
|
176 | + } elseif ($globalDebug) { |
|
177 | + echo 'Nothing to import'; |
|
178 | + } |
|
153 | 179 | } |
154 | 180 | } |
155 | 181 | |
@@ -182,14 +208,23 @@ discard block |
||
182 | 208 | } |
183 | 209 | } |
184 | 210 | fclose($handle); |
185 | - } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
186 | - } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
211 | + } elseif ($globalDebug) { |
|
212 | + echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
213 | + } |
|
214 | + } elseif ($globalDebug) { |
|
215 | + echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
216 | + } |
|
187 | 217 | $result = $Common->arr_diff($all_md5_new,$all_md5); |
188 | - if (empty($result) && $globalDebug) echo 'Nothing to update'; |
|
218 | + if (empty($result) && $globalDebug) { |
|
219 | + echo 'Nothing to update'; |
|
220 | + } |
|
189 | 221 | foreach ($result as $file => $md5) { |
190 | 222 | $Common->download('https://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
191 | - if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
192 | - elseif ($globalDebug) echo 'Download '.$file.' failed'; |
|
223 | + if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) { |
|
224 | + $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
225 | + } elseif ($globalDebug) { |
|
226 | + echo 'Download '.$file.' failed'; |
|
227 | + } |
|
193 | 228 | } |
194 | 229 | } |
195 | 230 | |
@@ -200,13 +235,17 @@ discard block |
||
200 | 235 | $Connection = new Connection(); |
201 | 236 | $Image = new Image(); |
202 | 237 | |
203 | - if (empty($crash)) return false; |
|
238 | + if (empty($crash)) { |
|
239 | + return false; |
|
240 | + } |
|
204 | 241 | if (!$new) { |
205 | 242 | $query_delete = 'DELETE FROM accidents WHERE source = :source'; |
206 | 243 | $sthd = $Connection->db->prepare($query_delete); |
207 | 244 | $sthd->execute(array(':source' => $crash[0]['source'])); |
208 | 245 | } |
209 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
246 | + if ($globalTransaction) { |
|
247 | + $Connection->db->beginTransaction(); |
|
248 | + } |
|
210 | 249 | $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null); |
211 | 250 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
212 | 251 | $sth_check = $Connection->db->prepare($query_check); |
@@ -241,9 +280,13 @@ discard block |
||
241 | 280 | $Connection->db->beginTransaction(); |
242 | 281 | } |
243 | 282 | } |
244 | - if ($globalTransaction) $Connection->db->commit(); |
|
283 | + if ($globalTransaction) { |
|
284 | + $Connection->db->commit(); |
|
285 | + } |
|
245 | 286 | } catch(PDOException $e) { |
246 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
287 | + if ($globalTransaction) { |
|
288 | + $Connection->db->rollBack(); |
|
289 | + } |
|
247 | 290 | echo $e->getMessage(); |
248 | 291 | } |
249 | 292 | $sth_check->closeCursor(); |
@@ -278,8 +321,11 @@ discard block |
||
278 | 321 | return "error : ".$e->getMessage(); |
279 | 322 | } |
280 | 323 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
281 | - if ($row['nb'] > 0) return false; |
|
282 | - else return true; |
|
324 | + if ($row['nb'] > 0) { |
|
325 | + return false; |
|
326 | + } else { |
|
327 | + return true; |
|
328 | + } |
|
283 | 329 | } |
284 | 330 | |
285 | 331 | public static function insert_last_accidents_update() { |