@@ -8,13 +8,13 @@ discard block |
||
8 | 8 | die(); |
9 | 9 | } |
10 | 10 | $Spotter = new Spotter(); |
11 | -$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING))); |
|
12 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
13 | -$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort); |
|
11 | +$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING))); |
|
12 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
13 | +$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, "0,1", $sort); |
|
14 | 14 | |
15 | 15 | if (!empty($spotter_array)) |
16 | 16 | { |
17 | - $title = sprintf(_("'Most Common Departure Airports by Country from %s"),$manufacturer); |
|
17 | + $title = sprintf(_("'Most Common Departure Airports by Country from %s"), $manufacturer); |
|
18 | 18 | |
19 | 19 | require_once('header.php'); |
20 | 20 | print '<div class="select-item">'; |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | $Stats = new Stats(); |
24 | 24 | $all_manufacturers = $Stats->getAllManufacturers(); |
25 | 25 | if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers(); |
26 | - foreach($all_manufacturers as $all_manufacturer) |
|
26 | + foreach ($all_manufacturers as $all_manufacturer) |
|
27 | 27 | { |
28 | - if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
|
28 | + if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
|
29 | 29 | { |
30 | 30 | print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>'; |
31 | 31 | } else { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | include('manufacturer-sub-menu.php'); |
45 | 45 | print '<div class="column">'; |
46 | 46 | print '<h2>'._("Most Common Departure Airports by Country").'</h2>'; |
47 | - print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights from <strong>%s</strong>."),$manufacturer).'</p>'; |
|
47 | + print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights from <strong>%s</strong>."), $manufacturer).'</p>'; |
|
48 | 48 | |
49 | 49 | $airport_country_array = $Spotter->countAllDepartureAirportCountriesByManufacturer($manufacturer); |
50 | 50 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
54 | 54 | print 'var series = ['; |
55 | 55 | $country_data = ''; |
56 | - foreach($airport_country_array as $airport_item) |
|
56 | + foreach ($airport_country_array as $airport_item) |
|
57 | 57 | { |
58 | 58 | $country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],'; |
59 | 59 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | print '</thead>'; |
102 | 102 | print '<tbody>'; |
103 | 103 | $i = 1; |
104 | - foreach($airport_country_array as $airport_item) |
|
104 | + foreach ($airport_country_array as $airport_item) |
|
105 | 105 | { |
106 | 106 | print '<tr>'; |
107 | 107 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | die(); |
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
11 | -$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
12 | -$spotter_array = $Spotter->getSpotterDataByIdent($ident,"0,1", $sort); |
|
10 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
11 | +$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
12 | +$spotter_array = $Spotter->getSpotterDataByIdent($ident, "0,1", $sort); |
|
13 | 13 | |
14 | 14 | if (!empty($spotter_array)) |
15 | 15 | { |
16 | - $title = sprintf(_("Most Common Departure Airports by Country of %s"),$spotter_array[0]['ident']); |
|
16 | + $title = sprintf(_("Most Common Departure Airports by Country of %s"), $spotter_array[0]['ident']); |
|
17 | 17 | require_once('header.php'); |
18 | 18 | print '<div class="info column">'; |
19 | 19 | print '<h1>'.$spotter_array[0]['ident'].'</h1>'; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | include('ident-sub-menu.php'); |
24 | 24 | print '<div class="column">'; |
25 | 25 | print '<h2>'._("Most Common Departure Airports by Country").'</h2>'; |
26 | - print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights with the ident/callsign <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
26 | + print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights with the ident/callsign <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>'; |
|
27 | 27 | |
28 | 28 | $airport_country_array = $Spotter->countAllDepartureAirportCountriesByIdent($ident); |
29 | 29 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
33 | 33 | print 'var series = ['; |
34 | 34 | $country_data = ''; |
35 | - foreach($airport_country_array as $airport_item) |
|
35 | + foreach ($airport_country_array as $airport_item) |
|
36 | 36 | { |
37 | 37 | $country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],'; |
38 | 38 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | print '</thead>'; |
81 | 81 | print '<tbody>'; |
82 | 82 | $i = 1; |
83 | - foreach($airport_country_array as $airport_item) |
|
83 | + foreach ($airport_country_array as $airport_item) |
|
84 | 84 | { |
85 | 85 | print '<tr>'; |
86 | 86 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | if (isset($_GET['coord'])) |
13 | 13 | { |
14 | - $coords = explode(',',$_GET['coord']); |
|
14 | + $coords = explode(',', $_GET['coord']); |
|
15 | 15 | $spotter_array = $Spotter->getAllAirportInfobyCoord($coords); |
16 | 16 | } else { |
17 | 17 | $spotter_array = $Spotter->getAllAirportInfo(); |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | |
23 | 23 | if (!empty($spotter_array)) |
24 | 24 | { |
25 | - foreach($spotter_array as $spotter_item) |
|
25 | + foreach ($spotter_array as $spotter_item) |
|
26 | 26 | { |
27 | 27 | date_default_timezone_set('UTC'); |
28 | 28 | //waypoint plotting |
29 | 29 | $output .= '{"type": "Feature",'; |
30 | 30 | $output .= '"properties": {'; |
31 | - $output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",'; |
|
32 | - $output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",'; |
|
31 | + $output .= '"name": "'.str_replace('"', "'", $spotter_item['name']).'",'; |
|
32 | + $output .= '"city": "'.str_replace('"', "'", $spotter_item['city']).'",'; |
|
33 | 33 | $output .= '"country": "'.$spotter_item['country'].'",'; |
34 | 34 | $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
35 | - $output .= '"popupContent": "'.str_replace('"',"'",$spotter_item['name']).' : '.str_replace('"',"'",$spotter_item['city']).', '.$spotter_item['country'].'",'; |
|
35 | + $output .= '"popupContent": "'.str_replace('"', "'", $spotter_item['name']).' : '.str_replace('"', "'", $spotter_item['city']).', '.$spotter_item['country'].'",'; |
|
36 | 36 | if ($spotter_item['type'] == 'large_airport') { |
37 | 37 | $output .= '"icon": "'.$globalURL.'/images/airport.png",'; |
38 | 38 | } elseif ($spotter_item['type'] == 'heliport') { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $output .= '}'; |
60 | 60 | $output .= '},'; |
61 | 61 | } |
62 | - $output = substr($output, 0, -1); |
|
62 | + $output = substr($output, 0, -1); |
|
63 | 63 | } |
64 | 64 | $output .= ']}'; |
65 | 65 | print $output; |
@@ -13,62 +13,62 @@ discard block |
||
13 | 13 | * @param Array $filter the filter |
14 | 14 | * @return Array the SQL part |
15 | 15 | */ |
16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
16 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
18 | 18 | $filters = array(); |
19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
20 | 20 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
21 | 21 | $filters = $globalStatsFilters[$globalFilterName]; |
22 | 22 | } else { |
23 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
23 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | if (isset($filter[0]['source'])) { |
27 | - $filters = array_merge($filters,$filter); |
|
27 | + $filters = array_merge($filters, $filter); |
|
28 | 28 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
29 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | - foreach($filters as $flt) { |
|
32 | + foreach ($filters as $flt) { |
|
33 | 33 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
34 | 34 | if ($flt['airlines'][0] != '') { |
35 | 35 | if (isset($flt['source'])) { |
36 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
36 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
37 | 37 | } else { |
38 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
43 | 43 | if (isset($flt['source'])) { |
44 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
44 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
45 | 45 | } else { |
46 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
46 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
50 | 50 | if (isset($flt['source'])) { |
51 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
51 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
52 | 52 | } else { |
53 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
53 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
57 | 57 | if (isset($flt['source'])) { |
58 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
58 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
59 | 59 | } else { |
60 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
60 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
64 | 64 | if (isset($flt['source'])) { |
65 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
65 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
69 | 69 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
70 | 70 | if ($filter['airlines'][0] != '') { |
71 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
71 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -76,16 +76,16 @@ discard block |
||
76 | 76 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
77 | 77 | } |
78 | 78 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
79 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
79 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
80 | 80 | } |
81 | 81 | if (isset($filter['source']) && !empty($filter['source'])) { |
82 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
82 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
83 | 83 | } |
84 | 84 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
85 | 85 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
86 | 86 | } |
87 | 87 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
88 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
88 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
89 | 89 | } |
90 | 90 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
91 | 91 | $filter_query_date = ''; |
@@ -111,41 +111,41 @@ discard block |
||
111 | 111 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
112 | 112 | } |
113 | 113 | } |
114 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
114 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
115 | 115 | } |
116 | 116 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
117 | 117 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
118 | 118 | if ($filter_query_where != '') { |
119 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
119 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
120 | 120 | } |
121 | 121 | $filter_query = $filter_query_join.$filter_query_where; |
122 | 122 | return $filter_query; |
123 | 123 | } |
124 | 124 | |
125 | 125 | // Spotter_archive |
126 | - public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
126 | + public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
127 | 127 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
128 | 128 | if ($over_country == '') { |
129 | 129 | $Spotter = new Spotter($this->db); |
130 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
130 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
131 | 131 | if (!empty($data_country)) $country = $data_country['iso2']; |
132 | 132 | else $country = ''; |
133 | 133 | } else $country = $over_country; |
134 | - if ($airline_type === NULL) $airline_type =''; |
|
134 | + if ($airline_type === NULL) $airline_type = ''; |
|
135 | 135 | |
136 | 136 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
137 | 137 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
138 | 138 | |
139 | 139 | // Route is not added in spotter_archive |
140 | - $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
140 | + $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
141 | 141 | VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)"; |
142 | 142 | |
143 | - $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
143 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
144 | 144 | try { |
145 | 145 | $sth = $this->db->prepare($query); |
146 | 146 | $sth->execute($query_values); |
147 | 147 | $sth->closeCursor(); |
148 | - } catch(PDOException $e) { |
|
148 | + } catch (PDOException $e) { |
|
149 | 149 | return "error : ".$e->getMessage(); |
150 | 150 | } |
151 | 151 | return "success"; |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | |
166 | 166 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
167 | 167 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
168 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
168 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
169 | 169 | |
170 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
170 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
171 | 171 | |
172 | 172 | return $spotter_array; |
173 | 173 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
187 | 187 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
188 | 188 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
189 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
189 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
190 | 190 | |
191 | 191 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
192 | 192 | /* |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
201 | 201 | */ |
202 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
202 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
203 | 203 | |
204 | 204 | return $spotter_array; |
205 | 205 | } |
@@ -214,14 +214,14 @@ discard block |
||
214 | 214 | { |
215 | 215 | date_default_timezone_set('UTC'); |
216 | 216 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
217 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
217 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
218 | 218 | |
219 | 219 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
220 | 220 | |
221 | 221 | try { |
222 | 222 | $sth = $this->db->prepare($query); |
223 | 223 | $sth->execute(array(':id' => $id)); |
224 | - } catch(PDOException $e) { |
|
224 | + } catch (PDOException $e) { |
|
225 | 225 | echo $e->getMessage(); |
226 | 226 | die; |
227 | 227 | } |
@@ -240,14 +240,14 @@ discard block |
||
240 | 240 | { |
241 | 241 | date_default_timezone_set('UTC'); |
242 | 242 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
243 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
243 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
244 | 244 | |
245 | 245 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
246 | 246 | |
247 | 247 | try { |
248 | 248 | $sth = $this->db->prepare($query); |
249 | 249 | $sth->execute(array(':id' => $id)); |
250 | - } catch(PDOException $e) { |
|
250 | + } catch (PDOException $e) { |
|
251 | 251 | echo $e->getMessage(); |
252 | 252 | die; |
253 | 253 | } |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | date_default_timezone_set('UTC'); |
270 | 270 | |
271 | 271 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
272 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
272 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
273 | 273 | |
274 | 274 | try { |
275 | 275 | $sth = $this->db->prepare($query); |
276 | 276 | $sth->execute(array(':ident' => $ident)); |
277 | - } catch(PDOException $e) { |
|
277 | + } catch (PDOException $e) { |
|
278 | 278 | echo $e->getMessage(); |
279 | 279 | die; |
280 | 280 | } |
@@ -295,12 +295,12 @@ discard block |
||
295 | 295 | date_default_timezone_set('UTC'); |
296 | 296 | |
297 | 297 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
298 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
298 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
299 | 299 | |
300 | 300 | try { |
301 | 301 | $sth = $this->db->prepare($query); |
302 | 302 | $sth->execute(array(':id' => $id)); |
303 | - } catch(PDOException $e) { |
|
303 | + } catch (PDOException $e) { |
|
304 | 304 | echo $e->getMessage(); |
305 | 305 | die; |
306 | 306 | } |
@@ -321,12 +321,12 @@ discard block |
||
321 | 321 | date_default_timezone_set('UTC'); |
322 | 322 | |
323 | 323 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
324 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
324 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
325 | 325 | |
326 | 326 | try { |
327 | 327 | $sth = $this->db->prepare($query); |
328 | 328 | $sth->execute(array(':id' => $id)); |
329 | - } catch(PDOException $e) { |
|
329 | + } catch (PDOException $e) { |
|
330 | 330 | echo $e->getMessage(); |
331 | 331 | die; |
332 | 332 | } |
@@ -348,13 +348,13 @@ discard block |
||
348 | 348 | date_default_timezone_set('UTC'); |
349 | 349 | |
350 | 350 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
351 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
351 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
352 | 352 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
353 | 353 | |
354 | 354 | try { |
355 | 355 | $sth = $this->db->prepare($query); |
356 | 356 | $sth->execute(array(':ident' => $ident)); |
357 | - } catch(PDOException $e) { |
|
357 | + } catch (PDOException $e) { |
|
358 | 358 | echo $e->getMessage(); |
359 | 359 | die; |
360 | 360 | } |
@@ -371,13 +371,13 @@ discard block |
||
371 | 371 | * @return Array the spotter information |
372 | 372 | * |
373 | 373 | */ |
374 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
374 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
375 | 375 | { |
376 | 376 | $Spotter = new Spotter($this->db); |
377 | 377 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
378 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
378 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
379 | 379 | |
380 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
380 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
381 | 381 | |
382 | 382 | return $spotter_array; |
383 | 383 | } |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | try { |
391 | 391 | $sth = $this->db->prepare($query); |
392 | 392 | $sth->execute(); |
393 | - } catch(PDOException $e) { |
|
393 | + } catch (PDOException $e) { |
|
394 | 394 | echo $e->getMessage(); |
395 | 395 | die; |
396 | 396 | } |
@@ -402,24 +402,24 @@ discard block |
||
402 | 402 | * @return Array the spotter information |
403 | 403 | * |
404 | 404 | */ |
405 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
405 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
406 | 406 | { |
407 | 407 | global $globalDBdriver, $globalLiveInterval; |
408 | 408 | date_default_timezone_set('UTC'); |
409 | 409 | |
410 | 410 | $filter_query = ''; |
411 | 411 | if (isset($filter['source']) && !empty($filter['source'])) { |
412 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
412 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
413 | 413 | } |
414 | 414 | // Use spotter_output also ? |
415 | 415 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
416 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
416 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
417 | 417 | } |
418 | 418 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
419 | 419 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
420 | 420 | } |
421 | 421 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
422 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
422 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -438,14 +438,14 @@ discard block |
||
438 | 438 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
439 | 439 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
440 | 440 | */ |
441 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
441 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
442 | 442 | FROM spotter_archive |
443 | 443 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
444 | 444 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
445 | 445 | '.$filter_query.' ORDER BY flightaware_id'; |
446 | 446 | } else { |
447 | 447 | //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
448 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
448 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
449 | 449 | FROM spotter_archive |
450 | 450 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
451 | 451 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | try { |
456 | 456 | $sth = $this->db->prepare($query); |
457 | 457 | $sth->execute(); |
458 | - } catch(PDOException $e) { |
|
458 | + } catch (PDOException $e) { |
|
459 | 459 | echo $e->getMessage(); |
460 | 460 | die; |
461 | 461 | } |
@@ -470,24 +470,24 @@ discard block |
||
470 | 470 | * @return Array the spotter information |
471 | 471 | * |
472 | 472 | */ |
473 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
473 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
474 | 474 | { |
475 | 475 | global $globalDBdriver, $globalLiveInterval; |
476 | 476 | date_default_timezone_set('UTC'); |
477 | 477 | |
478 | 478 | $filter_query = ''; |
479 | 479 | if (isset($filter['source']) && !empty($filter['source'])) { |
480 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
480 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
481 | 481 | } |
482 | 482 | // Should use spotter_output also ? |
483 | 483 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
484 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
484 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
485 | 485 | } |
486 | 486 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
487 | 487 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
488 | 488 | } |
489 | 489 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
490 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
490 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | FROM spotter_archive |
498 | 498 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
499 | 499 | */ |
500 | - $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
500 | + $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
501 | 501 | FROM spotter_archive_output |
502 | 502 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
503 | 503 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
513 | 513 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
514 | 514 | */ |
515 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
515 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
516 | 516 | FROM spotter_archive_output |
517 | 517 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
518 | 518 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | try { |
525 | 525 | $sth = $this->db->prepare($query); |
526 | 526 | $sth->execute(); |
527 | - } catch(PDOException $e) { |
|
527 | + } catch (PDOException $e) { |
|
528 | 528 | echo $e->getMessage(); |
529 | 529 | die; |
530 | 530 | } |
@@ -539,23 +539,23 @@ discard block |
||
539 | 539 | * @return Array the spotter information |
540 | 540 | * |
541 | 541 | */ |
542 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
542 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
543 | 543 | { |
544 | 544 | global $globalDBdriver, $globalLiveInterval; |
545 | 545 | date_default_timezone_set('UTC'); |
546 | 546 | |
547 | 547 | $filter_query = ''; |
548 | 548 | if (isset($filter['source']) && !empty($filter['source'])) { |
549 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
549 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
550 | 550 | } |
551 | 551 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
552 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
552 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
553 | 553 | } |
554 | 554 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
555 | 555 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
556 | 556 | } |
557 | 557 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
558 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
558 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | try { |
571 | 571 | $sth = $this->db->prepare($query); |
572 | 572 | $sth->execute(); |
573 | - } catch(PDOException $e) { |
|
573 | + } catch (PDOException $e) { |
|
574 | 574 | echo $e->getMessage(); |
575 | 575 | die; |
576 | 576 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * @return Array the spotter information |
591 | 591 | * |
592 | 592 | */ |
593 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
593 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
594 | 594 | { |
595 | 595 | global $globalTimezone, $globalDBdriver; |
596 | 596 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | |
613 | 613 | $q_array = explode(" ", $q); |
614 | 614 | |
615 | - foreach ($q_array as $q_item){ |
|
615 | + foreach ($q_array as $q_item) { |
|
616 | 616 | $additional_query .= " AND ("; |
617 | 617 | $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
618 | 618 | $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | |
645 | 645 | if ($registration != "") |
646 | 646 | { |
647 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
647 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
648 | 648 | if (!is_string($registration)) |
649 | 649 | { |
650 | 650 | return false; |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | |
656 | 656 | if ($aircraft_icao != "") |
657 | 657 | { |
658 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
658 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
659 | 659 | if (!is_string($aircraft_icao)) |
660 | 660 | { |
661 | 661 | return false; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | |
667 | 667 | if ($aircraft_manufacturer != "") |
668 | 668 | { |
669 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
669 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
670 | 670 | if (!is_string($aircraft_manufacturer)) |
671 | 671 | { |
672 | 672 | return false; |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | |
688 | 688 | if ($airline_icao != "") |
689 | 689 | { |
690 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
690 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
691 | 691 | if (!is_string($airline_icao)) |
692 | 692 | { |
693 | 693 | return false; |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | |
699 | 699 | if ($airline_country != "") |
700 | 700 | { |
701 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
701 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
702 | 702 | if (!is_string($airline_country)) |
703 | 703 | { |
704 | 704 | return false; |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | |
710 | 710 | if ($airline_type != "") |
711 | 711 | { |
712 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
712 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
713 | 713 | if (!is_string($airline_type)) |
714 | 714 | { |
715 | 715 | return false; |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | |
732 | 732 | if ($airport != "") |
733 | 733 | { |
734 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
734 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
735 | 735 | if (!is_string($airport)) |
736 | 736 | { |
737 | 737 | return false; |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | |
743 | 743 | if ($airport_country != "") |
744 | 744 | { |
745 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
745 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
746 | 746 | if (!is_string($airport_country)) |
747 | 747 | { |
748 | 748 | return false; |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | |
754 | 754 | if ($callsign != "") |
755 | 755 | { |
756 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
756 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
757 | 757 | if (!is_string($callsign)) |
758 | 758 | { |
759 | 759 | return false; |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | $translate = $Translation->ident2icao($callsign); |
762 | 762 | if ($translate != $callsign) { |
763 | 763 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
764 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
764 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
765 | 765 | } else { |
766 | 766 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
767 | 767 | } |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | |
771 | 771 | if ($owner != "") |
772 | 772 | { |
773 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
773 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
774 | 774 | if (!is_string($owner)) |
775 | 775 | { |
776 | 776 | return false; |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | |
782 | 782 | if ($pilot_name != "") |
783 | 783 | { |
784 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
784 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
785 | 785 | if (!is_string($pilot_name)) |
786 | 786 | { |
787 | 787 | return false; |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | |
793 | 793 | if ($pilot_id != "") |
794 | 794 | { |
795 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
795 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
796 | 796 | if (!is_string($pilot_id)) |
797 | 797 | { |
798 | 798 | return false; |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | |
804 | 804 | if ($departure_airport_route != "") |
805 | 805 | { |
806 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
806 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
807 | 807 | if (!is_string($departure_airport_route)) |
808 | 808 | { |
809 | 809 | return false; |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | |
815 | 815 | if ($arrival_airport_route != "") |
816 | 816 | { |
817 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
817 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
818 | 818 | if (!is_string($arrival_airport_route)) |
819 | 819 | { |
820 | 820 | return false; |
@@ -827,8 +827,8 @@ discard block |
||
827 | 827 | { |
828 | 828 | $altitude_array = explode(",", $altitude); |
829 | 829 | |
830 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
831 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
830 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
831 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
832 | 832 | |
833 | 833 | |
834 | 834 | if ($altitude_array[1] != "") |
@@ -846,8 +846,8 @@ discard block |
||
846 | 846 | { |
847 | 847 | $date_array = explode(",", $date_posted); |
848 | 848 | |
849 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
850 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
849 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
850 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
851 | 851 | |
852 | 852 | if ($globalTimezone != '') { |
853 | 853 | date_default_timezone_set($globalTimezone); |
@@ -879,8 +879,8 @@ discard block |
||
879 | 879 | { |
880 | 880 | $limit_array = explode(",", $limit); |
881 | 881 | |
882 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
883 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
882 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
883 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
884 | 884 | |
885 | 885 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
886 | 886 | { |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | |
892 | 892 | |
893 | 893 | if ($origLat != "" && $origLon != "" && $dist != "") { |
894 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
895 | - $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
894 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
895 | + $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
896 | 896 | FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
897 | 897 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
898 | 898 | } else { |
@@ -909,12 +909,12 @@ discard block |
||
909 | 909 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
910 | 910 | } |
911 | 911 | |
912 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
912 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
913 | 913 | WHERE spotter_archive_output.ident <> '' |
914 | 914 | ".$additional_query." |
915 | 915 | ".$filter_query.$orderby_query; |
916 | 916 | } |
917 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
917 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
918 | 918 | |
919 | 919 | return $spotter_array; |
920 | 920 | } |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | try { |
932 | 932 | $sth = $this->db->prepare($query); |
933 | 933 | $sth->execute(); |
934 | - } catch(PDOException $e) { |
|
934 | + } catch (PDOException $e) { |
|
935 | 935 | return "error"; |
936 | 936 | } |
937 | 937 | } |
@@ -968,8 +968,8 @@ discard block |
||
968 | 968 | { |
969 | 969 | $limit_array = explode(",", $limit); |
970 | 970 | |
971 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
972 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
971 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
972 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
973 | 973 | |
974 | 974 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
975 | 975 | { |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | $query_values = array(); |
1011 | 1011 | $limit_query = ''; |
1012 | 1012 | $additional_query = ''; |
1013 | - $filter_query = $this->getFilter($filter,true,true); |
|
1013 | + $filter_query = $this->getFilter($filter, true, true); |
|
1014 | 1014 | |
1015 | 1015 | if ($owner != "") |
1016 | 1016 | { |
@@ -1027,8 +1027,8 @@ discard block |
||
1027 | 1027 | { |
1028 | 1028 | $limit_array = explode(",", $limit); |
1029 | 1029 | |
1030 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1031 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1030 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1031 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1032 | 1032 | |
1033 | 1033 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1034 | 1034 | { |
@@ -1068,7 +1068,7 @@ discard block |
||
1068 | 1068 | $query_values = array(); |
1069 | 1069 | $limit_query = ''; |
1070 | 1070 | $additional_query = ''; |
1071 | - $filter_query = $this->getFilter($filter,true,true); |
|
1071 | + $filter_query = $this->getFilter($filter, true, true); |
|
1072 | 1072 | |
1073 | 1073 | if ($pilot != "") |
1074 | 1074 | { |
@@ -1080,8 +1080,8 @@ discard block |
||
1080 | 1080 | { |
1081 | 1081 | $limit_array = explode(",", $limit); |
1082 | 1082 | |
1083 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1084 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1083 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1084 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1085 | 1085 | |
1086 | 1086 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1087 | 1087 | { |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | * @return Array the airline country list |
1112 | 1112 | * |
1113 | 1113 | */ |
1114 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1114 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1115 | 1115 | { |
1116 | 1116 | global $globalDBdriver; |
1117 | 1117 | /* |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | $flight_array = array(); |
1141 | 1141 | $temp_array = array(); |
1142 | 1142 | |
1143 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1143 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1144 | 1144 | { |
1145 | 1145 | $temp_array['flight_count'] = $row['nb']; |
1146 | 1146 | $temp_array['flight_country'] = $row['name']; |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | * @return Array the airline country list |
1158 | 1158 | * |
1159 | 1159 | */ |
1160 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1160 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1161 | 1161 | { |
1162 | 1162 | global $globalDBdriver; |
1163 | 1163 | /* |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | $flight_array = array(); |
1187 | 1187 | $temp_array = array(); |
1188 | 1188 | |
1189 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1189 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1190 | 1190 | { |
1191 | 1191 | $temp_array['airline_icao'] = $row['airline_icao']; |
1192 | 1192 | $temp_array['flight_count'] = $row['nb']; |
@@ -1204,14 +1204,14 @@ discard block |
||
1204 | 1204 | * @return Array the spotter information |
1205 | 1205 | * |
1206 | 1206 | */ |
1207 | - public function getDateArchiveSpotterDataById($id,$date) |
|
1207 | + public function getDateArchiveSpotterDataById($id, $date) |
|
1208 | 1208 | { |
1209 | 1209 | $Spotter = new Spotter($this->db); |
1210 | 1210 | date_default_timezone_set('UTC'); |
1211 | 1211 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1212 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1213 | - $date = date('c',$date); |
|
1214 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1212 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1213 | + $date = date('c', $date); |
|
1214 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1215 | 1215 | return $spotter_array; |
1216 | 1216 | } |
1217 | 1217 | |
@@ -1221,14 +1221,14 @@ discard block |
||
1221 | 1221 | * @return Array the spotter information |
1222 | 1222 | * |
1223 | 1223 | */ |
1224 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1224 | + public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
1225 | 1225 | { |
1226 | 1226 | $Spotter = new Spotter($this->db); |
1227 | 1227 | date_default_timezone_set('UTC'); |
1228 | 1228 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1229 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1230 | - $date = date('c',$date); |
|
1231 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1229 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1230 | + $date = date('c', $date); |
|
1231 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1232 | 1232 | return $spotter_array; |
1233 | 1233 | } |
1234 | 1234 | |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | * @return Array the spotter information |
1239 | 1239 | * |
1240 | 1240 | */ |
1241 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1241 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1242 | 1242 | { |
1243 | 1243 | global $global_query; |
1244 | 1244 | $Spotter = new Spotter(); |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | $query_values = array(); |
1247 | 1247 | $limit_query = ''; |
1248 | 1248 | $additional_query = ''; |
1249 | - $filter_query = $this->getFilter($filters,true,true); |
|
1249 | + $filter_query = $this->getFilter($filters, true, true); |
|
1250 | 1250 | |
1251 | 1251 | if ($airport != "") |
1252 | 1252 | { |
@@ -1263,8 +1263,8 @@ discard block |
||
1263 | 1263 | { |
1264 | 1264 | $limit_array = explode(",", $limit); |
1265 | 1265 | |
1266 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1267 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1266 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1267 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1268 | 1268 | |
1269 | 1269 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1270 | 1270 | { |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | $s3 = sin($bank/2); |
44 | 44 | $c1c2 = $c1*$c2; |
45 | 45 | $s1s2 = $s1*$s2; |
46 | - $w =$c1c2*$c3 - $s1s2*$s3; |
|
47 | - $x =$c1c2*$s3 + $s1s2*$c3; |
|
48 | - $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
49 | - $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
50 | - return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
46 | + $w = $c1c2*$c3 - $s1s2*$s3; |
|
47 | + $x = $c1c2*$s3 + $s1s2*$c3; |
|
48 | + $y = $s1*$c2*$c3 + $c1*$s2*$s3; |
|
49 | + $z = $c1*$s2*$c3 - $s1*$c2*$s3; |
|
50 | + return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w); |
|
51 | 51 | // return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365'); |
52 | 52 | |
53 | 53 | } |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | $min = false; |
69 | 69 | $allhistory = false; |
70 | 70 | $filter['source'] = array(); |
71 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
72 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
73 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
74 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
75 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
76 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
77 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
78 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
79 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
80 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
71 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
72 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
73 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
74 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
75 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
76 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
77 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
78 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
79 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
80 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
81 | 81 | /* |
82 | 82 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
83 | 83 | $min = true; |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | $from_archive = true; |
125 | 125 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
126 | 126 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
127 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
128 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
129 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
130 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
131 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
132 | - $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter); |
|
127 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
128 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
129 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
130 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
131 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
132 | + $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter); |
|
133 | 133 | } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) { |
134 | 134 | $from_archive = true; |
135 | 135 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | $begindate = $_COOKIE['archive_begin']; |
140 | 140 | $enddate = $_COOKIE['archive_end']; |
141 | 141 | |
142 | - $archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT); |
|
143 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
144 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
142 | + $archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT); |
|
143 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
144 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
145 | 145 | // echo 'Begin : '.$begindate.' - End : '.$enddate."\n"; |
146 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
146 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
147 | 147 | } elseif ($tracker) { |
148 | 148 | $spotter_array = $TrackerLive->getMinLastLiveTrackerData($filter); |
149 | 149 | } elseif ($marine) { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | if (!empty($spotter_array)) { |
156 | 156 | if (isset($_GET['archive'])) { |
157 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
157 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
158 | 158 | } elseif ($tracker) { |
159 | 159 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
160 | 160 | } elseif ($marine) { |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | if ($flightcnt == '') $flightcnt = 0; |
166 | 166 | } else $flightcnt = 0; |
167 | 167 | |
168 | -$sqltime = round(microtime(true)-$begintime,2); |
|
168 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
169 | 169 | $minitime = time(); |
170 | 170 | $maxitime = 0; |
171 | 171 | |
172 | 172 | |
173 | 173 | $modelsdb = array(); |
174 | 174 | if (file_exists('models/modelsdb')) { |
175 | - if (($handle = fopen('models/modelsdb','r')) !== FALSE) { |
|
176 | - while (($row = fgetcsv($handle,1000)) !== FALSE) { |
|
177 | - if (isset($row[1]) ){ |
|
175 | + if (($handle = fopen('models/modelsdb', 'r')) !== FALSE) { |
|
176 | + while (($row = fgetcsv($handle, 1000)) !== FALSE) { |
|
177 | + if (isset($row[1])) { |
|
178 | 178 | $model = $row[0]; |
179 | 179 | $modelsdb[$model] = $row[1]; |
180 | 180 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER","interval": "%minitime%/%maxitime%"}'; |
204 | 204 | } else { |
205 | 205 | if (isset($globalArchive) && $globalArchive === TRUE) { |
206 | - $output .= ',"clock": {"currentTime" : "'.date("c",time()-$globalLiveInterval).'","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
|
206 | + $output .= ',"clock": {"currentTime" : "'.date("c", time() - $globalLiveInterval).'","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
|
207 | 207 | } else { |
208 | 208 | $output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
209 | 209 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $output .= '},'; |
214 | 214 | if (!empty($spotter_array) && is_array($spotter_array)) |
215 | 215 | { |
216 | - foreach($spotter_array as $spotter_item) |
|
216 | + foreach ($spotter_array as $spotter_item) |
|
217 | 217 | { |
218 | 218 | $j++; |
219 | 219 | date_default_timezone_set('UTC'); |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | $output .= '"cartographicDegrees": ['; |
502 | 502 | if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
503 | 503 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
504 | - $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
504 | + $output .= '"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
505 | 505 | $output .= $spotter_item['longitude'].', '; |
506 | 506 | $output .= $spotter_item['latitude']; |
507 | 507 | $prevlong = $spotter_item['longitude']; |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
516 | 516 | //$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
517 | 517 | } else { |
518 | - $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
518 | + $output .= ',"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
519 | 519 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
520 | 520 | if ($spotter_item['ground_speed'] == 0) { |
521 | 521 | $output .= $prevlong.', '; |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | $output = substr($output, 0, -1); |
548 | 548 | } |
549 | 549 | $output .= ']'; |
550 | -$output = str_replace('%minitime%',date("c",$minitime),$output); |
|
551 | -$output = str_replace('%maxitime%',date("c",$maxitime),$output); |
|
550 | +$output = str_replace('%minitime%', date("c", $minitime), $output); |
|
551 | +$output = str_replace('%maxitime%', date("c", $maxitime), $output); |
|
552 | 552 | print $output; |
553 | 553 | ?> |
@@ -16,62 +16,62 @@ discard block |
||
16 | 16 | * @param Array $filter the filter |
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($filter[0]['source'])) { |
30 | - $filters = array_merge($filters,$filter); |
|
30 | + $filters = array_merge($filters, $filter); |
|
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
33 | 33 | $filter_query_join = ''; |
34 | 34 | $filter_query_where = ''; |
35 | - foreach($filters as $flt) { |
|
35 | + foreach ($filters as $flt) { |
|
36 | 36 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
37 | 37 | if ($flt['airlines'][0] != '') { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
39 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
40 | 40 | } else { |
41 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
46 | 46 | if (isset($flt['source'])) { |
47 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
47 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
48 | 48 | } else { |
49 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
49 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
53 | 53 | if (isset($flt['source'])) { |
54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
55 | 55 | } else { |
56 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
56 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
60 | 60 | if (isset($flt['source'])) { |
61 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
61 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
62 | 62 | } else { |
63 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
63 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
67 | 67 | if (isset($flt['source'])) { |
68 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
68 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | } |
72 | 72 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
73 | 73 | if ($filter['airlines'][0] != '') { |
74 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
74 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
82 | 82 | } |
83 | 83 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
84 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
84 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
85 | 85 | } |
86 | 86 | if (isset($filter['source']) && !empty($filter['source'])) { |
87 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
87 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
88 | 88 | } |
89 | 89 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
90 | 90 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
114 | 114 | } |
115 | 115 | } |
116 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
116 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
117 | 117 | } |
118 | 118 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
119 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
119 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
120 | 120 | } |
121 | 121 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
122 | 122 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
123 | 123 | if ($filter_query_where != '') { |
124 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
124 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
125 | 125 | } |
126 | 126 | $filter_query = $filter_query_join.$filter_query_where; |
127 | 127 | return $filter_query; |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | if ($limit != '') |
145 | 145 | { |
146 | 146 | $limit_array = explode(',', $limit); |
147 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
148 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
147 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
148 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
149 | 149 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
150 | 150 | { |
151 | 151 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | } else { |
169 | 169 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
170 | 170 | } |
171 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
171 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
172 | 172 | |
173 | 173 | return $spotter_array; |
174 | 174 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | { |
184 | 184 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
185 | 185 | date_default_timezone_set('UTC'); |
186 | - $filter_query = $this->getFilter($filter,true,true); |
|
186 | + $filter_query = $this->getFilter($filter, true, true); |
|
187 | 187 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
188 | 188 | if ($globalDBdriver == 'mysql') { |
189 | 189 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | try { |
207 | 207 | $sth = $this->db->prepare($query); |
208 | 208 | $sth->execute(); |
209 | - } catch(PDOException $e) { |
|
209 | + } catch (PDOException $e) { |
|
210 | 210 | echo $e->getMessage(); |
211 | 211 | die; |
212 | 212 | } |
@@ -225,26 +225,26 @@ discard block |
||
225 | 225 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
226 | 226 | date_default_timezone_set('UTC'); |
227 | 227 | |
228 | - $filter_query = $this->getFilter($filter,true,true); |
|
228 | + $filter_query = $this->getFilter($filter, true, true); |
|
229 | 229 | |
230 | 230 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
231 | 231 | if ($globalDBdriver == 'mysql') { |
232 | 232 | if (isset($globalArchive) && $globalArchive === TRUE) { |
233 | - $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
233 | + $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
234 | 234 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id AND spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
235 | 235 | ORDER BY spotter_archive.flightaware_id, spotter_archive.date"; |
236 | 236 | } else { |
237 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
237 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
238 | 238 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
239 | 239 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
240 | 240 | } |
241 | 241 | } else { |
242 | 242 | if (isset($globalArchive) && $globalArchive === TRUE) { |
243 | - $query = "SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
243 | + $query = "SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
244 | 244 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
245 | 245 | ORDER BY spotter_archive.flightaware_id, spotter_archive.date"; |
246 | 246 | } else { |
247 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
247 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
248 | 248 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
249 | 249 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
250 | 250 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | try { |
254 | 254 | $sth = $this->db->prepare($query); |
255 | 255 | $sth->execute(); |
256 | - } catch(PDOException $e) { |
|
256 | + } catch (PDOException $e) { |
|
257 | 257 | echo $e->getMessage(); |
258 | 258 | die; |
259 | 259 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | public function getLiveSpotterCount($filter = array()) |
271 | 271 | { |
272 | 272 | global $globalDBdriver, $globalLiveInterval; |
273 | - $filter_query = $this->getFilter($filter,true,true); |
|
273 | + $filter_query = $this->getFilter($filter, true, true); |
|
274 | 274 | |
275 | 275 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
276 | 276 | if ($globalDBdriver == 'mysql') { |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | try { |
284 | 284 | $sth = $this->db->prepare($query); |
285 | 285 | $sth->execute(); |
286 | - } catch(PDOException $e) { |
|
286 | + } catch (PDOException $e) { |
|
287 | 287 | echo $e->getMessage(); |
288 | 288 | die; |
289 | 289 | } |
@@ -306,10 +306,10 @@ discard block |
||
306 | 306 | $filter_query = $this->getFilter($filter); |
307 | 307 | |
308 | 308 | if (is_array($coord)) { |
309 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
310 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
311 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
312 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
309 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
310 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
311 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
312 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
313 | 313 | } else return array(); |
314 | 314 | if ($globalDBdriver == 'mysql') { |
315 | 315 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -332,23 +332,23 @@ discard block |
||
332 | 332 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
333 | 333 | $Spotter = new Spotter($this->db); |
334 | 334 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
335 | - $filter_query = $this->getFilter($filter,true,true); |
|
335 | + $filter_query = $this->getFilter($filter, true, true); |
|
336 | 336 | |
337 | 337 | if (is_array($coord)) { |
338 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
339 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
340 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
341 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
338 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
339 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
340 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
341 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
342 | 342 | } else return array(); |
343 | 343 | if ($globalDBdriver == 'mysql') { |
344 | 344 | if (isset($globalArchive) && $globalArchive === TRUE) { |
345 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
345 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
346 | 346 | FROM spotter_live |
347 | 347 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
348 | 348 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
349 | 349 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0'; |
350 | 350 | } else { |
351 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
351 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
352 | 352 | FROM spotter_live |
353 | 353 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
354 | 354 | FROM spotter_live l |
@@ -360,14 +360,14 @@ discard block |
||
360 | 360 | } |
361 | 361 | } else { |
362 | 362 | if (isset($globalArchive) && $globalArchive === TRUE) { |
363 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
363 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
364 | 364 | FROM spotter_live |
365 | 365 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
366 | 366 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
367 | 367 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
368 | 368 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
369 | 369 | } else { |
370 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
370 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
371 | 371 | FROM spotter_live |
372 | 372 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
373 | 373 | FROM spotter_live l |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | try { |
383 | 383 | $sth = $this->db->prepare($query); |
384 | 384 | $sth->execute(); |
385 | - } catch(PDOException $e) { |
|
385 | + } catch (PDOException $e) { |
|
386 | 386 | echo $e->getMessage(); |
387 | 387 | die; |
388 | 388 | } |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | if ($interval == '1m') |
432 | 432 | { |
433 | 433 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
434 | - } else if ($interval == '15m'){ |
|
434 | + } else if ($interval == '15m') { |
|
435 | 435 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
436 | 436 | } |
437 | 437 | } |
@@ -439,14 +439,14 @@ discard block |
||
439 | 439 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
440 | 440 | } |
441 | 441 | |
442 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
442 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
443 | 443 | WHERE spotter_live.latitude <> '' |
444 | 444 | AND spotter_live.longitude <> '' |
445 | 445 | ".$additional_query." |
446 | 446 | HAVING distance < :radius |
447 | 447 | ORDER BY distance"; |
448 | 448 | |
449 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
449 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
450 | 450 | |
451 | 451 | return $spotter_array; |
452 | 452 | } |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | date_default_timezone_set('UTC'); |
465 | 465 | |
466 | 466 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
467 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
467 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
468 | 468 | |
469 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
469 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
470 | 470 | |
471 | 471 | return $spotter_array; |
472 | 472 | } |
@@ -477,16 +477,16 @@ discard block |
||
477 | 477 | * @return Array the spotter information |
478 | 478 | * |
479 | 479 | */ |
480 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
480 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
481 | 481 | { |
482 | 482 | $Spotter = new Spotter($this->db); |
483 | 483 | date_default_timezone_set('UTC'); |
484 | 484 | |
485 | 485 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
486 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
486 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
487 | 487 | |
488 | - $date = date('c',$date); |
|
489 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
488 | + $date = date('c', $date); |
|
489 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
490 | 490 | |
491 | 491 | return $spotter_array; |
492 | 492 | } |
@@ -503,9 +503,9 @@ discard block |
||
503 | 503 | date_default_timezone_set('UTC'); |
504 | 504 | |
505 | 505 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
506 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
506 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
507 | 507 | |
508 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
508 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
509 | 509 | |
510 | 510 | return $spotter_array; |
511 | 511 | } |
@@ -516,15 +516,15 @@ discard block |
||
516 | 516 | * @return Array the spotter information |
517 | 517 | * |
518 | 518 | */ |
519 | - public function getDateLiveSpotterDataById($id,$date) |
|
519 | + public function getDateLiveSpotterDataById($id, $date) |
|
520 | 520 | { |
521 | 521 | $Spotter = new Spotter($this->db); |
522 | 522 | date_default_timezone_set('UTC'); |
523 | 523 | |
524 | 524 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
525 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
526 | - $date = date('c',$date); |
|
527 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
525 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
526 | + $date = date('c', $date); |
|
527 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
528 | 528 | |
529 | 529 | return $spotter_array; |
530 | 530 | } |
@@ -541,13 +541,13 @@ discard block |
||
541 | 541 | date_default_timezone_set('UTC'); |
542 | 542 | |
543 | 543 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
544 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
544 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
545 | 545 | |
546 | 546 | try { |
547 | 547 | |
548 | 548 | $sth = $this->db->prepare($query); |
549 | 549 | $sth->execute(array(':ident' => $ident)); |
550 | - } catch(PDOException $e) { |
|
550 | + } catch (PDOException $e) { |
|
551 | 551 | echo $e->getMessage(); |
552 | 552 | die; |
553 | 553 | } |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | * @return Array the spotter information |
563 | 563 | * |
564 | 564 | */ |
565 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
565 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
566 | 566 | { |
567 | 567 | global $globalDBdriver, $globalLiveInterval; |
568 | 568 | date_default_timezone_set('UTC'); |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | try { |
582 | 582 | $sth = $this->db->prepare($query); |
583 | 583 | $sth->execute(array(':id' => $id)); |
584 | - } catch(PDOException $e) { |
|
584 | + } catch (PDOException $e) { |
|
585 | 585 | echo $e->getMessage(); |
586 | 586 | die; |
587 | 587 | } |
@@ -599,12 +599,12 @@ discard block |
||
599 | 599 | { |
600 | 600 | date_default_timezone_set('UTC'); |
601 | 601 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
602 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
602 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
603 | 603 | try { |
604 | 604 | |
605 | 605 | $sth = $this->db->prepare($query); |
606 | 606 | $sth->execute(array(':ident' => $ident)); |
607 | - } catch(PDOException $e) { |
|
607 | + } catch (PDOException $e) { |
|
608 | 608 | echo $e->getMessage(); |
609 | 609 | die; |
610 | 610 | } |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | |
635 | 635 | $sth = $this->db->prepare($query); |
636 | 636 | $sth->execute(); |
637 | - } catch(PDOException $e) { |
|
637 | + } catch (PDOException $e) { |
|
638 | 638 | return "error"; |
639 | 639 | } |
640 | 640 | |
@@ -657,14 +657,14 @@ discard block |
||
657 | 657 | |
658 | 658 | $sth = $this->db->prepare($query); |
659 | 659 | $sth->execute(); |
660 | - } catch(PDOException $e) { |
|
660 | + } catch (PDOException $e) { |
|
661 | 661 | return "error"; |
662 | 662 | } |
663 | 663 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
664 | 664 | $i = 0; |
665 | - $j =0; |
|
665 | + $j = 0; |
|
666 | 666 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
667 | - foreach($all as $row) |
|
667 | + foreach ($all as $row) |
|
668 | 668 | { |
669 | 669 | $i++; |
670 | 670 | $j++; |
@@ -672,9 +672,9 @@ discard block |
||
672 | 672 | if ($globalDebug) echo "."; |
673 | 673 | try { |
674 | 674 | |
675 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
675 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
676 | 676 | $sth->execute(); |
677 | - } catch(PDOException $e) { |
|
677 | + } catch (PDOException $e) { |
|
678 | 678 | return "error"; |
679 | 679 | } |
680 | 680 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -685,9 +685,9 @@ discard block |
||
685 | 685 | if ($i > 0) { |
686 | 686 | try { |
687 | 687 | |
688 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
688 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
689 | 689 | $sth->execute(); |
690 | - } catch(PDOException $e) { |
|
690 | + } catch (PDOException $e) { |
|
691 | 691 | return "error"; |
692 | 692 | } |
693 | 693 | } |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | |
701 | 701 | $sth = $this->db->prepare($query); |
702 | 702 | $sth->execute(); |
703 | - } catch(PDOException $e) { |
|
703 | + } catch (PDOException $e) { |
|
704 | 704 | return "error"; |
705 | 705 | } |
706 | 706 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -748,13 +748,13 @@ discard block |
||
748 | 748 | public function deleteLiveSpotterDataByIdent($ident) |
749 | 749 | { |
750 | 750 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
751 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
751 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
752 | 752 | |
753 | 753 | try { |
754 | 754 | |
755 | 755 | $sth = $this->db->prepare($query); |
756 | 756 | $sth->execute(array(':ident' => $ident)); |
757 | - } catch(PDOException $e) { |
|
757 | + } catch (PDOException $e) { |
|
758 | 758 | return "error"; |
759 | 759 | } |
760 | 760 | |
@@ -770,13 +770,13 @@ discard block |
||
770 | 770 | public function deleteLiveSpotterDataById($id) |
771 | 771 | { |
772 | 772 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
773 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
773 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
774 | 774 | |
775 | 775 | try { |
776 | 776 | |
777 | 777 | $sth = $this->db->prepare($query); |
778 | 778 | $sth->execute(array(':id' => $id)); |
779 | - } catch(PDOException $e) { |
|
779 | + } catch (PDOException $e) { |
|
780 | 780 | return "error"; |
781 | 781 | } |
782 | 782 | |
@@ -794,13 +794,13 @@ discard block |
||
794 | 794 | { |
795 | 795 | global $globalDBdriver, $globalTimezone; |
796 | 796 | if ($globalDBdriver == 'mysql') { |
797 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
797 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
798 | 798 | WHERE spotter_live.ident = :ident |
799 | 799 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
800 | 800 | AND spotter_live.date < UTC_TIMESTAMP()'; |
801 | 801 | $query_data = array(':ident' => $ident); |
802 | 802 | } else { |
803 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
803 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
804 | 804 | WHERE spotter_live.ident = :ident |
805 | 805 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
806 | 806 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -809,8 +809,8 @@ discard block |
||
809 | 809 | |
810 | 810 | $sth = $this->db->prepare($query); |
811 | 811 | $sth->execute($query_data); |
812 | - $ident_result=''; |
|
813 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
812 | + $ident_result = ''; |
|
813 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
814 | 814 | { |
815 | 815 | $ident_result = $row['ident']; |
816 | 816 | } |
@@ -827,13 +827,13 @@ discard block |
||
827 | 827 | { |
828 | 828 | global $globalDBdriver, $globalTimezone; |
829 | 829 | if ($globalDBdriver == 'mysql') { |
830 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
830 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
831 | 831 | WHERE spotter_live.ident = :ident |
832 | 832 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
833 | 833 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
834 | 834 | $query_data = array(':ident' => $ident); |
835 | 835 | } else { |
836 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
836 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
837 | 837 | WHERE spotter_live.ident = :ident |
838 | 838 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
839 | 839 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -842,8 +842,8 @@ discard block |
||
842 | 842 | |
843 | 843 | $sth = $this->db->prepare($query); |
844 | 844 | $sth->execute($query_data); |
845 | - $ident_result=''; |
|
846 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
845 | + $ident_result = ''; |
|
846 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
847 | 847 | { |
848 | 848 | $ident_result = $row['flightaware_id']; |
849 | 849 | } |
@@ -860,13 +860,13 @@ discard block |
||
860 | 860 | { |
861 | 861 | global $globalDBdriver, $globalTimezone; |
862 | 862 | if ($globalDBdriver == 'mysql') { |
863 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
863 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
864 | 864 | WHERE spotter_live.flightaware_id = :id |
865 | 865 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
866 | 866 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
867 | 867 | $query_data = array(':id' => $id); |
868 | 868 | } else { |
869 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
869 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
870 | 870 | WHERE spotter_live.flightaware_id = :id |
871 | 871 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
872 | 872 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -875,8 +875,8 @@ discard block |
||
875 | 875 | |
876 | 876 | $sth = $this->db->prepare($query); |
877 | 877 | $sth->execute($query_data); |
878 | - $ident_result=''; |
|
879 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
878 | + $ident_result = ''; |
|
879 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
880 | 880 | { |
881 | 881 | $ident_result = $row['flightaware_id']; |
882 | 882 | } |
@@ -893,13 +893,13 @@ discard block |
||
893 | 893 | { |
894 | 894 | global $globalDBdriver, $globalTimezone; |
895 | 895 | if ($globalDBdriver == 'mysql') { |
896 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
896 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
897 | 897 | WHERE spotter_live.ModeS = :modes |
898 | 898 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
899 | 899 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
900 | 900 | $query_data = array(':modes' => $modes); |
901 | 901 | } else { |
902 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
902 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
903 | 903 | WHERE spotter_live.ModeS = :modes |
904 | 904 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
905 | 905 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -908,8 +908,8 @@ discard block |
||
908 | 908 | |
909 | 909 | $sth = $this->db->prepare($query); |
910 | 910 | $sth->execute($query_data); |
911 | - $ident_result=''; |
|
912 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
911 | + $ident_result = ''; |
|
912 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
913 | 913 | { |
914 | 914 | //$ident_result = $row['spotter_live_id']; |
915 | 915 | $ident_result = $row['flightaware_id']; |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | * @return String success or false |
929 | 929 | * |
930 | 930 | */ |
931 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
931 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
932 | 932 | { |
933 | 933 | global $globalURL, $globalArchive, $globalDebug; |
934 | 934 | $Common = new Common(); |
@@ -1021,26 +1021,26 @@ discard block |
||
1021 | 1021 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
1022 | 1022 | |
1023 | 1023 | |
1024 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
1025 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1026 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
1027 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
1028 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
1029 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1030 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1031 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
1032 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1033 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
1034 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1035 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
1036 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
1037 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
1038 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
1039 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
1040 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
1041 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
1042 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
1043 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
1024 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
1025 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1026 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
1027 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
1028 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
1029 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1030 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1031 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
1032 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1033 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
1034 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1035 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
1036 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
1037 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
1038 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
1039 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
1040 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
1041 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
1042 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
1043 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
1044 | 1044 | |
1045 | 1045 | $airline_name = ''; |
1046 | 1046 | $airline_icao = ''; |
@@ -1062,10 +1062,10 @@ discard block |
||
1062 | 1062 | $arrival_airport_country = ''; |
1063 | 1063 | |
1064 | 1064 | |
1065 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1066 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1067 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1068 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1065 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
1066 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
1067 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
1068 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1069 | 1069 | |
1070 | 1070 | $query = ''; |
1071 | 1071 | if ($globalArchive) { |
@@ -1076,19 +1076,19 @@ discard block |
||
1076 | 1076 | $query .= 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
1077 | 1077 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
1078 | 1078 | |
1079 | - $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
1079 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
1080 | 1080 | try { |
1081 | 1081 | |
1082 | 1082 | $sth = $this->db->prepare($query); |
1083 | 1083 | $sth->execute($query_values); |
1084 | 1084 | $sth->closeCursor(); |
1085 | - } catch(PDOException $e) { |
|
1085 | + } catch (PDOException $e) { |
|
1086 | 1086 | return "error : ".$e->getMessage(); |
1087 | 1087 | } |
1088 | 1088 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1089 | 1089 | if ($globalDebug) echo '(Add to SBS archive : '; |
1090 | 1090 | $SpotterArchive = new SpotterArchive($this->db); |
1091 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1091 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
1092 | 1092 | if ($globalDebug) echo $result.')'; |
1093 | 1093 | } |
1094 | 1094 | return "success"; |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | |
1098 | 1098 | public function getOrderBy() |
1099 | 1099 | { |
1100 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
1100 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
1101 | 1101 | return $orderby; |
1102 | 1102 | } |
1103 | 1103 |
@@ -55,23 +55,23 @@ discard block |
||
55 | 55 | $min = true; |
56 | 56 | $allhistory = false; |
57 | 57 | $filter['source'] = array(); |
58 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
59 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
60 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
61 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
62 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
63 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
64 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
65 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
66 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
67 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
58 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
59 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
60 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
61 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
62 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
63 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
64 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
65 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
66 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
67 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
68 | 68 | |
69 | 69 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
70 | 70 | $min = true; |
71 | 71 | } else $min = false; |
72 | 72 | |
73 | 73 | if (isset($_GET['ident'])) { |
74 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
74 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
75 | 75 | if ($tracker) { |
76 | 76 | $spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident); |
77 | 77 | } elseif ($marine) { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | $allhistory = true; |
87 | 87 | } elseif (isset($_GET['flightaware_id'])) { |
88 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
88 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
89 | 89 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
90 | 90 | if (empty($spotter_array)) { |
91 | 91 | $from_archive = true; |
@@ -93,44 +93,44 @@ discard block |
||
93 | 93 | } |
94 | 94 | $allhistory = true; |
95 | 95 | } elseif (isset($_GET['famtrack_id'])) { |
96 | - $famtrack_id = filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING); |
|
96 | + $famtrack_id = filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING); |
|
97 | 97 | $spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id); |
98 | 98 | $allhistory = true; |
99 | 99 | } elseif (isset($_GET['fammarine_id'])) { |
100 | - $fammarine_id = filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING); |
|
100 | + $fammarine_id = filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING); |
|
101 | 101 | $spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id); |
102 | 102 | $allhistory = true; |
103 | 103 | } elseif (isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) { |
104 | 104 | //} elseif (isset($_GET['coord'])) { |
105 | 105 | $usecoord = true; |
106 | - $coord = explode(',',$_GET['coord']); |
|
106 | + $coord = explode(',', $_GET['coord']); |
|
107 | 107 | if ($tracker) { |
108 | - $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter); |
|
108 | + $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord, $filter); |
|
109 | 109 | } elseif ($marine) { |
110 | - $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord,$filter); |
|
110 | + $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord, $filter); |
|
111 | 111 | } else { |
112 | - $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter); |
|
112 | + $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter); |
|
113 | 113 | } |
114 | 114 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) { |
115 | 115 | $usecoord = true; |
116 | - $coord = explode(',',$_GET['coord']); |
|
116 | + $coord = explode(',', $_GET['coord']); |
|
117 | 117 | if ($tracker) { |
118 | - $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter); |
|
118 | + $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter); |
|
119 | 119 | } elseif ($marine) { |
120 | - $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter); |
|
120 | + $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter); |
|
121 | 121 | } else { |
122 | - $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter); |
|
122 | + $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter); |
|
123 | 123 | } |
124 | 124 | } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) { |
125 | 125 | $from_archive = true; |
126 | 126 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
127 | 127 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
128 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
129 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
130 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
131 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
132 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
133 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
128 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
129 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
130 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
131 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
132 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
133 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
134 | 134 | } elseif ($min) { |
135 | 135 | if ($tracker) { |
136 | 136 | $spotter_array = $TrackerLive->getMinLiveTrackerData($filter); |
@@ -142,18 +142,18 @@ discard block |
||
142 | 142 | # $min = true; |
143 | 143 | } else { |
144 | 144 | if ($tracker) { |
145 | - $spotter_array = $TrackerLive->getLiveTrackerData('','',$filter); |
|
145 | + $spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter); |
|
146 | 146 | } elseif ($marine) { |
147 | - $spotter_array = $marineLive->getLiveMarineData('','',$filter); |
|
147 | + $spotter_array = $marineLive->getLiveMarineData('', '', $filter); |
|
148 | 148 | } else { |
149 | - $spotter_array = $SpotterLive->getLiveSpotterData('','',$filter); |
|
149 | + $spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | if (!empty($spotter_array) || $usecoord) { |
154 | 154 | if ($usecoord) { |
155 | 155 | if (isset($_GET['archive'])) { |
156 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
156 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
157 | 157 | } else { |
158 | 158 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
159 | 159 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | if ($flightcnt == '') $flightcnt = 0; |
162 | 162 | } else $flightcnt = 0; |
163 | 163 | |
164 | -$sqltime = round(microtime(true)-$begintime,2); |
|
164 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
165 | 165 | |
166 | 166 | if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
167 | 167 | else $usenextlatlon = true; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | if (!empty($spotter_array) && is_array($spotter_array)) |
179 | 179 | { |
180 | 180 | $output .= '"features": ['; |
181 | - foreach($spotter_array as $spotter_item) |
|
181 | + foreach ($spotter_array as $spotter_item) |
|
182 | 182 | { |
183 | 183 | $j++; |
184 | 184 | date_default_timezone_set('UTC'); |
@@ -234,8 +234,8 @@ discard block |
||
234 | 234 | */ |
235 | 235 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
236 | 236 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
237 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
238 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
237 | + if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
238 | + else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
239 | 239 | //" |
240 | 240 | } else { |
241 | 241 | if ($compress) $output .= '"c": "NA",'; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
245 | 245 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
246 | 246 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
247 | - $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
|
247 | + $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",'; |
|
248 | 248 | } elseif (isset($spotter_item['aircraft_type'])) { |
249 | 249 | $output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",'; |
250 | 250 | } elseif (!$min) { |
@@ -384,16 +384,16 @@ discard block |
||
384 | 384 | else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
385 | 385 | |
386 | 386 | if (isset($archivespeed)) { |
387 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
|
387 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed); |
|
388 | 388 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
389 | 389 | } elseif ($usenextlatlon) { |
390 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']); |
|
390 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']); |
|
391 | 391 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
392 | 392 | } |
393 | 393 | |
394 | 394 | if (!$min) $output .= '"image": "'.$image.'",'; |
395 | 395 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
396 | - $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
|
396 | + $output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",'; |
|
397 | 397 | } |
398 | 398 | if (isset($spotter_item['image_source_website'])) { |
399 | 399 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
416 | 416 | } |
417 | 417 | if (isset($spotter_item['acars'])) { |
418 | - $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
|
418 | + $output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",'; |
|
419 | 419 | } |
420 | 420 | // type when not aircraft ? |
421 | 421 | if (isset($spotter_item['type'])) { |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | |
494 | 494 | } |
495 | 495 | */ |
496 | - $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
|
496 | + $history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING); |
|
497 | 497 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
498 | 498 | |
499 | 499 | if ( |
@@ -501,11 +501,11 @@ discard block |
||
501 | 501 | || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
502 | 502 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
503 | 503 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
504 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
504 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
505 | 505 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
506 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
506 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id'])) |
|
507 | 507 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
508 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
508 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid'])) |
|
509 | 509 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
510 | 510 | ) { |
511 | 511 | if ($tracker) { |
@@ -538,9 +538,9 @@ discard block |
||
538 | 538 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
539 | 539 | } |
540 | 540 | $output_history .= '['; |
541 | - $output_history .= $spotter_history['longitude'].', '; |
|
542 | - $output_history .= $spotter_history['latitude'].', '; |
|
543 | - $output_history .= $spotter_history['altitude']*30.48; |
|
541 | + $output_history .= $spotter_history['longitude'].', '; |
|
542 | + $output_history .= $spotter_history['latitude'].', '; |
|
543 | + $output_history .= $spotter_history['altitude']*30.48; |
|
544 | 544 | $output_history .= '],'; |
545 | 545 | /* |
546 | 546 | if ($from_archive === false) { |
@@ -558,8 +558,8 @@ discard block |
||
558 | 558 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
559 | 559 | } else $d = true; |
560 | 560 | $output_history .= '['; |
561 | - $output_history .= $spotter_history['longitude'].', '; |
|
562 | - $output_history .= $spotter_history['latitude']; |
|
561 | + $output_history .= $spotter_history['longitude'].', '; |
|
562 | + $output_history .= $spotter_history['latitude']; |
|
563 | 563 | $output_history .= '],'; |
564 | 564 | /* |
565 | 565 | if ($from_archive === false) { |
@@ -575,9 +575,9 @@ discard block |
||
575 | 575 | |
576 | 576 | if ($from_archive === false) { |
577 | 577 | $output_historyd = '['; |
578 | - $output_historyd .= $spotter_item['longitude'].', '; |
|
579 | - $output_historyd .= $spotter_item['latitude']; |
|
580 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
578 | + $output_historyd .= $spotter_item['longitude'].', '; |
|
579 | + $output_historyd .= $spotter_item['latitude']; |
|
580 | + if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
581 | 581 | $output_historyd .= '],'; |
582 | 582 | //$output_history = $output_historyd.$output_history; |
583 | 583 | $output_history = $output_history.$output_historyd; |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | $output = substr($output, 0, -1); |
618 | 618 | $output .= ']'; |
619 | 619 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
620 | - $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
|
620 | + $output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",'; |
|
621 | 621 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
622 | 622 | $output .= '"fc": "'.$j.'"'; |
623 | 623 | } else { |
@@ -29,20 +29,20 @@ discard block |
||
29 | 29 | * @param String $date get data for a date |
30 | 30 | * @return Array Return Accidents data in array |
31 | 31 | */ |
32 | - public function getAccidentData($limit = '',$type = '',$date = '') { |
|
32 | + public function getAccidentData($limit = '', $type = '', $date = '') { |
|
33 | 33 | global $globalURL, $globalDBdriver; |
34 | 34 | $Image = new Image($this->db); |
35 | 35 | $Spotter = new Spotter($this->db); |
36 | 36 | $Translation = new Translation($this->db); |
37 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
37 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
38 | 38 | date_default_timezone_set('UTC'); |
39 | 39 | $result = array(); |
40 | 40 | $limit_query = ''; |
41 | 41 | if ($limit != "") |
42 | 42 | { |
43 | 43 | $limit_array = explode(",", $limit); |
44 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
45 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
44 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
45 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
46 | 46 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
47 | 47 | { |
48 | 48 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -51,29 +51,29 @@ discard block |
||
51 | 51 | |
52 | 52 | if ($type != '') { |
53 | 53 | if ($date != '') { |
54 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
54 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
55 | 55 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
56 | 56 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
57 | - $query_values = array(':type' => $type,':date' => $date); |
|
58 | - } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) { |
|
57 | + $query_values = array(':type' => $type, ':date' => $date); |
|
58 | + } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) { |
|
59 | 59 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
60 | - $query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
61 | - } elseif (preg_match("/^[0-9]{4}$/",$date)) { |
|
60 | + $query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
61 | + } elseif (preg_match("/^[0-9]{4}$/", $date)) { |
|
62 | 62 | if ($globalDBdriver == 'mysql') { |
63 | 63 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
64 | 64 | } else { |
65 | 65 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
66 | 66 | } |
67 | - $query_values = array(':type' => $type,':date' => $date); |
|
67 | + $query_values = array(':type' => $type, ':date' => $date); |
|
68 | 68 | } else { |
69 | 69 | $date = $date.'%'; |
70 | 70 | if ($globalDBdriver == 'mysql') { |
71 | 71 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
72 | - $query_values = array(':type' => $type,':date' => $date); |
|
72 | + $query_values = array(':type' => $type, ':date' => $date); |
|
73 | 73 | } else { |
74 | 74 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
75 | 75 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
76 | - $query_values = array(':type' => $type,':date' => $date); |
|
76 | + $query_values = array(':type' => $type, ':date' => $date); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | } else { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | } else { |
85 | 85 | if ($date != '') { |
86 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
86 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
87 | 87 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
88 | 88 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
89 | 89 | } else { |
@@ -102,19 +102,19 @@ discard block |
||
102 | 102 | try { |
103 | 103 | $sth = $this->db->prepare($query); |
104 | 104 | $sth->execute($query_values); |
105 | - } catch(PDOException $e) { |
|
105 | + } catch (PDOException $e) { |
|
106 | 106 | echo "error : ".$e->getMessage(); |
107 | 107 | } |
108 | 108 | $i = 0; |
109 | 109 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
110 | 110 | //print_r($row); |
111 | 111 | //echo $row['flightaware_id']; |
112 | - if (preg_match('/^[\w\-]+$/',$row['registration'])) { |
|
112 | + if (preg_match('/^[\w\-]+$/', $row['registration'])) { |
|
113 | 113 | $data = array(); |
114 | 114 | if ($row['registration'] != '') { |
115 | 115 | $image_array = $Image->getSpotterImage($row['registration']); |
116 | - 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'])); |
|
117 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
116 | + 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'])); |
|
117 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
118 | 118 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
119 | 119 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
120 | 120 | if (!empty($aircraft_info)) { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $data['aircraft_name'] = $aircraft_info[0]['type']; |
123 | 123 | $data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer']; |
124 | 124 | } else { |
125 | - $data = array_merge($data,array('aircraft_type' => 'NA')); |
|
125 | + $data = array_merge($data, array('aircraft_type' => 'NA')); |
|
126 | 126 | } |
127 | 127 | $owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']); |
128 | 128 | if (!empty($owner_data)) { |
@@ -130,18 +130,18 @@ discard block |
||
130 | 130 | $data['aircraft_base'] = $owner_data['base']; |
131 | 131 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
132 | 132 | } |
133 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
133 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
134 | 134 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
135 | 135 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
136 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
|
136 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3)); |
|
137 | 137 | if (isset($identicao[0])) { |
138 | - if (substr($row['ident'],0,2) == 'AF') { |
|
139 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
140 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
141 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
142 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
138 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
139 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
140 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
141 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
142 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
143 | 143 | } else $icao = $row['ident']; |
144 | - $icao = $Translation->checkTranslation($icao,false); |
|
144 | + $icao = $Translation->checkTranslation($icao, false); |
|
145 | 145 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
146 | 146 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
147 | 147 | //echo 'Check airline info... for '.$row['airline_name'].' '; |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | if (!empty($airline_info)) { |
151 | 151 | //echo 'data found !'."\n"; |
152 | 152 | //print_r($airline_info); |
153 | - $data = array_merge($data,$airline_info); |
|
153 | + $data = array_merge($data, $airline_info); |
|
154 | 154 | } |
155 | 155 | //else echo 'No data...'."\n"; |
156 | 156 | } |
157 | - $data = array_merge($row,$data); |
|
157 | + $data = array_merge($row, $data); |
|
158 | 158 | if ($data['ident'] == null) $data['ident'] = $icao; |
159 | 159 | if ($data['title'] == null) { |
160 | 160 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | try { |
191 | 191 | $sth = $this->db->prepare($query); |
192 | 192 | $sth->execute(); |
193 | - } catch(PDOException $e) { |
|
193 | + } catch (PDOException $e) { |
|
194 | 194 | echo "Error : ".$e->getMessage(); |
195 | 195 | } |
196 | 196 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | try { |
211 | 211 | $sth = $this->db->prepare($query); |
212 | 212 | $sth->execute(); |
213 | - } catch(PDOException $e) { |
|
213 | + } catch (PDOException $e) { |
|
214 | 214 | echo "Error : ".$e->getMessage(); |
215 | 215 | } |
216 | 216 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -225,15 +225,15 @@ discard block |
||
225 | 225 | if ($globalDebug) echo 'Import '.$file."\n"; |
226 | 226 | $result = array(); |
227 | 227 | if (file_exists($file)) { |
228 | - if (($handle = fopen($file,'r')) !== FALSE) { |
|
229 | - while (($data = fgetcsv($handle,2000,",")) !== FALSE) { |
|
228 | + if (($handle = fopen($file, 'r')) !== FALSE) { |
|
229 | + while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) { |
|
230 | 230 | if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') { |
231 | - $result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam'); |
|
231 | + $result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam'); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | fclose($handle); |
235 | 235 | } |
236 | - if (!empty($result)) $this->add($result,true); |
|
236 | + if (!empty($result)) $this->add($result, true); |
|
237 | 237 | elseif ($globalDebug) echo 'Nothing to import'; |
238 | 238 | } |
239 | 239 | } |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | $all_md5_new = array(); |
250 | 250 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
251 | 251 | if ($this->check_accidents_nb() > 0) { |
252 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
253 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
252 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
253 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
254 | 254 | if (isset($data[1])) { |
255 | 255 | $year = $data[0]; |
256 | 256 | $all_md5[$year] = $data[1]; |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | } |
261 | 261 | } |
262 | 262 | } |
263 | - $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
263 | + $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
264 | 264 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
265 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
266 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
265 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
266 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
267 | 267 | if (isset($data[1])) { |
268 | 268 | $year = $data[0]; |
269 | 269 | $all_md5_new[$year] = $data[1]; |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | fclose($handle); |
273 | 273 | } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
274 | 274 | } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
275 | - $result = $Common->arr_diff($all_md5_new,$all_md5); |
|
275 | + $result = $Common->arr_diff($all_md5_new, $all_md5); |
|
276 | 276 | if (empty($result) && $globalDebug) echo 'Nothing to update'; |
277 | 277 | foreach ($result as $file => $md5) { |
278 | - $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
|
278 | + $Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file); |
|
279 | 279 | if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
280 | 280 | elseif ($globalDebug) echo 'Download '.$file.' failed'; |
281 | 281 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * Add data to DB |
286 | 286 | * @param Array $crash An array with accidents/incidents data |
287 | 287 | */ |
288 | - public function add($crash,$new = false) { |
|
288 | + public function add($crash, $new = false) { |
|
289 | 289 | global $globalTransaction, $globalDebug; |
290 | 290 | require_once('class.Connection.php'); |
291 | 291 | require_once('class.Image.php'); |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | $sthd->execute(array(':source' => $crash[0]['source'])); |
302 | 302 | } |
303 | 303 | if ($globalTransaction) $Connection->db->beginTransaction(); |
304 | - $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,'operator' => null); |
|
304 | + $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, 'operator' => null); |
|
305 | 305 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
306 | 306 | $sth_check = $Connection->db->prepare($query_check); |
307 | 307 | $query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)'; |
@@ -314,31 +314,31 @@ discard block |
||
314 | 314 | $cr = array_map(function($value) { |
315 | 315 | return $value === "" ? NULL : $value; |
316 | 316 | }, $cr); |
317 | - if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
|
318 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
319 | - $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
|
317 | + if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) { |
|
318 | + if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
319 | + $query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']); |
|
320 | 320 | $sth_check->execute($query_check_values); |
321 | 321 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
322 | 322 | if ($result_check['nb'] == 0) { |
323 | - $query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']); |
|
323 | + $query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']); |
|
324 | 324 | $sth->execute($query_values); |
325 | - if ($cr['date'] > time()-(30*86400)) { |
|
325 | + if ($cr['date'] > time() - (30*86400)) { |
|
326 | 326 | if (empty($Image->getSpotterImage($cr['registration']))) { |
327 | 327 | //if ($globalDebug) echo 'Get image...'."\n"; |
328 | 328 | $Image->addSpotterImage($cr['registration']); |
329 | 329 | } |
330 | 330 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
331 | 331 | } |
332 | - $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
|
332 | + $Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date'])); |
|
333 | 333 | } |
334 | 334 | } |
335 | - if ($globalTransaction && $j % 1000 == 0) { |
|
335 | + if ($globalTransaction && $j%1000 == 0) { |
|
336 | 336 | $Connection->db->commit(); |
337 | 337 | $Connection->db->beginTransaction(); |
338 | 338 | } |
339 | 339 | } |
340 | 340 | if ($globalTransaction) $Connection->db->commit(); |
341 | - } catch(PDOException $e) { |
|
341 | + } catch (PDOException $e) { |
|
342 | 342 | if ($globalTransaction) $Connection->db->rollBack(); |
343 | 343 | echo $e->getMessage(); |
344 | 344 | } |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $Connection = new Connection(); |
357 | 357 | $sth = $Connection->db->prepare($query); |
358 | 358 | $sth->execute(); |
359 | - } catch(PDOException $e) { |
|
359 | + } catch (PDOException $e) { |
|
360 | 360 | return "error : ".$e->getMessage(); |
361 | 361 | } |
362 | 362 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | $Connection = new Connection(); |
375 | 375 | $sth = $Connection->db->prepare($query); |
376 | 376 | $sth->execute(); |
377 | - } catch(PDOException $e) { |
|
377 | + } catch (PDOException $e) { |
|
378 | 378 | return "error : ".$e->getMessage(); |
379 | 379 | } |
380 | 380 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $Connection = new Connection(); |
390 | 390 | $sth = $Connection->db->prepare($query); |
391 | 391 | $sth->execute(); |
392 | - } catch(PDOException $e) { |
|
392 | + } catch (PDOException $e) { |
|
393 | 393 | return "error : ".$e->getMessage(); |
394 | 394 | } |
395 | 395 | } |
@@ -9,14 +9,14 @@ discard block |
||
9 | 9 | |
10 | 10 | $from_archive = false; |
11 | 11 | if (isset($_GET['ident'])) { |
12 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
12 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
13 | 13 | if (isset($_GET['currenttime'])) { |
14 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
14 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
15 | 15 | $currenttime = round($currenttime/1000); |
16 | - $spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident,$currenttime); |
|
16 | + $spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident, $currenttime); |
|
17 | 17 | if (empty($spotter_array)) { |
18 | 18 | $from_archive = true; |
19 | - $spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident,$currenttime); |
|
19 | + $spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident, $currenttime); |
|
20 | 20 | } |
21 | 21 | } else { |
22 | 22 | $spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident); |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($_GET['flightaware_id'])) { |
30 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
30 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
31 | 31 | if (isset($_GET['currenttime'])) { |
32 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
32 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
33 | 33 | $currenttime = round($currenttime/1000); |
34 | - $spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id,$currenttime); |
|
34 | + $spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id, $currenttime); |
|
35 | 35 | if (empty($spotter_array)) { |
36 | 36 | $from_archive = true; |
37 | 37 | // $spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id); |
38 | - $spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id,$currenttime); |
|
38 | + $spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id, $currenttime); |
|
39 | 39 | } |
40 | 40 | } else { |
41 | 41 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "") |
55 | 55 | { |
56 | 56 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
57 | - $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
57 | + $image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
58 | 58 | } else $image = $spotter_item['image_thumbnail']; |
59 | 59 | |
60 | 60 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country']; |
73 | 73 | if (isset($spotter_item['departure_airport_time'])) { |
74 | 74 | if ($spotter_item['departure_airport_time'] > 2460) { |
75 | - print '<br /><span class="time">'.date('H:m',$spotter_item['departure_airport_time']).'</span>'; |
|
75 | + print '<br /><span class="time">'.date('H:m', $spotter_item['departure_airport_time']).'</span>'; |
|
76 | 76 | } else { |
77 | 77 | print '<br /><span class="time">'.$spotter_item['departure_airport_time'].'</span>'; |
78 | 78 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country']; |
82 | 82 | if (isset($spotter_item['arrival_airport_time'])) { |
83 | 83 | if ($spotter_item['arrival_airport_time'] > 2460) { |
84 | - print '<br /><span class="time">'.date('H:m',$spotter_item['arrival_airport_time']).'</span>'; |
|
84 | + print '<br /><span class="time">'.date('H:m', $spotter_item['arrival_airport_time']).'</span>'; |
|
85 | 85 | } else { |
86 | 86 | print '<br /><span class="time">'.$spotter_item['arrival_airport_time'].'</span>'; |
87 | 87 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
153 | 153 | if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
154 | -if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
154 | +if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br/>', $spotter_item['acars']['message'])).'</div>'; |
|
155 | 155 | if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
156 | 156 | print '</div>'; |
157 | 157 | ?> |