@@ -4,7 +4,9 @@ |
||
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Stats = new Stats(); |
6 | 6 | $title = _("Statistics").' - '._("Most common Airline by Country"); |
7 | -if (!isset($filter_name)) $filter_name = ''; |
|
7 | +if (!isset($filter_name)) { |
|
8 | + $filter_name = ''; |
|
9 | +} |
|
8 | 10 | require_once('header.php'); |
9 | 11 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
10 | 12 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
@@ -5,7 +5,9 @@ |
||
5 | 5 | $Stats = new Stats(); |
6 | 6 | $title = _("Statistics").' - '._("Most common Airline"); |
7 | 7 | require_once('header.php'); |
8 | -if (!isset($filter_name)) $filter_name = ''; |
|
8 | +if (!isset($filter_name)) { |
|
9 | + $filter_name = ''; |
|
10 | +} |
|
9 | 11 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
10 | 12 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
11 | 13 | include('statistics-sub-menu.php'); |
@@ -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"; |
@@ -1332,20 +1390,28 @@ discard block |
||
1332 | 1390 | } |
1333 | 1391 | if ($globalDBdriver == 'mysql') { |
1334 | 1392 | $error .= create_db::import_file('../db/airlines.sql'); |
1335 | - if ($error != '') return $error; |
|
1393 | + if ($error != '') { |
|
1394 | + return $error; |
|
1395 | + } |
|
1336 | 1396 | } else { |
1337 | 1397 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
1338 | - if ($error != '') return $error; |
|
1398 | + if ($error != '') { |
|
1399 | + return $error; |
|
1400 | + } |
|
1339 | 1401 | } |
1340 | 1402 | if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) { |
1341 | 1403 | include_once(dirname(__FILE__).'/class.update_db.php'); |
1342 | 1404 | if (isset($globalVATSIM) && $globalVATSIM) { |
1343 | 1405 | $error .= update_db::update_vatsim(); |
1344 | - if ($error != '') return $error; |
|
1406 | + if ($error != '') { |
|
1407 | + return $error; |
|
1408 | + } |
|
1345 | 1409 | } |
1346 | 1410 | if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) { |
1347 | 1411 | $error .= update_db::update_IVAO(); |
1348 | - if ($error != '') return $error; |
|
1412 | + if ($error != '') { |
|
1413 | + return $error; |
|
1414 | + } |
|
1349 | 1415 | } |
1350 | 1416 | } |
1351 | 1417 | |
@@ -1391,8 +1457,11 @@ discard block |
||
1391 | 1457 | if ($Connection->tableExists('aircraft')) { |
1392 | 1458 | if (!$Connection->tableExists('config')) { |
1393 | 1459 | $version = '1'; |
1394 | - if ($update) return self::update_from_1(); |
|
1395 | - else return $version; |
|
1460 | + if ($update) { |
|
1461 | + return self::update_from_1(); |
|
1462 | + } else { |
|
1463 | + return $version; |
|
1464 | + } |
|
1396 | 1465 | } else { |
1397 | 1466 | $Connection = new Connection(); |
1398 | 1467 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
@@ -1406,138 +1475,239 @@ discard block |
||
1406 | 1475 | if ($update) { |
1407 | 1476 | if ($result['value'] == '2') { |
1408 | 1477 | $error = self::update_from_2(); |
1409 | - if ($error != '') return $error; |
|
1410 | - else return self::check_version(true); |
|
1478 | + if ($error != '') { |
|
1479 | + return $error; |
|
1480 | + } else { |
|
1481 | + return self::check_version(true); |
|
1482 | + } |
|
1411 | 1483 | } elseif ($result['value'] == '3') { |
1412 | 1484 | $error = self::update_from_3(); |
1413 | - if ($error != '') return $error; |
|
1414 | - else return self::check_version(true); |
|
1485 | + if ($error != '') { |
|
1486 | + return $error; |
|
1487 | + } else { |
|
1488 | + return self::check_version(true); |
|
1489 | + } |
|
1415 | 1490 | } elseif ($result['value'] == '4') { |
1416 | 1491 | $error = self::update_from_4(); |
1417 | - if ($error != '') return $error; |
|
1418 | - else return self::check_version(true); |
|
1492 | + if ($error != '') { |
|
1493 | + return $error; |
|
1494 | + } else { |
|
1495 | + return self::check_version(true); |
|
1496 | + } |
|
1419 | 1497 | } elseif ($result['value'] == '5') { |
1420 | 1498 | $error = self::update_from_5(); |
1421 | - if ($error != '') return $error; |
|
1422 | - else return self::check_version(true); |
|
1499 | + if ($error != '') { |
|
1500 | + return $error; |
|
1501 | + } else { |
|
1502 | + return self::check_version(true); |
|
1503 | + } |
|
1423 | 1504 | } elseif ($result['value'] == '6') { |
1424 | 1505 | $error = self::update_from_6(); |
1425 | - if ($error != '') return $error; |
|
1426 | - else return self::check_version(true); |
|
1506 | + if ($error != '') { |
|
1507 | + return $error; |
|
1508 | + } else { |
|
1509 | + return self::check_version(true); |
|
1510 | + } |
|
1427 | 1511 | } elseif ($result['value'] == '7') { |
1428 | 1512 | $error = self::update_from_7(); |
1429 | - if ($error != '') return $error; |
|
1430 | - else return self::check_version(true); |
|
1513 | + if ($error != '') { |
|
1514 | + return $error; |
|
1515 | + } else { |
|
1516 | + return self::check_version(true); |
|
1517 | + } |
|
1431 | 1518 | } elseif ($result['value'] == '8') { |
1432 | 1519 | $error = self::update_from_8(); |
1433 | - if ($error != '') return $error; |
|
1434 | - else return self::check_version(true); |
|
1520 | + if ($error != '') { |
|
1521 | + return $error; |
|
1522 | + } else { |
|
1523 | + return self::check_version(true); |
|
1524 | + } |
|
1435 | 1525 | } elseif ($result['value'] == '9') { |
1436 | 1526 | $error = self::update_from_9(); |
1437 | - if ($error != '') return $error; |
|
1438 | - else return self::check_version(true); |
|
1527 | + if ($error != '') { |
|
1528 | + return $error; |
|
1529 | + } else { |
|
1530 | + return self::check_version(true); |
|
1531 | + } |
|
1439 | 1532 | } elseif ($result['value'] == '10') { |
1440 | 1533 | $error = self::update_from_10(); |
1441 | - if ($error != '') return $error; |
|
1442 | - else return self::check_version(true); |
|
1534 | + if ($error != '') { |
|
1535 | + return $error; |
|
1536 | + } else { |
|
1537 | + return self::check_version(true); |
|
1538 | + } |
|
1443 | 1539 | } elseif ($result['value'] == '11') { |
1444 | 1540 | $error = self::update_from_11(); |
1445 | - if ($error != '') return $error; |
|
1446 | - else return self::check_version(true); |
|
1541 | + if ($error != '') { |
|
1542 | + return $error; |
|
1543 | + } else { |
|
1544 | + return self::check_version(true); |
|
1545 | + } |
|
1447 | 1546 | } elseif ($result['value'] == '12') { |
1448 | 1547 | $error = self::update_from_12(); |
1449 | - if ($error != '') return $error; |
|
1450 | - else return self::check_version(true); |
|
1548 | + if ($error != '') { |
|
1549 | + return $error; |
|
1550 | + } else { |
|
1551 | + return self::check_version(true); |
|
1552 | + } |
|
1451 | 1553 | } elseif ($result['value'] == '13') { |
1452 | 1554 | $error = self::update_from_13(); |
1453 | - if ($error != '') return $error; |
|
1454 | - else return self::check_version(true); |
|
1555 | + if ($error != '') { |
|
1556 | + return $error; |
|
1557 | + } else { |
|
1558 | + return self::check_version(true); |
|
1559 | + } |
|
1455 | 1560 | } elseif ($result['value'] == '14') { |
1456 | 1561 | $error = self::update_from_14(); |
1457 | - if ($error != '') return $error; |
|
1458 | - else return self::check_version(true); |
|
1562 | + if ($error != '') { |
|
1563 | + return $error; |
|
1564 | + } else { |
|
1565 | + return self::check_version(true); |
|
1566 | + } |
|
1459 | 1567 | } elseif ($result['value'] == '15') { |
1460 | 1568 | $error = self::update_from_15(); |
1461 | - if ($error != '') return $error; |
|
1462 | - else return self::check_version(true); |
|
1569 | + if ($error != '') { |
|
1570 | + return $error; |
|
1571 | + } else { |
|
1572 | + return self::check_version(true); |
|
1573 | + } |
|
1463 | 1574 | } elseif ($result['value'] == '16') { |
1464 | 1575 | $error = self::update_from_16(); |
1465 | - if ($error != '') return $error; |
|
1466 | - else return self::check_version(true); |
|
1576 | + if ($error != '') { |
|
1577 | + return $error; |
|
1578 | + } else { |
|
1579 | + return self::check_version(true); |
|
1580 | + } |
|
1467 | 1581 | } elseif ($result['value'] == '17') { |
1468 | 1582 | $error = self::update_from_17(); |
1469 | - if ($error != '') return $error; |
|
1470 | - else return self::check_version(true); |
|
1583 | + if ($error != '') { |
|
1584 | + return $error; |
|
1585 | + } else { |
|
1586 | + return self::check_version(true); |
|
1587 | + } |
|
1471 | 1588 | } elseif ($result['value'] == '18') { |
1472 | 1589 | $error = self::update_from_18(); |
1473 | - if ($error != '') return $error; |
|
1474 | - else return self::check_version(true); |
|
1590 | + if ($error != '') { |
|
1591 | + return $error; |
|
1592 | + } else { |
|
1593 | + return self::check_version(true); |
|
1594 | + } |
|
1475 | 1595 | } elseif ($result['value'] == '19') { |
1476 | 1596 | $error = self::update_from_19(); |
1477 | - if ($error != '') return $error; |
|
1478 | - else return self::check_version(true); |
|
1597 | + if ($error != '') { |
|
1598 | + return $error; |
|
1599 | + } else { |
|
1600 | + return self::check_version(true); |
|
1601 | + } |
|
1479 | 1602 | } elseif ($result['value'] == '20') { |
1480 | 1603 | $error = self::update_from_20(); |
1481 | - if ($error != '') return $error; |
|
1482 | - else return self::check_version(true); |
|
1604 | + if ($error != '') { |
|
1605 | + return $error; |
|
1606 | + } else { |
|
1607 | + return self::check_version(true); |
|
1608 | + } |
|
1483 | 1609 | } elseif ($result['value'] == '21') { |
1484 | 1610 | $error = self::update_from_21(); |
1485 | - if ($error != '') return $error; |
|
1486 | - else return self::check_version(true); |
|
1611 | + if ($error != '') { |
|
1612 | + return $error; |
|
1613 | + } else { |
|
1614 | + return self::check_version(true); |
|
1615 | + } |
|
1487 | 1616 | } elseif ($result['value'] == '22') { |
1488 | 1617 | $error = self::update_from_22(); |
1489 | - if ($error != '') return $error; |
|
1490 | - else return self::check_version(true); |
|
1618 | + if ($error != '') { |
|
1619 | + return $error; |
|
1620 | + } else { |
|
1621 | + return self::check_version(true); |
|
1622 | + } |
|
1491 | 1623 | } elseif ($result['value'] == '23') { |
1492 | 1624 | $error = self::update_from_23(); |
1493 | - if ($error != '') return $error; |
|
1494 | - else return self::check_version(true); |
|
1625 | + if ($error != '') { |
|
1626 | + return $error; |
|
1627 | + } else { |
|
1628 | + return self::check_version(true); |
|
1629 | + } |
|
1495 | 1630 | } elseif ($result['value'] == '24') { |
1496 | 1631 | $error = self::update_from_24(); |
1497 | - if ($error != '') return $error; |
|
1498 | - else return self::check_version(true); |
|
1632 | + if ($error != '') { |
|
1633 | + return $error; |
|
1634 | + } else { |
|
1635 | + return self::check_version(true); |
|
1636 | + } |
|
1499 | 1637 | } elseif ($result['value'] == '25') { |
1500 | 1638 | $error = self::update_from_25(); |
1501 | - if ($error != '') return $error; |
|
1502 | - else return self::check_version(true); |
|
1639 | + if ($error != '') { |
|
1640 | + return $error; |
|
1641 | + } else { |
|
1642 | + return self::check_version(true); |
|
1643 | + } |
|
1503 | 1644 | } elseif ($result['value'] == '26') { |
1504 | 1645 | $error = self::update_from_26(); |
1505 | - if ($error != '') return $error; |
|
1506 | - else return self::check_version(true); |
|
1646 | + if ($error != '') { |
|
1647 | + return $error; |
|
1648 | + } else { |
|
1649 | + return self::check_version(true); |
|
1650 | + } |
|
1507 | 1651 | } elseif ($result['value'] == '27') { |
1508 | 1652 | $error = self::update_from_27(); |
1509 | - if ($error != '') return $error; |
|
1510 | - else return self::check_version(true); |
|
1653 | + if ($error != '') { |
|
1654 | + return $error; |
|
1655 | + } else { |
|
1656 | + return self::check_version(true); |
|
1657 | + } |
|
1511 | 1658 | } elseif ($result['value'] == '28') { |
1512 | 1659 | $error = self::update_from_28(); |
1513 | - if ($error != '') return $error; |
|
1514 | - else return self::check_version(true); |
|
1660 | + if ($error != '') { |
|
1661 | + return $error; |
|
1662 | + } else { |
|
1663 | + return self::check_version(true); |
|
1664 | + } |
|
1515 | 1665 | } elseif ($result['value'] == '29') { |
1516 | 1666 | $error = self::update_from_29(); |
1517 | - if ($error != '') return $error; |
|
1518 | - else return self::check_version(true); |
|
1667 | + if ($error != '') { |
|
1668 | + return $error; |
|
1669 | + } else { |
|
1670 | + return self::check_version(true); |
|
1671 | + } |
|
1519 | 1672 | } elseif ($result['value'] == '30') { |
1520 | 1673 | $error = self::update_from_30(); |
1521 | - if ($error != '') return $error; |
|
1522 | - else return self::check_version(true); |
|
1674 | + if ($error != '') { |
|
1675 | + return $error; |
|
1676 | + } else { |
|
1677 | + return self::check_version(true); |
|
1678 | + } |
|
1523 | 1679 | } elseif ($result['value'] == '31') { |
1524 | 1680 | $error = self::update_from_31(); |
1525 | - if ($error != '') return $error; |
|
1526 | - else return self::check_version(true); |
|
1681 | + if ($error != '') { |
|
1682 | + return $error; |
|
1683 | + } else { |
|
1684 | + return self::check_version(true); |
|
1685 | + } |
|
1527 | 1686 | } elseif ($result['value'] == '32') { |
1528 | 1687 | $error = self::update_from_32(); |
1529 | - if ($error != '') return $error; |
|
1530 | - else return self::check_version(true); |
|
1688 | + if ($error != '') { |
|
1689 | + return $error; |
|
1690 | + } else { |
|
1691 | + return self::check_version(true); |
|
1692 | + } |
|
1531 | 1693 | } elseif ($result['value'] == '33') { |
1532 | 1694 | $error = self::update_from_33(); |
1533 | - if ($error != '') return $error; |
|
1534 | - else return self::check_version(true); |
|
1535 | - } else return ''; |
|
1695 | + if ($error != '') { |
|
1696 | + return $error; |
|
1697 | + } else { |
|
1698 | + return self::check_version(true); |
|
1699 | + } |
|
1700 | + } else { |
|
1701 | + return ''; |
|
1702 | + } |
|
1703 | + } else { |
|
1704 | + return $result['value']; |
|
1536 | 1705 | } |
1537 | - else return $result['value']; |
|
1538 | 1706 | } |
1539 | 1707 | |
1540 | - } else return $version; |
|
1708 | + } else { |
|
1709 | + return $version; |
|
1710 | + } |
|
1541 | 1711 | } |
1542 | 1712 | |
1543 | 1713 | } |
@@ -31,7 +31,9 @@ discard block |
||
31 | 31 | } |
32 | 32 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
33 | 33 | } |
34 | - if ($firstLetter != "'") $previous = $firstLetter; |
|
34 | + if ($firstLetter != "'") { |
|
35 | + $previous = $firstLetter; |
|
36 | + } |
|
35 | 37 | } |
36 | 38 | print '</div>'; |
37 | 39 | $previous = null; |
@@ -46,10 +48,15 @@ discard block |
||
46 | 48 | } |
47 | 49 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
48 | 50 | } |
49 | - if ($firstLetter != "'") $previous = $firstLetter; |
|
51 | + if ($firstLetter != "'") { |
|
52 | + $previous = $firstLetter; |
|
53 | + } |
|
50 | 54 | print '<div class="alphabet-item">'; |
51 | - if (isset($value['pilot_id']) && $value['pilot_id'] != '') print '<a href="'.$globalURL.'/pilot/'.$value['pilot_id'].'">'.$value['pilot_name'].' ('.$value['pilot_id'].')'; |
|
52 | - else print '<a href="'.$globalURL.'/pilot/'.$value['pilot_name'].'">'.$value['pilot_name']; |
|
55 | + if (isset($value['pilot_id']) && $value['pilot_id'] != '') { |
|
56 | + print '<a href="'.$globalURL.'/pilot/'.$value['pilot_id'].'">'.$value['pilot_name'].' ('.$value['pilot_id'].')'; |
|
57 | + } else { |
|
58 | + print '<a href="'.$globalURL.'/pilot/'.$value['pilot_name'].'">'.$value['pilot_name']; |
|
59 | + } |
|
53 | 60 | print '</a>'; |
54 | 61 | print '</div>'; |
55 | 62 | } |
@@ -53,8 +53,12 @@ |
||
53 | 53 | { |
54 | 54 | $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']); |
55 | 55 | //$ident = $spotter_array[0]['ident']; |
56 | - if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude']; |
|
57 | - if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude']; |
|
56 | + if (isset($spotter_array[0]['latitude'])) { |
|
57 | + $latitude = $spotter_array[0]['latitude']; |
|
58 | + } |
|
59 | + if (isset($spotter_array[0]['longitude'])) { |
|
60 | + $longitude = $spotter_array[0]['longitude']; |
|
61 | + } |
|
58 | 62 | require_once('header.php'); |
59 | 63 | /* |
60 | 64 | if (isset($globalArchive) && $globalArchive) { |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | } |
34 | 34 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
35 | 35 | } |
36 | - if ($firstLetter != "'" && $firstLetter != '"') $previous = $firstLetter; |
|
36 | + if ($firstLetter != "'" && $firstLetter != '"') { |
|
37 | + $previous = $firstLetter; |
|
38 | + } |
|
37 | 39 | } |
38 | 40 | print '</div>'; |
39 | 41 | $previous = null; |
@@ -48,7 +50,9 @@ discard block |
||
48 | 50 | } |
49 | 51 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
50 | 52 | } |
51 | - if ($firstLetter != "'" && $firstLetter != '"') $previous = $firstLetter; |
|
53 | + if ($firstLetter != "'" && $firstLetter != '"') { |
|
54 | + $previous = $firstLetter; |
|
55 | + } |
|
52 | 56 | print '<div class="alphabet-item">'; |
53 | 57 | print '<a href="'.$globalURL.'/owner/'.$value['owner_name'].'">'; |
54 | 58 | print $value['owner_name']; |
@@ -27,8 +27,11 @@ discard block |
||
27 | 27 | } else { |
28 | 28 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
29 | 29 | } |
30 | - if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
31 | - else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
30 | + if ($timeout == '') { |
|
31 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
32 | + } else { |
|
33 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
34 | + } |
|
32 | 35 | curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
33 | 36 | if ($type == 'post') { |
34 | 37 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -74,8 +77,9 @@ discard block |
||
74 | 77 | private function curlResponseHeaderCallback($ch, $headerLine) { |
75 | 78 | //global $cookies; |
76 | 79 | $cookies = array(); |
77 | - if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) |
|
78 | - $cookies[] = $cookie; |
|
80 | + if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) { |
|
81 | + $cookies[] = $cookie; |
|
82 | + } |
|
79 | 83 | return strlen($headerLine); // Needed by curl |
80 | 84 | } |
81 | 85 | |
@@ -86,11 +90,15 @@ discard block |
||
86 | 90 | curl_setopt($ch, CURLOPT_URL, $url); |
87 | 91 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
88 | 92 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
89 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
93 | + if ($referer != '') { |
|
94 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
95 | + } |
|
90 | 96 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
91 | 97 | curl_setopt($ch, CURLOPT_FILE, $fp); |
92 | 98 | curl_exec($ch); |
93 | - if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch); |
|
99 | + if (curl_errno($ch) && $globalDebug) { |
|
100 | + echo 'Download error: '.curl_error($ch); |
|
101 | + } |
|
94 | 102 | curl_close($ch); |
95 | 103 | fclose($fp); |
96 | 104 | } |
@@ -101,10 +109,16 @@ discard block |
||
101 | 109 | * @return Array array of the tables in HTML page |
102 | 110 | */ |
103 | 111 | public function table2array($data) { |
104 | - if (!is_string($data)) return array(); |
|
105 | - if ($data == '') return array(); |
|
112 | + if (!is_string($data)) { |
|
113 | + return array(); |
|
114 | + } |
|
115 | + if ($data == '') { |
|
116 | + return array(); |
|
117 | + } |
|
106 | 118 | $html = str_get_html($data); |
107 | - if ($html === false) return array(); |
|
119 | + if ($html === false) { |
|
120 | + return array(); |
|
121 | + } |
|
108 | 122 | $tabledata=array(); |
109 | 123 | foreach($html->find('tr') as $element) |
110 | 124 | { |
@@ -139,7 +153,9 @@ discard block |
||
139 | 153 | */ |
140 | 154 | public function text2array($data) { |
141 | 155 | $html = str_get_html($data); |
142 | - if ($html === false) return array(); |
|
156 | + if ($html === false) { |
|
157 | + return array(); |
|
158 | + } |
|
143 | 159 | $tabledata=array(); |
144 | 160 | foreach($html->find('p') as $element) |
145 | 161 | { |
@@ -160,7 +176,9 @@ discard block |
||
160 | 176 | * @return Float Distance in $unit |
161 | 177 | */ |
162 | 178 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
163 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
179 | + if ($lat == $latc && $lon == $lonc) { |
|
180 | + return 0; |
|
181 | + } |
|
164 | 182 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
165 | 183 | if ($unit == "km") { |
166 | 184 | return round($dist * 1.609344); |
@@ -184,10 +202,16 @@ discard block |
||
184 | 202 | public function withinThreshold ($timeDifference, $distance) { |
185 | 203 | $x = abs($timeDifference); |
186 | 204 | $d = abs($distance); |
187 | - if ($x == 0 || $d == 0) return true; |
|
205 | + if ($x == 0 || $d == 0) { |
|
206 | + return true; |
|
207 | + } |
|
188 | 208 | // may be due to Internet jitter; distance is realistic |
189 | - if ($x < 0.7 && $d < 2000) return true; |
|
190 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
209 | + if ($x < 0.7 && $d < 2000) { |
|
210 | + return true; |
|
211 | + } else { |
|
212 | + return $d/$x < 1500*0.27778; |
|
213 | + } |
|
214 | + // 1500 km/h max |
|
191 | 215 | } |
192 | 216 | |
193 | 217 | |
@@ -247,7 +271,9 @@ discard block |
||
247 | 271 | public function hex2str($hex) { |
248 | 272 | $str = ''; |
249 | 273 | $hexln = strlen($hex); |
250 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
274 | + for($i=0;$i<$hexln;$i+=2) { |
|
275 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
276 | + } |
|
251 | 277 | return $str; |
252 | 278 | } |
253 | 279 | |
@@ -275,8 +301,11 @@ discard block |
||
275 | 301 | $b = $lat2 - $lat1; |
276 | 302 | $c = -($a*$lat1+$b*$lon1); |
277 | 303 | $d = $a*$lat3+$b*$lon3+$c; |
278 | - if ($d > -$approx && $d < $approx) return true; |
|
279 | - else return false; |
|
304 | + if ($d > -$approx && $d < $approx) { |
|
305 | + return true; |
|
306 | + } else { |
|
307 | + return false; |
|
308 | + } |
|
280 | 309 | } |
281 | 310 | |
282 | 311 | public function array_merge_noappend() { |
@@ -312,7 +341,9 @@ discard block |
||
312 | 341 | return $result; |
313 | 342 | } |
314 | 343 | $handle = @opendir('./locale'); |
315 | - if ($handle === false) return $result; |
|
344 | + if ($handle === false) { |
|
345 | + return $result; |
|
346 | + } |
|
316 | 347 | while (false !== ($file = readdir($handle))) { |
317 | 348 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
318 | 349 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -379,8 +410,9 @@ discard block |
||
379 | 410 | $error = false; |
380 | 411 | if ($fp_out = gzopen($dest, $mode)) { |
381 | 412 | if ($fp_in = fopen($source,'rb')) { |
382 | - while (!feof($fp_in)) |
|
383 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
413 | + while (!feof($fp_in)) { |
|
414 | + gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
415 | + } |
|
384 | 416 | fclose($fp_in); |
385 | 417 | } else { |
386 | 418 | $error = true; |
@@ -389,14 +421,17 @@ discard block |
||
389 | 421 | } else { |
390 | 422 | $error = true; |
391 | 423 | } |
392 | - if ($error) |
|
393 | - return false; |
|
394 | - else |
|
395 | - return $dest; |
|
424 | + if ($error) { |
|
425 | + return false; |
|
426 | + } else { |
|
427 | + return $dest; |
|
428 | + } |
|
396 | 429 | } |
397 | 430 | |
398 | 431 | public function remove_accents($string) { |
399 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
432 | + if ( !preg_match('/[\x80-\xff]/', $string) ) { |
|
433 | + return $string; |
|
434 | + } |
|
400 | 435 | $chars = array( |
401 | 436 | // Decompositions for Latin-1 Supplement |
402 | 437 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -64,8 +64,11 @@ discard block |
||
64 | 64 | $globalDBSname = $globalDBname; |
65 | 65 | $globalDBSuser = $globalDBuser; |
66 | 66 | $globalDBSpass = $globalDBpass; |
67 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
68 | - else $globalDBSport = $globalDBport; |
|
67 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
68 | + $globalDBSport = 3306; |
|
69 | + } else { |
|
70 | + $globalDBSport = $globalDBport; |
|
71 | + } |
|
69 | 72 | } else { |
70 | 73 | $DBname = 'default'; |
71 | 74 | $globalDBSdriver = $globalDBdriver; |
@@ -73,8 +76,11 @@ discard block |
||
73 | 76 | $globalDBSname = $globalDBname; |
74 | 77 | $globalDBSuser = $user; |
75 | 78 | $globalDBSpass = $pass; |
76 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
77 | - else $globalDBSport = $globalDBport; |
|
79 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
80 | + $globalDBSport = 3306; |
|
81 | + } else { |
|
82 | + $globalDBSport = $globalDBport; |
|
83 | + } |
|
78 | 84 | } |
79 | 85 | } else { |
80 | 86 | $globalDBSdriver = $globalDB[$DBname]['driver']; |
@@ -82,11 +88,16 @@ discard block |
||
82 | 88 | $globalDBSname = $globalDB[$DBname]['name']; |
83 | 89 | $globalDBSuser = $globalDB[$DBname]['user']; |
84 | 90 | $globalDBSpass = $globalDB[$DBname]['pass']; |
85 | - if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port']; |
|
86 | - else $globalDBSport = 3306; |
|
91 | + if (isset($globalDB[$DBname]['port'])) { |
|
92 | + $globalDBSport = $globalDB[$DBname]['port']; |
|
93 | + } else { |
|
94 | + $globalDBSport = 3306; |
|
95 | + } |
|
87 | 96 | } |
88 | 97 | // Set number of try to connect to DB |
89 | - if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5; |
|
98 | + if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) { |
|
99 | + $globalDBretry = 5; |
|
100 | + } |
|
90 | 101 | $i = 0; |
91 | 102 | while (true) { |
92 | 103 | try { |
@@ -95,10 +106,16 @@ discard block |
||
95 | 106 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
96 | 107 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
97 | 108 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
98 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
99 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
100 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
101 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
109 | + if (!isset($globalDBTimeOut)) { |
|
110 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
111 | + } else { |
|
112 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
113 | + } |
|
114 | + if (!isset($globalDBPersistent)) { |
|
115 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
116 | + } else { |
|
117 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
118 | + } |
|
102 | 119 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
103 | 120 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
104 | 121 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -112,23 +129,35 @@ discard block |
||
112 | 129 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
113 | 130 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
114 | 131 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
115 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
116 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
117 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
118 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
132 | + if (!isset($globalDBTimeOut)) { |
|
133 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
134 | + } else { |
|
135 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
136 | + } |
|
137 | + if (!isset($globalDBPersistent)) { |
|
138 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
139 | + } else { |
|
140 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
141 | + } |
|
119 | 142 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
120 | 143 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
121 | 144 | } |
122 | 145 | break; |
123 | 146 | } catch(PDOException $e) { |
124 | 147 | $i++; |
125 | - if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
148 | + if (isset($globalDebug) && $globalDebug) { |
|
149 | + echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
150 | + } |
|
126 | 151 | //exit; |
127 | - if ($i > $globalDBretry) return false; |
|
152 | + if ($i > $globalDBretry) { |
|
153 | + return false; |
|
154 | + } |
|
128 | 155 | //return false; |
129 | 156 | } |
130 | 157 | } |
131 | - if ($DBname === 'default') $this->db = $this->dbs['default']; |
|
158 | + if ($DBname === 'default') { |
|
159 | + $this->db = $this->dbs['default']; |
|
160 | + } |
|
132 | 161 | return true; |
133 | 162 | } |
134 | 163 | |
@@ -140,7 +169,9 @@ discard block |
||
140 | 169 | } else { |
141 | 170 | $query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'"; |
142 | 171 | } |
143 | - if ($this->db == NULL) return false; |
|
172 | + if ($this->db == NULL) { |
|
173 | + return false; |
|
174 | + } |
|
144 | 175 | try { |
145 | 176 | //$Connection = new Connection(); |
146 | 177 | $results = $this->db->query($query); |
@@ -149,21 +180,28 @@ discard block |
||
149 | 180 | } |
150 | 181 | if($results->rowCount()>0) { |
151 | 182 | return true; |
183 | + } else { |
|
184 | + return false; |
|
152 | 185 | } |
153 | - else return false; |
|
154 | 186 | } |
155 | 187 | |
156 | 188 | public function connectionExists() |
157 | 189 | { |
158 | 190 | global $globalDBdriver, $globalDBCheckConnection; |
159 | - if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true; |
|
191 | + if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) { |
|
192 | + return true; |
|
193 | + } |
|
160 | 194 | $query = "SELECT 1 + 1"; |
161 | - if ($this->db === null) return false; |
|
195 | + if ($this->db === null) { |
|
196 | + return false; |
|
197 | + } |
|
162 | 198 | try { |
163 | 199 | $sum = @$this->db->query($query); |
164 | 200 | if ($sum instanceof \PDOStatement) { |
165 | 201 | $sum = $sum->fetchColumn(0); |
166 | - } else $sum = 0; |
|
202 | + } else { |
|
203 | + $sum = 0; |
|
204 | + } |
|
167 | 205 | if (intval($sum) !== 2) { |
168 | 206 | return false; |
169 | 207 | } |
@@ -198,8 +236,9 @@ discard block |
||
198 | 236 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
199 | 237 | if($nb[0]['nb'] > 0) { |
200 | 238 | return true; |
239 | + } else { |
|
240 | + return false; |
|
201 | 241 | } |
202 | - else return false; |
|
203 | 242 | } |
204 | 243 | |
205 | 244 | /* |
@@ -243,9 +282,12 @@ discard block |
||
243 | 282 | } |
244 | 283 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
245 | 284 | $sth->closeCursor(); |
246 | - if ($result['nb'] > 0) return true; |
|
247 | - else return false; |
|
248 | -/* } else { |
|
285 | + if ($result['nb'] > 0) { |
|
286 | + return true; |
|
287 | + } else { |
|
288 | + return false; |
|
289 | + } |
|
290 | + /* } else { |
|
249 | 291 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
250 | 292 | try { |
251 | 293 | $results = $this->db->query($query); |
@@ -284,7 +326,9 @@ discard block |
||
284 | 326 | $sth->closeCursor(); |
285 | 327 | return $result['value']; |
286 | 328 | } |
287 | - } else return $version; |
|
329 | + } else { |
|
330 | + return $version; |
|
331 | + } |
|
288 | 332 | } |
289 | 333 | |
290 | 334 | /* |
@@ -292,8 +336,11 @@ discard block |
||
292 | 336 | * @return Boolean if latest version or not |
293 | 337 | */ |
294 | 338 | public function latest() { |
295 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
296 | - else return false; |
|
339 | + if ($this->check_schema_version() == $this->latest_schema) { |
|
340 | + return true; |
|
341 | + } else { |
|
342 | + return false; |
|
343 | + } |
|
297 | 344 | } |
298 | 345 | |
299 | 346 | } |
@@ -71,8 +71,11 @@ |
||
71 | 71 | print '<tr>'; |
72 | 72 | print '<td><strong>'.$i.'</strong></td>'; |
73 | 73 | print '<td>'; |
74 | - if ($date_item['month'] < 10) $month = '0'.$date_item['month']; |
|
75 | - else $month = $date_item['month']; |
|
74 | + if ($date_item['month'] < 10) { |
|
75 | + $month = '0'.$date_item['month']; |
|
76 | + } else { |
|
77 | + $month = $date_item['month']; |
|
78 | + } |
|
76 | 79 | print '<a href="'.$globalURL.'/accident/'.$date_item['year'].'-'.$month.'">'.date('F, Y',strtotime($date_item['year'].'-'.$date_item['month'].'-01')).'</a>'; |
77 | 80 | print '</td>'; |
78 | 81 | print '<td>'; |