|
@@ -14,75 +14,75 @@ discard block |
|
|
block discarded – undo |
|
14
|
14
|
* @param Array $filter the filter |
|
15
|
15
|
* @return Array the SQL part |
|
16
|
16
|
*/ |
|
17
|
|
- public function getFilter($filter = array(),$where = false,$and = false) { |
|
|
17
|
+ public function getFilter($filter = array(), $where = false, $and = false) { |
|
18
|
18
|
global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
|
19
|
19
|
$filters = array(); |
|
20
|
20
|
if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
|
21
|
21
|
if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
|
22
|
22
|
$filters = $globalStatsFilters[$globalFilterName]; |
|
23
|
23
|
} else { |
|
24
|
|
- $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
|
24
|
+ $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
25
|
25
|
} |
|
26
|
26
|
} |
|
27
|
27
|
if (isset($filter[0]['source'])) { |
|
28
|
|
- $filters = array_merge($filters,$filter); |
|
|
28
|
+ $filters = array_merge($filters, $filter); |
|
29
|
29
|
} |
|
30
|
|
- if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
|
30
|
+ if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
31
|
31
|
$filter_query_join = ''; |
|
32
|
32
|
$filter_query_where = ''; |
|
33
|
|
- foreach($filters as $flt) { |
|
|
33
|
+ foreach ($filters as $flt) { |
|
34
|
34
|
if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
35
|
35
|
if ($flt['airlines'][0] != '' && $flt['airlines'][0] != 'all') { |
|
36
|
36
|
if (isset($flt['source'])) { |
|
37
|
|
- $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
|
+ $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"; |
|
38
|
38
|
} else { |
|
39
|
|
- $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
|
+ $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"; |
|
40
|
40
|
} |
|
41
|
41
|
} |
|
42
|
42
|
} |
|
43
|
43
|
if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
44
|
44
|
if (isset($flt['source'])) { |
|
45
|
|
- $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
|
+ $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"; |
|
46
|
46
|
} else { |
|
47
|
|
- $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
|
+ $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"; |
|
48
|
48
|
} |
|
49
|
49
|
} |
|
50
|
50
|
if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
51
|
51
|
if (isset($flt['source'])) { |
|
52
|
|
- $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
|
+ $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"; |
|
53
|
53
|
} else { |
|
54
|
|
- $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
|
+ $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"; |
|
55
|
55
|
} |
|
56
|
56
|
} |
|
57
|
57
|
if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
58
|
58
|
if (isset($flt['source'])) { |
|
59
|
|
- $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
|
+ $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"; |
|
60
|
60
|
} else { |
|
61
|
|
- $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
|
+ $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"; |
|
62
|
62
|
} |
|
63
|
63
|
} |
|
64
|
64
|
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']))) { |
|
65
|
65
|
if (isset($flt['source'])) { |
|
66
|
|
- $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
|
+ $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"; |
|
67
|
67
|
} |
|
68
|
68
|
} |
|
69
|
69
|
} |
|
70
|
70
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
71
|
71
|
if ($filter['airlines'][0] != '' && $filter['airlines'][0] != 'all') { |
|
72
|
|
- $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
|
+ $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"; |
|
73
|
73
|
} |
|
74
|
74
|
} |
|
75
|
75
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
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
|
82
|
if (count($filter['source']) == 1) { |
|
83
|
83
|
$filter_query_where .= " AND format_source = '".$filter['source'][0]."'"; |
|
84
|
84
|
} else { |
|
85
|
|
- $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
|
85
|
+ $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
86
|
86
|
} |
|
87
|
87
|
} |
|
88
|
88
|
if (isset($filter['ident']) && !empty($filter['ident'])) { |
|
@@ -92,7 +92,7 @@ discard block |
|
|
block discarded – undo |
|
92
|
92
|
$filter_query_where .= " AND flightaware_id = '".$filter['id']."'"; |
|
93
|
93
|
} |
|
94
|
94
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
95
|
|
- $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
95
|
+ $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
96
|
96
|
} |
|
97
|
97
|
if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
|
98
|
98
|
$filter_query_date = ''; |
|
@@ -117,41 +117,41 @@ discard block |
|
|
block discarded – undo |
|
117
|
117
|
$filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
118
|
118
|
} |
|
119
|
119
|
} |
|
120
|
|
- $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"; |
|
|
120
|
+ $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"; |
|
121
|
121
|
} |
|
122
|
122
|
if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
123
|
123
|
elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
124
|
124
|
if ($filter_query_where != '') { |
|
125
|
|
- $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
|
125
|
+ $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
126
|
126
|
} |
|
127
|
127
|
$filter_query = $filter_query_join.$filter_query_where; |
|
128
|
128
|
return $filter_query; |
|
129
|
129
|
} |
|
130
|
130
|
|
|
131
|
131
|
// Spotter_archive |
|
132
|
|
- 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 = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
|
132
|
+ 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 = '', $real_altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
133
|
133
|
require_once(dirname(__FILE__).'/class.Spotter.php'); |
|
134
|
134
|
if ($over_country == '') { |
|
135
|
135
|
$Spotter = new Spotter($this->db); |
|
136
|
|
- $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
|
136
|
+ $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
137
|
137
|
if (!empty($data_country)) $country = $data_country['iso2']; |
|
138
|
138
|
else $country = ''; |
|
139
|
139
|
} else $country = $over_country; |
|
140
|
|
- if ($airline_type === NULL) $airline_type =''; |
|
|
140
|
+ if ($airline_type === NULL) $airline_type = ''; |
|
141
|
141
|
|
|
142
|
142
|
//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
|
143
|
143
|
//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
|
144
|
144
|
|
|
145
|
145
|
// Route is not added in spotter_archive |
|
146
|
|
- $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,real_altitude) |
|
|
146
|
+ $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,real_altitude) |
|
147
|
147
|
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,:real_altitude)"; |
|
148
|
148
|
|
|
149
|
|
- $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,':real_altitude' => $real_altitude); |
|
|
149
|
+ $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, ':real_altitude' => $real_altitude); |
|
150
|
150
|
try { |
|
151
|
151
|
$sth = $this->db->prepare($query); |
|
152
|
152
|
$sth->execute($query_values); |
|
153
|
153
|
$sth->closeCursor(); |
|
154
|
|
- } catch(PDOException $e) { |
|
|
154
|
+ } catch (PDOException $e) { |
|
155
|
155
|
return "error : ".$e->getMessage(); |
|
156
|
156
|
} |
|
157
|
157
|
return "success"; |
|
@@ -170,9 +170,9 @@ discard block |
|
|
block discarded – undo |
|
170
|
170
|
|
|
171
|
171
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
172
|
172
|
//$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"; |
|
173
|
|
- $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
|
173
|
+ $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
174
|
174
|
|
|
175
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
|
175
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
176
|
176
|
|
|
177
|
177
|
return $spotter_array; |
|
178
|
178
|
} |
|
@@ -190,7 +190,7 @@ discard block |
|
|
block discarded – undo |
|
190
|
190
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
191
|
191
|
//$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
192
|
192
|
//$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"; |
|
193
|
|
- $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
|
193
|
+ $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
194
|
194
|
|
|
195
|
195
|
// $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
|
196
|
196
|
/* |
|
@@ -203,7 +203,7 @@ discard block |
|
|
block discarded – undo |
|
203
|
203
|
} |
|
204
|
204
|
$spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
|
205
|
205
|
*/ |
|
206
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
|
206
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
207
|
207
|
|
|
208
|
208
|
return $spotter_array; |
|
209
|
209
|
} |
|
@@ -217,14 +217,14 @@ discard block |
|
|
block discarded – undo |
|
217
|
217
|
public function getAllArchiveSpotterDataById($id) { |
|
218
|
218
|
date_default_timezone_set('UTC'); |
|
219
|
219
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
220
|
|
- $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
|
220
|
+ $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
221
|
221
|
|
|
222
|
222
|
// $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
|
223
|
223
|
|
|
224
|
224
|
try { |
|
225
|
225
|
$sth = $this->db->prepare($query); |
|
226
|
226
|
$sth->execute(array(':id' => $id)); |
|
227
|
|
- } catch(PDOException $e) { |
|
|
227
|
+ } catch (PDOException $e) { |
|
228
|
228
|
echo $e->getMessage(); |
|
229
|
229
|
die; |
|
230
|
230
|
} |
|
@@ -242,11 +242,11 @@ discard block |
|
|
block discarded – undo |
|
242
|
242
|
public function getCoordArchiveSpotterDataById($id) { |
|
243
|
243
|
date_default_timezone_set('UTC'); |
|
244
|
244
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
245
|
|
- $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER by spotter_archive.date ASC"; |
|
|
245
|
+ $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER by spotter_archive.date ASC"; |
|
246
|
246
|
try { |
|
247
|
247
|
$sth = $this->db->prepare($query); |
|
248
|
248
|
$sth->execute(array(':id' => $id)); |
|
249
|
|
- } catch(PDOException $e) { |
|
|
249
|
+ } catch (PDOException $e) { |
|
250
|
250
|
echo $e->getMessage(); |
|
251
|
251
|
die; |
|
252
|
252
|
} |
|
@@ -260,14 +260,14 @@ discard block |
|
|
block discarded – undo |
|
260
|
260
|
* @return Array the spotter information |
|
261
|
261
|
* |
|
262
|
262
|
*/ |
|
263
|
|
- public function getCoordArchiveSpotterDataByIdDate($id,$begindate,$enddate) { |
|
|
263
|
+ public function getCoordArchiveSpotterDataByIdDate($id, $begindate, $enddate) { |
|
264
|
264
|
date_default_timezone_set('UTC'); |
|
265
|
265
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
266
|
|
- $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.date BETWEEN '".$begindate."' AND '".$enddate."' ORDER by spotter_archive.date ASC"; |
|
|
266
|
+ $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.date BETWEEN '".$begindate."' AND '".$enddate."' ORDER by spotter_archive.date ASC"; |
|
267
|
267
|
try { |
|
268
|
268
|
$sth = $this->db->prepare($query); |
|
269
|
269
|
$sth->execute(array(':id' => $id)); |
|
270
|
|
- } catch(PDOException $e) { |
|
|
270
|
+ } catch (PDOException $e) { |
|
271
|
271
|
echo $e->getMessage(); |
|
272
|
272
|
die; |
|
273
|
273
|
} |
|
@@ -287,12 +287,12 @@ discard block |
|
|
block discarded – undo |
|
287
|
287
|
date_default_timezone_set('UTC'); |
|
288
|
288
|
|
|
289
|
289
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
290
|
|
- $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"; |
|
|
290
|
+ $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"; |
|
291
|
291
|
|
|
292
|
292
|
try { |
|
293
|
293
|
$sth = $this->db->prepare($query); |
|
294
|
294
|
$sth->execute(array(':ident' => $ident)); |
|
295
|
|
- } catch(PDOException $e) { |
|
|
295
|
+ } catch (PDOException $e) { |
|
296
|
296
|
echo $e->getMessage(); |
|
297
|
297
|
die; |
|
298
|
298
|
} |
|
@@ -312,12 +312,12 @@ discard block |
|
|
block discarded – undo |
|
312
|
312
|
date_default_timezone_set('UTC'); |
|
313
|
313
|
|
|
314
|
314
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
315
|
|
- $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"; |
|
|
315
|
+ $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"; |
|
316
|
316
|
|
|
317
|
317
|
try { |
|
318
|
318
|
$sth = $this->db->prepare($query); |
|
319
|
319
|
$sth->execute(array(':id' => $id)); |
|
320
|
|
- } catch(PDOException $e) { |
|
|
320
|
+ } catch (PDOException $e) { |
|
321
|
321
|
echo $e->getMessage(); |
|
322
|
322
|
die; |
|
323
|
323
|
} |
|
@@ -335,11 +335,11 @@ discard block |
|
|
block discarded – undo |
|
335
|
335
|
public function getAltitudeSpeedArchiveSpotterDataById($id) { |
|
336
|
336
|
date_default_timezone_set('UTC'); |
|
337
|
337
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
338
|
|
- $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
|
338
|
+ $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
339
|
339
|
try { |
|
340
|
340
|
$sth = $this->db->prepare($query); |
|
341
|
341
|
$sth->execute(array(':id' => $id)); |
|
342
|
|
- } catch(PDOException $e) { |
|
|
342
|
+ } catch (PDOException $e) { |
|
343
|
343
|
echo $e->getMessage(); |
|
344
|
344
|
die; |
|
345
|
345
|
} |
|
@@ -356,12 +356,12 @@ discard block |
|
|
block discarded – undo |
|
356
|
356
|
public function getLastAltitudeArchiveSpotterDataByIdent($ident) { |
|
357
|
357
|
date_default_timezone_set('UTC'); |
|
358
|
358
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
359
|
|
- $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"; |
|
|
359
|
+ $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"; |
|
360
|
360
|
// $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
361
|
361
|
try { |
|
362
|
362
|
$sth = $this->db->prepare($query); |
|
363
|
363
|
$sth->execute(array(':ident' => $ident)); |
|
364
|
|
- } catch(PDOException $e) { |
|
|
364
|
+ } catch (PDOException $e) { |
|
365
|
365
|
echo $e->getMessage(); |
|
366
|
366
|
die; |
|
367
|
367
|
} |
|
@@ -377,11 +377,11 @@ discard block |
|
|
block discarded – undo |
|
377
|
377
|
* @return Array the spotter information |
|
378
|
378
|
* |
|
379
|
379
|
*/ |
|
380
|
|
- public function getSpotterArchiveData($ident,$flightaware_id,$date) { |
|
|
380
|
+ public function getSpotterArchiveData($ident, $flightaware_id, $date) { |
|
381
|
381
|
$Spotter = new Spotter($this->db); |
|
382
|
382
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
383
|
|
- $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"; |
|
384
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
|
383
|
+ $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"; |
|
|
384
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
385
|
385
|
return $spotter_array; |
|
386
|
386
|
} |
|
387
|
387
|
|
|
@@ -395,7 +395,7 @@ discard block |
|
|
block discarded – undo |
|
395
|
395
|
try { |
|
396
|
396
|
$sth = $this->db->prepare($query); |
|
397
|
397
|
$sth->execute(); |
|
398
|
|
- } catch(PDOException $e) { |
|
|
398
|
+ } catch (PDOException $e) { |
|
399
|
399
|
echo $e->getMessage(); |
|
400
|
400
|
die; |
|
401
|
401
|
} |
|
@@ -407,34 +407,34 @@ discard block |
|
|
block discarded – undo |
|
407
|
407
|
* @return Array the spotter information |
|
408
|
408
|
* |
|
409
|
409
|
*/ |
|
410
|
|
- public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) { |
|
|
410
|
+ public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) { |
|
411
|
411
|
global $globalDBdriver, $globalLiveInterval; |
|
412
|
412
|
date_default_timezone_set('UTC'); |
|
413
|
413
|
//$filter_query = $this->getFilter($filter,true,true); |
|
414
|
414
|
|
|
415
|
415
|
$filter_query = ''; |
|
416
|
416
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
417
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
|
417
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
418
|
418
|
} |
|
419
|
419
|
// Use spotter_output also ? |
|
420
|
420
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
421
|
|
- $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 "; |
|
|
421
|
+ $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 "; |
|
422
|
422
|
} |
|
423
|
423
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
424
|
424
|
$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 "; |
|
425
|
425
|
} |
|
426
|
426
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
427
|
|
- $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
427
|
+ $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
428
|
428
|
} |
|
429
|
429
|
|
|
430
|
430
|
if ($globalDBdriver == 'mysql') { |
|
431
|
|
- $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 |
|
|
431
|
+ $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 |
|
432
|
432
|
FROM spotter_archive |
|
433
|
433
|
INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
|
434
|
434
|
WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".' |
|
435
|
435
|
'.$filter_query.' ORDER BY flightaware_id'; |
|
436
|
436
|
} else { |
|
437
|
|
- $query = 'SELECT spotter_archive.flightaware_id, spotter_archive.date, 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 |
|
|
437
|
+ $query = 'SELECT spotter_archive.flightaware_id, spotter_archive.date, 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 |
|
438
|
438
|
FROM spotter_archive |
|
439
|
439
|
INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
|
440
|
440
|
WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".' |
|
@@ -444,7 +444,7 @@ discard block |
|
|
block discarded – undo |
|
444
|
444
|
try { |
|
445
|
445
|
$sth = $this->db->prepare($query); |
|
446
|
446
|
$sth->execute(); |
|
447
|
|
- } catch(PDOException $e) { |
|
|
447
|
+ } catch (PDOException $e) { |
|
448
|
448
|
echo $e->getMessage(); |
|
449
|
449
|
die; |
|
450
|
450
|
} |
|
@@ -458,7 +458,7 @@ discard block |
|
|
block discarded – undo |
|
458
|
458
|
* @return Array the spotter information |
|
459
|
459
|
* |
|
460
|
460
|
*/ |
|
461
|
|
- public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) { |
|
|
461
|
+ public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) { |
|
462
|
462
|
global $globalDBdriver, $globalLiveInterval; |
|
463
|
463
|
date_default_timezone_set('UTC'); |
|
464
|
464
|
|
|
@@ -466,17 +466,17 @@ discard block |
|
|
block discarded – undo |
|
466
|
466
|
|
|
467
|
467
|
$filter_query = ''; |
|
468
|
468
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
469
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
|
469
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
470
|
470
|
} |
|
471
|
471
|
// Use spotter_output also ? |
|
472
|
472
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
473
|
|
- $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 "; |
|
|
473
|
+ $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 "; |
|
474
|
474
|
} |
|
475
|
475
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
476
|
476
|
$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 "; |
|
477
|
477
|
} |
|
478
|
478
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
479
|
|
- $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
479
|
+ $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
480
|
480
|
} |
|
481
|
481
|
|
|
482
|
482
|
|
|
@@ -487,7 +487,7 @@ discard block |
|
|
block discarded – undo |
|
487
|
487
|
FROM spotter_archive |
|
488
|
488
|
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'; |
|
489
|
489
|
*/ |
|
490
|
|
- $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 |
|
|
490
|
+ $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 |
|
491
|
491
|
FROM spotter_archive_output |
|
492
|
492
|
LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
|
493
|
493
|
WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
|
@@ -502,7 +502,7 @@ discard block |
|
|
block discarded – undo |
|
502
|
502
|
WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
|
503
|
503
|
'.$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'; |
|
504
|
504
|
*/ |
|
505
|
|
- $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 |
|
|
505
|
+ $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 |
|
506
|
506
|
FROM spotter_archive_output |
|
507
|
507
|
INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
|
508
|
508
|
WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
|
@@ -514,7 +514,7 @@ discard block |
|
|
block discarded – undo |
|
514
|
514
|
try { |
|
515
|
515
|
$sth = $this->db->prepare($query); |
|
516
|
516
|
$sth->execute(); |
|
517
|
|
- } catch(PDOException $e) { |
|
|
517
|
+ } catch (PDOException $e) { |
|
518
|
518
|
echo $e->getMessage(); |
|
519
|
519
|
die; |
|
520
|
520
|
} |
|
@@ -529,22 +529,22 @@ discard block |
|
|
block discarded – undo |
|
529
|
529
|
* @return Array the spotter information |
|
530
|
530
|
* |
|
531
|
531
|
*/ |
|
532
|
|
- public function getLiveSpotterCount($begindate,$enddate,$filter = array()) { |
|
|
532
|
+ public function getLiveSpotterCount($begindate, $enddate, $filter = array()) { |
|
533
|
533
|
global $globalDBdriver, $globalLiveInterval; |
|
534
|
534
|
date_default_timezone_set('UTC'); |
|
535
|
535
|
|
|
536
|
536
|
$filter_query = ''; |
|
537
|
537
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
538
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
|
538
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
539
|
539
|
} |
|
540
|
540
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
541
|
|
- $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 "; |
|
|
541
|
+ $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 "; |
|
542
|
542
|
} |
|
543
|
543
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
544
|
544
|
$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 "; |
|
545
|
545
|
} |
|
546
|
546
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
547
|
|
- $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
547
|
+ $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
548
|
548
|
} |
|
549
|
549
|
|
|
550
|
550
|
//if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
@@ -559,7 +559,7 @@ discard block |
|
|
block discarded – undo |
|
559
|
559
|
try { |
|
560
|
560
|
$sth = $this->db->prepare($query); |
|
561
|
561
|
$sth->execute(); |
|
562
|
|
- } catch(PDOException $e) { |
|
|
562
|
+ } catch (PDOException $e) { |
|
563
|
563
|
echo $e->getMessage(); |
|
564
|
564
|
die; |
|
565
|
565
|
} |
|
@@ -579,7 +579,7 @@ discard block |
|
|
block discarded – undo |
|
579
|
579
|
* @return Array the spotter information |
|
580
|
580
|
* |
|
581
|
581
|
*/ |
|
582
|
|
- 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()) { |
|
|
582
|
+ 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()) { |
|
583
|
583
|
global $globalTimezone, $globalDBdriver; |
|
584
|
584
|
require_once(dirname(__FILE__).'/class.Translation.php'); |
|
585
|
585
|
$Translation = new Translation($this->db); |
|
@@ -629,7 +629,7 @@ discard block |
|
|
block discarded – undo |
|
629
|
629
|
} |
|
630
|
630
|
|
|
631
|
631
|
if ($registration != "") { |
|
632
|
|
- $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
|
632
|
+ $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
633
|
633
|
if (!is_string($registration)) { |
|
634
|
634
|
return array(); |
|
635
|
635
|
} else { |
|
@@ -638,7 +638,7 @@ discard block |
|
|
block discarded – undo |
|
638
|
638
|
} |
|
639
|
639
|
|
|
640
|
640
|
if ($aircraft_icao != "") { |
|
641
|
|
- $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
|
641
|
+ $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
642
|
642
|
if (!is_string($aircraft_icao)) { |
|
643
|
643
|
return array(); |
|
644
|
644
|
} else { |
|
@@ -647,7 +647,7 @@ discard block |
|
|
block discarded – undo |
|
647
|
647
|
} |
|
648
|
648
|
|
|
649
|
649
|
if ($aircraft_manufacturer != "") { |
|
650
|
|
- $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
|
650
|
+ $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
651
|
651
|
if (!is_string($aircraft_manufacturer)) { |
|
652
|
652
|
return array(); |
|
653
|
653
|
} else { |
|
@@ -664,7 +664,7 @@ discard block |
|
|
block discarded – undo |
|
664
|
664
|
} |
|
665
|
665
|
|
|
666
|
666
|
if ($airline_icao != "") { |
|
667
|
|
- $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
|
667
|
+ $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
668
|
668
|
if (!is_string($airline_icao)) { |
|
669
|
669
|
return array(); |
|
670
|
670
|
} else { |
|
@@ -673,7 +673,7 @@ discard block |
|
|
block discarded – undo |
|
673
|
673
|
} |
|
674
|
674
|
|
|
675
|
675
|
if ($airline_country != "") { |
|
676
|
|
- $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
|
676
|
+ $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
677
|
677
|
if (!is_string($airline_country)) { |
|
678
|
678
|
return array(); |
|
679
|
679
|
} else { |
|
@@ -682,7 +682,7 @@ discard block |
|
|
block discarded – undo |
|
682
|
682
|
} |
|
683
|
683
|
|
|
684
|
684
|
if ($airline_type != "") { |
|
685
|
|
- $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
|
685
|
+ $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
686
|
686
|
if (!is_string($airline_type)) { |
|
687
|
687
|
return array(); |
|
688
|
688
|
} else { |
|
@@ -699,7 +699,7 @@ discard block |
|
|
block discarded – undo |
|
699
|
699
|
} |
|
700
|
700
|
|
|
701
|
701
|
if ($airport != "") { |
|
702
|
|
- $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
|
702
|
+ $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
703
|
703
|
if (!is_string($airport)) { |
|
704
|
704
|
return array(); |
|
705
|
705
|
} else { |
|
@@ -708,7 +708,7 @@ discard block |
|
|
block discarded – undo |
|
708
|
708
|
} |
|
709
|
709
|
|
|
710
|
710
|
if ($airport_country != "") { |
|
711
|
|
- $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
|
711
|
+ $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
712
|
712
|
if (!is_string($airport_country)) { |
|
713
|
713
|
return array(); |
|
714
|
714
|
} else { |
|
@@ -717,14 +717,14 @@ discard block |
|
|
block discarded – undo |
|
717
|
717
|
} |
|
718
|
718
|
|
|
719
|
719
|
if ($callsign != "") { |
|
720
|
|
- $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
|
720
|
+ $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
721
|
721
|
if (!is_string($callsign)) { |
|
722
|
722
|
return array(); |
|
723
|
723
|
} else { |
|
724
|
724
|
$translate = $Translation->ident2icao($callsign); |
|
725
|
725
|
if ($translate != $callsign) { |
|
726
|
726
|
$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
|
727
|
|
- $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
|
727
|
+ $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
728
|
728
|
} else { |
|
729
|
729
|
$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
|
730
|
730
|
} |
|
@@ -732,7 +732,7 @@ discard block |
|
|
block discarded – undo |
|
732
|
732
|
} |
|
733
|
733
|
|
|
734
|
734
|
if ($owner != "") { |
|
735
|
|
- $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
|
735
|
+ $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
736
|
736
|
if (!is_string($owner)) { |
|
737
|
737
|
return array(); |
|
738
|
738
|
} else { |
|
@@ -741,7 +741,7 @@ discard block |
|
|
block discarded – undo |
|
741
|
741
|
} |
|
742
|
742
|
|
|
743
|
743
|
if ($pilot_name != "") { |
|
744
|
|
- $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
|
744
|
+ $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
745
|
745
|
if (!is_string($pilot_name)) { |
|
746
|
746
|
return array(); |
|
747
|
747
|
} else { |
|
@@ -750,7 +750,7 @@ discard block |
|
|
block discarded – undo |
|
750
|
750
|
} |
|
751
|
751
|
|
|
752
|
752
|
if ($pilot_id != "") { |
|
753
|
|
- $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
|
753
|
+ $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
754
|
754
|
if (!is_string($pilot_id)) { |
|
755
|
755
|
return array(); |
|
756
|
756
|
} else { |
|
@@ -759,7 +759,7 @@ discard block |
|
|
block discarded – undo |
|
759
|
759
|
} |
|
760
|
760
|
|
|
761
|
761
|
if ($departure_airport_route != "") { |
|
762
|
|
- $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
|
762
|
+ $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
763
|
763
|
if (!is_string($departure_airport_route)) { |
|
764
|
764
|
return array(); |
|
765
|
765
|
} else { |
|
@@ -768,7 +768,7 @@ discard block |
|
|
block discarded – undo |
|
768
|
768
|
} |
|
769
|
769
|
|
|
770
|
770
|
if ($arrival_airport_route != "") { |
|
771
|
|
- $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
|
771
|
+ $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
772
|
772
|
if (!is_string($arrival_airport_route)) { |
|
773
|
773
|
return array(); |
|
774
|
774
|
} else { |
|
@@ -779,8 +779,8 @@ discard block |
|
|
block discarded – undo |
|
779
|
779
|
if ($altitude != "") { |
|
780
|
780
|
$altitude_array = explode(",", $altitude); |
|
781
|
781
|
|
|
782
|
|
- $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
783
|
|
- $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
|
782
|
+ $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
|
783
|
+ $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
784
|
784
|
|
|
785
|
785
|
|
|
786
|
786
|
if ($altitude_array[1] != "") { |
|
@@ -795,8 +795,8 @@ discard block |
|
|
block discarded – undo |
|
795
|
795
|
|
|
796
|
796
|
if ($date_posted != "") { |
|
797
|
797
|
$date_array = explode(",", $date_posted); |
|
798
|
|
- $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
799
|
|
- $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
|
798
|
+ $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
|
799
|
+ $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
800
|
800
|
if ($globalTimezone != '') { |
|
801
|
801
|
date_default_timezone_set($globalTimezone); |
|
802
|
802
|
$datetime = new DateTime(); |
|
@@ -821,16 +821,16 @@ discard block |
|
|
block discarded – undo |
|
821
|
821
|
} |
|
822
|
822
|
if ($limit != "") { |
|
823
|
823
|
$limit_array = explode(",", $limit); |
|
824
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
825
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
824
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
825
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
826
|
826
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) { |
|
827
|
827
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
828
|
828
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
829
|
829
|
} |
|
830
|
830
|
} |
|
831
|
831
|
if ($origLat != "" && $origLon != "" && $dist != "") { |
|
832
|
|
- $dist = number_format($dist*0.621371,2,'.',''); |
|
833
|
|
- $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 |
|
|
832
|
+ $dist = number_format($dist*0.621371, 2, '.', ''); |
|
|
833
|
+ $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 |
|
834
|
834
|
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)) |
|
835
|
835
|
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"; |
|
836
|
836
|
} else { |
|
@@ -844,12 +844,12 @@ discard block |
|
|
block discarded – undo |
|
844
|
844
|
$additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
|
845
|
845
|
} |
|
846
|
846
|
|
|
847
|
|
- $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
|
847
|
+ $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
848
|
848
|
WHERE spotter_archive_output.ident <> '' |
|
849
|
849
|
".$additional_query." |
|
850
|
850
|
".$filter_query.$orderby_query; |
|
851
|
851
|
} |
|
852
|
|
- $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
|
852
|
+ $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
853
|
853
|
return $spotter_array; |
|
854
|
854
|
} |
|
855
|
855
|
|
|
@@ -864,7 +864,7 @@ discard block |
|
|
block discarded – undo |
|
864
|
864
|
try { |
|
865
|
865
|
$sth = $this->db->prepare($query); |
|
866
|
866
|
$sth->execute(); |
|
867
|
|
- } catch(PDOException $e) { |
|
|
867
|
+ } catch (PDOException $e) { |
|
868
|
868
|
return "error"; |
|
869
|
869
|
} |
|
870
|
870
|
} |
|
@@ -897,8 +897,8 @@ discard block |
|
|
block discarded – undo |
|
897
|
897
|
if ($limit != "") { |
|
898
|
898
|
$limit_array = explode(",", $limit); |
|
899
|
899
|
|
|
900
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
901
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
900
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
901
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
902
|
902
|
|
|
903
|
903
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) { |
|
904
|
904
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
@@ -936,7 +936,7 @@ discard block |
|
|
block discarded – undo |
|
936
|
936
|
$query_values = array(); |
|
937
|
937
|
$limit_query = ''; |
|
938
|
938
|
$additional_query = ''; |
|
939
|
|
- $filter_query = $this->getFilter($filter,true,true); |
|
|
939
|
+ $filter_query = $this->getFilter($filter, true, true); |
|
940
|
940
|
|
|
941
|
941
|
if ($owner != "") { |
|
942
|
942
|
if (!is_string($owner)) { |
|
@@ -950,8 +950,8 @@ discard block |
|
|
block discarded – undo |
|
950
|
950
|
if ($limit != "") { |
|
951
|
951
|
$limit_array = explode(",", $limit); |
|
952
|
952
|
|
|
953
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
954
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
953
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
954
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
955
|
955
|
|
|
956
|
956
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) { |
|
957
|
957
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
@@ -988,7 +988,7 @@ discard block |
|
|
block discarded – undo |
|
988
|
988
|
$query_values = array(); |
|
989
|
989
|
$limit_query = ''; |
|
990
|
990
|
$additional_query = ''; |
|
991
|
|
- $filter_query = $this->getFilter($filter,true,true); |
|
|
991
|
+ $filter_query = $this->getFilter($filter, true, true); |
|
992
|
992
|
|
|
993
|
993
|
if ($pilot != "") { |
|
994
|
994
|
$additional_query = " AND (spotter_archive_output.pilot_id = :pilot OR spotter_archive_output.pilot_name = :pilot)"; |
|
@@ -998,8 +998,8 @@ discard block |
|
|
block discarded – undo |
|
998
|
998
|
if ($limit != "") { |
|
999
|
999
|
$limit_array = explode(",", $limit); |
|
1000
|
1000
|
|
|
1001
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1002
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
1001
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
1002
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1003
|
1003
|
|
|
1004
|
1004
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) { |
|
1005
|
1005
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
@@ -1027,7 +1027,7 @@ discard block |
|
|
block discarded – undo |
|
1027
|
1027
|
* @return Array the airline country list |
|
1028
|
1028
|
* |
|
1029
|
1029
|
*/ |
|
1030
|
|
- public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') { |
|
|
1030
|
+ public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') { |
|
1031
|
1031
|
global $globalDBdriver; |
|
1032
|
1032
|
/* |
|
1033
|
1033
|
$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
|
@@ -1055,7 +1055,7 @@ discard block |
|
|
block discarded – undo |
|
1055
|
1055
|
$flight_array = array(); |
|
1056
|
1056
|
$temp_array = array(); |
|
1057
|
1057
|
|
|
1058
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
|
1058
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
1059
|
1059
|
$temp_array['flight_count'] = $row['nb']; |
|
1060
|
1060
|
$temp_array['flight_country'] = $row['name']; |
|
1061
|
1061
|
$temp_array['flight_country_iso3'] = $row['iso3']; |
|
@@ -1071,7 +1071,7 @@ discard block |
|
|
block discarded – undo |
|
1071
|
1071
|
* @return Array the airline country list |
|
1072
|
1072
|
* |
|
1073
|
1073
|
*/ |
|
1074
|
|
- public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') { |
|
|
1074
|
+ public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') { |
|
1075
|
1075
|
global $globalDBdriver; |
|
1076
|
1076
|
/* |
|
1077
|
1077
|
$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
|
@@ -1099,7 +1099,7 @@ discard block |
|
|
block discarded – undo |
|
1099
|
1099
|
$flight_array = array(); |
|
1100
|
1100
|
$temp_array = array(); |
|
1101
|
1101
|
|
|
1102
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
|
1102
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
1103
|
1103
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
1104
|
1104
|
$temp_array['flight_count'] = $row['nb']; |
|
1105
|
1105
|
$temp_array['flight_country'] = $row['name']; |
|
@@ -1116,13 +1116,13 @@ discard block |
|
|
block discarded – undo |
|
1116
|
1116
|
* @return Array the spotter information |
|
1117
|
1117
|
* |
|
1118
|
1118
|
*/ |
|
1119
|
|
- public function getDateArchiveSpotterDataById($id,$date) { |
|
|
1119
|
+ public function getDateArchiveSpotterDataById($id, $date) { |
|
1120
|
1120
|
$Spotter = new Spotter($this->db); |
|
1121
|
1121
|
date_default_timezone_set('UTC'); |
|
1122
|
1122
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
1123
|
|
- $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'; |
|
1124
|
|
- $date = date('c',$date); |
|
1125
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
|
1123
|
+ $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'; |
|
|
1124
|
+ $date = date('c', $date); |
|
|
1125
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1126
|
1126
|
return $spotter_array; |
|
1127
|
1127
|
} |
|
1128
|
1128
|
|
|
@@ -1132,13 +1132,13 @@ discard block |
|
|
block discarded – undo |
|
1132
|
1132
|
* @return Array the spotter information |
|
1133
|
1133
|
* |
|
1134
|
1134
|
*/ |
|
1135
|
|
- public function getDateArchiveSpotterDataByIdent($ident,$date) { |
|
|
1135
|
+ public function getDateArchiveSpotterDataByIdent($ident, $date) { |
|
1136
|
1136
|
$Spotter = new Spotter($this->db); |
|
1137
|
1137
|
date_default_timezone_set('UTC'); |
|
1138
|
1138
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1139
|
|
- $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'; |
|
1140
|
|
- $date = date('c',$date); |
|
1141
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
|
1139
|
+ $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'; |
|
|
1140
|
+ $date = date('c', $date); |
|
|
1141
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1142
|
1142
|
return $spotter_array; |
|
1143
|
1143
|
} |
|
1144
|
1144
|
|
|
@@ -1148,14 +1148,14 @@ discard block |
|
|
block discarded – undo |
|
1148
|
1148
|
* @return Array the spotter information |
|
1149
|
1149
|
* |
|
1150
|
1150
|
*/ |
|
1151
|
|
- public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) { |
|
|
1151
|
+ public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) { |
|
1152
|
1152
|
global $global_query; |
|
1153
|
1153
|
$Spotter = new Spotter($this->db); |
|
1154
|
1154
|
date_default_timezone_set('UTC'); |
|
1155
|
1155
|
$query_values = array(); |
|
1156
|
1156
|
$limit_query = ''; |
|
1157
|
1157
|
$additional_query = ''; |
|
1158
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
|
1158
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
1159
|
1159
|
|
|
1160
|
1160
|
if ($airport != "") { |
|
1161
|
1161
|
if (!is_string($airport)) { |
|
@@ -1169,8 +1169,8 @@ discard block |
|
|
block discarded – undo |
|
1169
|
1169
|
if ($limit != "") { |
|
1170
|
1170
|
$limit_array = explode(",", $limit); |
|
1171
|
1171
|
|
|
1172
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1173
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
1172
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
1173
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1174
|
1174
|
|
|
1175
|
1175
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) { |
|
1176
|
1176
|
//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |