|
@@ -13,45 +13,45 @@ discard block |
|
|
block discarded – undo |
|
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
|
|
- if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
|
26
|
+ if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
27
|
27
|
$filter_query_join = ''; |
|
28
|
28
|
$filter_query_where = ''; |
|
29
|
|
- foreach($filters as $flt) { |
|
|
29
|
+ foreach ($filters as $flt) { |
|
30
|
30
|
if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
31
|
31
|
if ($flt['airlines'][0] != '') { |
|
32
|
32
|
if (isset($flt['source'])) { |
|
33
|
|
- $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"; |
|
|
33
|
+ $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"; |
|
34
|
34
|
} else { |
|
35
|
|
- $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"; |
|
|
35
|
+ $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"; |
|
36
|
36
|
} |
|
37
|
37
|
} |
|
38
|
38
|
} |
|
39
|
39
|
if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
40
|
40
|
if (isset($flt['source'])) { |
|
41
|
|
- $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"; |
|
|
41
|
+ $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"; |
|
42
|
42
|
} else { |
|
43
|
|
- $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"; |
|
|
43
|
+ $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"; |
|
44
|
44
|
} |
|
45
|
45
|
} |
|
46
|
46
|
if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
|
47
|
47
|
if (isset($flt['source'])) { |
|
48
|
|
- $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"; |
|
|
48
|
+ $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"; |
|
49
|
49
|
} |
|
50
|
50
|
} |
|
51
|
51
|
} |
|
52
|
52
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
53
|
53
|
if ($filter['airlines'][0] != '') { |
|
54
|
|
- $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"; |
|
|
54
|
+ $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"; |
|
55
|
55
|
} |
|
56
|
56
|
} |
|
57
|
57
|
|
|
@@ -59,16 +59,16 @@ discard block |
|
|
block discarded – undo |
|
59
|
59
|
$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 "; |
|
60
|
60
|
} |
|
61
|
61
|
if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
|
62
|
|
- $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"; |
|
|
62
|
+ $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"; |
|
63
|
63
|
} |
|
64
|
64
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
65
|
|
- $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
|
65
|
+ $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
66
|
66
|
} |
|
67
|
67
|
if (isset($filter['ident']) && !empty($filter['ident'])) { |
|
68
|
68
|
$filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
69
|
69
|
} |
|
70
|
70
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
71
|
|
- $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
71
|
+ $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
72
|
72
|
} |
|
73
|
73
|
if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
|
74
|
74
|
$filter_query_date = ''; |
|
@@ -94,40 +94,40 @@ discard block |
|
|
block discarded – undo |
|
94
|
94
|
$filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
95
|
95
|
} |
|
96
|
96
|
} |
|
97
|
|
- $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"; |
|
|
97
|
+ $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"; |
|
98
|
98
|
} |
|
99
|
99
|
if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
100
|
100
|
elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
101
|
101
|
if ($filter_query_where != '') { |
|
102
|
|
- $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
|
102
|
+ $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
103
|
103
|
} |
|
104
|
104
|
$filter_query = $filter_query_join.$filter_query_where; |
|
105
|
105
|
return $filter_query; |
|
106
|
106
|
} |
|
107
|
107
|
|
|
108
|
108
|
// Spotter_archive |
|
109
|
|
- 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 = '') { |
|
|
109
|
+ 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 = '') { |
|
110
|
110
|
require_once(dirname(__FILE__).'/class.Spotter.php'); |
|
111
|
111
|
if ($over_country == '') { |
|
112
|
112
|
$Spotter = new Spotter($this->db); |
|
113
|
|
- $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
|
113
|
+ $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
114
|
114
|
if (!empty($data_country)) $country = $data_country['iso2']; |
|
115
|
115
|
else $country = ''; |
|
116
|
116
|
} else $country = $over_country; |
|
117
|
|
- if ($airline_type === NULL) $airline_type =''; |
|
|
117
|
+ if ($airline_type === NULL) $airline_type = ''; |
|
118
|
118
|
|
|
119
|
119
|
//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
|
120
|
120
|
//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
|
121
|
121
|
|
|
122
|
122
|
// Route is not added in spotter_archive |
|
123
|
|
- $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) |
|
|
123
|
+ $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) |
|
124
|
124
|
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)"; |
|
125
|
125
|
|
|
126
|
|
- $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); |
|
|
126
|
+ $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); |
|
127
|
127
|
try { |
|
128
|
128
|
$sth = $this->db->prepare($query); |
|
129
|
129
|
$sth->execute($query_values); |
|
130
|
|
- } catch(PDOException $e) { |
|
|
130
|
+ } catch (PDOException $e) { |
|
131
|
131
|
return "error : ".$e->getMessage(); |
|
132
|
132
|
} |
|
133
|
133
|
return "success"; |
|
@@ -147,9 +147,9 @@ discard block |
|
|
block discarded – undo |
|
147
|
147
|
|
|
148
|
148
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
149
|
149
|
//$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"; |
|
150
|
|
- $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
|
150
|
+ $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
151
|
151
|
|
|
152
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
|
152
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
153
|
153
|
|
|
154
|
154
|
return $spotter_array; |
|
155
|
155
|
} |
|
@@ -168,7 +168,7 @@ discard block |
|
|
block discarded – undo |
|
168
|
168
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
169
|
169
|
//$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
170
|
170
|
//$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"; |
|
171
|
|
- $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
|
171
|
+ $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
172
|
172
|
|
|
173
|
173
|
// $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
|
174
|
174
|
/* |
|
@@ -181,7 +181,7 @@ discard block |
|
|
block discarded – undo |
|
181
|
181
|
} |
|
182
|
182
|
$spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
|
183
|
183
|
*/ |
|
184
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
|
184
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
185
|
185
|
|
|
186
|
186
|
return $spotter_array; |
|
187
|
187
|
} |
|
@@ -196,14 +196,14 @@ discard block |
|
|
block discarded – undo |
|
196
|
196
|
{ |
|
197
|
197
|
date_default_timezone_set('UTC'); |
|
198
|
198
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
199
|
|
- $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
|
199
|
+ $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
200
|
200
|
|
|
201
|
201
|
// $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
|
202
|
202
|
|
|
203
|
203
|
try { |
|
204
|
204
|
$sth = $this->db->prepare($query); |
|
205
|
205
|
$sth->execute(array(':id' => $id)); |
|
206
|
|
- } catch(PDOException $e) { |
|
|
206
|
+ } catch (PDOException $e) { |
|
207
|
207
|
echo $e->getMessage(); |
|
208
|
208
|
die; |
|
209
|
209
|
} |
|
@@ -222,14 +222,14 @@ discard block |
|
|
block discarded – undo |
|
222
|
222
|
{ |
|
223
|
223
|
date_default_timezone_set('UTC'); |
|
224
|
224
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
225
|
|
- $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
|
225
|
+ $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
226
|
226
|
|
|
227
|
227
|
// $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
|
228
|
228
|
|
|
229
|
229
|
try { |
|
230
|
230
|
$sth = $this->db->prepare($query); |
|
231
|
231
|
$sth->execute(array(':id' => $id)); |
|
232
|
|
- } catch(PDOException $e) { |
|
|
232
|
+ } catch (PDOException $e) { |
|
233
|
233
|
echo $e->getMessage(); |
|
234
|
234
|
die; |
|
235
|
235
|
} |
|
@@ -251,12 +251,12 @@ discard block |
|
|
block discarded – undo |
|
251
|
251
|
date_default_timezone_set('UTC'); |
|
252
|
252
|
|
|
253
|
253
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
254
|
|
- $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"; |
|
|
254
|
+ $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"; |
|
255
|
255
|
|
|
256
|
256
|
try { |
|
257
|
257
|
$sth = $this->db->prepare($query); |
|
258
|
258
|
$sth->execute(array(':ident' => $ident)); |
|
259
|
|
- } catch(PDOException $e) { |
|
|
259
|
+ } catch (PDOException $e) { |
|
260
|
260
|
echo $e->getMessage(); |
|
261
|
261
|
die; |
|
262
|
262
|
} |
|
@@ -277,12 +277,12 @@ discard block |
|
|
block discarded – undo |
|
277
|
277
|
date_default_timezone_set('UTC'); |
|
278
|
278
|
|
|
279
|
279
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
280
|
|
- $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"; |
|
|
280
|
+ $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"; |
|
281
|
281
|
|
|
282
|
282
|
try { |
|
283
|
283
|
$sth = $this->db->prepare($query); |
|
284
|
284
|
$sth->execute(array(':id' => $id)); |
|
285
|
|
- } catch(PDOException $e) { |
|
|
285
|
+ } catch (PDOException $e) { |
|
286
|
286
|
echo $e->getMessage(); |
|
287
|
287
|
die; |
|
288
|
288
|
} |
|
@@ -303,12 +303,12 @@ discard block |
|
|
block discarded – undo |
|
303
|
303
|
date_default_timezone_set('UTC'); |
|
304
|
304
|
|
|
305
|
305
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
306
|
|
- $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
|
306
|
+ $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
307
|
307
|
|
|
308
|
308
|
try { |
|
309
|
309
|
$sth = $this->db->prepare($query); |
|
310
|
310
|
$sth->execute(array(':id' => $id)); |
|
311
|
|
- } catch(PDOException $e) { |
|
|
311
|
+ } catch (PDOException $e) { |
|
312
|
312
|
echo $e->getMessage(); |
|
313
|
313
|
die; |
|
314
|
314
|
} |
|
@@ -330,13 +330,13 @@ discard block |
|
|
block discarded – undo |
|
330
|
330
|
date_default_timezone_set('UTC'); |
|
331
|
331
|
|
|
332
|
332
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
333
|
|
- $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"; |
|
|
333
|
+ $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"; |
|
334
|
334
|
// $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
335
|
335
|
|
|
336
|
336
|
try { |
|
337
|
337
|
$sth = $this->db->prepare($query); |
|
338
|
338
|
$sth->execute(array(':ident' => $ident)); |
|
339
|
|
- } catch(PDOException $e) { |
|
|
339
|
+ } catch (PDOException $e) { |
|
340
|
340
|
echo $e->getMessage(); |
|
341
|
341
|
die; |
|
342
|
342
|
} |
|
@@ -353,13 +353,13 @@ discard block |
|
|
block discarded – undo |
|
353
|
353
|
* @return Array the spotter information |
|
354
|
354
|
* |
|
355
|
355
|
*/ |
|
356
|
|
- public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
|
356
|
+ public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
357
|
357
|
{ |
|
358
|
358
|
$Spotter = new Spotter($this->db); |
|
359
|
359
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
360
|
|
- $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"; |
|
|
360
|
+ $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"; |
|
361
|
361
|
|
|
362
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
|
362
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
363
|
363
|
|
|
364
|
364
|
return $spotter_array; |
|
365
|
365
|
} |
|
@@ -372,7 +372,7 @@ discard block |
|
|
block discarded – undo |
|
372
|
372
|
try { |
|
373
|
373
|
$sth = $this->db->prepare($query); |
|
374
|
374
|
$sth->execute(); |
|
375
|
|
- } catch(PDOException $e) { |
|
|
375
|
+ } catch (PDOException $e) { |
|
376
|
376
|
echo $e->getMessage(); |
|
377
|
377
|
die; |
|
378
|
378
|
} |
|
@@ -384,24 +384,24 @@ discard block |
|
|
block discarded – undo |
|
384
|
384
|
* @return Array the spotter information |
|
385
|
385
|
* |
|
386
|
386
|
*/ |
|
387
|
|
- public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
|
387
|
+ public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
388
|
388
|
{ |
|
389
|
389
|
global $globalDBdriver, $globalLiveInterval; |
|
390
|
390
|
date_default_timezone_set('UTC'); |
|
391
|
391
|
|
|
392
|
392
|
$filter_query = ''; |
|
393
|
393
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
394
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
|
394
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
395
|
395
|
} |
|
396
|
396
|
// Use spotter_output also ? |
|
397
|
397
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
398
|
|
- $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 "; |
|
|
398
|
+ $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 "; |
|
399
|
399
|
} |
|
400
|
400
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
401
|
401
|
$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 "; |
|
402
|
402
|
} |
|
403
|
403
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
404
|
|
- $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
404
|
+ $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
405
|
405
|
} |
|
406
|
406
|
|
|
407
|
407
|
//if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
@@ -420,14 +420,14 @@ discard block |
|
|
block discarded – undo |
|
420
|
420
|
GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
|
421
|
421
|
AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
|
422
|
422
|
*/ |
|
423
|
|
- $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 |
|
|
423
|
+ $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 |
|
424
|
424
|
FROM spotter_archive |
|
425
|
425
|
INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
|
426
|
426
|
WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
|
427
|
427
|
'.$filter_query.' ORDER BY flightaware_id'; |
|
428
|
428
|
} else { |
|
429
|
429
|
//$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'; |
|
430
|
|
- $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 |
|
|
430
|
+ $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
|
431
|
FROM spotter_archive |
|
432
|
432
|
INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
|
433
|
433
|
WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
|
@@ -437,7 +437,7 @@ discard block |
|
|
block discarded – undo |
|
437
|
437
|
try { |
|
438
|
438
|
$sth = $this->db->prepare($query); |
|
439
|
439
|
$sth->execute(); |
|
440
|
|
- } catch(PDOException $e) { |
|
|
440
|
+ } catch (PDOException $e) { |
|
441
|
441
|
echo $e->getMessage(); |
|
442
|
442
|
die; |
|
443
|
443
|
} |
|
@@ -452,24 +452,24 @@ discard block |
|
|
block discarded – undo |
|
452
|
452
|
* @return Array the spotter information |
|
453
|
453
|
* |
|
454
|
454
|
*/ |
|
455
|
|
- public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
|
455
|
+ public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
456
|
456
|
{ |
|
457
|
457
|
global $globalDBdriver, $globalLiveInterval; |
|
458
|
458
|
date_default_timezone_set('UTC'); |
|
459
|
459
|
|
|
460
|
460
|
$filter_query = ''; |
|
461
|
461
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
462
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
|
462
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
463
|
463
|
} |
|
464
|
464
|
// Should use spotter_output also ? |
|
465
|
465
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
466
|
|
- $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 "; |
|
|
466
|
+ $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 "; |
|
467
|
467
|
} |
|
468
|
468
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
469
|
469
|
$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 "; |
|
470
|
470
|
} |
|
471
|
471
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
472
|
|
- $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
472
|
+ $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
473
|
473
|
} |
|
474
|
474
|
|
|
475
|
475
|
//if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
@@ -479,7 +479,7 @@ discard block |
|
|
block discarded – undo |
|
479
|
479
|
FROM spotter_archive |
|
480
|
480
|
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'; |
|
481
|
481
|
*/ |
|
482
|
|
- $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 |
|
|
482
|
+ $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 |
|
483
|
483
|
FROM spotter_archive_output |
|
484
|
484
|
LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
|
485
|
485
|
WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
|
@@ -494,7 +494,7 @@ discard block |
|
|
block discarded – undo |
|
494
|
494
|
WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
|
495
|
495
|
'.$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'; |
|
496
|
496
|
*/ |
|
497
|
|
- $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 |
|
|
497
|
+ $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 |
|
498
|
498
|
FROM spotter_archive_output |
|
499
|
499
|
INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
|
500
|
500
|
WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
|
@@ -506,7 +506,7 @@ discard block |
|
|
block discarded – undo |
|
506
|
506
|
try { |
|
507
|
507
|
$sth = $this->db->prepare($query); |
|
508
|
508
|
$sth->execute(); |
|
509
|
|
- } catch(PDOException $e) { |
|
|
509
|
+ } catch (PDOException $e) { |
|
510
|
510
|
echo $e->getMessage(); |
|
511
|
511
|
die; |
|
512
|
512
|
} |
|
@@ -521,23 +521,23 @@ discard block |
|
|
block discarded – undo |
|
521
|
521
|
* @return Array the spotter information |
|
522
|
522
|
* |
|
523
|
523
|
*/ |
|
524
|
|
- public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
|
524
|
+ public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
525
|
525
|
{ |
|
526
|
526
|
global $globalDBdriver, $globalLiveInterval; |
|
527
|
527
|
date_default_timezone_set('UTC'); |
|
528
|
528
|
|
|
529
|
529
|
$filter_query = ''; |
|
530
|
530
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
531
|
|
- $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
|
531
|
+ $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
532
|
532
|
} |
|
533
|
533
|
if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
534
|
|
- $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 "; |
|
|
534
|
+ $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 "; |
|
535
|
535
|
} |
|
536
|
536
|
if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
537
|
537
|
$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 "; |
|
538
|
538
|
} |
|
539
|
539
|
if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
540
|
|
- $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
|
540
|
+ $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
541
|
541
|
} |
|
542
|
542
|
|
|
543
|
543
|
//if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
@@ -552,7 +552,7 @@ discard block |
|
|
block discarded – undo |
|
552
|
552
|
try { |
|
553
|
553
|
$sth = $this->db->prepare($query); |
|
554
|
554
|
$sth->execute(); |
|
555
|
|
- } catch(PDOException $e) { |
|
|
555
|
+ } catch (PDOException $e) { |
|
556
|
556
|
echo $e->getMessage(); |
|
557
|
557
|
die; |
|
558
|
558
|
} |
|
@@ -572,7 +572,7 @@ discard block |
|
|
block discarded – undo |
|
572
|
572
|
* @return Array the spotter information |
|
573
|
573
|
* |
|
574
|
574
|
*/ |
|
575
|
|
- 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()) |
|
|
575
|
+ 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()) |
|
576
|
576
|
{ |
|
577
|
577
|
global $globalTimezone, $globalDBdriver; |
|
578
|
578
|
require_once(dirname(__FILE__).'/class.Translation.php'); |
|
@@ -594,7 +594,7 @@ discard block |
|
|
block discarded – undo |
|
594
|
594
|
|
|
595
|
595
|
$q_array = explode(" ", $q); |
|
596
|
596
|
|
|
597
|
|
- foreach ($q_array as $q_item){ |
|
|
597
|
+ foreach ($q_array as $q_item) { |
|
598
|
598
|
$additional_query .= " AND ("; |
|
599
|
599
|
$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
600
|
600
|
$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
@@ -626,7 +626,7 @@ discard block |
|
|
block discarded – undo |
|
626
|
626
|
|
|
627
|
627
|
if ($registration != "") |
|
628
|
628
|
{ |
|
629
|
|
- $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
|
629
|
+ $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
630
|
630
|
if (!is_string($registration)) |
|
631
|
631
|
{ |
|
632
|
632
|
return false; |
|
@@ -637,7 +637,7 @@ discard block |
|
|
block discarded – undo |
|
637
|
637
|
|
|
638
|
638
|
if ($aircraft_icao != "") |
|
639
|
639
|
{ |
|
640
|
|
- $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
|
640
|
+ $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
641
|
641
|
if (!is_string($aircraft_icao)) |
|
642
|
642
|
{ |
|
643
|
643
|
return false; |
|
@@ -648,7 +648,7 @@ discard block |
|
|
block discarded – undo |
|
648
|
648
|
|
|
649
|
649
|
if ($aircraft_manufacturer != "") |
|
650
|
650
|
{ |
|
651
|
|
- $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
|
651
|
+ $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
652
|
652
|
if (!is_string($aircraft_manufacturer)) |
|
653
|
653
|
{ |
|
654
|
654
|
return false; |
|
@@ -669,7 +669,7 @@ discard block |
|
|
block discarded – undo |
|
669
|
669
|
|
|
670
|
670
|
if ($airline_icao != "") |
|
671
|
671
|
{ |
|
672
|
|
- $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
|
672
|
+ $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
673
|
673
|
if (!is_string($airline_icao)) |
|
674
|
674
|
{ |
|
675
|
675
|
return false; |
|
@@ -680,7 +680,7 @@ discard block |
|
|
block discarded – undo |
|
680
|
680
|
|
|
681
|
681
|
if ($airline_country != "") |
|
682
|
682
|
{ |
|
683
|
|
- $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
|
683
|
+ $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
684
|
684
|
if (!is_string($airline_country)) |
|
685
|
685
|
{ |
|
686
|
686
|
return false; |
|
@@ -691,7 +691,7 @@ discard block |
|
|
block discarded – undo |
|
691
|
691
|
|
|
692
|
692
|
if ($airline_type != "") |
|
693
|
693
|
{ |
|
694
|
|
- $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
|
694
|
+ $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
695
|
695
|
if (!is_string($airline_type)) |
|
696
|
696
|
{ |
|
697
|
697
|
return false; |
|
@@ -713,7 +713,7 @@ discard block |
|
|
block discarded – undo |
|
713
|
713
|
|
|
714
|
714
|
if ($airport != "") |
|
715
|
715
|
{ |
|
716
|
|
- $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
|
716
|
+ $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
717
|
717
|
if (!is_string($airport)) |
|
718
|
718
|
{ |
|
719
|
719
|
return false; |
|
@@ -724,7 +724,7 @@ discard block |
|
|
block discarded – undo |
|
724
|
724
|
|
|
725
|
725
|
if ($airport_country != "") |
|
726
|
726
|
{ |
|
727
|
|
- $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
|
727
|
+ $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
728
|
728
|
if (!is_string($airport_country)) |
|
729
|
729
|
{ |
|
730
|
730
|
return false; |
|
@@ -735,7 +735,7 @@ discard block |
|
|
block discarded – undo |
|
735
|
735
|
|
|
736
|
736
|
if ($callsign != "") |
|
737
|
737
|
{ |
|
738
|
|
- $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
|
738
|
+ $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
739
|
739
|
if (!is_string($callsign)) |
|
740
|
740
|
{ |
|
741
|
741
|
return false; |
|
@@ -743,7 +743,7 @@ discard block |
|
|
block discarded – undo |
|
743
|
743
|
$translate = $Translation->ident2icao($callsign); |
|
744
|
744
|
if ($translate != $callsign) { |
|
745
|
745
|
$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
|
746
|
|
- $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
|
746
|
+ $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
747
|
747
|
} else { |
|
748
|
748
|
$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
|
749
|
749
|
} |
|
@@ -752,7 +752,7 @@ discard block |
|
|
block discarded – undo |
|
752
|
752
|
|
|
753
|
753
|
if ($owner != "") |
|
754
|
754
|
{ |
|
755
|
|
- $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
|
755
|
+ $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
756
|
756
|
if (!is_string($owner)) |
|
757
|
757
|
{ |
|
758
|
758
|
return false; |
|
@@ -763,7 +763,7 @@ discard block |
|
|
block discarded – undo |
|
763
|
763
|
|
|
764
|
764
|
if ($pilot_name != "") |
|
765
|
765
|
{ |
|
766
|
|
- $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
|
766
|
+ $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
767
|
767
|
if (!is_string($pilot_name)) |
|
768
|
768
|
{ |
|
769
|
769
|
return false; |
|
@@ -774,7 +774,7 @@ discard block |
|
|
block discarded – undo |
|
774
|
774
|
|
|
775
|
775
|
if ($pilot_id != "") |
|
776
|
776
|
{ |
|
777
|
|
- $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
|
777
|
+ $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
778
|
778
|
if (!is_string($pilot_id)) |
|
779
|
779
|
{ |
|
780
|
780
|
return false; |
|
@@ -785,7 +785,7 @@ discard block |
|
|
block discarded – undo |
|
785
|
785
|
|
|
786
|
786
|
if ($departure_airport_route != "") |
|
787
|
787
|
{ |
|
788
|
|
- $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
|
788
|
+ $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
789
|
789
|
if (!is_string($departure_airport_route)) |
|
790
|
790
|
{ |
|
791
|
791
|
return false; |
|
@@ -796,7 +796,7 @@ discard block |
|
|
block discarded – undo |
|
796
|
796
|
|
|
797
|
797
|
if ($arrival_airport_route != "") |
|
798
|
798
|
{ |
|
799
|
|
- $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
|
799
|
+ $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
800
|
800
|
if (!is_string($arrival_airport_route)) |
|
801
|
801
|
{ |
|
802
|
802
|
return false; |
|
@@ -809,8 +809,8 @@ discard block |
|
|
block discarded – undo |
|
809
|
809
|
{ |
|
810
|
810
|
$altitude_array = explode(",", $altitude); |
|
811
|
811
|
|
|
812
|
|
- $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
813
|
|
- $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
|
812
|
+ $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
|
813
|
+ $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
814
|
814
|
|
|
815
|
815
|
|
|
816
|
816
|
if ($altitude_array[1] != "") |
|
@@ -828,8 +828,8 @@ discard block |
|
|
block discarded – undo |
|
828
|
828
|
{ |
|
829
|
829
|
$date_array = explode(",", $date_posted); |
|
830
|
830
|
|
|
831
|
|
- $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
832
|
|
- $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
|
831
|
+ $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
|
832
|
+ $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
833
|
833
|
|
|
834
|
834
|
if ($globalTimezone != '') { |
|
835
|
835
|
date_default_timezone_set($globalTimezone); |
|
@@ -861,8 +861,8 @@ discard block |
|
|
block discarded – undo |
|
861
|
861
|
{ |
|
862
|
862
|
$limit_array = explode(",", $limit); |
|
863
|
863
|
|
|
864
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
865
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
864
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
865
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
866
|
866
|
|
|
867
|
867
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
868
|
868
|
{ |
|
@@ -873,8 +873,8 @@ discard block |
|
|
block discarded – undo |
|
873
|
873
|
|
|
874
|
874
|
|
|
875
|
875
|
if ($origLat != "" && $origLon != "" && $dist != "") { |
|
876
|
|
- $dist = number_format($dist*0.621371,2,'.',''); |
|
877
|
|
- $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 |
|
|
876
|
+ $dist = number_format($dist*0.621371, 2, '.', ''); |
|
|
877
|
+ $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 |
|
878
|
878
|
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)) |
|
879
|
879
|
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"; |
|
880
|
880
|
} else { |
|
@@ -891,12 +891,12 @@ discard block |
|
|
block discarded – undo |
|
891
|
891
|
$additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
|
892
|
892
|
} |
|
893
|
893
|
|
|
894
|
|
- $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
|
894
|
+ $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
895
|
895
|
WHERE spotter_archive_output.ident <> '' |
|
896
|
896
|
".$additional_query." |
|
897
|
897
|
".$filter_query.$orderby_query; |
|
898
|
898
|
} |
|
899
|
|
- $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
|
899
|
+ $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
900
|
900
|
|
|
901
|
901
|
return $spotter_array; |
|
902
|
902
|
} |
|
@@ -913,7 +913,7 @@ discard block |
|
|
block discarded – undo |
|
913
|
913
|
try { |
|
914
|
914
|
$sth = $this->db->prepare($query); |
|
915
|
915
|
$sth->execute(); |
|
916
|
|
- } catch(PDOException $e) { |
|
|
916
|
+ } catch (PDOException $e) { |
|
917
|
917
|
return "error"; |
|
918
|
918
|
} |
|
919
|
919
|
} |
|
@@ -950,8 +950,8 @@ discard block |
|
|
block discarded – undo |
|
950
|
950
|
{ |
|
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
|
{ |
|
@@ -992,7 +992,7 @@ discard block |
|
|
block discarded – undo |
|
992
|
992
|
$query_values = array(); |
|
993
|
993
|
$limit_query = ''; |
|
994
|
994
|
$additional_query = ''; |
|
995
|
|
- $filter_query = $this->getFilter($filter,true,true); |
|
|
995
|
+ $filter_query = $this->getFilter($filter, true, true); |
|
996
|
996
|
|
|
997
|
997
|
if ($owner != "") |
|
998
|
998
|
{ |
|
@@ -1009,8 +1009,8 @@ discard block |
|
|
block discarded – undo |
|
1009
|
1009
|
{ |
|
1010
|
1010
|
$limit_array = explode(",", $limit); |
|
1011
|
1011
|
|
|
1012
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1013
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
1012
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
1013
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1014
|
1014
|
|
|
1015
|
1015
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1016
|
1016
|
{ |
|
@@ -1050,7 +1050,7 @@ discard block |
|
|
block discarded – undo |
|
1050
|
1050
|
$query_values = array(); |
|
1051
|
1051
|
$limit_query = ''; |
|
1052
|
1052
|
$additional_query = ''; |
|
1053
|
|
- $filter_query = $this->getFilter($filter,true,true); |
|
|
1053
|
+ $filter_query = $this->getFilter($filter, true, true); |
|
1054
|
1054
|
|
|
1055
|
1055
|
if ($pilot != "") |
|
1056
|
1056
|
{ |
|
@@ -1062,8 +1062,8 @@ discard block |
|
|
block discarded – undo |
|
1062
|
1062
|
{ |
|
1063
|
1063
|
$limit_array = explode(",", $limit); |
|
1064
|
1064
|
|
|
1065
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1066
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
1065
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
1066
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1067
|
1067
|
|
|
1068
|
1068
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1069
|
1069
|
{ |
|
@@ -1093,7 +1093,7 @@ discard block |
|
|
block discarded – undo |
|
1093
|
1093
|
* @return Array the airline country list |
|
1094
|
1094
|
* |
|
1095
|
1095
|
*/ |
|
1096
|
|
- public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
|
1096
|
+ public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1097
|
1097
|
{ |
|
1098
|
1098
|
global $globalDBdriver; |
|
1099
|
1099
|
/* |
|
@@ -1122,7 +1122,7 @@ discard block |
|
|
block discarded – undo |
|
1122
|
1122
|
$flight_array = array(); |
|
1123
|
1123
|
$temp_array = array(); |
|
1124
|
1124
|
|
|
1125
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1125
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1126
|
1126
|
{ |
|
1127
|
1127
|
$temp_array['flight_count'] = $row['nb']; |
|
1128
|
1128
|
$temp_array['flight_country'] = $row['name']; |
|
@@ -1139,7 +1139,7 @@ discard block |
|
|
block discarded – undo |
|
1139
|
1139
|
* @return Array the airline country list |
|
1140
|
1140
|
* |
|
1141
|
1141
|
*/ |
|
1142
|
|
- public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
|
1142
|
+ public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1143
|
1143
|
{ |
|
1144
|
1144
|
global $globalDBdriver; |
|
1145
|
1145
|
/* |
|
@@ -1168,7 +1168,7 @@ discard block |
|
|
block discarded – undo |
|
1168
|
1168
|
$flight_array = array(); |
|
1169
|
1169
|
$temp_array = array(); |
|
1170
|
1170
|
|
|
1171
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1171
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1172
|
1172
|
{ |
|
1173
|
1173
|
$temp_array['airline_icao'] = $row['airline_icao']; |
|
1174
|
1174
|
$temp_array['flight_count'] = $row['nb']; |
|
@@ -1186,14 +1186,14 @@ discard block |
|
|
block discarded – undo |
|
1186
|
1186
|
* @return Array the spotter information |
|
1187
|
1187
|
* |
|
1188
|
1188
|
*/ |
|
1189
|
|
- public function getDateArchiveSpotterDataById($id,$date) |
|
|
1189
|
+ public function getDateArchiveSpotterDataById($id, $date) |
|
1190
|
1190
|
{ |
|
1191
|
1191
|
$Spotter = new Spotter($this->db); |
|
1192
|
1192
|
date_default_timezone_set('UTC'); |
|
1193
|
1193
|
$id = filter_var($id, FILTER_SANITIZE_STRING); |
|
1194
|
|
- $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'; |
|
1195
|
|
- $date = date('c',$date); |
|
1196
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
|
1194
|
+ $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'; |
|
|
1195
|
+ $date = date('c', $date); |
|
|
1196
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1197
|
1197
|
return $spotter_array; |
|
1198
|
1198
|
} |
|
1199
|
1199
|
|
|
@@ -1203,14 +1203,14 @@ discard block |
|
|
block discarded – undo |
|
1203
|
1203
|
* @return Array the spotter information |
|
1204
|
1204
|
* |
|
1205
|
1205
|
*/ |
|
1206
|
|
- public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
|
1206
|
+ public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
1207
|
1207
|
{ |
|
1208
|
1208
|
$Spotter = new Spotter($this->db); |
|
1209
|
1209
|
date_default_timezone_set('UTC'); |
|
1210
|
1210
|
$ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1211
|
|
- $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'; |
|
1212
|
|
- $date = date('c',$date); |
|
1213
|
|
- $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
|
1211
|
+ $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'; |
|
|
1212
|
+ $date = date('c', $date); |
|
|
1213
|
+ $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1214
|
1214
|
return $spotter_array; |
|
1215
|
1215
|
} |
|
1216
|
1216
|
|
|
@@ -1220,7 +1220,7 @@ discard block |
|
|
block discarded – undo |
|
1220
|
1220
|
* @return Array the spotter information |
|
1221
|
1221
|
* |
|
1222
|
1222
|
*/ |
|
1223
|
|
- public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
|
1223
|
+ public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1224
|
1224
|
{ |
|
1225
|
1225
|
global $global_query; |
|
1226
|
1226
|
$Spotter = new Spotter(); |
|
@@ -1228,7 +1228,7 @@ discard block |
|
|
block discarded – undo |
|
1228
|
1228
|
$query_values = array(); |
|
1229
|
1229
|
$limit_query = ''; |
|
1230
|
1230
|
$additional_query = ''; |
|
1231
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
|
1231
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
1232
|
1232
|
|
|
1233
|
1233
|
if ($airport != "") |
|
1234
|
1234
|
{ |
|
@@ -1245,8 +1245,8 @@ discard block |
|
|
block discarded – undo |
|
1245
|
1245
|
{ |
|
1246
|
1246
|
$limit_array = explode(",", $limit); |
|
1247
|
1247
|
|
|
1248
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1249
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
1248
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
1249
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1250
|
1250
|
|
|
1251
|
1251
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1252
|
1252
|
{ |