@@ -3,8 +3,8 @@ |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | if (!isset($_GET['ident'])) { |
6 | - header('Location: '.$globalURL.'/ident'); |
|
7 | - die(); |
|
6 | + header('Location: '.$globalURL.'/ident'); |
|
7 | + die(); |
|
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
@@ -3,8 +3,8 @@ |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | if (!isset($_GET['ident'])) { |
6 | - header('Location: '.$globalURL.'/ident'); |
|
7 | - die(); |
|
6 | + header('Location: '.$globalURL.'/ident'); |
|
7 | + die(); |
|
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
@@ -4,8 +4,8 @@ |
||
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | |
6 | 6 | if (!isset($_GET['aircraft_type'])) { |
7 | - header('Location: '.$globalURL.'/aircraft'); |
|
8 | - die(); |
|
7 | + header('Location: '.$globalURL.'/aircraft'); |
|
8 | + die(); |
|
9 | 9 | } |
10 | 10 | $aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING); |
11 | 11 | $Spotter = new Spotter(); |
@@ -3,8 +3,8 @@ |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | if (!isset($_GET['ident'])) { |
6 | - header('Location: '.$globalURL.'/ident'); |
|
7 | - die(); |
|
6 | + header('Location: '.$globalURL.'/ident'); |
|
7 | + die(); |
|
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
@@ -3,8 +3,8 @@ |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | if (!isset($_GET['ident'])) { |
6 | - header('Location: '.$globalURL.'/ident'); |
|
7 | - die(); |
|
6 | + header('Location: '.$globalURL.'/ident'); |
|
7 | + die(); |
|
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
@@ -3,8 +3,8 @@ |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | if (!isset($_GET['aircraft_manufacturer'])) { |
6 | - header('Location: '.$globalURL.'/manufacturer'); |
|
7 | - die(); |
|
6 | + header('Location: '.$globalURL.'/manufacturer'); |
|
7 | + die(); |
|
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | $manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING))); |
@@ -3,8 +3,8 @@ |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | if (!isset($_GET['country'])) { |
6 | - header('Location: '.$globalURL.'/country'); |
|
7 | - die(); |
|
6 | + header('Location: '.$globalURL.'/country'); |
|
7 | + die(); |
|
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | $country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | if (!isset($_GET['airport'])) { |
6 | - header('Location: '.$globalURL.'/airport'); |
|
7 | - die(); |
|
6 | + header('Location: '.$globalURL.'/airport'); |
|
7 | + die(); |
|
8 | 8 | } |
9 | 9 | $airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING); |
10 | 10 | $Spotter = new Spotter(); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | function drawChart() { |
66 | 66 | var data = google.visualization.arrayToDataTable([ |
67 | 67 | ["'._("Country").'", "'._("# of times").'"], '; |
68 | - $country_data = ''; |
|
68 | + $country_data = ''; |
|
69 | 69 | foreach($airport_country_array as $airport_item) |
70 | 70 | { |
71 | 71 | $country_data .= '[ "'.$airport_item['departure_airport_country'].'",'.$airport_item['airport_departure_country_count'].'],'; |
@@ -1,21 +1,21 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class SpotterArchive { |
3 | - public $global_query = "SELECT spotter_archive.* FROM spotter_archive"; |
|
4 | - public $db; |
|
3 | + public $global_query = "SELECT spotter_archive.* FROM spotter_archive"; |
|
4 | + public $db; |
|
5 | 5 | |
6 | - function __construct($dbc = null) { |
|
7 | - $Connection = new Connection($dbc); |
|
8 | - $this->db = $Connection->db; |
|
9 | - } |
|
6 | + function __construct($dbc = null) { |
|
7 | + $Connection = new Connection($dbc); |
|
8 | + $this->db = $Connection->db; |
|
9 | + } |
|
10 | 10 | |
11 | 11 | |
12 | - // Spotter_archive |
|
12 | + // Spotter_archive |
|
13 | 13 | |
14 | - 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 = '') { |
|
14 | + 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 = '') { |
|
15 | 15 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
16 | - if ($over_country == '') { |
|
17 | - $Spotter = new Spotter($this->db); |
|
18 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
16 | + if ($over_country == '') { |
|
17 | + $Spotter = new Spotter($this->db); |
|
18 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
19 | 19 | if (!empty($data_country)) $country = $data_country['iso2']; |
20 | 20 | else $country = ''; |
21 | 21 | } else $country = $over_country; |
@@ -28,55 +28,55 @@ discard block |
||
28 | 28 | $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) |
29 | 29 | 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)"; |
30 | 30 | |
31 | - $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); |
|
32 | - try { |
|
33 | - $sth = $this->db->prepare($query); |
|
34 | - $sth->execute($query_values); |
|
35 | - } catch(PDOException $e) { |
|
36 | - return "error : ".$e->getMessage(); |
|
37 | - } |
|
38 | - return "success"; |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * Gets all the spotter information based on a particular callsign |
|
44 | - * |
|
45 | - * @return Array the spotter information |
|
46 | - * |
|
47 | - */ |
|
48 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
49 | - { |
|
31 | + $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); |
|
32 | + try { |
|
33 | + $sth = $this->db->prepare($query); |
|
34 | + $sth->execute($query_values); |
|
35 | + } catch(PDOException $e) { |
|
36 | + return "error : ".$e->getMessage(); |
|
37 | + } |
|
38 | + return "success"; |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * Gets all the spotter information based on a particular callsign |
|
44 | + * |
|
45 | + * @return Array the spotter information |
|
46 | + * |
|
47 | + */ |
|
48 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
49 | + { |
|
50 | 50 | $Spotter = new Spotter($this->db); |
51 | - date_default_timezone_set('UTC'); |
|
51 | + date_default_timezone_set('UTC'); |
|
52 | 52 | |
53 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
54 | - //$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"; |
|
55 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
53 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
54 | + //$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"; |
|
55 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
56 | 56 | |
57 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
57 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
58 | 58 | |
59 | - return $spotter_array; |
|
60 | - } |
|
59 | + return $spotter_array; |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * Gets last the spotter information based on a particular id |
|
65 | - * |
|
66 | - * @return Array the spotter information |
|
67 | - * |
|
68 | - */ |
|
69 | - public function getLastArchiveSpotterDataById($id) |
|
70 | - { |
|
71 | - $Spotter = new Spotter($this->db); |
|
72 | - date_default_timezone_set('UTC'); |
|
73 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
74 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
75 | - //$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"; |
|
76 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
63 | + /** |
|
64 | + * Gets last the spotter information based on a particular id |
|
65 | + * |
|
66 | + * @return Array the spotter information |
|
67 | + * |
|
68 | + */ |
|
69 | + public function getLastArchiveSpotterDataById($id) |
|
70 | + { |
|
71 | + $Spotter = new Spotter($this->db); |
|
72 | + date_default_timezone_set('UTC'); |
|
73 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
74 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
75 | + //$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"; |
|
76 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
77 | 77 | |
78 | 78 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
79 | - /* |
|
79 | + /* |
|
80 | 80 | try { |
81 | 81 | $Connection = new Connection(); |
82 | 82 | $sth = Connection->$db->prepare($query); |
@@ -86,225 +86,225 @@ discard block |
||
86 | 86 | } |
87 | 87 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
88 | 88 | */ |
89 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
90 | - |
|
91 | - return $spotter_array; |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Gets all the spotter information based on a particular id |
|
96 | - * |
|
97 | - * @return Array the spotter information |
|
98 | - * |
|
99 | - */ |
|
100 | - public function getAllArchiveSpotterDataById($id) |
|
101 | - { |
|
102 | - date_default_timezone_set('UTC'); |
|
103 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
104 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
89 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
90 | + |
|
91 | + return $spotter_array; |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Gets all the spotter information based on a particular id |
|
96 | + * |
|
97 | + * @return Array the spotter information |
|
98 | + * |
|
99 | + */ |
|
100 | + public function getAllArchiveSpotterDataById($id) |
|
101 | + { |
|
102 | + date_default_timezone_set('UTC'); |
|
103 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
104 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
105 | 105 | |
106 | 106 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
107 | 107 | |
108 | - try { |
|
109 | - $sth = $this->db->prepare($query); |
|
110 | - $sth->execute(array(':id' => $id)); |
|
111 | - } catch(PDOException $e) { |
|
112 | - return "error"; |
|
113 | - } |
|
114 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
115 | - |
|
116 | - return $spotter_array; |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * Gets coordinate & time spotter information based on a particular id |
|
121 | - * |
|
122 | - * @return Array the spotter information |
|
123 | - * |
|
124 | - */ |
|
125 | - public function getCoordArchiveSpotterDataById($id) |
|
126 | - { |
|
127 | - date_default_timezone_set('UTC'); |
|
128 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
129 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
108 | + try { |
|
109 | + $sth = $this->db->prepare($query); |
|
110 | + $sth->execute(array(':id' => $id)); |
|
111 | + } catch(PDOException $e) { |
|
112 | + return "error"; |
|
113 | + } |
|
114 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
115 | + |
|
116 | + return $spotter_array; |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * Gets coordinate & time spotter information based on a particular id |
|
121 | + * |
|
122 | + * @return Array the spotter information |
|
123 | + * |
|
124 | + */ |
|
125 | + public function getCoordArchiveSpotterDataById($id) |
|
126 | + { |
|
127 | + date_default_timezone_set('UTC'); |
|
128 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
129 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
130 | 130 | |
131 | 131 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
132 | 132 | |
133 | - try { |
|
134 | - $sth = $this->db->prepare($query); |
|
135 | - $sth->execute(array(':id' => $id)); |
|
136 | - } catch(PDOException $e) { |
|
137 | - return $e->getMessage(); |
|
138 | - } |
|
139 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
133 | + try { |
|
134 | + $sth = $this->db->prepare($query); |
|
135 | + $sth->execute(array(':id' => $id)); |
|
136 | + } catch(PDOException $e) { |
|
137 | + return $e->getMessage(); |
|
138 | + } |
|
139 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
140 | 140 | |
141 | - return $spotter_array; |
|
142 | - } |
|
141 | + return $spotter_array; |
|
142 | + } |
|
143 | 143 | |
144 | 144 | |
145 | - /** |
|
146 | - * Gets altitude information based on a particular callsign |
|
147 | - * |
|
148 | - * @return Array the spotter information |
|
149 | - * |
|
150 | - */ |
|
151 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
152 | - { |
|
145 | + /** |
|
146 | + * Gets altitude information based on a particular callsign |
|
147 | + * |
|
148 | + * @return Array the spotter information |
|
149 | + * |
|
150 | + */ |
|
151 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
152 | + { |
|
153 | 153 | |
154 | - date_default_timezone_set('UTC'); |
|
154 | + date_default_timezone_set('UTC'); |
|
155 | 155 | |
156 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
157 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
156 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
157 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
158 | 158 | |
159 | - try { |
|
160 | - $sth = $this->db->prepare($query); |
|
161 | - $sth->execute(array(':ident' => $ident)); |
|
162 | - } catch(PDOException $e) { |
|
163 | - return "error"; |
|
164 | - } |
|
165 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
159 | + try { |
|
160 | + $sth = $this->db->prepare($query); |
|
161 | + $sth->execute(array(':ident' => $ident)); |
|
162 | + } catch(PDOException $e) { |
|
163 | + return "error"; |
|
164 | + } |
|
165 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
166 | 166 | |
167 | - return $spotter_array; |
|
168 | - } |
|
167 | + return $spotter_array; |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * Gets altitude information based on a particular id |
|
172 | - * |
|
173 | - * @return Array the spotter information |
|
174 | - * |
|
175 | - */ |
|
176 | - public function getAltitudeArchiveSpotterDataById($id) |
|
177 | - { |
|
170 | + /** |
|
171 | + * Gets altitude information based on a particular id |
|
172 | + * |
|
173 | + * @return Array the spotter information |
|
174 | + * |
|
175 | + */ |
|
176 | + public function getAltitudeArchiveSpotterDataById($id) |
|
177 | + { |
|
178 | 178 | |
179 | - date_default_timezone_set('UTC'); |
|
179 | + date_default_timezone_set('UTC'); |
|
180 | 180 | |
181 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
182 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
181 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
182 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
183 | 183 | |
184 | - try { |
|
185 | - $sth = $this->db->prepare($query); |
|
186 | - $sth->execute(array(':id' => $id)); |
|
187 | - } catch(PDOException $e) { |
|
188 | - return "error"; |
|
189 | - } |
|
190 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
184 | + try { |
|
185 | + $sth = $this->db->prepare($query); |
|
186 | + $sth->execute(array(':id' => $id)); |
|
187 | + } catch(PDOException $e) { |
|
188 | + return "error"; |
|
189 | + } |
|
190 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
191 | 191 | |
192 | - return $spotter_array; |
|
193 | - } |
|
192 | + return $spotter_array; |
|
193 | + } |
|
194 | 194 | |
195 | - /** |
|
196 | - * Gets altitude & speed information based on a particular id |
|
197 | - * |
|
198 | - * @return Array the spotter information |
|
199 | - * |
|
200 | - */ |
|
201 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
202 | - { |
|
195 | + /** |
|
196 | + * Gets altitude & speed information based on a particular id |
|
197 | + * |
|
198 | + * @return Array the spotter information |
|
199 | + * |
|
200 | + */ |
|
201 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
202 | + { |
|
203 | 203 | |
204 | - date_default_timezone_set('UTC'); |
|
204 | + date_default_timezone_set('UTC'); |
|
205 | 205 | |
206 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
207 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
206 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
207 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
208 | 208 | |
209 | - try { |
|
210 | - $sth = $this->db->prepare($query); |
|
211 | - $sth->execute(array(':id' => $id)); |
|
212 | - } catch(PDOException $e) { |
|
213 | - return "error : ".$e->getMessage(); |
|
214 | - } |
|
215 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
209 | + try { |
|
210 | + $sth = $this->db->prepare($query); |
|
211 | + $sth->execute(array(':id' => $id)); |
|
212 | + } catch(PDOException $e) { |
|
213 | + return "error : ".$e->getMessage(); |
|
214 | + } |
|
215 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
216 | 216 | |
217 | - return $spotter_array; |
|
218 | - } |
|
217 | + return $spotter_array; |
|
218 | + } |
|
219 | 219 | |
220 | 220 | |
221 | - /** |
|
222 | - * Gets altitude information based on a particular callsign |
|
223 | - * |
|
224 | - * @return Array the spotter information |
|
225 | - * |
|
226 | - */ |
|
227 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
228 | - { |
|
221 | + /** |
|
222 | + * Gets altitude information based on a particular callsign |
|
223 | + * |
|
224 | + * @return Array the spotter information |
|
225 | + * |
|
226 | + */ |
|
227 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
228 | + { |
|
229 | 229 | |
230 | - date_default_timezone_set('UTC'); |
|
230 | + date_default_timezone_set('UTC'); |
|
231 | 231 | |
232 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
233 | - $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"; |
|
232 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
233 | + $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"; |
|
234 | 234 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
235 | 235 | |
236 | - try { |
|
237 | - $sth = $this->db->prepare($query); |
|
238 | - $sth->execute(array(':ident' => $ident)); |
|
239 | - } catch(PDOException $e) { |
|
240 | - return "error"; |
|
241 | - } |
|
242 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
236 | + try { |
|
237 | + $sth = $this->db->prepare($query); |
|
238 | + $sth->execute(array(':ident' => $ident)); |
|
239 | + } catch(PDOException $e) { |
|
240 | + return "error"; |
|
241 | + } |
|
242 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
243 | 243 | |
244 | - return $spotter_array; |
|
245 | - } |
|
244 | + return $spotter_array; |
|
245 | + } |
|
246 | 246 | |
247 | 247 | |
248 | 248 | |
249 | - /** |
|
250 | - * Gets all the archive spotter information |
|
251 | - * |
|
252 | - * @return Array the spotter information |
|
253 | - * |
|
254 | - */ |
|
255 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
256 | - { |
|
257 | - $Spotter = new Spotter($this->db); |
|
258 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
259 | - $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"; |
|
249 | + /** |
|
250 | + * Gets all the archive spotter information |
|
251 | + * |
|
252 | + * @return Array the spotter information |
|
253 | + * |
|
254 | + */ |
|
255 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
256 | + { |
|
257 | + $Spotter = new Spotter($this->db); |
|
258 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
259 | + $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"; |
|
260 | 260 | |
261 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
261 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
262 | 262 | |
263 | - return $spotter_array; |
|
264 | - } |
|
263 | + return $spotter_array; |
|
264 | + } |
|
265 | 265 | |
266 | - public function deleteSpotterArchiveTrackData() |
|
267 | - { |
|
266 | + public function deleteSpotterArchiveTrackData() |
|
267 | + { |
|
268 | 268 | global $globalArchiveKeepTrackMonths; |
269 | - date_default_timezone_set('UTC'); |
|
269 | + date_default_timezone_set('UTC'); |
|
270 | 270 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
271 | - try { |
|
272 | - $sth = $this->db->prepare($query); |
|
273 | - $sth->execute(); |
|
274 | - } catch(PDOException $e) { |
|
275 | - return "error"; |
|
276 | - } |
|
271 | + try { |
|
272 | + $sth = $this->db->prepare($query); |
|
273 | + $sth->execute(); |
|
274 | + } catch(PDOException $e) { |
|
275 | + return "error"; |
|
276 | + } |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
280 | - * Gets Minimal Live Spotter data |
|
281 | - * |
|
282 | - * @return Array the spotter information |
|
283 | - * |
|
284 | - */ |
|
285 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
286 | - { |
|
287 | - global $globalDBdriver, $globalLiveInterval; |
|
288 | - date_default_timezone_set('UTC'); |
|
289 | - |
|
290 | - $filter_query = ''; |
|
291 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
292 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
293 | - } |
|
294 | - // Use spotter_output also ? |
|
295 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
296 | - $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 "; |
|
297 | - } |
|
298 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
299 | - $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 "; |
|
300 | - } |
|
301 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
302 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
303 | - } |
|
304 | - |
|
305 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
306 | - if ($globalDBdriver == 'mysql') { |
|
307 | - /* |
|
280 | + * Gets Minimal Live Spotter data |
|
281 | + * |
|
282 | + * @return Array the spotter information |
|
283 | + * |
|
284 | + */ |
|
285 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
286 | + { |
|
287 | + global $globalDBdriver, $globalLiveInterval; |
|
288 | + date_default_timezone_set('UTC'); |
|
289 | + |
|
290 | + $filter_query = ''; |
|
291 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
292 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
293 | + } |
|
294 | + // Use spotter_output also ? |
|
295 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
296 | + $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 "; |
|
297 | + } |
|
298 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
299 | + $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 "; |
|
300 | + } |
|
301 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
302 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
303 | + } |
|
304 | + |
|
305 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
306 | + if ($globalDBdriver == 'mysql') { |
|
307 | + /* |
|
308 | 308 | $query = 'SELECT a.aircraft_shadow, 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 |
309 | 309 | FROM spotter_archive |
310 | 310 | 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'; |
@@ -316,50 +316,50 @@ discard block |
||
316 | 316 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".') |
317 | 317 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
318 | 318 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
319 | - } else if ($globalDBdriver == 'pgsql') { |
|
320 | - $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'; |
|
321 | - } |
|
322 | - //echo $query; |
|
323 | - try { |
|
324 | - $sth = $this->db->prepare($query); |
|
325 | - $sth->execute(); |
|
326 | - } catch(PDOException $e) { |
|
327 | - return "error"; |
|
328 | - } |
|
329 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
330 | - |
|
331 | - return $spotter_array; |
|
332 | - } |
|
319 | + } else if ($globalDBdriver == 'pgsql') { |
|
320 | + $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'; |
|
321 | + } |
|
322 | + //echo $query; |
|
323 | + try { |
|
324 | + $sth = $this->db->prepare($query); |
|
325 | + $sth->execute(); |
|
326 | + } catch(PDOException $e) { |
|
327 | + return "error"; |
|
328 | + } |
|
329 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
330 | + |
|
331 | + return $spotter_array; |
|
332 | + } |
|
333 | 333 | |
334 | 334 | /** |
335 | - * Gets Minimal Live Spotter data |
|
336 | - * |
|
337 | - * @return Array the spotter information |
|
338 | - * |
|
339 | - */ |
|
340 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
341 | - { |
|
342 | - global $globalDBdriver, $globalLiveInterval; |
|
343 | - date_default_timezone_set('UTC'); |
|
344 | - |
|
345 | - $filter_query = ''; |
|
346 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
347 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
348 | - } |
|
349 | - // Should use spotter_output also ? |
|
350 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
351 | - $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 "; |
|
352 | - } |
|
353 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
354 | - $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 "; |
|
355 | - } |
|
356 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
357 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
358 | - } |
|
359 | - |
|
360 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
361 | - if ($globalDBdriver == 'mysql') { |
|
362 | - /* |
|
335 | + * Gets Minimal Live Spotter data |
|
336 | + * |
|
337 | + * @return Array the spotter information |
|
338 | + * |
|
339 | + */ |
|
340 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
341 | + { |
|
342 | + global $globalDBdriver, $globalLiveInterval; |
|
343 | + date_default_timezone_set('UTC'); |
|
344 | + |
|
345 | + $filter_query = ''; |
|
346 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
347 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
348 | + } |
|
349 | + // Should use spotter_output also ? |
|
350 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
351 | + $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 "; |
|
352 | + } |
|
353 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
354 | + $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 "; |
|
355 | + } |
|
356 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
357 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
358 | + } |
|
359 | + |
|
360 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
361 | + if ($globalDBdriver == 'mysql') { |
|
362 | + /* |
|
363 | 363 | $query = 'SELECT a.aircraft_shadow, 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 |
364 | 364 | FROM spotter_archive |
365 | 365 | 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'; |
@@ -370,91 +370,91 @@ discard block |
||
370 | 370 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
371 | 371 | '.$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'; |
372 | 372 | |
373 | - } else if ($globalDBdriver == 'pgsql') { |
|
374 | - //$query = 'SELECT 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, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
375 | - $query = 'SELECT 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, a.aircraft_shadow |
|
373 | + } else if ($globalDBdriver == 'pgsql') { |
|
374 | + //$query = 'SELECT 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, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
375 | + $query = 'SELECT 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, a.aircraft_shadow |
|
376 | 376 | FROM spotter_archive_output |
377 | 377 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
378 | 378 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
379 | 379 | '.$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'; |
380 | - $query = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow |
|
380 | + $query = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow |
|
381 | 381 | FROM spotter_output |
382 | 382 | INNER JOIN (SELECT * FROM aircraft) a on spotter_output.aircraft_icao = a.icao |
383 | 383 | WHERE spotter_output.date >= '."'".$begindate."'".' AND spotter_output.date <= '."'".$enddate."'".' |
384 | 384 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
385 | 385 | // .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
386 | 386 | |
387 | - } |
|
388 | - //echo $query; |
|
389 | - try { |
|
390 | - $sth = $this->db->prepare($query); |
|
391 | - $sth->execute(); |
|
392 | - } catch(PDOException $e) { |
|
393 | - return $e->getMessage(); |
|
394 | - } |
|
395 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
396 | - |
|
397 | - return $spotter_array; |
|
398 | - } |
|
387 | + } |
|
388 | + //echo $query; |
|
389 | + try { |
|
390 | + $sth = $this->db->prepare($query); |
|
391 | + $sth->execute(); |
|
392 | + } catch(PDOException $e) { |
|
393 | + return $e->getMessage(); |
|
394 | + } |
|
395 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
396 | + |
|
397 | + return $spotter_array; |
|
398 | + } |
|
399 | 399 | |
400 | 400 | /** |
401 | - * Gets count Live Spotter data |
|
402 | - * |
|
403 | - * @return Array the spotter information |
|
404 | - * |
|
405 | - */ |
|
406 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
407 | - { |
|
408 | - global $globalDBdriver, $globalLiveInterval; |
|
409 | - date_default_timezone_set('UTC'); |
|
410 | - |
|
411 | - $filter_query = ''; |
|
412 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
413 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
414 | - } |
|
415 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
416 | - $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 "; |
|
417 | - } |
|
418 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
419 | - $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 "; |
|
420 | - } |
|
421 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
422 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
423 | - } |
|
424 | - |
|
425 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
426 | - if ($globalDBdriver == 'mysql') { |
|
401 | + * Gets count Live Spotter data |
|
402 | + * |
|
403 | + * @return Array the spotter information |
|
404 | + * |
|
405 | + */ |
|
406 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
407 | + { |
|
408 | + global $globalDBdriver, $globalLiveInterval; |
|
409 | + date_default_timezone_set('UTC'); |
|
410 | + |
|
411 | + $filter_query = ''; |
|
412 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
413 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
414 | + } |
|
415 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
416 | + $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 "; |
|
417 | + } |
|
418 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
419 | + $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 "; |
|
420 | + } |
|
421 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
422 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
423 | + } |
|
424 | + |
|
425 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
426 | + if ($globalDBdriver == 'mysql') { |
|
427 | 427 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
428 | 428 | FROM spotter_archive l |
429 | 429 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
430 | 430 | |
431 | - } else if ($globalDBdriver == 'pgsql') { |
|
431 | + } else if ($globalDBdriver == 'pgsql') { |
|
432 | 432 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
433 | - } |
|
434 | - //echo $query; |
|
435 | - try { |
|
436 | - $sth = $this->db->prepare($query); |
|
437 | - $sth->execute(); |
|
438 | - } catch(PDOException $e) { |
|
439 | - return "error"; |
|
440 | - } |
|
433 | + } |
|
434 | + //echo $query; |
|
435 | + try { |
|
436 | + $sth = $this->db->prepare($query); |
|
437 | + $sth->execute(); |
|
438 | + } catch(PDOException $e) { |
|
439 | + return "error"; |
|
440 | + } |
|
441 | 441 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
442 | - return $result['nb']; |
|
442 | + return $result['nb']; |
|
443 | 443 | |
444 | - } |
|
444 | + } |
|
445 | 445 | |
446 | 446 | |
447 | 447 | |
448 | 448 | // Spotter_Archive_output |
449 | 449 | |
450 | - /** |
|
451 | - * Gets all the spotter information |
|
452 | - * |
|
453 | - * @return Array the spotter information |
|
454 | - * |
|
455 | - */ |
|
456 | - 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 = '') |
|
457 | - { |
|
450 | + /** |
|
451 | + * Gets all the spotter information |
|
452 | + * |
|
453 | + * @return Array the spotter information |
|
454 | + * |
|
455 | + */ |
|
456 | + 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 = '') |
|
457 | + { |
|
458 | 458 | global $globalTimezone, $globalDbdriver; |
459 | 459 | require_once(dirname(__FILE__).'/class.Translation.php'); |
460 | 460 | $Translation = new Translation(); |
@@ -465,159 +465,159 @@ discard block |
||
465 | 465 | $additional_query = ''; |
466 | 466 | if ($q != "") |
467 | 467 | { |
468 | - if (!is_string($q)) |
|
469 | - { |
|
468 | + if (!is_string($q)) |
|
469 | + { |
|
470 | 470 | return false; |
471 | - } else { |
|
471 | + } else { |
|
472 | 472 | |
473 | 473 | $q_array = explode(" ", $q); |
474 | 474 | |
475 | 475 | foreach ($q_array as $q_item){ |
476 | - $additional_query .= " AND ("; |
|
477 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
478 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
479 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
480 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
481 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
482 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
483 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
484 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
485 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
486 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
487 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
488 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
489 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
490 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
491 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
492 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
493 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
494 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
495 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
496 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
497 | - $translate = $Translation->ident2icao($q_item); |
|
498 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
499 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
500 | - $additional_query .= ")"; |
|
501 | - } |
|
502 | - } |
|
476 | + $additional_query .= " AND ("; |
|
477 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
478 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
479 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
480 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
481 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
482 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
483 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
484 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
485 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
486 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
487 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
488 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
489 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
490 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
491 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
492 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
493 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
494 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
495 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
496 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
497 | + $translate = $Translation->ident2icao($q_item); |
|
498 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
499 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
500 | + $additional_query .= ")"; |
|
501 | + } |
|
502 | + } |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | if ($registration != "") |
506 | 506 | { |
507 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
508 | - if (!is_string($registration)) |
|
509 | - { |
|
507 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
508 | + if (!is_string($registration)) |
|
509 | + { |
|
510 | 510 | return false; |
511 | - } else { |
|
511 | + } else { |
|
512 | 512 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
513 | - } |
|
513 | + } |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | if ($aircraft_icao != "") |
517 | 517 | { |
518 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
519 | - if (!is_string($aircraft_icao)) |
|
520 | - { |
|
518 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
519 | + if (!is_string($aircraft_icao)) |
|
520 | + { |
|
521 | 521 | return false; |
522 | - } else { |
|
522 | + } else { |
|
523 | 523 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
524 | - } |
|
524 | + } |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | if ($aircraft_manufacturer != "") |
528 | 528 | { |
529 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
530 | - if (!is_string($aircraft_manufacturer)) |
|
531 | - { |
|
529 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
530 | + if (!is_string($aircraft_manufacturer)) |
|
531 | + { |
|
532 | 532 | return false; |
533 | - } else { |
|
533 | + } else { |
|
534 | 534 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
535 | - } |
|
535 | + } |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | if ($highlights == "true") |
539 | 539 | { |
540 | - if (!is_string($highlights)) |
|
541 | - { |
|
540 | + if (!is_string($highlights)) |
|
541 | + { |
|
542 | 542 | return false; |
543 | - } else { |
|
543 | + } else { |
|
544 | 544 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
545 | - } |
|
545 | + } |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | if ($airline_icao != "") |
549 | 549 | { |
550 | - $registration = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
551 | - if (!is_string($airline_icao)) |
|
552 | - { |
|
550 | + $registration = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
551 | + if (!is_string($airline_icao)) |
|
552 | + { |
|
553 | 553 | return false; |
554 | - } else { |
|
554 | + } else { |
|
555 | 555 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
556 | - } |
|
556 | + } |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | if ($airline_country != "") |
560 | 560 | { |
561 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
562 | - if (!is_string($airline_country)) |
|
563 | - { |
|
561 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
562 | + if (!is_string($airline_country)) |
|
563 | + { |
|
564 | 564 | return false; |
565 | - } else { |
|
565 | + } else { |
|
566 | 566 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
567 | - } |
|
567 | + } |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | if ($airline_type != "") |
571 | 571 | { |
572 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
573 | - if (!is_string($airline_type)) |
|
574 | - { |
|
572 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
573 | + if (!is_string($airline_type)) |
|
574 | + { |
|
575 | 575 | return false; |
576 | - } else { |
|
576 | + } else { |
|
577 | 577 | if ($airline_type == "passenger") |
578 | 578 | { |
579 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
579 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
580 | 580 | } |
581 | 581 | if ($airline_type == "cargo") |
582 | 582 | { |
583 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
583 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
584 | 584 | } |
585 | 585 | if ($airline_type == "military") |
586 | 586 | { |
587 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
587 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
588 | + } |
|
588 | 589 | } |
589 | - } |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | if ($airport != "") |
593 | 593 | { |
594 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
595 | - if (!is_string($airport)) |
|
596 | - { |
|
594 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
595 | + if (!is_string($airport)) |
|
596 | + { |
|
597 | 597 | return false; |
598 | - } else { |
|
598 | + } else { |
|
599 | 599 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
600 | - } |
|
600 | + } |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | if ($airport_country != "") |
604 | 604 | { |
605 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
606 | - if (!is_string($airport_country)) |
|
607 | - { |
|
605 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
606 | + if (!is_string($airport_country)) |
|
607 | + { |
|
608 | 608 | return false; |
609 | - } else { |
|
609 | + } else { |
|
610 | 610 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
611 | - } |
|
611 | + } |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | if ($callsign != "") |
615 | 615 | { |
616 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
617 | - if (!is_string($callsign)) |
|
618 | - { |
|
616 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
617 | + if (!is_string($callsign)) |
|
618 | + { |
|
619 | 619 | return false; |
620 | - } else { |
|
620 | + } else { |
|
621 | 621 | $translate = $Translation->ident2icao($callsign); |
622 | 622 | if ($translate != $callsign) { |
623 | 623 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -625,99 +625,99 @@ discard block |
||
625 | 625 | } else { |
626 | 626 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
627 | 627 | } |
628 | - } |
|
628 | + } |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | if ($owner != "") |
632 | 632 | { |
633 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
634 | - if (!is_string($owner)) |
|
635 | - { |
|
633 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
634 | + if (!is_string($owner)) |
|
635 | + { |
|
636 | 636 | return false; |
637 | - } else { |
|
637 | + } else { |
|
638 | 638 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
639 | - } |
|
639 | + } |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | if ($pilot_name != "") |
643 | 643 | { |
644 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
645 | - if (!is_string($pilot_name)) |
|
646 | - { |
|
644 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
645 | + if (!is_string($pilot_name)) |
|
646 | + { |
|
647 | 647 | return false; |
648 | - } else { |
|
648 | + } else { |
|
649 | 649 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
650 | - } |
|
650 | + } |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | if ($pilot_id != "") |
654 | 654 | { |
655 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
656 | - if (!is_string($pilot_id)) |
|
657 | - { |
|
655 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
656 | + if (!is_string($pilot_id)) |
|
657 | + { |
|
658 | 658 | return false; |
659 | - } else { |
|
659 | + } else { |
|
660 | 660 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
661 | - } |
|
661 | + } |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | if ($departure_airport_route != "") |
665 | 665 | { |
666 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
667 | - if (!is_string($departure_airport_route)) |
|
668 | - { |
|
666 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
667 | + if (!is_string($departure_airport_route)) |
|
668 | + { |
|
669 | 669 | return false; |
670 | - } else { |
|
670 | + } else { |
|
671 | 671 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
672 | - } |
|
672 | + } |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | if ($arrival_airport_route != "") |
676 | 676 | { |
677 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
678 | - if (!is_string($arrival_airport_route)) |
|
679 | - { |
|
677 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
678 | + if (!is_string($arrival_airport_route)) |
|
679 | + { |
|
680 | 680 | return false; |
681 | - } else { |
|
681 | + } else { |
|
682 | 682 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
683 | - } |
|
683 | + } |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | if ($altitude != "") |
687 | 687 | { |
688 | - $altitude_array = explode(",", $altitude); |
|
688 | + $altitude_array = explode(",", $altitude); |
|
689 | 689 | |
690 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
691 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
690 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
691 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
692 | 692 | |
693 | 693 | |
694 | - if ($altitude_array[1] != "") |
|
695 | - { |
|
694 | + if ($altitude_array[1] != "") |
|
695 | + { |
|
696 | 696 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
697 | 697 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
698 | 698 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
699 | - } else { |
|
699 | + } else { |
|
700 | 700 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
701 | 701 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
702 | - } |
|
702 | + } |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | if ($date_posted != "") |
706 | 706 | { |
707 | - $date_array = explode(",", $date_posted); |
|
707 | + $date_array = explode(",", $date_posted); |
|
708 | 708 | |
709 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
710 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
709 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
710 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
711 | 711 | |
712 | - if ($globalTimezone != '') { |
|
712 | + if ($globalTimezone != '') { |
|
713 | 713 | date_default_timezone_set($globalTimezone); |
714 | 714 | $datetime = new DateTime(); |
715 | 715 | $offset = $datetime->format('P'); |
716 | - } else $offset = '+00:00'; |
|
716 | + } else $offset = '+00:00'; |
|
717 | 717 | |
718 | 718 | |
719 | - if ($date_array[1] != "") |
|
720 | - { |
|
719 | + if ($date_array[1] != "") |
|
720 | + { |
|
721 | 721 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
722 | 722 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
723 | 723 | if ($globalDBdriver == 'mysql') { |
@@ -725,28 +725,28 @@ discard block |
||
725 | 725 | } else { |
726 | 726 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
727 | 727 | } |
728 | - } else { |
|
728 | + } else { |
|
729 | 729 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
730 | - if ($globalDBdriver == 'mysql') { |
|
730 | + if ($globalDBdriver == 'mysql') { |
|
731 | 731 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
732 | 732 | } else { |
733 | 733 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
734 | 734 | } |
735 | - } |
|
735 | + } |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | if ($limit != "") |
739 | 739 | { |
740 | - $limit_array = explode(",", $limit); |
|
740 | + $limit_array = explode(",", $limit); |
|
741 | 741 | |
742 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
743 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
742 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
743 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
744 | 744 | |
745 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
746 | - { |
|
745 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
746 | + { |
|
747 | 747 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
748 | 748 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
749 | - } |
|
749 | + } |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | |
@@ -778,33 +778,33 @@ discard block |
||
778 | 778 | $spotter_array = $Spotter->getDataFromDB($query, array(),$limit_query); |
779 | 779 | |
780 | 780 | return $spotter_array; |
781 | - } |
|
781 | + } |
|
782 | 782 | |
783 | - public function deleteSpotterArchiveData() |
|
784 | - { |
|
783 | + public function deleteSpotterArchiveData() |
|
784 | + { |
|
785 | 785 | global $globalArchiveKeepMonths, $globalDBdriver; |
786 | - date_default_timezone_set('UTC'); |
|
787 | - if ($globalDBdriver == 'mysql') { |
|
786 | + date_default_timezone_set('UTC'); |
|
787 | + if ($globalDBdriver == 'mysql') { |
|
788 | 788 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
789 | 789 | } else { |
790 | 790 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
791 | 791 | } |
792 | - try { |
|
793 | - $sth = $this->db->prepare($query); |
|
794 | - $sth->execute(); |
|
795 | - } catch(PDOException $e) { |
|
796 | - return "error"; |
|
797 | - } |
|
792 | + try { |
|
793 | + $sth = $this->db->prepare($query); |
|
794 | + $sth->execute(); |
|
795 | + } catch(PDOException $e) { |
|
796 | + return "error"; |
|
797 | + } |
|
798 | 798 | } |
799 | 799 | |
800 | - /** |
|
801 | - * Gets all the spotter information based on the callsign |
|
802 | - * |
|
803 | - * @return Array the spotter information |
|
804 | - * |
|
805 | - */ |
|
806 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
807 | - { |
|
800 | + /** |
|
801 | + * Gets all the spotter information based on the callsign |
|
802 | + * |
|
803 | + * @return Array the spotter information |
|
804 | + * |
|
805 | + */ |
|
806 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
807 | + { |
|
808 | 808 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
809 | 809 | |
810 | 810 | date_default_timezone_set('UTC'); |
@@ -813,35 +813,35 @@ discard block |
||
813 | 813 | |
814 | 814 | if ($ident != "") |
815 | 815 | { |
816 | - if (!is_string($ident)) |
|
817 | - { |
|
816 | + if (!is_string($ident)) |
|
817 | + { |
|
818 | 818 | return false; |
819 | - } else { |
|
819 | + } else { |
|
820 | 820 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
821 | 821 | $query_values = array(':ident' => $ident); |
822 | - } |
|
822 | + } |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | if ($limit != "") |
826 | 826 | { |
827 | - $limit_array = explode(",", $limit); |
|
827 | + $limit_array = explode(",", $limit); |
|
828 | 828 | |
829 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
830 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
829 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
830 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
831 | 831 | |
832 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
833 | - { |
|
832 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
833 | + { |
|
834 | 834 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
835 | 835 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
836 | - } |
|
836 | + } |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | if ($sort != "") |
840 | 840 | { |
841 | - $search_orderby_array = $this->getOrderBy(); |
|
842 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
841 | + $search_orderby_array = $this->getOrderBy(); |
|
842 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
843 | 843 | } else { |
844 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
844 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -850,16 +850,16 @@ discard block |
||
850 | 850 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
851 | 851 | |
852 | 852 | return $spotter_array; |
853 | - } |
|
854 | - |
|
855 | - /** |
|
856 | - * Gets all number of flight over countries |
|
857 | - * |
|
858 | - * @return Array the airline country list |
|
859 | - * |
|
860 | - */ |
|
861 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
862 | - { |
|
853 | + } |
|
854 | + |
|
855 | + /** |
|
856 | + * Gets all number of flight over countries |
|
857 | + * |
|
858 | + * @return Array the airline country list |
|
859 | + * |
|
860 | + */ |
|
861 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
862 | + { |
|
863 | 863 | global $globalDBdriver; |
864 | 864 | /* |
865 | 865 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -869,14 +869,14 @@ discard block |
||
869 | 869 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
870 | 870 | FROM countries c, spotter_archive s |
871 | 871 | WHERE c.iso2 = s.over_country "; |
872 | - if ($olderthanmonths > 0) { |
|
873 | - if ($globalDBdriver == 'mysql') { |
|
872 | + if ($olderthanmonths > 0) { |
|
873 | + if ($globalDBdriver == 'mysql') { |
|
874 | 874 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
875 | 875 | } else { |
876 | 876 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
877 | 877 | } |
878 | 878 | } |
879 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
879 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
880 | 880 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
881 | 881 | if ($limit) $query .= " LIMIT 0,10"; |
882 | 882 | |
@@ -889,14 +889,14 @@ discard block |
||
889 | 889 | |
890 | 890 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
891 | 891 | { |
892 | - $temp_array['flight_count'] = $row['nb']; |
|
893 | - $temp_array['flight_country'] = $row['name']; |
|
894 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
895 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
896 | - $flight_array[] = $temp_array; |
|
892 | + $temp_array['flight_count'] = $row['nb']; |
|
893 | + $temp_array['flight_country'] = $row['name']; |
|
894 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
895 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
896 | + $flight_array[] = $temp_array; |
|
897 | 897 | } |
898 | 898 | return $flight_array; |
899 | - } |
|
899 | + } |
|
900 | 900 | |
901 | 901 | } |
902 | 902 | ?> |
903 | 903 | \ No newline at end of file |