@@ -14,40 +14,40 @@ |
||
14 | 14 | { |
15 | 15 | $coords = explode(',',$_GET['coord']); |
16 | 16 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
17 | - || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) { |
|
17 | + || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) { |
|
18 | 18 | //$spotter_array = $Source->getAllLocationInfo(); |
19 | 19 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs',$coords)); |
20 | 20 | } |
21 | 21 | if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') |
22 | - || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) { |
|
22 | + || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) { |
|
23 | 23 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx',$coords)); |
24 | 24 | } |
25 | 25 | if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') |
26 | - || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) { |
|
26 | + || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) { |
|
27 | 27 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning',$coords)); |
28 | 28 | } |
29 | 29 | |
30 | 30 | if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true') |
31 | - || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) { |
|
31 | + || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) { |
|
32 | 32 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',$coords,true)); |
33 | 33 | } |
34 | 34 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('')); |
35 | 35 | } else { |
36 | 36 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
37 | - || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) { |
|
37 | + || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) { |
|
38 | 38 | //$spotter_array = $Source->getAllLocationInfo(); |
39 | 39 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs')); |
40 | 40 | } |
41 | 41 | if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') |
42 | - || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) { |
|
42 | + || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) { |
|
43 | 43 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx')); |
44 | 44 | } |
45 | 45 | if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') |
46 | - || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) { |
|
46 | + || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) { |
|
47 | 47 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning')); |
48 | 48 | } |
49 | 49 | if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true') |
50 | - || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) { |
|
50 | + || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) { |
|
51 | 51 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',array(),true)); |
52 | 52 | } |
53 | 53 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('')); |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
13 | - * Get SQL query part for filter used |
|
14 | - * @param Array $filter the filter |
|
15 | - * @return Array the SQL part |
|
16 | - */ |
|
13 | + * Get SQL query part for filter used |
|
14 | + * @param Array $filter the filter |
|
15 | + * @return Array the SQL part |
|
16 | + */ |
|
17 | 17 | public function getFilter($filter = array(),$where = false,$and = false) { |
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
@@ -106,44 +106,44 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | - /** |
|
110 | - * Gets all the spotter information based on a particular callsign |
|
111 | - * |
|
112 | - * @return Array the spotter information |
|
113 | - * |
|
114 | - */ |
|
115 | - public function getLastArchiveTrackerDataByIdent($ident) |
|
116 | - { |
|
109 | + /** |
|
110 | + * Gets all the spotter information based on a particular callsign |
|
111 | + * |
|
112 | + * @return Array the spotter information |
|
113 | + * |
|
114 | + */ |
|
115 | + public function getLastArchiveTrackerDataByIdent($ident) |
|
116 | + { |
|
117 | 117 | $Tracker = new Tracker($this->db); |
118 | - date_default_timezone_set('UTC'); |
|
118 | + date_default_timezone_set('UTC'); |
|
119 | 119 | |
120 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
121 | - //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
122 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
120 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
121 | + //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
122 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
123 | 123 | |
124 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
124 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
125 | 125 | |
126 | - return $spotter_array; |
|
127 | - } |
|
126 | + return $spotter_array; |
|
127 | + } |
|
128 | 128 | |
129 | 129 | |
130 | - /** |
|
131 | - * Gets last the spotter information based on a particular id |
|
132 | - * |
|
133 | - * @return Array the spotter information |
|
134 | - * |
|
135 | - */ |
|
136 | - public function getLastArchiveTrackerDataById($id) |
|
137 | - { |
|
138 | - $Tracker = new Tracker($this->db); |
|
139 | - date_default_timezone_set('UTC'); |
|
140 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
141 | - //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
|
142 | - //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
143 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
130 | + /** |
|
131 | + * Gets last the spotter information based on a particular id |
|
132 | + * |
|
133 | + * @return Array the spotter information |
|
134 | + * |
|
135 | + */ |
|
136 | + public function getLastArchiveTrackerDataById($id) |
|
137 | + { |
|
138 | + $Tracker = new Tracker($this->db); |
|
139 | + date_default_timezone_set('UTC'); |
|
140 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
141 | + //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
|
142 | + //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
143 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
144 | 144 | |
145 | 145 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
146 | - /* |
|
146 | + /* |
|
147 | 147 | try { |
148 | 148 | $Connection = new Connection(); |
149 | 149 | $sth = Connection->$db->prepare($query); |
@@ -153,188 +153,188 @@ discard block |
||
153 | 153 | } |
154 | 154 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
155 | 155 | */ |
156 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
157 | - |
|
158 | - return $spotter_array; |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * Gets all the spotter information based on a particular id |
|
163 | - * |
|
164 | - * @return Array the spotter information |
|
165 | - * |
|
166 | - */ |
|
167 | - public function getAllArchiveTrackerDataById($id) |
|
156 | + $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
157 | + |
|
158 | + return $spotter_array; |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * Gets all the spotter information based on a particular id |
|
163 | + * |
|
164 | + * @return Array the spotter information |
|
165 | + * |
|
166 | + */ |
|
167 | + public function getAllArchiveTrackerDataById($id) |
|
168 | 168 | { |
169 | - date_default_timezone_set('UTC'); |
|
170 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
171 | - $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
169 | + date_default_timezone_set('UTC'); |
|
170 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
171 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
172 | 172 | |
173 | 173 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
174 | 174 | |
175 | - try { |
|
176 | - $sth = $this->db->prepare($query); |
|
177 | - $sth->execute(array(':id' => $id)); |
|
178 | - } catch(PDOException $e) { |
|
179 | - echo $e->getMessage(); |
|
180 | - die; |
|
181 | - } |
|
182 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
183 | - |
|
184 | - return $spotter_array; |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * Gets coordinate & time spotter information based on a particular id |
|
189 | - * |
|
190 | - * @return Array the spotter information |
|
191 | - * |
|
192 | - */ |
|
193 | - public function getCoordArchiveTrackerDataById($id) |
|
194 | - { |
|
195 | - date_default_timezone_set('UTC'); |
|
196 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
197 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
175 | + try { |
|
176 | + $sth = $this->db->prepare($query); |
|
177 | + $sth->execute(array(':id' => $id)); |
|
178 | + } catch(PDOException $e) { |
|
179 | + echo $e->getMessage(); |
|
180 | + die; |
|
181 | + } |
|
182 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
183 | + |
|
184 | + return $spotter_array; |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * Gets coordinate & time spotter information based on a particular id |
|
189 | + * |
|
190 | + * @return Array the spotter information |
|
191 | + * |
|
192 | + */ |
|
193 | + public function getCoordArchiveTrackerDataById($id) |
|
194 | + { |
|
195 | + date_default_timezone_set('UTC'); |
|
196 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
197 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
198 | 198 | |
199 | 199 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
200 | 200 | |
201 | - try { |
|
202 | - $sth = $this->db->prepare($query); |
|
203 | - $sth->execute(array(':id' => $id)); |
|
204 | - } catch(PDOException $e) { |
|
205 | - echo $e->getMessage(); |
|
206 | - die; |
|
207 | - } |
|
208 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
201 | + try { |
|
202 | + $sth = $this->db->prepare($query); |
|
203 | + $sth->execute(array(':id' => $id)); |
|
204 | + } catch(PDOException $e) { |
|
205 | + echo $e->getMessage(); |
|
206 | + die; |
|
207 | + } |
|
208 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
209 | 209 | |
210 | - return $spotter_array; |
|
211 | - } |
|
210 | + return $spotter_array; |
|
211 | + } |
|
212 | 212 | |
213 | 213 | |
214 | - /** |
|
215 | - * Gets altitude information based on a particular callsign |
|
216 | - * |
|
217 | - * @return Array the spotter information |
|
218 | - * |
|
219 | - */ |
|
220 | - public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
221 | - { |
|
214 | + /** |
|
215 | + * Gets altitude information based on a particular callsign |
|
216 | + * |
|
217 | + * @return Array the spotter information |
|
218 | + * |
|
219 | + */ |
|
220 | + public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
221 | + { |
|
222 | 222 | |
223 | - date_default_timezone_set('UTC'); |
|
223 | + date_default_timezone_set('UTC'); |
|
224 | 224 | |
225 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
226 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
225 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
226 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
227 | 227 | |
228 | - try { |
|
229 | - $sth = $this->db->prepare($query); |
|
230 | - $sth->execute(array(':ident' => $ident)); |
|
231 | - } catch(PDOException $e) { |
|
232 | - echo $e->getMessage(); |
|
233 | - die; |
|
234 | - } |
|
235 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
228 | + try { |
|
229 | + $sth = $this->db->prepare($query); |
|
230 | + $sth->execute(array(':ident' => $ident)); |
|
231 | + } catch(PDOException $e) { |
|
232 | + echo $e->getMessage(); |
|
233 | + die; |
|
234 | + } |
|
235 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
236 | 236 | |
237 | - return $spotter_array; |
|
238 | - } |
|
237 | + return $spotter_array; |
|
238 | + } |
|
239 | 239 | |
240 | - /** |
|
241 | - * Gets altitude information based on a particular id |
|
242 | - * |
|
243 | - * @return Array the spotter information |
|
244 | - * |
|
245 | - */ |
|
246 | - public function getAltitudeArchiveTrackerDataById($id) |
|
247 | - { |
|
240 | + /** |
|
241 | + * Gets altitude information based on a particular id |
|
242 | + * |
|
243 | + * @return Array the spotter information |
|
244 | + * |
|
245 | + */ |
|
246 | + public function getAltitudeArchiveTrackerDataById($id) |
|
247 | + { |
|
248 | 248 | |
249 | - date_default_timezone_set('UTC'); |
|
249 | + date_default_timezone_set('UTC'); |
|
250 | 250 | |
251 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
252 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
251 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
252 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
253 | 253 | |
254 | - try { |
|
255 | - $sth = $this->db->prepare($query); |
|
256 | - $sth->execute(array(':id' => $id)); |
|
257 | - } catch(PDOException $e) { |
|
258 | - echo $e->getMessage(); |
|
259 | - die; |
|
260 | - } |
|
261 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
254 | + try { |
|
255 | + $sth = $this->db->prepare($query); |
|
256 | + $sth->execute(array(':id' => $id)); |
|
257 | + } catch(PDOException $e) { |
|
258 | + echo $e->getMessage(); |
|
259 | + die; |
|
260 | + } |
|
261 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
262 | 262 | |
263 | - return $spotter_array; |
|
264 | - } |
|
263 | + return $spotter_array; |
|
264 | + } |
|
265 | 265 | |
266 | - /** |
|
267 | - * Gets altitude & speed information based on a particular id |
|
268 | - * |
|
269 | - * @return Array the spotter information |
|
270 | - * |
|
271 | - */ |
|
272 | - public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
273 | - { |
|
266 | + /** |
|
267 | + * Gets altitude & speed information based on a particular id |
|
268 | + * |
|
269 | + * @return Array the spotter information |
|
270 | + * |
|
271 | + */ |
|
272 | + public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
273 | + { |
|
274 | 274 | |
275 | - date_default_timezone_set('UTC'); |
|
275 | + date_default_timezone_set('UTC'); |
|
276 | 276 | |
277 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
278 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
277 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
278 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
279 | 279 | |
280 | - try { |
|
281 | - $sth = $this->db->prepare($query); |
|
282 | - $sth->execute(array(':id' => $id)); |
|
283 | - } catch(PDOException $e) { |
|
284 | - echo $e->getMessage(); |
|
285 | - die; |
|
286 | - } |
|
287 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
280 | + try { |
|
281 | + $sth = $this->db->prepare($query); |
|
282 | + $sth->execute(array(':id' => $id)); |
|
283 | + } catch(PDOException $e) { |
|
284 | + echo $e->getMessage(); |
|
285 | + die; |
|
286 | + } |
|
287 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
288 | 288 | |
289 | - return $spotter_array; |
|
290 | - } |
|
289 | + return $spotter_array; |
|
290 | + } |
|
291 | 291 | |
292 | 292 | |
293 | - /** |
|
294 | - * Gets altitude information based on a particular callsign |
|
295 | - * |
|
296 | - * @return Array the spotter information |
|
297 | - * |
|
298 | - */ |
|
299 | - public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
300 | - { |
|
293 | + /** |
|
294 | + * Gets altitude information based on a particular callsign |
|
295 | + * |
|
296 | + * @return Array the spotter information |
|
297 | + * |
|
298 | + */ |
|
299 | + public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
300 | + { |
|
301 | 301 | |
302 | - date_default_timezone_set('UTC'); |
|
302 | + date_default_timezone_set('UTC'); |
|
303 | 303 | |
304 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
305 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
304 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
305 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
306 | 306 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
307 | 307 | |
308 | - try { |
|
309 | - $sth = $this->db->prepare($query); |
|
310 | - $sth->execute(array(':ident' => $ident)); |
|
311 | - } catch(PDOException $e) { |
|
312 | - echo $e->getMessage(); |
|
313 | - die; |
|
314 | - } |
|
315 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
308 | + try { |
|
309 | + $sth = $this->db->prepare($query); |
|
310 | + $sth->execute(array(':ident' => $ident)); |
|
311 | + } catch(PDOException $e) { |
|
312 | + echo $e->getMessage(); |
|
313 | + die; |
|
314 | + } |
|
315 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
316 | 316 | |
317 | - return $spotter_array; |
|
318 | - } |
|
317 | + return $spotter_array; |
|
318 | + } |
|
319 | 319 | |
320 | 320 | |
321 | 321 | |
322 | - /** |
|
323 | - * Gets all the archive spotter information |
|
324 | - * |
|
325 | - * @return Array the spotter information |
|
326 | - * |
|
327 | - */ |
|
328 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
329 | - { |
|
330 | - $Tracker = new Tracker($this->db); |
|
331 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
332 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
322 | + /** |
|
323 | + * Gets all the archive spotter information |
|
324 | + * |
|
325 | + * @return Array the spotter information |
|
326 | + * |
|
327 | + */ |
|
328 | + public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
329 | + { |
|
330 | + $Tracker = new Tracker($this->db); |
|
331 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
332 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
333 | 333 | |
334 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
334 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
335 | 335 | |
336 | - return $spotter_array; |
|
337 | - } |
|
336 | + return $spotter_array; |
|
337 | + } |
|
338 | 338 | |
339 | 339 | public function deleteTrackerArchiveTrackData() |
340 | 340 | { |
@@ -354,34 +354,34 @@ discard block |
||
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
357 | - * Gets Minimal Live Tracker data |
|
358 | - * |
|
359 | - * @return Array the spotter information |
|
360 | - * |
|
361 | - */ |
|
362 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
363 | - { |
|
364 | - global $globalDBdriver, $globalLiveInterval; |
|
365 | - date_default_timezone_set('UTC'); |
|
366 | - |
|
367 | - $filter_query = ''; |
|
368 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
369 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
370 | - } |
|
371 | - // Use spotter_output also ? |
|
372 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
373 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
374 | - } |
|
375 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
376 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
377 | - } |
|
378 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
379 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
380 | - } |
|
357 | + * Gets Minimal Live Tracker data |
|
358 | + * |
|
359 | + * @return Array the spotter information |
|
360 | + * |
|
361 | + */ |
|
362 | + public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
363 | + { |
|
364 | + global $globalDBdriver, $globalLiveInterval; |
|
365 | + date_default_timezone_set('UTC'); |
|
381 | 366 | |
382 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
383 | - if ($globalDBdriver == 'mysql') { |
|
384 | - /* |
|
367 | + $filter_query = ''; |
|
368 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
369 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
370 | + } |
|
371 | + // Use spotter_output also ? |
|
372 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
373 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
374 | + } |
|
375 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
376 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
377 | + } |
|
378 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
379 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
380 | + } |
|
381 | + |
|
382 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
383 | + if ($globalDBdriver == 'mysql') { |
|
384 | + /* |
|
385 | 385 | $query = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk |
386 | 386 | FROM tracker_archive |
387 | 387 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
@@ -400,56 +400,56 @@ discard block |
||
400 | 400 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
401 | 401 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
402 | 402 | '.$filter_query.' ORDER BY famtrackid'; |
403 | - } else { |
|
404 | - //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
|
405 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
403 | + } else { |
|
404 | + //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
|
405 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
406 | 406 | FROM tracker_archive |
407 | 407 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
408 | 408 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
409 | 409 | '.$filter_query.' ORDER BY famtrackid'; |
410 | - } |
|
411 | - //echo $query; |
|
412 | - try { |
|
413 | - $sth = $this->db->prepare($query); |
|
414 | - $sth->execute(); |
|
415 | - } catch(PDOException $e) { |
|
416 | - echo $e->getMessage(); |
|
417 | - die; |
|
418 | - } |
|
419 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
410 | + } |
|
411 | + //echo $query; |
|
412 | + try { |
|
413 | + $sth = $this->db->prepare($query); |
|
414 | + $sth->execute(); |
|
415 | + } catch(PDOException $e) { |
|
416 | + echo $e->getMessage(); |
|
417 | + die; |
|
418 | + } |
|
419 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
420 | 420 | |
421 | - return $spotter_array; |
|
422 | - } |
|
421 | + return $spotter_array; |
|
422 | + } |
|
423 | 423 | |
424 | 424 | /** |
425 | - * Gets Minimal Live Tracker data |
|
426 | - * |
|
427 | - * @return Array the spotter information |
|
428 | - * |
|
429 | - */ |
|
430 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
431 | - { |
|
432 | - global $globalDBdriver, $globalLiveInterval; |
|
433 | - date_default_timezone_set('UTC'); |
|
434 | - |
|
435 | - $filter_query = ''; |
|
436 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
437 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
438 | - } |
|
439 | - // Should use spotter_output also ? |
|
440 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
441 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
442 | - } |
|
443 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
444 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
445 | - } |
|
446 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
447 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
448 | - } |
|
425 | + * Gets Minimal Live Tracker data |
|
426 | + * |
|
427 | + * @return Array the spotter information |
|
428 | + * |
|
429 | + */ |
|
430 | + public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
431 | + { |
|
432 | + global $globalDBdriver, $globalLiveInterval; |
|
433 | + date_default_timezone_set('UTC'); |
|
434 | + |
|
435 | + $filter_query = ''; |
|
436 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
437 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
438 | + } |
|
439 | + // Should use spotter_output also ? |
|
440 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
441 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
442 | + } |
|
443 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
444 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
445 | + } |
|
446 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
447 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
448 | + } |
|
449 | 449 | |
450 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
451 | - if ($globalDBdriver == 'mysql') { |
|
452 | - /* |
|
450 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
451 | + if ($globalDBdriver == 'mysql') { |
|
452 | + /* |
|
453 | 453 | $query = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk |
454 | 454 | FROM tracker_archive |
455 | 455 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
@@ -460,95 +460,95 @@ discard block |
||
460 | 460 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
461 | 461 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
462 | 462 | |
463 | - } else { |
|
464 | - //$query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao'; |
|
465 | - /* |
|
463 | + } else { |
|
464 | + //$query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao'; |
|
465 | + /* |
|
466 | 466 | $query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
467 | 467 | FROM tracker_archive_output |
468 | 468 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
469 | 469 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
470 | 470 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
471 | 471 | */ |
472 | - $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
472 | + $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
473 | 473 | FROM tracker_archive_output |
474 | 474 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
475 | 475 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
476 | 476 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
477 | 477 | // .' GROUP BY spotter_output.famtrackid, 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'; |
478 | 478 | |
479 | - } |
|
480 | - //echo $query; |
|
481 | - try { |
|
482 | - $sth = $this->db->prepare($query); |
|
483 | - $sth->execute(); |
|
484 | - } catch(PDOException $e) { |
|
485 | - echo $e->getMessage(); |
|
486 | - die; |
|
487 | - } |
|
488 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
479 | + } |
|
480 | + //echo $query; |
|
481 | + try { |
|
482 | + $sth = $this->db->prepare($query); |
|
483 | + $sth->execute(); |
|
484 | + } catch(PDOException $e) { |
|
485 | + echo $e->getMessage(); |
|
486 | + die; |
|
487 | + } |
|
488 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
489 | 489 | |
490 | - return $spotter_array; |
|
491 | - } |
|
490 | + return $spotter_array; |
|
491 | + } |
|
492 | 492 | |
493 | 493 | /** |
494 | - * Gets count Live Tracker data |
|
495 | - * |
|
496 | - * @return Array the spotter information |
|
497 | - * |
|
498 | - */ |
|
499 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
500 | - { |
|
501 | - global $globalDBdriver, $globalLiveInterval; |
|
502 | - date_default_timezone_set('UTC'); |
|
503 | - |
|
504 | - $filter_query = ''; |
|
505 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
506 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
507 | - } |
|
508 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
509 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
510 | - } |
|
511 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
512 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
513 | - } |
|
514 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
515 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
516 | - } |
|
494 | + * Gets count Live Tracker data |
|
495 | + * |
|
496 | + * @return Array the spotter information |
|
497 | + * |
|
498 | + */ |
|
499 | + public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
500 | + { |
|
501 | + global $globalDBdriver, $globalLiveInterval; |
|
502 | + date_default_timezone_set('UTC'); |
|
517 | 503 | |
518 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
519 | - if ($globalDBdriver == 'mysql') { |
|
504 | + $filter_query = ''; |
|
505 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
506 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
507 | + } |
|
508 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
509 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
510 | + } |
|
511 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
512 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
513 | + } |
|
514 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
515 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
516 | + } |
|
517 | + |
|
518 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
519 | + if ($globalDBdriver == 'mysql') { |
|
520 | 520 | $query = 'SELECT COUNT(DISTINCT famtrackid) as nb |
521 | 521 | FROM tracker_archive l |
522 | 522 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
523 | - } else { |
|
523 | + } else { |
|
524 | 524 | $query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
525 | - } |
|
526 | - //echo $query; |
|
527 | - try { |
|
528 | - $sth = $this->db->prepare($query); |
|
529 | - $sth->execute(); |
|
530 | - } catch(PDOException $e) { |
|
531 | - echo $e->getMessage(); |
|
532 | - die; |
|
533 | - } |
|
525 | + } |
|
526 | + //echo $query; |
|
527 | + try { |
|
528 | + $sth = $this->db->prepare($query); |
|
529 | + $sth->execute(); |
|
530 | + } catch(PDOException $e) { |
|
531 | + echo $e->getMessage(); |
|
532 | + die; |
|
533 | + } |
|
534 | 534 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
535 | 535 | $sth->closeCursor(); |
536 | - return $result['nb']; |
|
536 | + return $result['nb']; |
|
537 | 537 | |
538 | - } |
|
538 | + } |
|
539 | 539 | |
540 | 540 | |
541 | 541 | |
542 | 542 | // tracker_archive_output |
543 | 543 | |
544 | - /** |
|
545 | - * Gets all the spotter information |
|
546 | - * |
|
547 | - * @return Array the spotter information |
|
548 | - * |
|
549 | - */ |
|
550 | - public function searchTrackerData($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()) |
|
551 | - { |
|
544 | + /** |
|
545 | + * Gets all the spotter information |
|
546 | + * |
|
547 | + * @return Array the spotter information |
|
548 | + * |
|
549 | + */ |
|
550 | + public function searchTrackerData($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()) |
|
551 | + { |
|
552 | 552 | global $globalTimezone, $globalDBdriver; |
553 | 553 | require_once(dirname(__FILE__).'/class.Translation.php'); |
554 | 554 | $Translation = new Translation($this->db); |
@@ -562,159 +562,159 @@ discard block |
||
562 | 562 | $filter_query = $this->getFilter($filters); |
563 | 563 | if ($q != "") |
564 | 564 | { |
565 | - if (!is_string($q)) |
|
566 | - { |
|
565 | + if (!is_string($q)) |
|
566 | + { |
|
567 | 567 | return false; |
568 | - } else { |
|
568 | + } else { |
|
569 | 569 | |
570 | 570 | $q_array = explode(" ", $q); |
571 | 571 | |
572 | 572 | foreach ($q_array as $q_item){ |
573 | - $additional_query .= " AND ("; |
|
574 | - $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
575 | - $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
576 | - $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
577 | - $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
578 | - $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
579 | - $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
580 | - $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
581 | - $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
582 | - $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
583 | - $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
584 | - $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
585 | - $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
586 | - $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
587 | - $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
588 | - $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
589 | - $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
590 | - $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
591 | - $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
592 | - $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
593 | - $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
594 | - $translate = $Translation->ident2icao($q_item); |
|
595 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
596 | - $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
597 | - $additional_query .= ")"; |
|
573 | + $additional_query .= " AND ("; |
|
574 | + $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
575 | + $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
576 | + $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
577 | + $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
578 | + $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
579 | + $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
580 | + $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
581 | + $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
582 | + $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
583 | + $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
584 | + $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
585 | + $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
586 | + $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
587 | + $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
588 | + $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
589 | + $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
590 | + $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
591 | + $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
592 | + $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
593 | + $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
594 | + $translate = $Translation->ident2icao($q_item); |
|
595 | + if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
596 | + $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
597 | + $additional_query .= ")"; |
|
598 | + } |
|
598 | 599 | } |
599 | - } |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | if ($registration != "") |
603 | 603 | { |
604 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
605 | - if (!is_string($registration)) |
|
606 | - { |
|
604 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
605 | + if (!is_string($registration)) |
|
606 | + { |
|
607 | 607 | return false; |
608 | - } else { |
|
608 | + } else { |
|
609 | 609 | $additional_query .= " AND (tracker_archive_output.registration = '".$registration."')"; |
610 | - } |
|
610 | + } |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | if ($aircraft_icao != "") |
614 | 614 | { |
615 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
616 | - if (!is_string($aircraft_icao)) |
|
617 | - { |
|
615 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
616 | + if (!is_string($aircraft_icao)) |
|
617 | + { |
|
618 | 618 | return false; |
619 | - } else { |
|
619 | + } else { |
|
620 | 620 | $additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
621 | - } |
|
621 | + } |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | if ($aircraft_manufacturer != "") |
625 | 625 | { |
626 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
627 | - if (!is_string($aircraft_manufacturer)) |
|
628 | - { |
|
626 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
627 | + if (!is_string($aircraft_manufacturer)) |
|
628 | + { |
|
629 | 629 | return false; |
630 | - } else { |
|
630 | + } else { |
|
631 | 631 | $additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
632 | - } |
|
632 | + } |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | if ($highlights == "true") |
636 | 636 | { |
637 | - if (!is_string($highlights)) |
|
638 | - { |
|
637 | + if (!is_string($highlights)) |
|
638 | + { |
|
639 | 639 | return false; |
640 | - } else { |
|
640 | + } else { |
|
641 | 641 | $additional_query .= " AND (tracker_archive_output.highlight <> '')"; |
642 | - } |
|
642 | + } |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | if ($airline_icao != "") |
646 | 646 | { |
647 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
648 | - if (!is_string($airline_icao)) |
|
649 | - { |
|
647 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
648 | + if (!is_string($airline_icao)) |
|
649 | + { |
|
650 | 650 | return false; |
651 | - } else { |
|
651 | + } else { |
|
652 | 652 | $additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')"; |
653 | - } |
|
653 | + } |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | if ($airline_country != "") |
657 | 657 | { |
658 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
659 | - if (!is_string($airline_country)) |
|
660 | - { |
|
658 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
659 | + if (!is_string($airline_country)) |
|
660 | + { |
|
661 | 661 | return false; |
662 | - } else { |
|
662 | + } else { |
|
663 | 663 | $additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')"; |
664 | - } |
|
664 | + } |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | if ($airline_type != "") |
668 | 668 | { |
669 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
670 | - if (!is_string($airline_type)) |
|
671 | - { |
|
669 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
670 | + if (!is_string($airline_type)) |
|
671 | + { |
|
672 | 672 | return false; |
673 | - } else { |
|
673 | + } else { |
|
674 | 674 | if ($airline_type == "passenger") |
675 | 675 | { |
676 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
676 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
677 | 677 | } |
678 | 678 | if ($airline_type == "cargo") |
679 | 679 | { |
680 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
680 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
681 | 681 | } |
682 | 682 | if ($airline_type == "military") |
683 | 683 | { |
684 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
684 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
685 | + } |
|
685 | 686 | } |
686 | - } |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | if ($airport != "") |
690 | 690 | { |
691 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
692 | - if (!is_string($airport)) |
|
693 | - { |
|
691 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
692 | + if (!is_string($airport)) |
|
693 | + { |
|
694 | 694 | return false; |
695 | - } else { |
|
695 | + } else { |
|
696 | 696 | $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))"; |
697 | - } |
|
697 | + } |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | if ($airport_country != "") |
701 | 701 | { |
702 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
703 | - if (!is_string($airport_country)) |
|
704 | - { |
|
702 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
703 | + if (!is_string($airport_country)) |
|
704 | + { |
|
705 | 705 | return false; |
706 | - } else { |
|
706 | + } else { |
|
707 | 707 | $additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))"; |
708 | - } |
|
708 | + } |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | if ($callsign != "") |
712 | 712 | { |
713 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
714 | - if (!is_string($callsign)) |
|
715 | - { |
|
713 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
714 | + if (!is_string($callsign)) |
|
715 | + { |
|
716 | 716 | return false; |
717 | - } else { |
|
717 | + } else { |
|
718 | 718 | $translate = $Translation->ident2icao($callsign); |
719 | 719 | if ($translate != $callsign) { |
720 | 720 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
@@ -722,99 +722,99 @@ discard block |
||
722 | 722 | } else { |
723 | 723 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
724 | 724 | } |
725 | - } |
|
725 | + } |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | if ($owner != "") |
729 | 729 | { |
730 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
731 | - if (!is_string($owner)) |
|
732 | - { |
|
730 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
731 | + if (!is_string($owner)) |
|
732 | + { |
|
733 | 733 | return false; |
734 | - } else { |
|
734 | + } else { |
|
735 | 735 | $additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')"; |
736 | - } |
|
736 | + } |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | if ($pilot_name != "") |
740 | 740 | { |
741 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
742 | - if (!is_string($pilot_name)) |
|
743 | - { |
|
741 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
742 | + if (!is_string($pilot_name)) |
|
743 | + { |
|
744 | 744 | return false; |
745 | - } else { |
|
745 | + } else { |
|
746 | 746 | $additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')"; |
747 | - } |
|
747 | + } |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | if ($pilot_id != "") |
751 | 751 | { |
752 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
753 | - if (!is_string($pilot_id)) |
|
754 | - { |
|
752 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
753 | + if (!is_string($pilot_id)) |
|
754 | + { |
|
755 | 755 | return false; |
756 | - } else { |
|
756 | + } else { |
|
757 | 757 | $additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')"; |
758 | - } |
|
758 | + } |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | if ($departure_airport_route != "") |
762 | 762 | { |
763 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
764 | - if (!is_string($departure_airport_route)) |
|
765 | - { |
|
763 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
764 | + if (!is_string($departure_airport_route)) |
|
765 | + { |
|
766 | 766 | return false; |
767 | - } else { |
|
767 | + } else { |
|
768 | 768 | $additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
769 | - } |
|
769 | + } |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | if ($arrival_airport_route != "") |
773 | 773 | { |
774 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
775 | - if (!is_string($arrival_airport_route)) |
|
776 | - { |
|
774 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
775 | + if (!is_string($arrival_airport_route)) |
|
776 | + { |
|
777 | 777 | return false; |
778 | - } else { |
|
778 | + } else { |
|
779 | 779 | $additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
780 | - } |
|
780 | + } |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | if ($altitude != "") |
784 | 784 | { |
785 | - $altitude_array = explode(",", $altitude); |
|
785 | + $altitude_array = explode(",", $altitude); |
|
786 | 786 | |
787 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
787 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
789 | 789 | |
790 | 790 | |
791 | - if ($altitude_array[1] != "") |
|
792 | - { |
|
791 | + if ($altitude_array[1] != "") |
|
792 | + { |
|
793 | 793 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
794 | 794 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
795 | 795 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
796 | - } else { |
|
796 | + } else { |
|
797 | 797 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
798 | 798 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
799 | - } |
|
799 | + } |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | if ($date_posted != "") |
803 | 803 | { |
804 | - $date_array = explode(",", $date_posted); |
|
804 | + $date_array = explode(",", $date_posted); |
|
805 | 805 | |
806 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
807 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
806 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
807 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
808 | 808 | |
809 | - if ($globalTimezone != '') { |
|
809 | + if ($globalTimezone != '') { |
|
810 | 810 | date_default_timezone_set($globalTimezone); |
811 | 811 | $datetime = new DateTime(); |
812 | 812 | $offset = $datetime->format('P'); |
813 | - } else $offset = '+00:00'; |
|
813 | + } else $offset = '+00:00'; |
|
814 | 814 | |
815 | 815 | |
816 | - if ($date_array[1] != "") |
|
817 | - { |
|
816 | + if ($date_array[1] != "") |
|
817 | + { |
|
818 | 818 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
819 | 819 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
820 | 820 | if ($globalDBdriver == 'mysql') { |
@@ -822,28 +822,28 @@ discard block |
||
822 | 822 | } else { |
823 | 823 | $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
824 | 824 | } |
825 | - } else { |
|
825 | + } else { |
|
826 | 826 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
827 | - if ($globalDBdriver == 'mysql') { |
|
827 | + if ($globalDBdriver == 'mysql') { |
|
828 | 828 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
829 | 829 | } else { |
830 | 830 | $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
831 | 831 | } |
832 | - } |
|
832 | + } |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | if ($limit != "") |
836 | 836 | { |
837 | - $limit_array = explode(",", $limit); |
|
837 | + $limit_array = explode(",", $limit); |
|
838 | 838 | |
839 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
840 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
839 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
840 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
841 | 841 | |
842 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
843 | - { |
|
842 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
843 | + { |
|
844 | 844 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
845 | 845 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
846 | - } |
|
846 | + } |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | |
@@ -874,33 +874,33 @@ discard block |
||
874 | 874 | $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
875 | 875 | |
876 | 876 | return $spotter_array; |
877 | - } |
|
877 | + } |
|
878 | 878 | |
879 | - public function deleteTrackerArchiveData() |
|
880 | - { |
|
879 | + public function deleteTrackerArchiveData() |
|
880 | + { |
|
881 | 881 | global $globalArchiveKeepMonths, $globalDBdriver; |
882 | - date_default_timezone_set('UTC'); |
|
883 | - if ($globalDBdriver == 'mysql') { |
|
882 | + date_default_timezone_set('UTC'); |
|
883 | + if ($globalDBdriver == 'mysql') { |
|
884 | 884 | $query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
885 | 885 | } else { |
886 | 886 | $query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
887 | 887 | } |
888 | - try { |
|
889 | - $sth = $this->db->prepare($query); |
|
890 | - $sth->execute(); |
|
891 | - } catch(PDOException $e) { |
|
892 | - return "error"; |
|
893 | - } |
|
888 | + try { |
|
889 | + $sth = $this->db->prepare($query); |
|
890 | + $sth->execute(); |
|
891 | + } catch(PDOException $e) { |
|
892 | + return "error"; |
|
893 | + } |
|
894 | 894 | } |
895 | 895 | |
896 | - /** |
|
897 | - * Gets all the spotter information based on the callsign |
|
898 | - * |
|
899 | - * @return Array the spotter information |
|
900 | - * |
|
901 | - */ |
|
902 | - public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
903 | - { |
|
896 | + /** |
|
897 | + * Gets all the spotter information based on the callsign |
|
898 | + * |
|
899 | + * @return Array the spotter information |
|
900 | + * |
|
901 | + */ |
|
902 | + public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
903 | + { |
|
904 | 904 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
905 | 905 | |
906 | 906 | date_default_timezone_set('UTC'); |
@@ -912,35 +912,35 @@ discard block |
||
912 | 912 | |
913 | 913 | if ($ident != "") |
914 | 914 | { |
915 | - if (!is_string($ident)) |
|
916 | - { |
|
915 | + if (!is_string($ident)) |
|
916 | + { |
|
917 | 917 | return false; |
918 | - } else { |
|
918 | + } else { |
|
919 | 919 | $additional_query = " AND (tracker_archive_output.ident = :ident)"; |
920 | 920 | $query_values = array(':ident' => $ident); |
921 | - } |
|
921 | + } |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | if ($limit != "") |
925 | 925 | { |
926 | - $limit_array = explode(",", $limit); |
|
926 | + $limit_array = explode(",", $limit); |
|
927 | 927 | |
928 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
929 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
928 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
929 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
930 | 930 | |
931 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
932 | - { |
|
931 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
932 | + { |
|
933 | 933 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
934 | 934 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
935 | - } |
|
935 | + } |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | if ($sort != "") |
939 | 939 | { |
940 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
941 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
940 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
941 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
942 | 942 | } else { |
943 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
943 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | $query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -948,17 +948,17 @@ discard block |
||
948 | 948 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
949 | 949 | |
950 | 950 | return $spotter_array; |
951 | - } |
|
951 | + } |
|
952 | 952 | |
953 | 953 | |
954 | - /** |
|
955 | - * Gets all the spotter information based on the owner |
|
956 | - * |
|
957 | - * @return Array the spotter information |
|
958 | - * |
|
959 | - */ |
|
960 | - public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
961 | - { |
|
954 | + /** |
|
955 | + * Gets all the spotter information based on the owner |
|
956 | + * |
|
957 | + * @return Array the spotter information |
|
958 | + * |
|
959 | + */ |
|
960 | + public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
961 | + { |
|
962 | 962 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
963 | 963 | |
964 | 964 | date_default_timezone_set('UTC'); |
@@ -971,35 +971,35 @@ discard block |
||
971 | 971 | |
972 | 972 | if ($owner != "") |
973 | 973 | { |
974 | - if (!is_string($owner)) |
|
975 | - { |
|
974 | + if (!is_string($owner)) |
|
975 | + { |
|
976 | 976 | return false; |
977 | - } else { |
|
977 | + } else { |
|
978 | 978 | $additional_query = " AND (tracker_archive_output.owner_name = :owner)"; |
979 | 979 | $query_values = array(':owner' => $owner); |
980 | - } |
|
980 | + } |
|
981 | 981 | } |
982 | 982 | |
983 | 983 | if ($limit != "") |
984 | 984 | { |
985 | - $limit_array = explode(",", $limit); |
|
985 | + $limit_array = explode(",", $limit); |
|
986 | 986 | |
987 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
988 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
987 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
988 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
989 | 989 | |
990 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
991 | - { |
|
990 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
991 | + { |
|
992 | 992 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
993 | 993 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
994 | - } |
|
994 | + } |
|
995 | 995 | } |
996 | 996 | |
997 | 997 | if ($sort != "") |
998 | 998 | { |
999 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
1000 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
999 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
1000 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1001 | 1001 | } else { |
1002 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1002 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | $query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1007,16 +1007,16 @@ discard block |
||
1007 | 1007 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
1008 | 1008 | |
1009 | 1009 | return $spotter_array; |
1010 | - } |
|
1011 | - |
|
1012 | - /** |
|
1013 | - * Gets all the spotter information based on the pilot |
|
1014 | - * |
|
1015 | - * @return Array the spotter information |
|
1016 | - * |
|
1017 | - */ |
|
1018 | - public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1019 | - { |
|
1010 | + } |
|
1011 | + |
|
1012 | + /** |
|
1013 | + * Gets all the spotter information based on the pilot |
|
1014 | + * |
|
1015 | + * @return Array the spotter information |
|
1016 | + * |
|
1017 | + */ |
|
1018 | + public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1019 | + { |
|
1020 | 1020 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
1021 | 1021 | |
1022 | 1022 | date_default_timezone_set('UTC'); |
@@ -1035,24 +1035,24 @@ discard block |
||
1035 | 1035 | |
1036 | 1036 | if ($limit != "") |
1037 | 1037 | { |
1038 | - $limit_array = explode(",", $limit); |
|
1038 | + $limit_array = explode(",", $limit); |
|
1039 | 1039 | |
1040 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1040 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1042 | 1042 | |
1043 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1044 | - { |
|
1043 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1044 | + { |
|
1045 | 1045 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1046 | 1046 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1047 | - } |
|
1047 | + } |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | if ($sort != "") |
1051 | 1051 | { |
1052 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
1053 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1052 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
1053 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1054 | 1054 | } else { |
1055 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1055 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | $query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1060,16 +1060,16 @@ discard block |
||
1060 | 1060 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
1061 | 1061 | |
1062 | 1062 | return $spotter_array; |
1063 | - } |
|
1064 | - |
|
1065 | - /** |
|
1066 | - * Gets all number of flight over countries |
|
1067 | - * |
|
1068 | - * @return Array the airline country list |
|
1069 | - * |
|
1070 | - */ |
|
1071 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1072 | - { |
|
1063 | + } |
|
1064 | + |
|
1065 | + /** |
|
1066 | + * Gets all number of flight over countries |
|
1067 | + * |
|
1068 | + * @return Array the airline country list |
|
1069 | + * |
|
1070 | + */ |
|
1071 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1072 | + { |
|
1073 | 1073 | global $globalDBdriver; |
1074 | 1074 | /* |
1075 | 1075 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1079,14 +1079,14 @@ discard block |
||
1079 | 1079 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1080 | 1080 | FROM countries c, tracker_archive s |
1081 | 1081 | WHERE c.iso2 = s.over_country "; |
1082 | - if ($olderthanmonths > 0) { |
|
1083 | - if ($globalDBdriver == 'mysql') { |
|
1082 | + if ($olderthanmonths > 0) { |
|
1083 | + if ($globalDBdriver == 'mysql') { |
|
1084 | 1084 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1085 | 1085 | } else { |
1086 | 1086 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1087 | 1087 | } |
1088 | 1088 | } |
1089 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1089 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1090 | 1090 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1091 | 1091 | if ($limit) $query .= " LIMIT 0,10"; |
1092 | 1092 | |
@@ -1099,23 +1099,23 @@ discard block |
||
1099 | 1099 | |
1100 | 1100 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1101 | 1101 | { |
1102 | - $temp_array['flight_count'] = $row['nb']; |
|
1103 | - $temp_array['flight_country'] = $row['name']; |
|
1104 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1105 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1106 | - $flight_array[] = $temp_array; |
|
1102 | + $temp_array['flight_count'] = $row['nb']; |
|
1103 | + $temp_array['flight_country'] = $row['name']; |
|
1104 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1105 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1106 | + $flight_array[] = $temp_array; |
|
1107 | 1107 | } |
1108 | 1108 | return $flight_array; |
1109 | - } |
|
1110 | - |
|
1111 | - /** |
|
1112 | - * Gets all number of flight over countries |
|
1113 | - * |
|
1114 | - * @return Array the airline country list |
|
1115 | - * |
|
1116 | - */ |
|
1117 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1118 | - { |
|
1109 | + } |
|
1110 | + |
|
1111 | + /** |
|
1112 | + * Gets all number of flight over countries |
|
1113 | + * |
|
1114 | + * @return Array the airline country list |
|
1115 | + * |
|
1116 | + */ |
|
1117 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1118 | + { |
|
1119 | 1119 | global $globalDBdriver; |
1120 | 1120 | /* |
1121 | 1121 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1125,14 +1125,14 @@ discard block |
||
1125 | 1125 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1126 | 1126 | FROM countries c, tracker_archive s, spotter_output o |
1127 | 1127 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.famtrackid = s.famtrackid "; |
1128 | - if ($olderthanmonths > 0) { |
|
1129 | - if ($globalDBdriver == 'mysql') { |
|
1128 | + if ($olderthanmonths > 0) { |
|
1129 | + if ($globalDBdriver == 'mysql') { |
|
1130 | 1130 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1131 | 1131 | } else { |
1132 | 1132 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1133 | 1133 | } |
1134 | 1134 | } |
1135 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1135 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1136 | 1136 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1137 | 1137 | if ($limit) $query .= " LIMIT 0,10"; |
1138 | 1138 | |
@@ -1145,24 +1145,24 @@ discard block |
||
1145 | 1145 | |
1146 | 1146 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1147 | 1147 | { |
1148 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1149 | - $temp_array['flight_count'] = $row['nb']; |
|
1150 | - $temp_array['flight_country'] = $row['name']; |
|
1151 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1152 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1153 | - $flight_array[] = $temp_array; |
|
1148 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1149 | + $temp_array['flight_count'] = $row['nb']; |
|
1150 | + $temp_array['flight_country'] = $row['name']; |
|
1151 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1152 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1153 | + $flight_array[] = $temp_array; |
|
1154 | 1154 | } |
1155 | 1155 | return $flight_array; |
1156 | - } |
|
1157 | - |
|
1158 | - /** |
|
1159 | - * Gets last spotter information based on a particular callsign |
|
1160 | - * |
|
1161 | - * @return Array the spotter information |
|
1162 | - * |
|
1163 | - */ |
|
1164 | - public function getDateArchiveTrackerDataById($id,$date) |
|
1165 | - { |
|
1156 | + } |
|
1157 | + |
|
1158 | + /** |
|
1159 | + * Gets last spotter information based on a particular callsign |
|
1160 | + * |
|
1161 | + * @return Array the spotter information |
|
1162 | + * |
|
1163 | + */ |
|
1164 | + public function getDateArchiveTrackerDataById($id,$date) |
|
1165 | + { |
|
1166 | 1166 | $Tracker = new Tracker($this->db); |
1167 | 1167 | date_default_timezone_set('UTC'); |
1168 | 1168 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1170,16 +1170,16 @@ discard block |
||
1170 | 1170 | $date = date('c',$date); |
1171 | 1171 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1172 | 1172 | return $spotter_array; |
1173 | - } |
|
1174 | - |
|
1175 | - /** |
|
1176 | - * Gets all the spotter information based on a particular callsign |
|
1177 | - * |
|
1178 | - * @return Array the spotter information |
|
1179 | - * |
|
1180 | - */ |
|
1181 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
1182 | - { |
|
1173 | + } |
|
1174 | + |
|
1175 | + /** |
|
1176 | + * Gets all the spotter information based on a particular callsign |
|
1177 | + * |
|
1178 | + * @return Array the spotter information |
|
1179 | + * |
|
1180 | + */ |
|
1181 | + public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
1182 | + { |
|
1183 | 1183 | $Tracker = new Tracker($this->db); |
1184 | 1184 | date_default_timezone_set('UTC'); |
1185 | 1185 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1187,16 +1187,16 @@ discard block |
||
1187 | 1187 | $date = date('c',$date); |
1188 | 1188 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1189 | 1189 | return $spotter_array; |
1190 | - } |
|
1191 | - |
|
1192 | - /** |
|
1193 | - * Gets all the spotter information based on the airport |
|
1194 | - * |
|
1195 | - * @return Array the spotter information |
|
1196 | - * |
|
1197 | - */ |
|
1198 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1199 | - { |
|
1190 | + } |
|
1191 | + |
|
1192 | + /** |
|
1193 | + * Gets all the spotter information based on the airport |
|
1194 | + * |
|
1195 | + * @return Array the spotter information |
|
1196 | + * |
|
1197 | + */ |
|
1198 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1199 | + { |
|
1200 | 1200 | global $global_query; |
1201 | 1201 | $Tracker = new Tracker($this->db); |
1202 | 1202 | date_default_timezone_set('UTC'); |
@@ -1207,35 +1207,35 @@ discard block |
||
1207 | 1207 | |
1208 | 1208 | if ($airport != "") |
1209 | 1209 | { |
1210 | - if (!is_string($airport)) |
|
1211 | - { |
|
1210 | + if (!is_string($airport)) |
|
1211 | + { |
|
1212 | 1212 | return false; |
1213 | - } else { |
|
1213 | + } else { |
|
1214 | 1214 | $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))"; |
1215 | 1215 | $query_values = array(':airport' => $airport); |
1216 | - } |
|
1216 | + } |
|
1217 | 1217 | } |
1218 | 1218 | |
1219 | 1219 | if ($limit != "") |
1220 | 1220 | { |
1221 | - $limit_array = explode(",", $limit); |
|
1221 | + $limit_array = explode(",", $limit); |
|
1222 | 1222 | |
1223 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1224 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1223 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1224 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1225 | 1225 | |
1226 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1227 | - { |
|
1226 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1227 | + { |
|
1228 | 1228 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1229 | 1229 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1230 | - } |
|
1230 | + } |
|
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | if ($sort != "") |
1234 | 1234 | { |
1235 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
1236 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1235 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
1236 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1237 | 1237 | } else { |
1238 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1238 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1239 | 1239 | } |
1240 | 1240 | |
1241 | 1241 | $query = $global_query.$filter_query." tracker_archive_output.ident <> '' ".$additional_query." AND ((tracker_archive_output.departure_airport_icao <> 'NA') AND (tracker_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1243,6 +1243,6 @@ discard block |
||
1243 | 1243 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
1244 | 1244 | |
1245 | 1245 | return $spotter_array; |
1246 | - } |
|
1246 | + } |
|
1247 | 1247 | } |
1248 | 1248 | ?> |
1249 | 1249 | \ No newline at end of file |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
13 | - * Get SQL query part for filter used |
|
14 | - * @param Array $filter the filter |
|
15 | - * @return Array the SQL part |
|
16 | - */ |
|
13 | + * Get SQL query part for filter used |
|
14 | + * @param Array $filter the filter |
|
15 | + * @return Array the SQL part |
|
16 | + */ |
|
17 | 17 | public function getFilter($filter = array(),$where = false,$and = false) { |
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
@@ -110,44 +110,44 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | |
113 | - /** |
|
114 | - * Gets all the spotter information based on a particular callsign |
|
115 | - * |
|
116 | - * @return Array the spotter information |
|
117 | - * |
|
118 | - */ |
|
119 | - public function getLastArchiveMarineDataByIdent($ident) |
|
120 | - { |
|
113 | + /** |
|
114 | + * Gets all the spotter information based on a particular callsign |
|
115 | + * |
|
116 | + * @return Array the spotter information |
|
117 | + * |
|
118 | + */ |
|
119 | + public function getLastArchiveMarineDataByIdent($ident) |
|
120 | + { |
|
121 | 121 | $Marine = new Marine($this->db); |
122 | - date_default_timezone_set('UTC'); |
|
122 | + date_default_timezone_set('UTC'); |
|
123 | 123 | |
124 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
125 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
126 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
124 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
125 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
126 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
127 | 127 | |
128 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
128 | + $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
129 | 129 | |
130 | - return $spotter_array; |
|
131 | - } |
|
130 | + return $spotter_array; |
|
131 | + } |
|
132 | 132 | |
133 | 133 | |
134 | - /** |
|
135 | - * Gets last the spotter information based on a particular id |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
140 | - public function getLastArchiveMarineDataById($id) |
|
141 | - { |
|
142 | - $Marine = new Marine($this->db); |
|
143 | - date_default_timezone_set('UTC'); |
|
144 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
145 | - //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
146 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
147 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
134 | + /** |
|
135 | + * Gets last the spotter information based on a particular id |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | + public function getLastArchiveMarineDataById($id) |
|
141 | + { |
|
142 | + $Marine = new Marine($this->db); |
|
143 | + date_default_timezone_set('UTC'); |
|
144 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
145 | + //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
146 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
147 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
148 | 148 | |
149 | 149 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
150 | - /* |
|
150 | + /* |
|
151 | 151 | try { |
152 | 152 | $Connection = new Connection(); |
153 | 153 | $sth = Connection->$db->prepare($query); |
@@ -157,178 +157,178 @@ discard block |
||
157 | 157 | } |
158 | 158 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
159 | 159 | */ |
160 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
161 | - |
|
162 | - return $spotter_array; |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Gets all the spotter information based on a particular id |
|
167 | - * |
|
168 | - * @return Array the spotter information |
|
169 | - * |
|
170 | - */ |
|
171 | - public function getAllArchiveMarineDataById($id) |
|
160 | + $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
161 | + |
|
162 | + return $spotter_array; |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Gets all the spotter information based on a particular id |
|
167 | + * |
|
168 | + * @return Array the spotter information |
|
169 | + * |
|
170 | + */ |
|
171 | + public function getAllArchiveMarineDataById($id) |
|
172 | 172 | { |
173 | - date_default_timezone_set('UTC'); |
|
174 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
175 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
173 | + date_default_timezone_set('UTC'); |
|
174 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
175 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
176 | 176 | |
177 | 177 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
178 | 178 | |
179 | - try { |
|
180 | - $sth = $this->db->prepare($query); |
|
181 | - $sth->execute(array(':id' => $id)); |
|
182 | - } catch(PDOException $e) { |
|
183 | - echo $e->getMessage(); |
|
184 | - die; |
|
185 | - } |
|
186 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
187 | - |
|
188 | - return $spotter_array; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Gets coordinate & time spotter information based on a particular id |
|
193 | - * |
|
194 | - * @return Array the spotter information |
|
195 | - * |
|
196 | - */ |
|
197 | - public function getCoordArchiveMarineDataById($id) |
|
198 | - { |
|
199 | - date_default_timezone_set('UTC'); |
|
200 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
201 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
179 | + try { |
|
180 | + $sth = $this->db->prepare($query); |
|
181 | + $sth->execute(array(':id' => $id)); |
|
182 | + } catch(PDOException $e) { |
|
183 | + echo $e->getMessage(); |
|
184 | + die; |
|
185 | + } |
|
186 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
187 | + |
|
188 | + return $spotter_array; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Gets coordinate & time spotter information based on a particular id |
|
193 | + * |
|
194 | + * @return Array the spotter information |
|
195 | + * |
|
196 | + */ |
|
197 | + public function getCoordArchiveMarineDataById($id) |
|
198 | + { |
|
199 | + date_default_timezone_set('UTC'); |
|
200 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
201 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
202 | 202 | |
203 | 203 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
204 | 204 | |
205 | - try { |
|
206 | - $sth = $this->db->prepare($query); |
|
207 | - $sth->execute(array(':id' => $id)); |
|
208 | - } catch(PDOException $e) { |
|
209 | - echo $e->getMessage(); |
|
210 | - die; |
|
211 | - } |
|
212 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
205 | + try { |
|
206 | + $sth = $this->db->prepare($query); |
|
207 | + $sth->execute(array(':id' => $id)); |
|
208 | + } catch(PDOException $e) { |
|
209 | + echo $e->getMessage(); |
|
210 | + die; |
|
211 | + } |
|
212 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
213 | 213 | |
214 | - return $spotter_array; |
|
215 | - } |
|
214 | + return $spotter_array; |
|
215 | + } |
|
216 | 216 | |
217 | 217 | |
218 | - /** |
|
219 | - * Gets altitude information based on a particular callsign |
|
220 | - * |
|
221 | - * @return Array the spotter information |
|
222 | - * |
|
223 | - */ |
|
224 | - public function getAltitudeArchiveMarineDataByIdent($ident) |
|
225 | - { |
|
218 | + /** |
|
219 | + * Gets altitude information based on a particular callsign |
|
220 | + * |
|
221 | + * @return Array the spotter information |
|
222 | + * |
|
223 | + */ |
|
224 | + public function getAltitudeArchiveMarineDataByIdent($ident) |
|
225 | + { |
|
226 | 226 | |
227 | - date_default_timezone_set('UTC'); |
|
227 | + date_default_timezone_set('UTC'); |
|
228 | 228 | |
229 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
230 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
229 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
230 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
231 | 231 | |
232 | - try { |
|
233 | - $sth = $this->db->prepare($query); |
|
234 | - $sth->execute(array(':ident' => $ident)); |
|
235 | - } catch(PDOException $e) { |
|
236 | - echo $e->getMessage(); |
|
237 | - die; |
|
238 | - } |
|
239 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
232 | + try { |
|
233 | + $sth = $this->db->prepare($query); |
|
234 | + $sth->execute(array(':ident' => $ident)); |
|
235 | + } catch(PDOException $e) { |
|
236 | + echo $e->getMessage(); |
|
237 | + die; |
|
238 | + } |
|
239 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
240 | 240 | |
241 | - return $spotter_array; |
|
242 | - } |
|
241 | + return $spotter_array; |
|
242 | + } |
|
243 | 243 | |
244 | - /** |
|
245 | - * Gets altitude information based on a particular id |
|
246 | - * |
|
247 | - * @return Array the spotter information |
|
248 | - * |
|
249 | - */ |
|
250 | - public function getAltitudeArchiveMarineDataById($id) |
|
251 | - { |
|
244 | + /** |
|
245 | + * Gets altitude information based on a particular id |
|
246 | + * |
|
247 | + * @return Array the spotter information |
|
248 | + * |
|
249 | + */ |
|
250 | + public function getAltitudeArchiveMarineDataById($id) |
|
251 | + { |
|
252 | 252 | |
253 | - date_default_timezone_set('UTC'); |
|
253 | + date_default_timezone_set('UTC'); |
|
254 | 254 | |
255 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
256 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
255 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
256 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
257 | 257 | |
258 | - try { |
|
259 | - $sth = $this->db->prepare($query); |
|
260 | - $sth->execute(array(':id' => $id)); |
|
261 | - } catch(PDOException $e) { |
|
262 | - echo $e->getMessage(); |
|
263 | - die; |
|
264 | - } |
|
265 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
258 | + try { |
|
259 | + $sth = $this->db->prepare($query); |
|
260 | + $sth->execute(array(':id' => $id)); |
|
261 | + } catch(PDOException $e) { |
|
262 | + echo $e->getMessage(); |
|
263 | + die; |
|
264 | + } |
|
265 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
266 | 266 | |
267 | - return $spotter_array; |
|
268 | - } |
|
267 | + return $spotter_array; |
|
268 | + } |
|
269 | 269 | |
270 | - /** |
|
271 | - * Gets altitude & speed information based on a particular id |
|
272 | - * |
|
273 | - * @return Array the spotter information |
|
274 | - * |
|
275 | - */ |
|
276 | - public function getAltitudeSpeedArchiveMarineDataById($id) |
|
277 | - { |
|
270 | + /** |
|
271 | + * Gets altitude & speed information based on a particular id |
|
272 | + * |
|
273 | + * @return Array the spotter information |
|
274 | + * |
|
275 | + */ |
|
276 | + public function getAltitudeSpeedArchiveMarineDataById($id) |
|
277 | + { |
|
278 | 278 | |
279 | - date_default_timezone_set('UTC'); |
|
279 | + date_default_timezone_set('UTC'); |
|
280 | 280 | |
281 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
282 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
281 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
282 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
283 | 283 | |
284 | - try { |
|
285 | - $sth = $this->db->prepare($query); |
|
286 | - $sth->execute(array(':id' => $id)); |
|
287 | - } catch(PDOException $e) { |
|
288 | - echo $e->getMessage(); |
|
289 | - die; |
|
290 | - } |
|
291 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
284 | + try { |
|
285 | + $sth = $this->db->prepare($query); |
|
286 | + $sth->execute(array(':id' => $id)); |
|
287 | + } catch(PDOException $e) { |
|
288 | + echo $e->getMessage(); |
|
289 | + die; |
|
290 | + } |
|
291 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
292 | 292 | |
293 | - return $spotter_array; |
|
294 | - } |
|
293 | + return $spotter_array; |
|
294 | + } |
|
295 | 295 | |
296 | 296 | |
297 | - /** |
|
298 | - * Gets altitude information based on a particular callsign |
|
299 | - * |
|
300 | - * @return Array the spotter information |
|
301 | - * |
|
302 | - */ |
|
303 | - public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
304 | - { |
|
297 | + /** |
|
298 | + * Gets altitude information based on a particular callsign |
|
299 | + * |
|
300 | + * @return Array the spotter information |
|
301 | + * |
|
302 | + */ |
|
303 | + public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
304 | + { |
|
305 | 305 | |
306 | - date_default_timezone_set('UTC'); |
|
306 | + date_default_timezone_set('UTC'); |
|
307 | 307 | |
308 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
309 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
308 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
309 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
310 | 310 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
311 | 311 | |
312 | - try { |
|
313 | - $sth = $this->db->prepare($query); |
|
314 | - $sth->execute(array(':ident' => $ident)); |
|
315 | - } catch(PDOException $e) { |
|
316 | - echo $e->getMessage(); |
|
317 | - die; |
|
318 | - } |
|
319 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
312 | + try { |
|
313 | + $sth = $this->db->prepare($query); |
|
314 | + $sth->execute(array(':ident' => $ident)); |
|
315 | + } catch(PDOException $e) { |
|
316 | + echo $e->getMessage(); |
|
317 | + die; |
|
318 | + } |
|
319 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
320 | 320 | |
321 | - return $spotter_array; |
|
322 | - } |
|
321 | + return $spotter_array; |
|
322 | + } |
|
323 | 323 | |
324 | 324 | |
325 | 325 | |
326 | - /** |
|
327 | - * Gets all the archive spotter information |
|
328 | - * |
|
329 | - * @return Array the spotter information |
|
330 | - * |
|
331 | - */ |
|
326 | + /** |
|
327 | + * Gets all the archive spotter information |
|
328 | + * |
|
329 | + * @return Array the spotter information |
|
330 | + * |
|
331 | + */ |
|
332 | 332 | public function getMarineArchiveData($ident,$fammarine_id,$date) |
333 | 333 | { |
334 | 334 | $Marine = new Marine($this->db); |
@@ -338,10 +338,10 @@ discard block |
||
338 | 338 | return $spotter_array; |
339 | 339 | } |
340 | 340 | |
341 | - /** |
|
342 | - * Delete all tracking data |
|
343 | - * |
|
344 | - */ |
|
341 | + /** |
|
342 | + * Delete all tracking data |
|
343 | + * |
|
344 | + */ |
|
345 | 345 | public function deleteMarineArchiveTrackData() |
346 | 346 | { |
347 | 347 | global $globalArchiveKeepTrackMonths, $globalDBdriver; |
@@ -360,34 +360,34 @@ discard block |
||
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
363 | - * Gets Minimal Live Marine data |
|
364 | - * |
|
365 | - * @return Array the spotter information |
|
366 | - * |
|
367 | - */ |
|
368 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
369 | - { |
|
370 | - global $globalDBdriver, $globalLiveInterval; |
|
371 | - date_default_timezone_set('UTC'); |
|
372 | - |
|
373 | - $filter_query = ''; |
|
374 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
375 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
376 | - } |
|
377 | - // Use spotter_output also ? |
|
378 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
379 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
380 | - } |
|
381 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
382 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
383 | - } |
|
384 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
385 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
386 | - } |
|
363 | + * Gets Minimal Live Marine data |
|
364 | + * |
|
365 | + * @return Array the spotter information |
|
366 | + * |
|
367 | + */ |
|
368 | + public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
369 | + { |
|
370 | + global $globalDBdriver, $globalLiveInterval; |
|
371 | + date_default_timezone_set('UTC'); |
|
387 | 372 | |
388 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
389 | - if ($globalDBdriver == 'mysql') { |
|
390 | - /* |
|
373 | + $filter_query = ''; |
|
374 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
375 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
376 | + } |
|
377 | + // Use spotter_output also ? |
|
378 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
379 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
380 | + } |
|
381 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
382 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
383 | + } |
|
384 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
385 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
386 | + } |
|
387 | + |
|
388 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
389 | + if ($globalDBdriver == 'mysql') { |
|
390 | + /* |
|
391 | 391 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
392 | 392 | FROM marine_archive |
393 | 393 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
@@ -406,56 +406,56 @@ discard block |
||
406 | 406 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
407 | 407 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
408 | 408 | '.$filter_query.' ORDER BY fammarine_id'; |
409 | - } else { |
|
410 | - //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
411 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
409 | + } else { |
|
410 | + //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
411 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
412 | 412 | FROM marine_archive |
413 | 413 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
414 | 414 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
415 | 415 | '.$filter_query.' ORDER BY fammarine_id'; |
416 | - } |
|
417 | - //echo $query; |
|
418 | - try { |
|
419 | - $sth = $this->db->prepare($query); |
|
420 | - $sth->execute(); |
|
421 | - } catch(PDOException $e) { |
|
422 | - echo $e->getMessage(); |
|
423 | - die; |
|
424 | - } |
|
425 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
416 | + } |
|
417 | + //echo $query; |
|
418 | + try { |
|
419 | + $sth = $this->db->prepare($query); |
|
420 | + $sth->execute(); |
|
421 | + } catch(PDOException $e) { |
|
422 | + echo $e->getMessage(); |
|
423 | + die; |
|
424 | + } |
|
425 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
426 | 426 | |
427 | - return $spotter_array; |
|
428 | - } |
|
427 | + return $spotter_array; |
|
428 | + } |
|
429 | 429 | |
430 | 430 | /** |
431 | - * Gets Minimal Live Marine data |
|
432 | - * |
|
433 | - * @return Array the spotter information |
|
434 | - * |
|
435 | - */ |
|
436 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
437 | - { |
|
438 | - global $globalDBdriver, $globalLiveInterval; |
|
439 | - date_default_timezone_set('UTC'); |
|
440 | - |
|
441 | - $filter_query = ''; |
|
442 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
443 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
444 | - } |
|
445 | - // Should use spotter_output also ? |
|
446 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
447 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
448 | - } |
|
449 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
450 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
451 | - } |
|
452 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
453 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
454 | - } |
|
431 | + * Gets Minimal Live Marine data |
|
432 | + * |
|
433 | + * @return Array the spotter information |
|
434 | + * |
|
435 | + */ |
|
436 | + public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
437 | + { |
|
438 | + global $globalDBdriver, $globalLiveInterval; |
|
439 | + date_default_timezone_set('UTC'); |
|
455 | 440 | |
456 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
457 | - if ($globalDBdriver == 'mysql') { |
|
458 | - /* |
|
441 | + $filter_query = ''; |
|
442 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
443 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
444 | + } |
|
445 | + // Should use spotter_output also ? |
|
446 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
447 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
448 | + } |
|
449 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
450 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
451 | + } |
|
452 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
453 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
454 | + } |
|
455 | + |
|
456 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
457 | + if ($globalDBdriver == 'mysql') { |
|
458 | + /* |
|
459 | 459 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
460 | 460 | FROM marine_archive |
461 | 461 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
@@ -466,95 +466,95 @@ discard block |
||
466 | 466 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
467 | 467 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
468 | 468 | |
469 | - } else { |
|
470 | - //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
471 | - /* |
|
469 | + } else { |
|
470 | + //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
471 | + /* |
|
472 | 472 | $query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
473 | 473 | FROM marine_archive_output |
474 | 474 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
475 | 475 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
476 | 476 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
477 | 477 | */ |
478 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
478 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
479 | 479 | FROM marine_archive_output |
480 | 480 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
481 | 481 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
482 | 482 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
483 | 483 | // .' GROUP BY spotter_output.fammarine_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'; |
484 | 484 | |
485 | - } |
|
486 | - //echo $query; |
|
487 | - try { |
|
488 | - $sth = $this->db->prepare($query); |
|
489 | - $sth->execute(); |
|
490 | - } catch(PDOException $e) { |
|
491 | - echo $e->getMessage(); |
|
492 | - die; |
|
493 | - } |
|
494 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
485 | + } |
|
486 | + //echo $query; |
|
487 | + try { |
|
488 | + $sth = $this->db->prepare($query); |
|
489 | + $sth->execute(); |
|
490 | + } catch(PDOException $e) { |
|
491 | + echo $e->getMessage(); |
|
492 | + die; |
|
493 | + } |
|
494 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
495 | 495 | |
496 | - return $spotter_array; |
|
497 | - } |
|
496 | + return $spotter_array; |
|
497 | + } |
|
498 | 498 | |
499 | 499 | /** |
500 | - * Gets count Live Marine data |
|
501 | - * |
|
502 | - * @return Array the spotter information |
|
503 | - * |
|
504 | - */ |
|
505 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
506 | - { |
|
507 | - global $globalDBdriver, $globalLiveInterval; |
|
508 | - date_default_timezone_set('UTC'); |
|
509 | - |
|
510 | - $filter_query = ''; |
|
511 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
512 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
513 | - } |
|
514 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
515 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
516 | - } |
|
517 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
518 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
519 | - } |
|
520 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
521 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
522 | - } |
|
500 | + * Gets count Live Marine data |
|
501 | + * |
|
502 | + * @return Array the spotter information |
|
503 | + * |
|
504 | + */ |
|
505 | + public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
506 | + { |
|
507 | + global $globalDBdriver, $globalLiveInterval; |
|
508 | + date_default_timezone_set('UTC'); |
|
523 | 509 | |
524 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
525 | - if ($globalDBdriver == 'mysql') { |
|
510 | + $filter_query = ''; |
|
511 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
512 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
513 | + } |
|
514 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
515 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
516 | + } |
|
517 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
518 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
519 | + } |
|
520 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
521 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
522 | + } |
|
523 | + |
|
524 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
525 | + if ($globalDBdriver == 'mysql') { |
|
526 | 526 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb |
527 | 527 | FROM marine_archive l |
528 | 528 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
529 | - } else { |
|
529 | + } else { |
|
530 | 530 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
531 | - } |
|
532 | - //echo $query; |
|
533 | - try { |
|
534 | - $sth = $this->db->prepare($query); |
|
535 | - $sth->execute(); |
|
536 | - } catch(PDOException $e) { |
|
537 | - echo $e->getMessage(); |
|
538 | - die; |
|
539 | - } |
|
531 | + } |
|
532 | + //echo $query; |
|
533 | + try { |
|
534 | + $sth = $this->db->prepare($query); |
|
535 | + $sth->execute(); |
|
536 | + } catch(PDOException $e) { |
|
537 | + echo $e->getMessage(); |
|
538 | + die; |
|
539 | + } |
|
540 | 540 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
541 | 541 | $sth->closeCursor(); |
542 | - return $result['nb']; |
|
542 | + return $result['nb']; |
|
543 | 543 | |
544 | - } |
|
544 | + } |
|
545 | 545 | |
546 | 546 | |
547 | 547 | |
548 | 548 | // marine_archive_output |
549 | 549 | |
550 | - /** |
|
551 | - * Gets all the spotter information |
|
552 | - * |
|
553 | - * @return Array the spotter information |
|
554 | - * |
|
555 | - */ |
|
556 | - public function searchMarineData($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()) |
|
557 | - { |
|
550 | + /** |
|
551 | + * Gets all the spotter information |
|
552 | + * |
|
553 | + * @return Array the spotter information |
|
554 | + * |
|
555 | + */ |
|
556 | + public function searchMarineData($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()) |
|
557 | + { |
|
558 | 558 | global $globalTimezone, $globalDBdriver; |
559 | 559 | require_once(dirname(__FILE__).'/class.Translation.php'); |
560 | 560 | $Translation = new Translation($this->db); |
@@ -568,159 +568,159 @@ discard block |
||
568 | 568 | $filter_query = $this->getFilter($filters); |
569 | 569 | if ($q != "") |
570 | 570 | { |
571 | - if (!is_string($q)) |
|
572 | - { |
|
571 | + if (!is_string($q)) |
|
572 | + { |
|
573 | 573 | return false; |
574 | - } else { |
|
574 | + } else { |
|
575 | 575 | |
576 | 576 | $q_array = explode(" ", $q); |
577 | 577 | |
578 | 578 | foreach ($q_array as $q_item){ |
579 | - $additional_query .= " AND ("; |
|
580 | - $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
581 | - $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
582 | - $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
583 | - $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
584 | - $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
585 | - $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
586 | - $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
587 | - $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
588 | - $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
589 | - $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
590 | - $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
591 | - $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
592 | - $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
593 | - $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
594 | - $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
595 | - $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
596 | - $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
597 | - $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
598 | - $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
599 | - $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
600 | - $translate = $Translation->ident2icao($q_item); |
|
601 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
602 | - $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
603 | - $additional_query .= ")"; |
|
579 | + $additional_query .= " AND ("; |
|
580 | + $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
581 | + $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
582 | + $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
583 | + $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
584 | + $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
585 | + $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
586 | + $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
587 | + $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
588 | + $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
589 | + $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
590 | + $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
591 | + $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
592 | + $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
593 | + $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
594 | + $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
595 | + $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
596 | + $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
597 | + $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
598 | + $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
599 | + $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
600 | + $translate = $Translation->ident2icao($q_item); |
|
601 | + if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
602 | + $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
603 | + $additional_query .= ")"; |
|
604 | + } |
|
604 | 605 | } |
605 | - } |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | if ($registration != "") |
609 | 609 | { |
610 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
611 | - if (!is_string($registration)) |
|
612 | - { |
|
610 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
611 | + if (!is_string($registration)) |
|
612 | + { |
|
613 | 613 | return false; |
614 | - } else { |
|
614 | + } else { |
|
615 | 615 | $additional_query .= " AND (marine_archive_output.registration = '".$registration."')"; |
616 | - } |
|
616 | + } |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | if ($aircraft_icao != "") |
620 | 620 | { |
621 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
622 | - if (!is_string($aircraft_icao)) |
|
623 | - { |
|
621 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
622 | + if (!is_string($aircraft_icao)) |
|
623 | + { |
|
624 | 624 | return false; |
625 | - } else { |
|
625 | + } else { |
|
626 | 626 | $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
627 | - } |
|
627 | + } |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | if ($aircraft_manufacturer != "") |
631 | 631 | { |
632 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
633 | - if (!is_string($aircraft_manufacturer)) |
|
634 | - { |
|
632 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
633 | + if (!is_string($aircraft_manufacturer)) |
|
634 | + { |
|
635 | 635 | return false; |
636 | - } else { |
|
636 | + } else { |
|
637 | 637 | $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
638 | - } |
|
638 | + } |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | if ($highlights == "true") |
642 | 642 | { |
643 | - if (!is_string($highlights)) |
|
644 | - { |
|
643 | + if (!is_string($highlights)) |
|
644 | + { |
|
645 | 645 | return false; |
646 | - } else { |
|
646 | + } else { |
|
647 | 647 | $additional_query .= " AND (marine_archive_output.highlight <> '')"; |
648 | - } |
|
648 | + } |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | if ($airline_icao != "") |
652 | 652 | { |
653 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
654 | - if (!is_string($airline_icao)) |
|
655 | - { |
|
653 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
654 | + if (!is_string($airline_icao)) |
|
655 | + { |
|
656 | 656 | return false; |
657 | - } else { |
|
657 | + } else { |
|
658 | 658 | $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')"; |
659 | - } |
|
659 | + } |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | if ($airline_country != "") |
663 | 663 | { |
664 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
665 | - if (!is_string($airline_country)) |
|
666 | - { |
|
664 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
665 | + if (!is_string($airline_country)) |
|
666 | + { |
|
667 | 667 | return false; |
668 | - } else { |
|
668 | + } else { |
|
669 | 669 | $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')"; |
670 | - } |
|
670 | + } |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | if ($airline_type != "") |
674 | 674 | { |
675 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
676 | - if (!is_string($airline_type)) |
|
677 | - { |
|
675 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
676 | + if (!is_string($airline_type)) |
|
677 | + { |
|
678 | 678 | return false; |
679 | - } else { |
|
679 | + } else { |
|
680 | 680 | if ($airline_type == "passenger") |
681 | 681 | { |
682 | - $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
682 | + $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
683 | 683 | } |
684 | 684 | if ($airline_type == "cargo") |
685 | 685 | { |
686 | - $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
686 | + $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
687 | 687 | } |
688 | 688 | if ($airline_type == "military") |
689 | 689 | { |
690 | - $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
690 | + $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
691 | + } |
|
691 | 692 | } |
692 | - } |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | if ($airport != "") |
696 | 696 | { |
697 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
698 | - if (!is_string($airport)) |
|
699 | - { |
|
697 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
698 | + if (!is_string($airport)) |
|
699 | + { |
|
700 | 700 | return false; |
701 | - } else { |
|
701 | + } else { |
|
702 | 702 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))"; |
703 | - } |
|
703 | + } |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | if ($airport_country != "") |
707 | 707 | { |
708 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
709 | - if (!is_string($airport_country)) |
|
710 | - { |
|
708 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
709 | + if (!is_string($airport_country)) |
|
710 | + { |
|
711 | 711 | return false; |
712 | - } else { |
|
712 | + } else { |
|
713 | 713 | $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))"; |
714 | - } |
|
714 | + } |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | if ($callsign != "") |
718 | 718 | { |
719 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
720 | - if (!is_string($callsign)) |
|
721 | - { |
|
719 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
720 | + if (!is_string($callsign)) |
|
721 | + { |
|
722 | 722 | return false; |
723 | - } else { |
|
723 | + } else { |
|
724 | 724 | $translate = $Translation->ident2icao($callsign); |
725 | 725 | if ($translate != $callsign) { |
726 | 726 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
@@ -728,99 +728,99 @@ discard block |
||
728 | 728 | } else { |
729 | 729 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
730 | 730 | } |
731 | - } |
|
731 | + } |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | if ($owner != "") |
735 | 735 | { |
736 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
737 | - if (!is_string($owner)) |
|
738 | - { |
|
736 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
737 | + if (!is_string($owner)) |
|
738 | + { |
|
739 | 739 | return false; |
740 | - } else { |
|
740 | + } else { |
|
741 | 741 | $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')"; |
742 | - } |
|
742 | + } |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | if ($pilot_name != "") |
746 | 746 | { |
747 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
748 | - if (!is_string($pilot_name)) |
|
749 | - { |
|
747 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
748 | + if (!is_string($pilot_name)) |
|
749 | + { |
|
750 | 750 | return false; |
751 | - } else { |
|
751 | + } else { |
|
752 | 752 | $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')"; |
753 | - } |
|
753 | + } |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | if ($pilot_id != "") |
757 | 757 | { |
758 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
759 | - if (!is_string($pilot_id)) |
|
760 | - { |
|
758 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
759 | + if (!is_string($pilot_id)) |
|
760 | + { |
|
761 | 761 | return false; |
762 | - } else { |
|
762 | + } else { |
|
763 | 763 | $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')"; |
764 | - } |
|
764 | + } |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | if ($departure_airport_route != "") |
768 | 768 | { |
769 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
770 | - if (!is_string($departure_airport_route)) |
|
771 | - { |
|
769 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
770 | + if (!is_string($departure_airport_route)) |
|
771 | + { |
|
772 | 772 | return false; |
773 | - } else { |
|
773 | + } else { |
|
774 | 774 | $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
775 | - } |
|
775 | + } |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | if ($arrival_airport_route != "") |
779 | 779 | { |
780 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
781 | - if (!is_string($arrival_airport_route)) |
|
782 | - { |
|
780 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
781 | + if (!is_string($arrival_airport_route)) |
|
782 | + { |
|
783 | 783 | return false; |
784 | - } else { |
|
784 | + } else { |
|
785 | 785 | $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
786 | - } |
|
786 | + } |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | if ($altitude != "") |
790 | 790 | { |
791 | - $altitude_array = explode(",", $altitude); |
|
791 | + $altitude_array = explode(",", $altitude); |
|
792 | 792 | |
793 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
794 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
793 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
794 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
795 | 795 | |
796 | 796 | |
797 | - if ($altitude_array[1] != "") |
|
798 | - { |
|
797 | + if ($altitude_array[1] != "") |
|
798 | + { |
|
799 | 799 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
800 | 800 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
801 | 801 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
802 | - } else { |
|
802 | + } else { |
|
803 | 803 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
804 | 804 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
805 | - } |
|
805 | + } |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | if ($date_posted != "") |
809 | 809 | { |
810 | - $date_array = explode(",", $date_posted); |
|
810 | + $date_array = explode(",", $date_posted); |
|
811 | 811 | |
812 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
813 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
812 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
813 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
814 | 814 | |
815 | - if ($globalTimezone != '') { |
|
815 | + if ($globalTimezone != '') { |
|
816 | 816 | date_default_timezone_set($globalTimezone); |
817 | 817 | $datetime = new DateTime(); |
818 | 818 | $offset = $datetime->format('P'); |
819 | - } else $offset = '+00:00'; |
|
819 | + } else $offset = '+00:00'; |
|
820 | 820 | |
821 | 821 | |
822 | - if ($date_array[1] != "") |
|
823 | - { |
|
822 | + if ($date_array[1] != "") |
|
823 | + { |
|
824 | 824 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
825 | 825 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
826 | 826 | if ($globalDBdriver == 'mysql') { |
@@ -828,28 +828,28 @@ discard block |
||
828 | 828 | } else { |
829 | 829 | $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
830 | 830 | } |
831 | - } else { |
|
831 | + } else { |
|
832 | 832 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
833 | - if ($globalDBdriver == 'mysql') { |
|
833 | + if ($globalDBdriver == 'mysql') { |
|
834 | 834 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
835 | 835 | } else { |
836 | 836 | $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
837 | 837 | } |
838 | - } |
|
838 | + } |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | if ($limit != "") |
842 | 842 | { |
843 | - $limit_array = explode(",", $limit); |
|
843 | + $limit_array = explode(",", $limit); |
|
844 | 844 | |
845 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
846 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
845 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
846 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
847 | 847 | |
848 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
849 | - { |
|
848 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
849 | + { |
|
850 | 850 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
851 | 851 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
852 | - } |
|
852 | + } |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | |
@@ -880,33 +880,33 @@ discard block |
||
880 | 880 | $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
881 | 881 | |
882 | 882 | return $spotter_array; |
883 | - } |
|
883 | + } |
|
884 | 884 | |
885 | - public function deleteMarineArchiveData() |
|
886 | - { |
|
885 | + public function deleteMarineArchiveData() |
|
886 | + { |
|
887 | 887 | global $globalArchiveKeepMonths, $globalDBdriver; |
888 | - date_default_timezone_set('UTC'); |
|
889 | - if ($globalDBdriver == 'mysql') { |
|
888 | + date_default_timezone_set('UTC'); |
|
889 | + if ($globalDBdriver == 'mysql') { |
|
890 | 890 | $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
891 | 891 | } else { |
892 | 892 | $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
893 | 893 | } |
894 | - try { |
|
895 | - $sth = $this->db->prepare($query); |
|
896 | - $sth->execute(); |
|
897 | - } catch(PDOException $e) { |
|
898 | - return "error"; |
|
899 | - } |
|
894 | + try { |
|
895 | + $sth = $this->db->prepare($query); |
|
896 | + $sth->execute(); |
|
897 | + } catch(PDOException $e) { |
|
898 | + return "error"; |
|
899 | + } |
|
900 | 900 | } |
901 | 901 | |
902 | - /** |
|
903 | - * Gets all the spotter information based on the callsign |
|
904 | - * |
|
905 | - * @return Array the spotter information |
|
906 | - * |
|
907 | - */ |
|
908 | - public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
909 | - { |
|
902 | + /** |
|
903 | + * Gets all the spotter information based on the callsign |
|
904 | + * |
|
905 | + * @return Array the spotter information |
|
906 | + * |
|
907 | + */ |
|
908 | + public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
909 | + { |
|
910 | 910 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
911 | 911 | |
912 | 912 | date_default_timezone_set('UTC'); |
@@ -918,35 +918,35 @@ discard block |
||
918 | 918 | |
919 | 919 | if ($ident != "") |
920 | 920 | { |
921 | - if (!is_string($ident)) |
|
922 | - { |
|
921 | + if (!is_string($ident)) |
|
922 | + { |
|
923 | 923 | return false; |
924 | - } else { |
|
924 | + } else { |
|
925 | 925 | $additional_query = " AND (marine_archive_output.ident = :ident)"; |
926 | 926 | $query_values = array(':ident' => $ident); |
927 | - } |
|
927 | + } |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | if ($limit != "") |
931 | 931 | { |
932 | - $limit_array = explode(",", $limit); |
|
932 | + $limit_array = explode(",", $limit); |
|
933 | 933 | |
934 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
935 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
934 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
935 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
936 | 936 | |
937 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
938 | - { |
|
937 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
938 | + { |
|
939 | 939 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
940 | 940 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
941 | - } |
|
941 | + } |
|
942 | 942 | } |
943 | 943 | |
944 | 944 | if ($sort != "") |
945 | 945 | { |
946 | - $search_orderby_array = $Marine->getOrderBy(); |
|
947 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
946 | + $search_orderby_array = $Marine->getOrderBy(); |
|
947 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
948 | 948 | } else { |
949 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
949 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
950 | 950 | } |
951 | 951 | |
952 | 952 | $query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -954,17 +954,17 @@ discard block |
||
954 | 954 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
955 | 955 | |
956 | 956 | return $spotter_array; |
957 | - } |
|
957 | + } |
|
958 | 958 | |
959 | 959 | |
960 | - /** |
|
961 | - * Gets all the spotter information based on the owner |
|
962 | - * |
|
963 | - * @return Array the spotter information |
|
964 | - * |
|
965 | - */ |
|
966 | - public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
967 | - { |
|
960 | + /** |
|
961 | + * Gets all the spotter information based on the owner |
|
962 | + * |
|
963 | + * @return Array the spotter information |
|
964 | + * |
|
965 | + */ |
|
966 | + public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
967 | + { |
|
968 | 968 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
969 | 969 | |
970 | 970 | date_default_timezone_set('UTC'); |
@@ -977,35 +977,35 @@ discard block |
||
977 | 977 | |
978 | 978 | if ($owner != "") |
979 | 979 | { |
980 | - if (!is_string($owner)) |
|
981 | - { |
|
980 | + if (!is_string($owner)) |
|
981 | + { |
|
982 | 982 | return false; |
983 | - } else { |
|
983 | + } else { |
|
984 | 984 | $additional_query = " AND (marine_archive_output.owner_name = :owner)"; |
985 | 985 | $query_values = array(':owner' => $owner); |
986 | - } |
|
986 | + } |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | if ($limit != "") |
990 | 990 | { |
991 | - $limit_array = explode(",", $limit); |
|
991 | + $limit_array = explode(",", $limit); |
|
992 | 992 | |
993 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
994 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
993 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
994 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
995 | 995 | |
996 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
997 | - { |
|
996 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
997 | + { |
|
998 | 998 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
999 | 999 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1000 | - } |
|
1000 | + } |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | if ($sort != "") |
1004 | 1004 | { |
1005 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1006 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1005 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1006 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1007 | 1007 | } else { |
1008 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1008 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | $query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1013,16 +1013,16 @@ discard block |
||
1013 | 1013 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1014 | 1014 | |
1015 | 1015 | return $spotter_array; |
1016 | - } |
|
1017 | - |
|
1018 | - /** |
|
1019 | - * Gets all the spotter information based on the pilot |
|
1020 | - * |
|
1021 | - * @return Array the spotter information |
|
1022 | - * |
|
1023 | - */ |
|
1024 | - public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1025 | - { |
|
1016 | + } |
|
1017 | + |
|
1018 | + /** |
|
1019 | + * Gets all the spotter information based on the pilot |
|
1020 | + * |
|
1021 | + * @return Array the spotter information |
|
1022 | + * |
|
1023 | + */ |
|
1024 | + public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1025 | + { |
|
1026 | 1026 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
1027 | 1027 | |
1028 | 1028 | date_default_timezone_set('UTC'); |
@@ -1041,24 +1041,24 @@ discard block |
||
1041 | 1041 | |
1042 | 1042 | if ($limit != "") |
1043 | 1043 | { |
1044 | - $limit_array = explode(",", $limit); |
|
1044 | + $limit_array = explode(",", $limit); |
|
1045 | 1045 | |
1046 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1047 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1046 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1047 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1048 | 1048 | |
1049 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1050 | - { |
|
1049 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1050 | + { |
|
1051 | 1051 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1052 | 1052 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1053 | - } |
|
1053 | + } |
|
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | if ($sort != "") |
1057 | 1057 | { |
1058 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1059 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1058 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1059 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1060 | 1060 | } else { |
1061 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1061 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | $query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1066,16 +1066,16 @@ discard block |
||
1066 | 1066 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1067 | 1067 | |
1068 | 1068 | return $spotter_array; |
1069 | - } |
|
1070 | - |
|
1071 | - /** |
|
1072 | - * Gets all number of flight over countries |
|
1073 | - * |
|
1074 | - * @return Array the airline country list |
|
1075 | - * |
|
1076 | - */ |
|
1077 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1078 | - { |
|
1069 | + } |
|
1070 | + |
|
1071 | + /** |
|
1072 | + * Gets all number of flight over countries |
|
1073 | + * |
|
1074 | + * @return Array the airline country list |
|
1075 | + * |
|
1076 | + */ |
|
1077 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1078 | + { |
|
1079 | 1079 | global $globalDBdriver; |
1080 | 1080 | /* |
1081 | 1081 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1085,14 +1085,14 @@ discard block |
||
1085 | 1085 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1086 | 1086 | FROM countries c, marine_archive s |
1087 | 1087 | WHERE c.iso2 = s.over_country "; |
1088 | - if ($olderthanmonths > 0) { |
|
1089 | - if ($globalDBdriver == 'mysql') { |
|
1088 | + if ($olderthanmonths > 0) { |
|
1089 | + if ($globalDBdriver == 'mysql') { |
|
1090 | 1090 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1091 | 1091 | } else { |
1092 | 1092 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1093 | 1093 | } |
1094 | 1094 | } |
1095 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1095 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1096 | 1096 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1097 | 1097 | if ($limit) $query .= " LIMIT 0,10"; |
1098 | 1098 | |
@@ -1105,23 +1105,23 @@ discard block |
||
1105 | 1105 | |
1106 | 1106 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1107 | 1107 | { |
1108 | - $temp_array['flight_count'] = $row['nb']; |
|
1109 | - $temp_array['flight_country'] = $row['name']; |
|
1110 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1111 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1112 | - $flight_array[] = $temp_array; |
|
1108 | + $temp_array['flight_count'] = $row['nb']; |
|
1109 | + $temp_array['flight_country'] = $row['name']; |
|
1110 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1111 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1112 | + $flight_array[] = $temp_array; |
|
1113 | 1113 | } |
1114 | 1114 | return $flight_array; |
1115 | - } |
|
1116 | - |
|
1117 | - /** |
|
1118 | - * Gets all number of flight over countries |
|
1119 | - * |
|
1120 | - * @return Array the airline country list |
|
1121 | - * |
|
1122 | - */ |
|
1123 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1124 | - { |
|
1115 | + } |
|
1116 | + |
|
1117 | + /** |
|
1118 | + * Gets all number of flight over countries |
|
1119 | + * |
|
1120 | + * @return Array the airline country list |
|
1121 | + * |
|
1122 | + */ |
|
1123 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1124 | + { |
|
1125 | 1125 | global $globalDBdriver; |
1126 | 1126 | /* |
1127 | 1127 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1131,14 +1131,14 @@ discard block |
||
1131 | 1131 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1132 | 1132 | FROM countries c, marine_archive s, spotter_output o |
1133 | 1133 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id "; |
1134 | - if ($olderthanmonths > 0) { |
|
1135 | - if ($globalDBdriver == 'mysql') { |
|
1134 | + if ($olderthanmonths > 0) { |
|
1135 | + if ($globalDBdriver == 'mysql') { |
|
1136 | 1136 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1137 | 1137 | } else { |
1138 | 1138 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1139 | 1139 | } |
1140 | 1140 | } |
1141 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1141 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1142 | 1142 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1143 | 1143 | if ($limit) $query .= " LIMIT 0,10"; |
1144 | 1144 | |
@@ -1151,24 +1151,24 @@ discard block |
||
1151 | 1151 | |
1152 | 1152 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1153 | 1153 | { |
1154 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1155 | - $temp_array['flight_count'] = $row['nb']; |
|
1156 | - $temp_array['flight_country'] = $row['name']; |
|
1157 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1158 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1159 | - $flight_array[] = $temp_array; |
|
1154 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1155 | + $temp_array['flight_count'] = $row['nb']; |
|
1156 | + $temp_array['flight_country'] = $row['name']; |
|
1157 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1158 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1159 | + $flight_array[] = $temp_array; |
|
1160 | 1160 | } |
1161 | 1161 | return $flight_array; |
1162 | - } |
|
1163 | - |
|
1164 | - /** |
|
1165 | - * Gets last spotter information based on a particular callsign |
|
1166 | - * |
|
1167 | - * @return Array the spotter information |
|
1168 | - * |
|
1169 | - */ |
|
1170 | - public function getDateArchiveMarineDataById($id,$date) |
|
1171 | - { |
|
1162 | + } |
|
1163 | + |
|
1164 | + /** |
|
1165 | + * Gets last spotter information based on a particular callsign |
|
1166 | + * |
|
1167 | + * @return Array the spotter information |
|
1168 | + * |
|
1169 | + */ |
|
1170 | + public function getDateArchiveMarineDataById($id,$date) |
|
1171 | + { |
|
1172 | 1172 | $Marine = new Marine($this->db); |
1173 | 1173 | date_default_timezone_set('UTC'); |
1174 | 1174 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1176,16 +1176,16 @@ discard block |
||
1176 | 1176 | $date = date('c',$date); |
1177 | 1177 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1178 | 1178 | return $spotter_array; |
1179 | - } |
|
1180 | - |
|
1181 | - /** |
|
1182 | - * Gets all the spotter information based on a particular callsign |
|
1183 | - * |
|
1184 | - * @return Array the spotter information |
|
1185 | - * |
|
1186 | - */ |
|
1187 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1188 | - { |
|
1179 | + } |
|
1180 | + |
|
1181 | + /** |
|
1182 | + * Gets all the spotter information based on a particular callsign |
|
1183 | + * |
|
1184 | + * @return Array the spotter information |
|
1185 | + * |
|
1186 | + */ |
|
1187 | + public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1188 | + { |
|
1189 | 1189 | $Marine = new Marine($this->db); |
1190 | 1190 | date_default_timezone_set('UTC'); |
1191 | 1191 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1193,16 +1193,16 @@ discard block |
||
1193 | 1193 | $date = date('c',$date); |
1194 | 1194 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1195 | 1195 | return $spotter_array; |
1196 | - } |
|
1197 | - |
|
1198 | - /** |
|
1199 | - * Gets all the spotter information based on the airport |
|
1200 | - * |
|
1201 | - * @return Array the spotter information |
|
1202 | - * |
|
1203 | - */ |
|
1204 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1205 | - { |
|
1196 | + } |
|
1197 | + |
|
1198 | + /** |
|
1199 | + * Gets all the spotter information based on the airport |
|
1200 | + * |
|
1201 | + * @return Array the spotter information |
|
1202 | + * |
|
1203 | + */ |
|
1204 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1205 | + { |
|
1206 | 1206 | global $global_query; |
1207 | 1207 | $Marine = new Marine($this->db); |
1208 | 1208 | date_default_timezone_set('UTC'); |
@@ -1213,35 +1213,35 @@ discard block |
||
1213 | 1213 | |
1214 | 1214 | if ($airport != "") |
1215 | 1215 | { |
1216 | - if (!is_string($airport)) |
|
1217 | - { |
|
1216 | + if (!is_string($airport)) |
|
1217 | + { |
|
1218 | 1218 | return false; |
1219 | - } else { |
|
1219 | + } else { |
|
1220 | 1220 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))"; |
1221 | 1221 | $query_values = array(':airport' => $airport); |
1222 | - } |
|
1222 | + } |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | if ($limit != "") |
1226 | 1226 | { |
1227 | - $limit_array = explode(",", $limit); |
|
1227 | + $limit_array = explode(",", $limit); |
|
1228 | 1228 | |
1229 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1230 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1229 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1230 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1231 | 1231 | |
1232 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1233 | - { |
|
1232 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1233 | + { |
|
1234 | 1234 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1235 | 1235 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1236 | - } |
|
1236 | + } |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | if ($sort != "") |
1240 | 1240 | { |
1241 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1242 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1241 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1242 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1243 | 1243 | } else { |
1244 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1244 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | $query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1249,6 +1249,6 @@ discard block |
||
1249 | 1249 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1250 | 1250 | |
1251 | 1251 | return $spotter_array; |
1252 | - } |
|
1252 | + } |
|
1253 | 1253 | } |
1254 | 1254 | ?> |
1255 | 1255 | \ No newline at end of file |
@@ -554,8 +554,8 @@ discard block |
||
554 | 554 | } |
555 | 555 | } |
556 | 556 | <?php |
557 | - } else { |
|
558 | - ?> |
|
557 | + } else { |
|
558 | + ?> |
|
559 | 559 | if (map.getZoom() > 7) { |
560 | 560 | var style = { |
561 | 561 | "color": "#1a3151", |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | layer_tracker_data.addLayer(layer); |
575 | 575 | } |
576 | 576 | <?php |
577 | - } |
|
577 | + } |
|
578 | 578 | ?> |
579 | 579 | } |
580 | 580 | } |
@@ -599,11 +599,11 @@ discard block |
||
599 | 599 | $( document ).ready(function() { |
600 | 600 | map.on('moveend', function() { |
601 | 601 | <?php |
602 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
602 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
603 | 603 | ?> |
604 | 604 | getLiveTrackerData(1); |
605 | 605 | <?php |
606 | - } |
|
606 | + } |
|
607 | 607 | ?> |
608 | 608 | }); |
609 | 609 | //load the function on startup |
@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Stats.php'); |
10 | 10 | require_once(dirname(__FILE__).'/class.Source.php'); |
11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | class MarineImport { |
16 | - private $all_tracked = array(); |
|
17 | - private $last_delete_hourly = 0; |
|
18 | - private $last_delete = 0; |
|
19 | - private $stats = array(); |
|
20 | - private $tmd = 0; |
|
21 | - private $source_location = array(); |
|
22 | - public $db = null; |
|
23 | - public $nb = 0; |
|
16 | + private $all_tracked = array(); |
|
17 | + private $last_delete_hourly = 0; |
|
18 | + private $last_delete = 0; |
|
19 | + private $stats = array(); |
|
20 | + private $tmd = 0; |
|
21 | + private $source_location = array(); |
|
22 | + public $db = null; |
|
23 | + public $nb = 0; |
|
24 | 24 | |
25 | - public function __construct($dbc = null) { |
|
25 | + public function __construct($dbc = null) { |
|
26 | 26 | global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB; |
27 | 27 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
28 | - $Connection = new Connection($dbc); |
|
29 | - $this->db = $Connection->db(); |
|
30 | - date_default_timezone_set('UTC'); |
|
28 | + $Connection = new Connection($dbc); |
|
29 | + $this->db = $Connection->db(); |
|
30 | + date_default_timezone_set('UTC'); |
|
31 | 31 | } |
32 | 32 | // Get previous source stats |
33 | 33 | /* |
@@ -46,57 +46,57 @@ discard block |
||
46 | 46 | } |
47 | 47 | */ |
48 | 48 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
49 | - $APRSMarine = new APRSMarine(); |
|
50 | - //$APRSSpotter->connect(); |
|
49 | + $APRSMarine = new APRSMarine(); |
|
50 | + //$APRSSpotter->connect(); |
|
51 | + } |
|
51 | 52 | } |
52 | - } |
|
53 | 53 | |
54 | - public function checkAll() { |
|
54 | + public function checkAll() { |
|
55 | 55 | global $globalDebug, $globalNoDB; |
56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
58 | - foreach ($this->all_tracked as $key => $flight) { |
|
57 | + if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
58 | + foreach ($this->all_tracked as $key => $flight) { |
|
59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
60 | - //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
61 | - $Marine = new Marine($this->db); |
|
62 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
60 | + //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
61 | + $Marine = new Marine($this->db); |
|
62 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
63 | 63 | } |
64 | - } |
|
64 | + } |
|
65 | + } |
|
65 | 66 | } |
66 | - } |
|
67 | 67 | |
68 | - public function del() { |
|
68 | + public function del() { |
|
69 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 70 | // Delete old infos |
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | - if (isset($flight['lastupdate'])) { |
|
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
75 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
76 | - if (isset($this->all_tracked[$key]['id'])) { |
|
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
78 | - /* |
|
73 | + if (isset($flight['lastupdate'])) { |
|
74 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
75 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
76 | + if (isset($this->all_tracked[$key]['id'])) { |
|
77 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
78 | + /* |
|
79 | 79 | $MarineLive = new MarineLive(); |
80 | 80 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
81 | 81 | $MarineLive->db = null; |
82 | 82 | */ |
83 | - //$real_arrival = $this->arrival($key); |
|
84 | - $Marine = new Marine($this->db); |
|
85 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
83 | + //$real_arrival = $this->arrival($key); |
|
84 | + $Marine = new Marine($this->db); |
|
85 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
86 | 86 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
88 | - } |
|
89 | - // Put in archive |
|
88 | + } |
|
89 | + // Put in archive |
|
90 | 90 | // $Marine->db = null; |
91 | 91 | } |
92 | - } |
|
93 | - unset($this->all_tracked[$key]); |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
97 | - } |
|
92 | + } |
|
93 | + unset($this->all_tracked[$key]); |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | + } |
|
98 | 98 | |
99 | - public function add($line) { |
|
99 | + public function add($line) { |
|
100 | 100 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
@@ -105,83 +105,83 @@ discard block |
||
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | 107 | if(is_array($line) && isset($line['mmsi'])) { |
108 | - //print_r($line); |
|
109 | - if (isset($line['mmsi'])) { |
|
108 | + //print_r($line); |
|
109 | + if (isset($line['mmsi'])) { |
|
110 | 110 | |
111 | 111 | |
112 | 112 | // Increment message number |
113 | 113 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | - $current_date = date('Y-m-d'); |
|
115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | - else $source = ''; |
|
117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
118 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
119 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
120 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
114 | + $current_date = date('Y-m-d'); |
|
115 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | + else $source = ''; |
|
117 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
118 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
119 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
120 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
121 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | |
125 | 125 | $Common = new Common(); |
126 | 126 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
127 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | + else $id = trim($line['id']); |
|
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | - $this->all_tracked[$id] = array(); |
|
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
135 | - if (!isset($line['id'])) { |
|
131 | + $this->all_tracked[$id] = array(); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
135 | + if (!isset($line['id'])) { |
|
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
137 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
144 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
144 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
145 | 145 | $Marine = new Marine($this->db); |
146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
147 | 147 | if (!empty($identity)) { |
148 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
148 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
150 | 150 | } |
151 | 151 | //print_r($identity); |
152 | 152 | unset($Marine); |
153 | 153 | //$dataFound = true; |
154 | - } |
|
154 | + } |
|
155 | 155 | } |
156 | 156 | if (isset($line['type_id'])) { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | 158 | } |
159 | 159 | if (isset($line['type']) && $line['type'] != '') { |
160 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
160 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
161 | 161 | } |
162 | 162 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
164 | 164 | } |
165 | 165 | if (isset($line['imo']) && $line['imo'] != '') { |
166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
167 | 167 | } |
168 | 168 | if (isset($line['callsign']) && $line['callsign'] != '') { |
169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
170 | 170 | } |
171 | 171 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
172 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
172 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
173 | 173 | } |
174 | 174 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
175 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
175 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
179 | 179 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
180 | 180 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
181 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
182 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
181 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
182 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
183 | 183 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
184 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
184 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
185 | 185 | $timeelapsed = microtime(true); |
186 | 186 | $Marine = new Marine($this->db); |
187 | 187 | $fromsource = NULL; |
@@ -189,20 +189,20 @@ discard block |
||
189 | 189 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
190 | 190 | $Marine->db = null; |
191 | 191 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
192 | - } |
|
192 | + } |
|
193 | 193 | } |
194 | - } |
|
195 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
194 | + } |
|
195 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
199 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
199 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
200 | 200 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
201 | - } else { |
|
201 | + } else { |
|
202 | 202 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
203 | 203 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
204 | 204 | return ''; |
205 | - } |
|
205 | + } |
|
206 | 206 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
207 | 207 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
208 | 208 | return ''; |
@@ -219,24 +219,24 @@ discard block |
||
219 | 219 | |
220 | 220 | |
221 | 221 | if (isset($line['speed'])) { |
222 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
223 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
222 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
223 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
224 | 224 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
225 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
226 | - if ($distance > 1000 && $distance < 10000) { |
|
225 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
226 | + if ($distance > 1000 && $distance < 10000) { |
|
227 | 227 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
228 | 228 | $speed = $speed*3.6; |
229 | 229 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
230 | 230 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
231 | - } |
|
231 | + } |
|
232 | 232 | } |
233 | 233 | |
234 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
235 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
236 | - else unset($timediff); |
|
237 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
234 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
235 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
236 | + else unset($timediff); |
|
237 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
238 | 238 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
239 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
239 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
240 | 240 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
241 | 241 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
242 | 242 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -244,211 +244,211 @@ discard block |
||
244 | 244 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
245 | 245 | $timeelapsed = microtime(true); |
246 | 246 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
247 | - $Marine = new Marine($this->db); |
|
248 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
249 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
250 | - $Marine->db = null; |
|
251 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
247 | + $Marine = new Marine($this->db); |
|
248 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
249 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
250 | + $Marine->db = null; |
|
251 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
252 | 252 | } |
253 | 253 | $this->tmd = 0; |
254 | 254 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
255 | - } |
|
255 | + } |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
259 | 259 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
260 | 260 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
261 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
262 | - $dataFound = true; |
|
263 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
261 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
262 | + $dataFound = true; |
|
263 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
264 | 264 | } |
265 | 265 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
266 | 266 | } |
267 | 267 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
268 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
268 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
269 | 269 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
270 | 270 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
271 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
272 | - $dataFound = true; |
|
273 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
271 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
272 | + $dataFound = true; |
|
273 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
274 | 274 | } |
275 | 275 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
276 | 276 | } |
277 | 277 | |
278 | - } else if ($globalDebug && $timediff > 20) { |
|
278 | + } else if ($globalDebug && $timediff > 20) { |
|
279 | 279 | $this->tmd = $this->tmd + 1; |
280 | 280 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
281 | 281 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
282 | 282 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
283 | 283 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
284 | - } |
|
284 | + } |
|
285 | 285 | } |
286 | 286 | if (isset($line['last_update']) && $line['last_update'] != '') { |
287 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
288 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
287 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
288 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
289 | 289 | } |
290 | 290 | if (isset($line['format_source']) && $line['format_source'] != '') { |
291 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
291 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
292 | 292 | } |
293 | 293 | if (isset($line['source_name']) && $line['source_name'] != '') { |
294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
295 | 295 | } |
296 | 296 | if (isset($line['status']) && $line['status'] != '') { |
297 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
297 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
298 | 298 | } |
299 | 299 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
300 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
301 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
300 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
301 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
302 | 302 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
303 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
303 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
304 | 304 | $Marine = new Marine($this->db); |
305 | 305 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
306 | 306 | unset($Marine); |
307 | - } |
|
307 | + } |
|
308 | + } |
|
308 | 309 | } |
309 | - } |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
313 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
313 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | if (isset($line['heading']) && $line['heading'] != '') { |
317 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
318 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
319 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
320 | - //$dataFound = true; |
|
317 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
318 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
319 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
320 | + //$dataFound = true; |
|
321 | 321 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
322 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
323 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
324 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
325 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
322 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
323 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
324 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
325 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
326 | 326 | } |
327 | 327 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
328 | 328 | |
329 | 329 | |
330 | 330 | |
331 | 331 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
332 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
333 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
334 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
335 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
332 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
333 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
334 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
335 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
336 | 336 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
337 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
338 | - $timeelapsed = microtime(true); |
|
339 | - $MarineLive = new MarineLive($this->db); |
|
340 | - if (isset($line['id'])) { |
|
337 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
338 | + $timeelapsed = microtime(true); |
|
339 | + $MarineLive = new MarineLive($this->db); |
|
340 | + if (isset($line['id'])) { |
|
341 | 341 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
342 | 342 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
343 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
343 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
344 | 344 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
345 | 345 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
346 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
346 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
347 | 347 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
348 | 348 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
349 | - } else $recent_ident = ''; |
|
350 | - $MarineLive->db=null; |
|
351 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
352 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
349 | + } else $recent_ident = ''; |
|
350 | + $MarineLive->db=null; |
|
351 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
352 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
353 | 353 | } else $recent_ident = ''; |
354 | - } else { |
|
354 | + } else { |
|
355 | 355 | $recent_ident = ''; |
356 | 356 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
357 | - } |
|
358 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
359 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
360 | - { |
|
357 | + } |
|
358 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
359 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
360 | + { |
|
361 | 361 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
362 | 362 | //adds the spotter data for the archive |
363 | - $highlight = ''; |
|
364 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
365 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
363 | + $highlight = ''; |
|
364 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
365 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
366 | 366 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
367 | - $timeelapsed = microtime(true); |
|
368 | - $Marine = new Marine($this->db); |
|
369 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
370 | - $Marine->db = null; |
|
371 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
372 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
367 | + $timeelapsed = microtime(true); |
|
368 | + $Marine = new Marine($this->db); |
|
369 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
370 | + $Marine->db = null; |
|
371 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
372 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
373 | + } |
|
373 | 374 | } |
374 | - } |
|
375 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
375 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
376 | 376 | // Add source stat in DB |
377 | 377 | $Stats = new Stats($this->db); |
378 | 378 | if (!empty($this->stats)) { |
379 | - if ($globalDebug) echo 'Add source stats : '; |
|
380 | - foreach($this->stats as $date => $data) { |
|
379 | + if ($globalDebug) echo 'Add source stats : '; |
|
380 | + foreach($this->stats as $date => $data) { |
|
381 | 381 | foreach($data as $source => $sourced) { |
382 | - //print_r($sourced); |
|
383 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
384 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
385 | - if (isset($sourced['msg'])) { |
|
386 | - if (time() - $sourced['msg']['date'] > 10) { |
|
387 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
388 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
389 | - unset($this->stats[$date][$source]['msg']); |
|
390 | - } |
|
391 | - } |
|
392 | - } |
|
393 | - if ($date != date('Y-m-d')) { |
|
394 | - unset($this->stats[$date]); |
|
395 | - } |
|
396 | - } |
|
397 | - if ($globalDebug) echo 'Done'."\n"; |
|
382 | + //print_r($sourced); |
|
383 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
384 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
385 | + if (isset($sourced['msg'])) { |
|
386 | + if (time() - $sourced['msg']['date'] > 10) { |
|
387 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
388 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
389 | + unset($this->stats[$date][$source]['msg']); |
|
390 | + } |
|
391 | + } |
|
392 | + } |
|
393 | + if ($date != date('Y-m-d')) { |
|
394 | + unset($this->stats[$date]); |
|
395 | + } |
|
396 | + } |
|
397 | + if ($globalDebug) echo 'Done'."\n"; |
|
398 | 398 | } |
399 | 399 | $Stats->db = null; |
400 | - } |
|
400 | + } |
|
401 | 401 | |
402 | - $this->del(); |
|
402 | + $this->del(); |
|
403 | 403 | //$ignoreImport = false; |
404 | 404 | $this->all_tracked[$id]['addedMarine'] = 1; |
405 | 405 | //print_r($this->all_tracked[$id]); |
406 | 406 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
407 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
408 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
409 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
407 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
408 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
409 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
410 | 410 | $MarineLive = new MarineLive($this->db); |
411 | 411 | $MarineLive->deleteLiveMarineData(); |
412 | 412 | $MarineLive->db=null; |
413 | 413 | if ($globalDebug) echo " Done\n"; |
414 | - } |
|
415 | - $this->last_delete = time(); |
|
414 | + } |
|
415 | + $this->last_delete = time(); |
|
416 | 416 | } |
417 | - } elseif ($recent_ident != '') { |
|
417 | + } elseif ($recent_ident != '') { |
|
418 | 418 | $this->all_tracked[$id]['id'] = $recent_ident; |
419 | 419 | $this->all_tracked[$id]['addedMarine'] = 1; |
420 | 420 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
421 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
421 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
422 | 422 | $Marine = new Marine($this->db); |
423 | 423 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
424 | 424 | $Marine->db = null; |
425 | - } |
|
425 | + } |
|
426 | 426 | } |
427 | 427 | |
428 | - } |
|
428 | + } |
|
429 | + } |
|
429 | 430 | } |
430 | - } |
|
431 | - //adds the spotter LIVE data |
|
432 | - if ($globalDebug) { |
|
431 | + //adds the spotter LIVE data |
|
432 | + if ($globalDebug) { |
|
433 | 433 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
434 | - } |
|
435 | - $ignoreImport = false; |
|
434 | + } |
|
435 | + $ignoreImport = false; |
|
436 | 436 | |
437 | - if (!$ignoreImport) { |
|
437 | + if (!$ignoreImport) { |
|
438 | 438 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
439 | 439 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
440 | 440 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
441 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
441 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
442 | 442 | $timeelapsed = microtime(true); |
443 | 443 | $MarineLive = new MarineLive($this->db); |
444 | 444 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
445 | 445 | $MarineLive->db = null; |
446 | 446 | if ($globalDebug) echo $result."\n"; |
447 | 447 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
448 | - } |
|
448 | + } |
|
449 | 449 | } |
450 | 450 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
451 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
451 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
452 | 452 | } |
453 | 453 | $this->all_tracked[$id]['putinarchive'] = false; |
454 | 454 | |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | if ($stats_heading == 16) $stats_heading = 0; |
481 | 481 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
482 | 482 | for ($i=0;$i<=15;$i++) { |
483 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
483 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
484 | 484 | } |
485 | 485 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
486 | 486 | } else { |
@@ -493,11 +493,11 @@ discard block |
||
493 | 493 | //var_dump($this->stats); |
494 | 494 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
495 | 495 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
496 | - end($this->stats[$current_date][$source]['hist']); |
|
497 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
496 | + end($this->stats[$current_date][$source]['hist']); |
|
497 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
498 | 498 | } else $mini = 0; |
499 | 499 | for ($i=$mini;$i<=$distance;$i+=10) { |
500 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
500 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
501 | 501 | } |
502 | 502 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
503 | 503 | } else { |
@@ -513,24 +513,24 @@ discard block |
||
513 | 513 | |
514 | 514 | |
515 | 515 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
516 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
516 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
517 | 517 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
518 | 518 | $MarineLive = new MarineLive($this->db); |
519 | 519 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
520 | 520 | $MarineLive->db = null; |
521 | 521 | //MarineLive->deleteLiveMarineData(); |
522 | 522 | if ($globalDebug) echo " Done\n"; |
523 | - } |
|
524 | - $this->last_delete_hourly = time(); |
|
523 | + } |
|
524 | + $this->last_delete_hourly = time(); |
|
525 | 525 | } |
526 | 526 | |
527 | - } |
|
528 | - //$ignoreImport = false; |
|
527 | + } |
|
528 | + //$ignoreImport = false; |
|
529 | 529 | } |
530 | 530 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
531 | 531 | if ($send) return $this->all_tracked[$id]; |
532 | - } |
|
532 | + } |
|
533 | + } |
|
533 | 534 | } |
534 | - } |
|
535 | 535 | } |
536 | 536 | ?> |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | /** |
16 | - * Get SQL query part for filter used |
|
17 | - * @param Array $filter the filter |
|
18 | - * @return Array the SQL part |
|
19 | - */ |
|
16 | + * Get SQL query part for filter used |
|
17 | + * @param Array $filter the filter |
|
18 | + * @return Array the SQL part |
|
19 | + */ |
|
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
@@ -87,11 +87,11 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * Gets all the spotter information based on the latest data entry |
|
91 | - * |
|
92 | - * @return Array the spotter information |
|
93 | - * |
|
94 | - */ |
|
90 | + * Gets all the spotter information based on the latest data entry |
|
91 | + * |
|
92 | + * @return Array the spotter information |
|
93 | + * |
|
94 | + */ |
|
95 | 95 | public function getLiveTrackerData($limit = '', $sort = '', $filter = array()) |
96 | 96 | { |
97 | 97 | global $globalDBdriver, $globalLiveInterval; |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | - * Gets Minimal Live Spotter data |
|
137 | - * |
|
138 | - * @return Array the spotter information |
|
139 | - * |
|
140 | - */ |
|
136 | + * Gets Minimal Live Spotter data |
|
137 | + * |
|
138 | + * @return Array the spotter information |
|
139 | + * |
|
140 | + */ |
|
141 | 141 | public function getMinLiveTrackerData($filter = array()) |
142 | 142 | { |
143 | 143 | global $globalDBdriver, $globalLiveInterval; |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
174 | - * Gets Minimal Live Spotter data since xx seconds |
|
175 | - * |
|
176 | - * @return Array the spotter information |
|
177 | - * |
|
178 | - */ |
|
174 | + * Gets Minimal Live Spotter data since xx seconds |
|
175 | + * |
|
176 | + * @return Array the spotter information |
|
177 | + * |
|
178 | + */ |
|
179 | 179 | public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false) |
180 | 180 | { |
181 | 181 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit; |
@@ -249,11 +249,11 @@ discard block |
||
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
252 | - * Gets number of latest data entry |
|
253 | - * |
|
254 | - * @return String number of entry |
|
255 | - * |
|
256 | - */ |
|
252 | + * Gets number of latest data entry |
|
253 | + * |
|
254 | + * @return String number of entry |
|
255 | + * |
|
256 | + */ |
|
257 | 257 | public function getLiveTrackerCount($filter = array()) |
258 | 258 | { |
259 | 259 | global $globalDBdriver, $globalLiveInterval; |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
281 | - * Gets all the spotter information based on the latest data entry and coord |
|
282 | - * |
|
283 | - * @return Array the spotter information |
|
284 | - * |
|
285 | - */ |
|
281 | + * Gets all the spotter information based on the latest data entry and coord |
|
282 | + * |
|
283 | + * @return Array the spotter information |
|
284 | + * |
|
285 | + */ |
|
286 | 286 | public function getLiveTrackerDatabyCoord($coord, $filter = array()) |
287 | 287 | { |
288 | 288 | global $globalDBdriver, $globalLiveInterval; |
@@ -306,11 +306,11 @@ discard block |
||
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
309 | - * Gets all the spotter information based on the latest data entry and coord |
|
310 | - * |
|
311 | - * @return Array the spotter information |
|
312 | - * |
|
313 | - */ |
|
309 | + * Gets all the spotter information based on the latest data entry and coord |
|
310 | + * |
|
311 | + * @return Array the spotter information |
|
312 | + * |
|
313 | + */ |
|
314 | 314 | public function getMinLiveTrackerDatabyCoord($coord, $filter = array()) |
315 | 315 | { |
316 | 316 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -378,11 +378,11 @@ discard block |
||
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
381 | - * Gets all the spotter information based on a user's latitude and longitude |
|
382 | - * |
|
383 | - * @return Array the spotter information |
|
384 | - * |
|
385 | - */ |
|
381 | + * Gets all the spotter information based on a user's latitude and longitude |
|
382 | + * |
|
383 | + * @return Array the spotter information |
|
384 | + * |
|
385 | + */ |
|
386 | 386 | public function getLatestTrackerForLayar($lat, $lng, $radius, $interval) |
387 | 387 | { |
388 | 388 | $Tracker = new Tracker($this->db); |
@@ -395,142 +395,142 @@ discard block |
||
395 | 395 | if ($lng != '') |
396 | 396 | { |
397 | 397 | if (!is_numeric($lng)) |
398 | - { |
|
399 | - return false; |
|
400 | - } |
|
401 | - } |
|
402 | - |
|
403 | - if ($radius != '') |
|
404 | - { |
|
405 | - if (!is_numeric($radius)) |
|
406 | - { |
|
407 | - return false; |
|
408 | - } |
|
409 | - } |
|
398 | + { |
|
399 | + return false; |
|
400 | + } |
|
401 | + } |
|
402 | + |
|
403 | + if ($radius != '') |
|
404 | + { |
|
405 | + if (!is_numeric($radius)) |
|
406 | + { |
|
407 | + return false; |
|
408 | + } |
|
409 | + } |
|
410 | 410 | $additional_query = ''; |
411 | 411 | if ($interval != '') |
412 | - { |
|
413 | - if (!is_string($interval)) |
|
414 | - { |
|
415 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
416 | - return false; |
|
417 | - } else { |
|
418 | - if ($interval == '1m') |
|
419 | - { |
|
420 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
421 | - } else if ($interval == '15m'){ |
|
422 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
423 | - } |
|
424 | - } |
|
425 | - } else { |
|
426 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
427 | - } |
|
428 | - |
|
429 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
412 | + { |
|
413 | + if (!is_string($interval)) |
|
414 | + { |
|
415 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
416 | + return false; |
|
417 | + } else { |
|
418 | + if ($interval == '1m') |
|
419 | + { |
|
420 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
421 | + } else if ($interval == '15m'){ |
|
422 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
423 | + } |
|
424 | + } |
|
425 | + } else { |
|
426 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
427 | + } |
|
428 | + |
|
429 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
430 | 430 | WHERE tracker_live.latitude <> '' |
431 | 431 | AND tracker_live.longitude <> '' |
432 | 432 | ".$additional_query." |
433 | 433 | HAVING distance < :radius |
434 | 434 | ORDER BY distance"; |
435 | 435 | |
436 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
436 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
437 | 437 | |
438 | - return $spotter_array; |
|
439 | - } |
|
438 | + return $spotter_array; |
|
439 | + } |
|
440 | 440 | |
441 | 441 | |
442 | - /** |
|
443 | - * Gets all the spotter information based on a particular callsign |
|
444 | - * |
|
445 | - * @return Array the spotter information |
|
446 | - * |
|
447 | - */ |
|
442 | + /** |
|
443 | + * Gets all the spotter information based on a particular callsign |
|
444 | + * |
|
445 | + * @return Array the spotter information |
|
446 | + * |
|
447 | + */ |
|
448 | 448 | public function getLastLiveTrackerDataByIdent($ident) |
449 | 449 | { |
450 | 450 | $Tracker = new Tracker($this->db); |
451 | 451 | date_default_timezone_set('UTC'); |
452 | 452 | |
453 | 453 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
454 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
454 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
455 | 455 | |
456 | 456 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
457 | 457 | |
458 | 458 | return $spotter_array; |
459 | 459 | } |
460 | 460 | |
461 | - /** |
|
462 | - * Gets all the spotter information based on a particular callsign |
|
463 | - * |
|
464 | - * @return Array the spotter information |
|
465 | - * |
|
466 | - */ |
|
461 | + /** |
|
462 | + * Gets all the spotter information based on a particular callsign |
|
463 | + * |
|
464 | + * @return Array the spotter information |
|
465 | + * |
|
466 | + */ |
|
467 | 467 | public function getDateLiveTrackerDataByIdent($ident,$date) |
468 | 468 | { |
469 | 469 | $Tracker = new Tracker($this->db); |
470 | 470 | date_default_timezone_set('UTC'); |
471 | 471 | |
472 | 472 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
473 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
473 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
474 | 474 | |
475 | - $date = date('c',$date); |
|
475 | + $date = date('c',$date); |
|
476 | 476 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
477 | 477 | |
478 | 478 | return $spotter_array; |
479 | 479 | } |
480 | 480 | |
481 | - /** |
|
482 | - * Gets last spotter information based on a particular callsign |
|
483 | - * |
|
484 | - * @return Array the spotter information |
|
485 | - * |
|
486 | - */ |
|
481 | + /** |
|
482 | + * Gets last spotter information based on a particular callsign |
|
483 | + * |
|
484 | + * @return Array the spotter information |
|
485 | + * |
|
486 | + */ |
|
487 | 487 | public function getLastLiveTrackerDataById($id) |
488 | 488 | { |
489 | 489 | $Tracker = new Tracker($this->db); |
490 | 490 | date_default_timezone_set('UTC'); |
491 | 491 | |
492 | 492 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
493 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
493 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
494 | 494 | |
495 | 495 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
496 | 496 | |
497 | 497 | return $spotter_array; |
498 | 498 | } |
499 | 499 | |
500 | - /** |
|
501 | - * Gets last spotter information based on a particular callsign |
|
502 | - * |
|
503 | - * @return Array the spotter information |
|
504 | - * |
|
505 | - */ |
|
500 | + /** |
|
501 | + * Gets last spotter information based on a particular callsign |
|
502 | + * |
|
503 | + * @return Array the spotter information |
|
504 | + * |
|
505 | + */ |
|
506 | 506 | public function getDateLiveTrackerDataById($id,$date) |
507 | 507 | { |
508 | 508 | $Tracker = new Tracker($this->db); |
509 | 509 | date_default_timezone_set('UTC'); |
510 | 510 | |
511 | 511 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
512 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
513 | - $date = date('c',$date); |
|
512 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
513 | + $date = date('c',$date); |
|
514 | 514 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
515 | 515 | |
516 | 516 | return $spotter_array; |
517 | 517 | } |
518 | 518 | |
519 | - /** |
|
520 | - * Gets altitude information based on a particular callsign |
|
521 | - * |
|
522 | - * @return Array the spotter information |
|
523 | - * |
|
524 | - */ |
|
519 | + /** |
|
520 | + * Gets altitude information based on a particular callsign |
|
521 | + * |
|
522 | + * @return Array the spotter information |
|
523 | + * |
|
524 | + */ |
|
525 | 525 | public function getAltitudeLiveTrackerDataByIdent($ident) |
526 | 526 | { |
527 | 527 | |
528 | 528 | date_default_timezone_set('UTC'); |
529 | 529 | |
530 | 530 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
531 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
531 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
532 | 532 | |
533 | - try { |
|
533 | + try { |
|
534 | 534 | |
535 | 535 | $sth = $this->db->prepare($query); |
536 | 536 | $sth->execute(array(':ident' => $ident)); |
@@ -543,12 +543,12 @@ discard block |
||
543 | 543 | return $spotter_array; |
544 | 544 | } |
545 | 545 | |
546 | - /** |
|
547 | - * Gets all the spotter information based on a particular id |
|
548 | - * |
|
549 | - * @return Array the spotter information |
|
550 | - * |
|
551 | - */ |
|
546 | + /** |
|
547 | + * Gets all the spotter information based on a particular id |
|
548 | + * |
|
549 | + * @return Array the spotter information |
|
550 | + * |
|
551 | + */ |
|
552 | 552 | public function getAllLiveTrackerDataById($id,$liveinterval = false) |
553 | 553 | { |
554 | 554 | global $globalDBdriver, $globalLiveInterval; |
@@ -576,18 +576,18 @@ discard block |
||
576 | 576 | return $spotter_array; |
577 | 577 | } |
578 | 578 | |
579 | - /** |
|
580 | - * Gets all the spotter information based on a particular ident |
|
581 | - * |
|
582 | - * @return Array the spotter information |
|
583 | - * |
|
584 | - */ |
|
579 | + /** |
|
580 | + * Gets all the spotter information based on a particular ident |
|
581 | + * |
|
582 | + * @return Array the spotter information |
|
583 | + * |
|
584 | + */ |
|
585 | 585 | public function getAllLiveTrackerDataByIdent($ident) |
586 | 586 | { |
587 | 587 | date_default_timezone_set('UTC'); |
588 | 588 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
589 | 589 | $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
590 | - try { |
|
590 | + try { |
|
591 | 591 | |
592 | 592 | $sth = $this->db->prepare($query); |
593 | 593 | $sth->execute(array(':ident' => $ident)); |
@@ -601,23 +601,23 @@ discard block |
||
601 | 601 | |
602 | 602 | |
603 | 603 | /** |
604 | - * Deletes all info in the table |
|
605 | - * |
|
606 | - * @return String success or false |
|
607 | - * |
|
608 | - */ |
|
604 | + * Deletes all info in the table |
|
605 | + * |
|
606 | + * @return String success or false |
|
607 | + * |
|
608 | + */ |
|
609 | 609 | public function deleteLiveTrackerData() |
610 | 610 | { |
611 | 611 | global $globalDBdriver; |
612 | 612 | if ($globalDBdriver == 'mysql') { |
613 | 613 | //$query = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date"; |
614 | 614 | $query = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date'; |
615 | - //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
615 | + //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
616 | 616 | } else { |
617 | 617 | $query = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date"; |
618 | 618 | } |
619 | 619 | |
620 | - try { |
|
620 | + try { |
|
621 | 621 | |
622 | 622 | $sth = $this->db->prepare($query); |
623 | 623 | $sth->execute(); |
@@ -629,18 +629,18 @@ discard block |
||
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
632 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
633 | - * |
|
634 | - * @return String success or false |
|
635 | - * |
|
636 | - */ |
|
632 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
633 | + * |
|
634 | + * @return String success or false |
|
635 | + * |
|
636 | + */ |
|
637 | 637 | public function deleteLiveTrackerDataNotUpdated() |
638 | 638 | { |
639 | 639 | global $globalDBdriver, $globalDebug; |
640 | 640 | if ($globalDBdriver == 'mysql') { |
641 | 641 | //$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0'; |
642 | - $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
643 | - try { |
|
642 | + $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
643 | + try { |
|
644 | 644 | |
645 | 645 | $sth = $this->db->prepare($query); |
646 | 646 | $sth->execute(); |
@@ -648,8 +648,8 @@ discard block |
||
648 | 648 | return "error"; |
649 | 649 | } |
650 | 650 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
651 | - $i = 0; |
|
652 | - $j =0; |
|
651 | + $i = 0; |
|
652 | + $j =0; |
|
653 | 653 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
654 | 654 | foreach($all as $row) |
655 | 655 | { |
@@ -657,20 +657,20 @@ discard block |
||
657 | 657 | $j++; |
658 | 658 | if ($j == 30) { |
659 | 659 | if ($globalDebug) echo "."; |
660 | - try { |
|
660 | + try { |
|
661 | 661 | |
662 | 662 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
663 | 663 | $sth->execute(); |
664 | 664 | } catch(PDOException $e) { |
665 | 665 | return "error"; |
666 | 666 | } |
667 | - $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
668 | - $j = 0; |
|
667 | + $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
668 | + $j = 0; |
|
669 | 669 | } |
670 | 670 | $query_delete .= "'".$row['famtrackid']."',"; |
671 | 671 | } |
672 | 672 | if ($i > 0) { |
673 | - try { |
|
673 | + try { |
|
674 | 674 | |
675 | 675 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
676 | 676 | $sth->execute(); |
@@ -681,9 +681,9 @@ discard block |
||
681 | 681 | return "success"; |
682 | 682 | } elseif ($globalDBdriver == 'pgsql') { |
683 | 683 | //$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0"; |
684 | - //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
685 | - $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
686 | - try { |
|
684 | + //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
685 | + $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
686 | + try { |
|
687 | 687 | |
688 | 688 | $sth = $this->db->prepare($query); |
689 | 689 | $sth->execute(); |
@@ -727,17 +727,17 @@ discard block |
||
727 | 727 | } |
728 | 728 | |
729 | 729 | /** |
730 | - * Deletes all info in the table for an ident |
|
731 | - * |
|
732 | - * @return String success or false |
|
733 | - * |
|
734 | - */ |
|
730 | + * Deletes all info in the table for an ident |
|
731 | + * |
|
732 | + * @return String success or false |
|
733 | + * |
|
734 | + */ |
|
735 | 735 | public function deleteLiveTrackerDataByIdent($ident) |
736 | 736 | { |
737 | 737 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
738 | 738 | $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
739 | 739 | |
740 | - try { |
|
740 | + try { |
|
741 | 741 | |
742 | 742 | $sth = $this->db->prepare($query); |
743 | 743 | $sth->execute(array(':ident' => $ident)); |
@@ -749,17 +749,17 @@ discard block |
||
749 | 749 | } |
750 | 750 | |
751 | 751 | /** |
752 | - * Deletes all info in the table for an id |
|
753 | - * |
|
754 | - * @return String success or false |
|
755 | - * |
|
756 | - */ |
|
752 | + * Deletes all info in the table for an id |
|
753 | + * |
|
754 | + * @return String success or false |
|
755 | + * |
|
756 | + */ |
|
757 | 757 | public function deleteLiveTrackerDataById($id) |
758 | 758 | { |
759 | 759 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
760 | 760 | $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
761 | 761 | |
762 | - try { |
|
762 | + try { |
|
763 | 763 | |
764 | 764 | $sth = $this->db->prepare($query); |
765 | 765 | $sth->execute(array(':id' => $id)); |
@@ -772,11 +772,11 @@ discard block |
||
772 | 772 | |
773 | 773 | |
774 | 774 | /** |
775 | - * Gets the aircraft ident within the last hour |
|
776 | - * |
|
777 | - * @return String the ident |
|
778 | - * |
|
779 | - */ |
|
775 | + * Gets the aircraft ident within the last hour |
|
776 | + * |
|
777 | + * @return String the ident |
|
778 | + * |
|
779 | + */ |
|
780 | 780 | public function getIdentFromLastHour($ident) |
781 | 781 | { |
782 | 782 | global $globalDBdriver, $globalTimezone; |
@@ -802,14 +802,14 @@ discard block |
||
802 | 802 | $ident_result = $row['ident']; |
803 | 803 | } |
804 | 804 | return $ident_result; |
805 | - } |
|
805 | + } |
|
806 | 806 | |
807 | 807 | /** |
808 | - * Check recent aircraft |
|
809 | - * |
|
810 | - * @return String the ident |
|
811 | - * |
|
812 | - */ |
|
808 | + * Check recent aircraft |
|
809 | + * |
|
810 | + * @return String the ident |
|
811 | + * |
|
812 | + */ |
|
813 | 813 | public function checkIdentRecent($ident) |
814 | 814 | { |
815 | 815 | global $globalDBdriver, $globalTimezone; |
@@ -835,14 +835,14 @@ discard block |
||
835 | 835 | $ident_result = $row['famtrackid']; |
836 | 836 | } |
837 | 837 | return $ident_result; |
838 | - } |
|
838 | + } |
|
839 | 839 | |
840 | 840 | /** |
841 | - * Check recent aircraft by id |
|
842 | - * |
|
843 | - * @return String the ident |
|
844 | - * |
|
845 | - */ |
|
841 | + * Check recent aircraft by id |
|
842 | + * |
|
843 | + * @return String the ident |
|
844 | + * |
|
845 | + */ |
|
846 | 846 | public function checkIdRecent($id) |
847 | 847 | { |
848 | 848 | global $globalDBdriver, $globalTimezone; |
@@ -868,19 +868,19 @@ discard block |
||
868 | 868 | $ident_result = $row['famtrackid']; |
869 | 869 | } |
870 | 870 | return $ident_result; |
871 | - } |
|
871 | + } |
|
872 | 872 | |
873 | 873 | /** |
874 | - * Adds a new spotter data |
|
875 | - * |
|
876 | - * @param String $famtrackid the ID from flightaware |
|
877 | - * @param String $ident the flight ident |
|
878 | - * @param String $aircraft_icao the aircraft type |
|
879 | - * @param String $departure_airport_icao the departure airport |
|
880 | - * @param String $arrival_airport_icao the arrival airport |
|
881 | - * @return String success or false |
|
882 | - * |
|
883 | - */ |
|
874 | + * Adds a new spotter data |
|
875 | + * |
|
876 | + * @param String $famtrackid the ID from flightaware |
|
877 | + * @param String $ident the flight ident |
|
878 | + * @param String $aircraft_icao the aircraft type |
|
879 | + * @param String $departure_airport_icao the departure airport |
|
880 | + * @param String $arrival_airport_icao the arrival airport |
|
881 | + * @return String success or false |
|
882 | + * |
|
883 | + */ |
|
884 | 884 | public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
885 | 885 | { |
886 | 886 | global $globalURL, $globalArchive, $globalDebug; |
@@ -953,8 +953,8 @@ discard block |
||
953 | 953 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
954 | 954 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
955 | 955 | |
956 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
956 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
958 | 958 | |
959 | 959 | $query = ''; |
960 | 960 | if ($globalArchive) { |
@@ -972,15 +972,15 @@ discard block |
||
972 | 972 | } catch(PDOException $e) { |
973 | 973 | return "error : ".$e->getMessage(); |
974 | 974 | } |
975 | - /* |
|
975 | + /* |
|
976 | 976 | echo 'putinarchive : '.$putinarchive."\n"; |
977 | 977 | echo 'noarchive : '.$noarchive."\n"; |
978 | 978 | */ |
979 | 979 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
980 | - if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
981 | - $TrackerArchive = new TrackerArchive($this->db); |
|
982 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
983 | - if ($globalDebug) echo $result.')'; |
|
980 | + if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
981 | + $TrackerArchive = new TrackerArchive($this->db); |
|
982 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
983 | + if ($globalDebug) echo $result.')'; |
|
984 | 984 | } |
985 | 985 | |
986 | 986 | return "success"; |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | /** |
16 | - * Get SQL query part for filter used |
|
17 | - * @param Array $filter the filter |
|
18 | - * @return Array the SQL part |
|
19 | - */ |
|
16 | + * Get SQL query part for filter used |
|
17 | + * @param Array $filter the filter |
|
18 | + * @return Array the SQL part |
|
19 | + */ |
|
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
@@ -87,11 +87,11 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * Gets all the spotter information based on the latest data entry |
|
91 | - * |
|
92 | - * @return Array the spotter information |
|
93 | - * |
|
94 | - */ |
|
90 | + * Gets all the spotter information based on the latest data entry |
|
91 | + * |
|
92 | + * @return Array the spotter information |
|
93 | + * |
|
94 | + */ |
|
95 | 95 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
96 | 96 | { |
97 | 97 | global $globalDBdriver, $globalLiveInterval; |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
137 | - * Gets Minimal Live Spotter data |
|
138 | - * |
|
139 | - * @return Array the spotter information |
|
140 | - * |
|
141 | - */ |
|
137 | + * Gets Minimal Live Spotter data |
|
138 | + * |
|
139 | + * @return Array the spotter information |
|
140 | + * |
|
141 | + */ |
|
142 | 142 | public function getMinLiveMarineData($filter = array()) |
143 | 143 | { |
144 | 144 | global $globalDBdriver, $globalLiveInterval; |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
171 | - * Gets Minimal Live Spotter data since xx seconds |
|
172 | - * |
|
173 | - * @return Array the spotter information |
|
174 | - * |
|
175 | - */ |
|
171 | + * Gets Minimal Live Spotter data since xx seconds |
|
172 | + * |
|
173 | + * @return Array the spotter information |
|
174 | + * |
|
175 | + */ |
|
176 | 176 | public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false) |
177 | 177 | { |
178 | 178 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
246 | - * Gets number of latest data entry |
|
247 | - * |
|
248 | - * @return String number of entry |
|
249 | - * |
|
250 | - */ |
|
246 | + * Gets number of latest data entry |
|
247 | + * |
|
248 | + * @return String number of entry |
|
249 | + * |
|
250 | + */ |
|
251 | 251 | public function getLiveMarineCount($filter = array()) |
252 | 252 | { |
253 | 253 | global $globalDBdriver, $globalLiveInterval; |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
275 | - * Gets all the spotter information based on the latest data entry and coord |
|
276 | - * |
|
277 | - * @return Array the spotter information |
|
278 | - * |
|
279 | - */ |
|
275 | + * Gets all the spotter information based on the latest data entry and coord |
|
276 | + * |
|
277 | + * @return Array the spotter information |
|
278 | + * |
|
279 | + */ |
|
280 | 280 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
281 | 281 | { |
282 | 282 | global $globalDBdriver, $globalLiveInterval; |
@@ -300,11 +300,11 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
303 | - * Gets all the spotter information based on the latest data entry and coord |
|
304 | - * |
|
305 | - * @return Array the spotter information |
|
306 | - * |
|
307 | - */ |
|
303 | + * Gets all the spotter information based on the latest data entry and coord |
|
304 | + * |
|
305 | + * @return Array the spotter information |
|
306 | + * |
|
307 | + */ |
|
308 | 308 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
309 | 309 | { |
310 | 310 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -373,11 +373,11 @@ discard block |
||
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
376 | - * Gets all the spotter information based on a user's latitude and longitude |
|
377 | - * |
|
378 | - * @return Array the spotter information |
|
379 | - * |
|
380 | - */ |
|
376 | + * Gets all the spotter information based on a user's latitude and longitude |
|
377 | + * |
|
378 | + * @return Array the spotter information |
|
379 | + * |
|
380 | + */ |
|
381 | 381 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
382 | 382 | { |
383 | 383 | $Marine = new Marine($this->db); |
@@ -390,134 +390,134 @@ discard block |
||
390 | 390 | if ($lng != '') |
391 | 391 | { |
392 | 392 | if (!is_numeric($lng)) |
393 | - { |
|
394 | - return false; |
|
395 | - } |
|
396 | - } |
|
397 | - |
|
398 | - if ($radius != '') |
|
399 | - { |
|
400 | - if (!is_numeric($radius)) |
|
401 | - { |
|
402 | - return false; |
|
403 | - } |
|
404 | - } |
|
393 | + { |
|
394 | + return false; |
|
395 | + } |
|
396 | + } |
|
397 | + |
|
398 | + if ($radius != '') |
|
399 | + { |
|
400 | + if (!is_numeric($radius)) |
|
401 | + { |
|
402 | + return false; |
|
403 | + } |
|
404 | + } |
|
405 | 405 | $additional_query = ''; |
406 | 406 | if ($interval != '') |
407 | - { |
|
408 | - if (!is_string($interval)) |
|
409 | - { |
|
410 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
411 | - return false; |
|
412 | - } else { |
|
413 | - if ($interval == '1m') |
|
414 | - { |
|
415 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
416 | - } else if ($interval == '15m'){ |
|
417 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
418 | - } |
|
419 | - } |
|
420 | - } else { |
|
421 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
422 | - } |
|
423 | - |
|
424 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
407 | + { |
|
408 | + if (!is_string($interval)) |
|
409 | + { |
|
410 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
411 | + return false; |
|
412 | + } else { |
|
413 | + if ($interval == '1m') |
|
414 | + { |
|
415 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
416 | + } else if ($interval == '15m'){ |
|
417 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
418 | + } |
|
419 | + } |
|
420 | + } else { |
|
421 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
422 | + } |
|
423 | + |
|
424 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
425 | 425 | WHERE marine_live.latitude <> '' |
426 | 426 | AND marine_live.longitude <> '' |
427 | 427 | ".$additional_query." |
428 | 428 | HAVING distance < :radius |
429 | 429 | ORDER BY distance"; |
430 | 430 | |
431 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
431 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
432 | 432 | |
433 | - return $spotter_array; |
|
434 | - } |
|
433 | + return $spotter_array; |
|
434 | + } |
|
435 | 435 | |
436 | 436 | |
437 | - /** |
|
438 | - * Gets all the spotter information based on a particular callsign |
|
439 | - * |
|
440 | - * @return Array the spotter information |
|
441 | - * |
|
442 | - */ |
|
437 | + /** |
|
438 | + * Gets all the spotter information based on a particular callsign |
|
439 | + * |
|
440 | + * @return Array the spotter information |
|
441 | + * |
|
442 | + */ |
|
443 | 443 | public function getLastLiveMarineDataByIdent($ident) |
444 | 444 | { |
445 | 445 | $Marine = new Marine($this->db); |
446 | 446 | date_default_timezone_set('UTC'); |
447 | 447 | |
448 | 448 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
449 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
449 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
450 | 450 | |
451 | 451 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
452 | 452 | |
453 | 453 | return $spotter_array; |
454 | 454 | } |
455 | 455 | |
456 | - /** |
|
457 | - * Gets all the spotter information based on a particular callsign |
|
458 | - * |
|
459 | - * @return Array the spotter information |
|
460 | - * |
|
461 | - */ |
|
456 | + /** |
|
457 | + * Gets all the spotter information based on a particular callsign |
|
458 | + * |
|
459 | + * @return Array the spotter information |
|
460 | + * |
|
461 | + */ |
|
462 | 462 | public function getDateLiveMarineDataByIdent($ident,$date) |
463 | 463 | { |
464 | 464 | $Marine = new Marine($this->db); |
465 | 465 | date_default_timezone_set('UTC'); |
466 | 466 | |
467 | 467 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
468 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
468 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
469 | 469 | |
470 | - $date = date('c',$date); |
|
470 | + $date = date('c',$date); |
|
471 | 471 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
472 | 472 | |
473 | 473 | return $spotter_array; |
474 | 474 | } |
475 | 475 | |
476 | - /** |
|
477 | - * Gets last spotter information based on a particular callsign |
|
478 | - * |
|
479 | - * @return Array the spotter information |
|
480 | - * |
|
481 | - */ |
|
476 | + /** |
|
477 | + * Gets last spotter information based on a particular callsign |
|
478 | + * |
|
479 | + * @return Array the spotter information |
|
480 | + * |
|
481 | + */ |
|
482 | 482 | public function getLastLiveMarineDataById($id) |
483 | 483 | { |
484 | 484 | $Marine = new Marine($this->db); |
485 | 485 | date_default_timezone_set('UTC'); |
486 | 486 | |
487 | 487 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
488 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
488 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
489 | 489 | |
490 | 490 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
491 | 491 | |
492 | 492 | return $spotter_array; |
493 | 493 | } |
494 | 494 | |
495 | - /** |
|
496 | - * Gets last spotter information based on a particular callsign |
|
497 | - * |
|
498 | - * @return Array the spotter information |
|
499 | - * |
|
500 | - */ |
|
495 | + /** |
|
496 | + * Gets last spotter information based on a particular callsign |
|
497 | + * |
|
498 | + * @return Array the spotter information |
|
499 | + * |
|
500 | + */ |
|
501 | 501 | public function getDateLiveMarineDataById($id,$date) |
502 | 502 | { |
503 | 503 | $Marine = new Marine($this->db); |
504 | 504 | date_default_timezone_set('UTC'); |
505 | 505 | |
506 | 506 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
507 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
508 | - $date = date('c',$date); |
|
507 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
508 | + $date = date('c',$date); |
|
509 | 509 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
510 | 510 | |
511 | 511 | return $spotter_array; |
512 | 512 | } |
513 | 513 | |
514 | 514 | |
515 | - /** |
|
516 | - * Gets all the spotter information based on a particular id |
|
517 | - * |
|
518 | - * @return Array the spotter information |
|
519 | - * |
|
520 | - */ |
|
515 | + /** |
|
516 | + * Gets all the spotter information based on a particular id |
|
517 | + * |
|
518 | + * @return Array the spotter information |
|
519 | + * |
|
520 | + */ |
|
521 | 521 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
522 | 522 | { |
523 | 523 | global $globalDBdriver, $globalLiveInterval; |
@@ -545,18 +545,18 @@ discard block |
||
545 | 545 | return $spotter_array; |
546 | 546 | } |
547 | 547 | |
548 | - /** |
|
549 | - * Gets all the spotter information based on a particular ident |
|
550 | - * |
|
551 | - * @return Array the spotter information |
|
552 | - * |
|
553 | - */ |
|
548 | + /** |
|
549 | + * Gets all the spotter information based on a particular ident |
|
550 | + * |
|
551 | + * @return Array the spotter information |
|
552 | + * |
|
553 | + */ |
|
554 | 554 | public function getAllLiveMarineDataByIdent($ident) |
555 | 555 | { |
556 | 556 | date_default_timezone_set('UTC'); |
557 | 557 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
558 | 558 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
559 | - try { |
|
559 | + try { |
|
560 | 560 | |
561 | 561 | $sth = $this->db->prepare($query); |
562 | 562 | $sth->execute(array(':ident' => $ident)); |
@@ -570,23 +570,23 @@ discard block |
||
570 | 570 | |
571 | 571 | |
572 | 572 | /** |
573 | - * Deletes all info in the table |
|
574 | - * |
|
575 | - * @return String success or false |
|
576 | - * |
|
577 | - */ |
|
573 | + * Deletes all info in the table |
|
574 | + * |
|
575 | + * @return String success or false |
|
576 | + * |
|
577 | + */ |
|
578 | 578 | public function deleteLiveMarineData() |
579 | 579 | { |
580 | 580 | global $globalDBdriver; |
581 | 581 | if ($globalDBdriver == 'mysql') { |
582 | 582 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
583 | 583 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
584 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
584 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
585 | 585 | } else { |
586 | 586 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
587 | 587 | } |
588 | 588 | |
589 | - try { |
|
589 | + try { |
|
590 | 590 | |
591 | 591 | $sth = $this->db->prepare($query); |
592 | 592 | $sth->execute(); |
@@ -598,18 +598,18 @@ discard block |
||
598 | 598 | } |
599 | 599 | |
600 | 600 | /** |
601 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
602 | - * |
|
603 | - * @return String success or false |
|
604 | - * |
|
605 | - */ |
|
601 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
602 | + * |
|
603 | + * @return String success or false |
|
604 | + * |
|
605 | + */ |
|
606 | 606 | public function deleteLiveMarineDataNotUpdated() |
607 | 607 | { |
608 | 608 | global $globalDBdriver, $globalDebug; |
609 | 609 | if ($globalDBdriver == 'mysql') { |
610 | 610 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
611 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
612 | - try { |
|
611 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
612 | + try { |
|
613 | 613 | |
614 | 614 | $sth = $this->db->prepare($query); |
615 | 615 | $sth->execute(); |
@@ -617,8 +617,8 @@ discard block |
||
617 | 617 | return "error"; |
618 | 618 | } |
619 | 619 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
620 | - $i = 0; |
|
621 | - $j =0; |
|
620 | + $i = 0; |
|
621 | + $j =0; |
|
622 | 622 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
623 | 623 | foreach($all as $row) |
624 | 624 | { |
@@ -626,20 +626,20 @@ discard block |
||
626 | 626 | $j++; |
627 | 627 | if ($j == 30) { |
628 | 628 | if ($globalDebug) echo "."; |
629 | - try { |
|
629 | + try { |
|
630 | 630 | |
631 | 631 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
632 | 632 | $sth->execute(); |
633 | 633 | } catch(PDOException $e) { |
634 | 634 | return "error"; |
635 | 635 | } |
636 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
637 | - $j = 0; |
|
636 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
637 | + $j = 0; |
|
638 | 638 | } |
639 | 639 | $query_delete .= "'".$row['fammarine_id']."',"; |
640 | 640 | } |
641 | 641 | if ($i > 0) { |
642 | - try { |
|
642 | + try { |
|
643 | 643 | |
644 | 644 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
645 | 645 | $sth->execute(); |
@@ -650,9 +650,9 @@ discard block |
||
650 | 650 | return "success"; |
651 | 651 | } elseif ($globalDBdriver == 'pgsql') { |
652 | 652 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
653 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
654 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
655 | - try { |
|
653 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
654 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
655 | + try { |
|
656 | 656 | |
657 | 657 | $sth = $this->db->prepare($query); |
658 | 658 | $sth->execute(); |
@@ -696,17 +696,17 @@ discard block |
||
696 | 696 | } |
697 | 697 | |
698 | 698 | /** |
699 | - * Deletes all info in the table for an ident |
|
700 | - * |
|
701 | - * @return String success or false |
|
702 | - * |
|
703 | - */ |
|
699 | + * Deletes all info in the table for an ident |
|
700 | + * |
|
701 | + * @return String success or false |
|
702 | + * |
|
703 | + */ |
|
704 | 704 | public function deleteLiveMarineDataByIdent($ident) |
705 | 705 | { |
706 | 706 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
707 | 707 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
708 | 708 | |
709 | - try { |
|
709 | + try { |
|
710 | 710 | |
711 | 711 | $sth = $this->db->prepare($query); |
712 | 712 | $sth->execute(array(':ident' => $ident)); |
@@ -718,17 +718,17 @@ discard block |
||
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
721 | - * Deletes all info in the table for an id |
|
722 | - * |
|
723 | - * @return String success or false |
|
724 | - * |
|
725 | - */ |
|
721 | + * Deletes all info in the table for an id |
|
722 | + * |
|
723 | + * @return String success or false |
|
724 | + * |
|
725 | + */ |
|
726 | 726 | public function deleteLiveMarineDataById($id) |
727 | 727 | { |
728 | 728 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
729 | 729 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
730 | 730 | |
731 | - try { |
|
731 | + try { |
|
732 | 732 | |
733 | 733 | $sth = $this->db->prepare($query); |
734 | 734 | $sth->execute(array(':id' => $id)); |
@@ -741,11 +741,11 @@ discard block |
||
741 | 741 | |
742 | 742 | |
743 | 743 | /** |
744 | - * Gets the aircraft ident within the last hour |
|
745 | - * |
|
746 | - * @return String the ident |
|
747 | - * |
|
748 | - */ |
|
744 | + * Gets the aircraft ident within the last hour |
|
745 | + * |
|
746 | + * @return String the ident |
|
747 | + * |
|
748 | + */ |
|
749 | 749 | public function getIdentFromLastHour($ident) |
750 | 750 | { |
751 | 751 | global $globalDBdriver, $globalTimezone; |
@@ -771,14 +771,14 @@ discard block |
||
771 | 771 | $ident_result = $row['ident']; |
772 | 772 | } |
773 | 773 | return $ident_result; |
774 | - } |
|
774 | + } |
|
775 | 775 | |
776 | 776 | /** |
777 | - * Check recent aircraft |
|
778 | - * |
|
779 | - * @return String the ident |
|
780 | - * |
|
781 | - */ |
|
777 | + * Check recent aircraft |
|
778 | + * |
|
779 | + * @return String the ident |
|
780 | + * |
|
781 | + */ |
|
782 | 782 | public function checkIdentRecent($ident) |
783 | 783 | { |
784 | 784 | global $globalDBdriver, $globalTimezone; |
@@ -804,14 +804,14 @@ discard block |
||
804 | 804 | $ident_result = $row['fammarine_id']; |
805 | 805 | } |
806 | 806 | return $ident_result; |
807 | - } |
|
807 | + } |
|
808 | 808 | |
809 | 809 | /** |
810 | - * Check recent aircraft by id |
|
811 | - * |
|
812 | - * @return String the ident |
|
813 | - * |
|
814 | - */ |
|
810 | + * Check recent aircraft by id |
|
811 | + * |
|
812 | + * @return String the ident |
|
813 | + * |
|
814 | + */ |
|
815 | 815 | public function checkIdRecent($id) |
816 | 816 | { |
817 | 817 | global $globalDBdriver, $globalTimezone; |
@@ -837,14 +837,14 @@ discard block |
||
837 | 837 | $ident_result = $row['fammarine_id']; |
838 | 838 | } |
839 | 839 | return $ident_result; |
840 | - } |
|
840 | + } |
|
841 | 841 | |
842 | 842 | /** |
843 | - * Check recent aircraft by mmsi |
|
844 | - * |
|
845 | - * @return String the ident |
|
846 | - * |
|
847 | - */ |
|
843 | + * Check recent aircraft by mmsi |
|
844 | + * |
|
845 | + * @return String the ident |
|
846 | + * |
|
847 | + */ |
|
848 | 848 | public function checkMMSIRecent($mmsi) |
849 | 849 | { |
850 | 850 | global $globalDBdriver, $globalTimezone; |
@@ -870,19 +870,19 @@ discard block |
||
870 | 870 | $ident_result = $row['fammarine_id']; |
871 | 871 | } |
872 | 872 | return $ident_result; |
873 | - } |
|
873 | + } |
|
874 | 874 | |
875 | 875 | /** |
876 | - * Adds a new spotter data |
|
877 | - * |
|
878 | - * @param String $fammarine_id the ID from flightaware |
|
879 | - * @param String $ident the flight ident |
|
880 | - * @param String $aircraft_icao the aircraft type |
|
881 | - * @param String $departure_airport_icao the departure airport |
|
882 | - * @param String $arrival_airport_icao the arrival airport |
|
883 | - * @return String success or false |
|
884 | - * |
|
885 | - */ |
|
876 | + * Adds a new spotter data |
|
877 | + * |
|
878 | + * @param String $fammarine_id the ID from flightaware |
|
879 | + * @param String $ident the flight ident |
|
880 | + * @param String $aircraft_icao the aircraft type |
|
881 | + * @param String $departure_airport_icao the departure airport |
|
882 | + * @param String $arrival_airport_icao the arrival airport |
|
883 | + * @return String success or false |
|
884 | + * |
|
885 | + */ |
|
886 | 886 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
887 | 887 | { |
888 | 888 | global $globalURL, $globalArchive, $globalDebug; |
@@ -953,10 +953,10 @@ discard block |
||
953 | 953 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
954 | 954 | |
955 | 955 | |
956 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
958 | - if ($arrival_date == '') $arrival_date = NULL; |
|
959 | - $query = ''; |
|
956 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
958 | + if ($arrival_date == '') $arrival_date = NULL; |
|
959 | + $query = ''; |
|
960 | 960 | if ($globalArchive) { |
961 | 961 | if ($globalDebug) echo '-- Delete previous data -- '; |
962 | 962 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | } |
554 | 554 | } |
555 | 555 | <?php |
556 | - } else { |
|
557 | - ?> |
|
556 | + } else { |
|
557 | + ?> |
|
558 | 558 | if (map.getZoom() > 7) { |
559 | 559 | var style = { |
560 | 560 | "color": "#1a3151", |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | layer_marine_data.addLayer(layer); |
574 | 574 | } |
575 | 575 | <?php |
576 | - } |
|
576 | + } |
|
577 | 577 | ?> |
578 | 578 | } |
579 | 579 | } |
@@ -598,11 +598,11 @@ discard block |
||
598 | 598 | $( document ).ready(function() { |
599 | 599 | map.on('moveend', function() { |
600 | 600 | <?php |
601 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
601 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
602 | 602 | ?> |
603 | 603 | getLiveMarineData(1); |
604 | 604 | <?php |
605 | - } |
|
605 | + } |
|
606 | 606 | ?> |
607 | 607 | }); |
608 | 608 | //load the function on startup |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
18 | 18 | if (isset($globalMarine) && $globalMarine) { |
19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,46 +25,46 @@ discard block |
||
25 | 25 | // Check if schema is at latest version |
26 | 26 | $Connection = new Connection(); |
27 | 27 | if ($Connection->connectionExists() === false) { |
28 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | - exit(); |
|
28 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | + exit(); |
|
30 | 30 | } |
31 | 31 | if ($Connection->latest() === false) { |
32 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | - exit(); |
|
32 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | + exit(); |
|
34 | 34 | } |
35 | 35 | if (PHP_SAPI != 'cli') { |
36 | - echo "This script MUST be called from console, not a web browser."; |
|
36 | + echo "This script MUST be called from console, not a web browser."; |
|
37 | 37 | // exit(); |
38 | 38 | } |
39 | 39 | |
40 | 40 | // This is to be compatible with old version of settings.php |
41 | 41 | if (!isset($globalSources)) { |
42 | - if (isset($globalSBS1Hosts)) { |
|
43 | - //$hosts = $globalSBS1Hosts; |
|
44 | - foreach ($globalSBS1Hosts as $host) { |
|
45 | - $globalSources[] = array('host' => $host); |
|
46 | - } |
|
47 | - } else { |
|
48 | - if (!isset($globalSBS1Host)) { |
|
49 | - echo '$globalSources MUST be defined !'; |
|
50 | - die; |
|
42 | + if (isset($globalSBS1Hosts)) { |
|
43 | + //$hosts = $globalSBS1Hosts; |
|
44 | + foreach ($globalSBS1Hosts as $host) { |
|
45 | + $globalSources[] = array('host' => $host); |
|
46 | + } |
|
47 | + } else { |
|
48 | + if (!isset($globalSBS1Host)) { |
|
49 | + echo '$globalSources MUST be defined !'; |
|
50 | + die; |
|
51 | 51 | } |
52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
53 | 53 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
54 | - } |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 60 | if (isset($options['s'])) { |
61 | - $globalSources = array(); |
|
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
61 | + $globalSources = array(); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | + else $globalSources[] = array('host' => $options['s']); |
|
64 | 64 | } elseif (isset($options['source'])) { |
65 | - $globalSources = array(); |
|
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
65 | + $globalSources = array(); |
|
66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | + else $globalSources[] = array('host' => $options['source']); |
|
68 | 68 | } |
69 | 69 | if (isset($options['aprsserverhost'])) { |
70 | 70 | $globalServerAPRS = TRUE; |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
104 | 104 | else $id_source = 1; |
105 | 105 | if (isset($globalServer) && $globalServer) { |
106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
107 | - $SI=new SpotterServer(); |
|
106 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
107 | + $SI=new SpotterServer(); |
|
108 | 108 | /* |
109 | 109 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 110 | $SI = new adsb2aprs(); |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | |
115 | 115 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
116 | 116 | if (isset($globalMarine) && $globalMarine) { |
117 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
118 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
117 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
118 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
122 | 122 | if (isset($globalMarine) && $globalMarine) { |
123 | - $AIS = new AIS(); |
|
124 | - $MI = new MarineImport($Connection->db); |
|
123 | + $AIS = new AIS(); |
|
124 | + $MI = new MarineImport($Connection->db); |
|
125 | 125 | } |
126 | 126 | //$APRS=new APRS($Connection->db); |
127 | 127 | $SBS=new SBS(); |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | //$servertz = system('date +%Z'); |
135 | 135 | // signal handler - playing nice with sockets and dump1090 |
136 | 136 | if (function_exists('pcntl_fork')) { |
137 | - pcntl_signal(SIGINT, function() { |
|
138 | - global $sockets; |
|
139 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
140 | - die("Bye!\n"); |
|
141 | - }); |
|
142 | - pcntl_signal_dispatch(); |
|
137 | + pcntl_signal(SIGINT, function() { |
|
138 | + global $sockets; |
|
139 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
140 | + die("Bye!\n"); |
|
141 | + }); |
|
142 | + pcntl_signal_dispatch(); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // let's try and connect |
@@ -149,36 +149,36 @@ discard block |
||
149 | 149 | $reset = 0; |
150 | 150 | |
151 | 151 | function connect_all($hosts) { |
152 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
153 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
154 | - $reset++; |
|
155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
156 | - foreach ($hosts as $id => $value) { |
|
152 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
153 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
154 | + $reset++; |
|
155 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
156 | + foreach ($hosts as $id => $value) { |
|
157 | 157 | $host = $value['host']; |
158 | 158 | $globalSources[$id]['last_exec'] = 0; |
159 | 159 | // Here we check type of source(s) |
160 | 160 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
161 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
162 | - //$formats[$id] = 'deltadbtxt'; |
|
163 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
164 | - //$last_exec['deltadbtxt'] = 0; |
|
165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
166 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
167 | - //$formats[$id] = 'vatsimtxt'; |
|
168 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
169 | - //$last_exec['vatsimtxt'] = 0; |
|
170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
171 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
172 | - //$formats[$id] = 'aircraftlistjson'; |
|
173 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
174 | - //$last_exec['aircraftlistjson'] = 0; |
|
175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
176 | - } else if (preg_match('/opensky/i',$host)) { |
|
177 | - //$formats[$id] = 'aircraftlistjson'; |
|
178 | - $globalSources[$id]['format'] = 'opensky'; |
|
179 | - //$last_exec['aircraftlistjson'] = 0; |
|
180 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
181 | - /* |
|
161 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
162 | + //$formats[$id] = 'deltadbtxt'; |
|
163 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
164 | + //$last_exec['deltadbtxt'] = 0; |
|
165 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
166 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
167 | + //$formats[$id] = 'vatsimtxt'; |
|
168 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
169 | + //$last_exec['vatsimtxt'] = 0; |
|
170 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
171 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
172 | + //$formats[$id] = 'aircraftlistjson'; |
|
173 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
174 | + //$last_exec['aircraftlistjson'] = 0; |
|
175 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
176 | + } else if (preg_match('/opensky/i',$host)) { |
|
177 | + //$formats[$id] = 'aircraftlistjson'; |
|
178 | + $globalSources[$id]['format'] = 'opensky'; |
|
179 | + //$last_exec['aircraftlistjson'] = 0; |
|
180 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
181 | + /* |
|
182 | 182 | // Disabled for now, site change source format |
183 | 183 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
184 | 184 | //$formats[$id] = 'radarvirtueljson'; |
@@ -190,121 +190,121 @@ discard block |
||
190 | 190 | exit(0); |
191 | 191 | } |
192 | 192 | */ |
193 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
194 | - //$formats[$id] = 'planeupdatefaa'; |
|
195 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
196 | - //$last_exec['planeupdatefaa'] = 0; |
|
197 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
198 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
199 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
200 | - exit(0); |
|
201 | - } |
|
202 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
203 | - //$formats[$id] = 'phpvmacars'; |
|
204 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
205 | - //$last_exec['phpvmacars'] = 0; |
|
206 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
207 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
208 | - //$formats[$id] = 'phpvmacars'; |
|
209 | - $globalSources[$id]['format'] = 'vam'; |
|
210 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
211 | - } else if (preg_match('/whazzup/i',$host)) { |
|
212 | - //$formats[$id] = 'whazzup'; |
|
213 | - $globalSources[$id]['format'] = 'whazzup'; |
|
214 | - //$last_exec['whazzup'] = 0; |
|
215 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
216 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
217 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
218 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
219 | - } else if (preg_match('/airwhere/i',$host)) { |
|
220 | - $globalSources[$id]['format'] = 'airwhere'; |
|
221 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
222 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
223 | - //$formats[$id] = 'pirepsjson'; |
|
224 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
225 | - //$last_exec['pirepsjson'] = 0; |
|
226 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
227 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
228 | - //$formats[$id] = 'fr24json'; |
|
229 | - $globalSources[$id]['format'] = 'fr24json'; |
|
230 | - //$last_exec['fr24json'] = 0; |
|
231 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
232 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
233 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
234 | - exit(0); |
|
235 | - } |
|
236 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
237 | - //$formats[$id] = 'fr24json'; |
|
238 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
239 | - //$last_exec['fr24json'] = 0; |
|
240 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
241 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
242 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
243 | - exit(0); |
|
244 | - } |
|
245 | - //} else if (preg_match('/10001/',$host)) { |
|
246 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
247 | - //$formats[$id] = 'tsv'; |
|
248 | - $globalSources[$id]['format'] = 'tsv'; |
|
249 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
250 | - } |
|
251 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
252 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
253 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
254 | - if ($idf !== false) { |
|
255 | - $httpfeeds[$id] = $idf; |
|
256 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
257 | - } |
|
258 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
259 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
260 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
261 | - $hostport = explode(':',$host); |
|
262 | - if (isset($hostport[1])) { |
|
193 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
194 | + //$formats[$id] = 'planeupdatefaa'; |
|
195 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
196 | + //$last_exec['planeupdatefaa'] = 0; |
|
197 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
198 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
199 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
200 | + exit(0); |
|
201 | + } |
|
202 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
203 | + //$formats[$id] = 'phpvmacars'; |
|
204 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
205 | + //$last_exec['phpvmacars'] = 0; |
|
206 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
207 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
208 | + //$formats[$id] = 'phpvmacars'; |
|
209 | + $globalSources[$id]['format'] = 'vam'; |
|
210 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
211 | + } else if (preg_match('/whazzup/i',$host)) { |
|
212 | + //$formats[$id] = 'whazzup'; |
|
213 | + $globalSources[$id]['format'] = 'whazzup'; |
|
214 | + //$last_exec['whazzup'] = 0; |
|
215 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
216 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
217 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
218 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
219 | + } else if (preg_match('/airwhere/i',$host)) { |
|
220 | + $globalSources[$id]['format'] = 'airwhere'; |
|
221 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
222 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
223 | + //$formats[$id] = 'pirepsjson'; |
|
224 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
225 | + //$last_exec['pirepsjson'] = 0; |
|
226 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
227 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
228 | + //$formats[$id] = 'fr24json'; |
|
229 | + $globalSources[$id]['format'] = 'fr24json'; |
|
230 | + //$last_exec['fr24json'] = 0; |
|
231 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
232 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
233 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
234 | + exit(0); |
|
235 | + } |
|
236 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
237 | + //$formats[$id] = 'fr24json'; |
|
238 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
239 | + //$last_exec['fr24json'] = 0; |
|
240 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
241 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
242 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
243 | + exit(0); |
|
244 | + } |
|
245 | + //} else if (preg_match('/10001/',$host)) { |
|
246 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
247 | + //$formats[$id] = 'tsv'; |
|
248 | + $globalSources[$id]['format'] = 'tsv'; |
|
249 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
250 | + } |
|
251 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
252 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
253 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
254 | + if ($idf !== false) { |
|
255 | + $httpfeeds[$id] = $idf; |
|
256 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
257 | + } |
|
258 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
259 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
260 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
261 | + $hostport = explode(':',$host); |
|
262 | + if (isset($hostport[1])) { |
|
263 | 263 | $port = $hostport[1]; |
264 | 264 | $hostn = $hostport[0]; |
265 | - } else { |
|
265 | + } else { |
|
266 | 266 | $port = $globalSources[$id]['port']; |
267 | 267 | $hostn = $globalSources[$id]['host']; |
268 | - } |
|
269 | - $Common = new Common(); |
|
270 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
271 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
272 | - } else { |
|
273 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
274 | - } |
|
275 | - if ($s) { |
|
276 | - $sockets[$id] = $s; |
|
277 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
278 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
268 | + } |
|
269 | + $Common = new Common(); |
|
270 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
271 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
272 | + } else { |
|
273 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
274 | + } |
|
275 | + if ($s) { |
|
276 | + $sockets[$id] = $s; |
|
277 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
278 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
279 | 279 | //$formats[$id] = 'aprs'; |
280 | 280 | $globalSources[$id]['format'] = 'aprs'; |
281 | 281 | //$aprs_connect = 0; |
282 | 282 | //$use_aprs = true; |
283 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
283 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
284 | 284 | $globalSources[$id]['format'] = 'vrstcp'; |
285 | - } elseif ($port == '10001') { |
|
286 | - //$formats[$id] = 'tsv'; |
|
287 | - $globalSources[$id]['format'] = 'tsv'; |
|
288 | - } elseif ($port == '30002') { |
|
289 | - //$formats[$id] = 'raw'; |
|
290 | - $globalSources[$id]['format'] = 'raw'; |
|
291 | - } elseif ($port == '5001') { |
|
292 | - //$formats[$id] = 'raw'; |
|
293 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
294 | - } elseif ($port == '30005') { |
|
285 | + } elseif ($port == '10001') { |
|
286 | + //$formats[$id] = 'tsv'; |
|
287 | + $globalSources[$id]['format'] = 'tsv'; |
|
288 | + } elseif ($port == '30002') { |
|
289 | + //$formats[$id] = 'raw'; |
|
290 | + $globalSources[$id]['format'] = 'raw'; |
|
291 | + } elseif ($port == '5001') { |
|
292 | + //$formats[$id] = 'raw'; |
|
293 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
294 | + } elseif ($port == '30005') { |
|
295 | 295 | // Not yet supported |
296 | - //$formats[$id] = 'beast'; |
|
297 | - $globalSources[$id]['format'] = 'beast'; |
|
298 | - //} else $formats[$id] = 'sbs'; |
|
299 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
300 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
296 | + //$formats[$id] = 'beast'; |
|
297 | + $globalSources[$id]['format'] = 'beast'; |
|
298 | + //} else $formats[$id] = 'sbs'; |
|
299 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
300 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
301 | 301 | } |
302 | 302 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
303 | - } else { |
|
303 | + } else { |
|
304 | 304 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
305 | - } |
|
306 | - } |
|
307 | - } |
|
305 | + } |
|
306 | + } |
|
307 | + } |
|
308 | 308 | } |
309 | 309 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
310 | 310 | |
@@ -327,9 +327,9 @@ discard block |
||
327 | 327 | //connect_all($globalSources); |
328 | 328 | |
329 | 329 | if (isset($globalProxy) && $globalProxy) { |
330 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
330 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
331 | 331 | } else { |
332 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
332 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | // APRS Configuration |
@@ -338,21 +338,21 @@ discard block |
||
338 | 338 | die; |
339 | 339 | } |
340 | 340 | foreach ($globalSources as $key => $source) { |
341 | - if (!isset($source['format'])) { |
|
342 | - $globalSources[$key]['format'] = 'auto'; |
|
343 | - } |
|
344 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
345 | - unset($globalSources[$key]); |
|
346 | - } |
|
341 | + if (!isset($source['format'])) { |
|
342 | + $globalSources[$key]['format'] = 'auto'; |
|
343 | + } |
|
344 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
345 | + unset($globalSources[$key]); |
|
346 | + } |
|
347 | 347 | } |
348 | 348 | connect_all($globalSources); |
349 | 349 | foreach ($globalSources as $key => $source) { |
350 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
350 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
351 | 351 | $aprs_connect = 0; |
352 | 352 | $use_aprs = true; |
353 | 353 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
354 | 354 | break; |
355 | - } |
|
355 | + } |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | if ($use_aprs) { |
@@ -393,126 +393,126 @@ discard block |
||
393 | 393 | |
394 | 394 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
395 | 395 | while ($i > 0) { |
396 | - if (!$globalDaemon) $i = $endtime-time(); |
|
397 | - // Delete old ATC |
|
398 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
396 | + if (!$globalDaemon) $i = $endtime-time(); |
|
397 | + // Delete old ATC |
|
398 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
399 | 399 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
400 | - $ATC->deleteOldATC(); |
|
401 | - } |
|
400 | + $ATC->deleteOldATC(); |
|
401 | + } |
|
402 | 402 | |
403 | - if (count($last_exec) == count($globalSources)) { |
|
403 | + if (count($last_exec) == count($globalSources)) { |
|
404 | 404 | $max = $globalMinFetch; |
405 | 405 | foreach ($last_exec as $last) { |
406 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
406 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
407 | 407 | } |
408 | 408 | if ($max != $globalMinFetch) { |
409 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
410 | - sleep($globalMinFetch-$max+2); |
|
409 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
410 | + sleep($globalMinFetch-$max+2); |
|
411 | + } |
|
411 | 412 | } |
412 | - } |
|
413 | 413 | |
414 | 414 | |
415 | - //foreach ($formats as $id => $value) { |
|
416 | - foreach ($globalSources as $id => $value) { |
|
415 | + //foreach ($formats as $id => $value) { |
|
416 | + foreach ($globalSources as $id => $value) { |
|
417 | 417 | date_default_timezone_set('UTC'); |
418 | 418 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
419 | 419 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
420 | 420 | if ($value['format'] == 'deltadbtxt' && |
421 | - ( |
|
421 | + ( |
|
422 | 422 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
423 | 423 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
424 | - ) |
|
424 | + ) |
|
425 | 425 | ) { |
426 | - //$buffer = $Common->getData($hosts[$id]); |
|
427 | - $buffer = $Common->getData($value['host']); |
|
428 | - if ($buffer != '') $reset = 0; |
|
429 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
430 | - $buffer = explode('\n',$buffer); |
|
431 | - foreach ($buffer as $line) { |
|
432 | - if ($line != '' && count($line) > 7) { |
|
433 | - $line = explode(',', $line); |
|
434 | - $data = array(); |
|
435 | - $data['hex'] = $line[1]; // hex |
|
436 | - $data['ident'] = $line[2]; // ident |
|
437 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
438 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
439 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
440 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
441 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
442 | - $data['verticalrate'] = ''; // vertical rate |
|
443 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
444 | - $data['emergency'] = ''; // emergency |
|
445 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
446 | - $data['format_source'] = 'deltadbtxt'; |
|
447 | - $data['id_source'] = $id_source; |
|
448 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
449 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
450 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
451 | - $SI->add($data); |
|
452 | - unset($data); |
|
453 | - } |
|
454 | - } |
|
455 | - $last_exec[$id]['last'] = time(); |
|
426 | + //$buffer = $Common->getData($hosts[$id]); |
|
427 | + $buffer = $Common->getData($value['host']); |
|
428 | + if ($buffer != '') $reset = 0; |
|
429 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
430 | + $buffer = explode('\n',$buffer); |
|
431 | + foreach ($buffer as $line) { |
|
432 | + if ($line != '' && count($line) > 7) { |
|
433 | + $line = explode(',', $line); |
|
434 | + $data = array(); |
|
435 | + $data['hex'] = $line[1]; // hex |
|
436 | + $data['ident'] = $line[2]; // ident |
|
437 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
438 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
439 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
440 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
441 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
442 | + $data['verticalrate'] = ''; // vertical rate |
|
443 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
444 | + $data['emergency'] = ''; // emergency |
|
445 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
446 | + $data['format_source'] = 'deltadbtxt'; |
|
447 | + $data['id_source'] = $id_source; |
|
448 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
449 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
450 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
451 | + $SI->add($data); |
|
452 | + unset($data); |
|
453 | + } |
|
454 | + } |
|
455 | + $last_exec[$id]['last'] = time(); |
|
456 | 456 | } elseif ($value['format'] == 'aisnmeatxt' && |
457 | - ( |
|
457 | + ( |
|
458 | 458 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
459 | 459 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
460 | - ) |
|
460 | + ) |
|
461 | 461 | ) { |
462 | - date_default_timezone_set('CET'); |
|
463 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
464 | - date_default_timezone_set('UTC'); |
|
465 | - if ($buffer != '') $reset = 0; |
|
466 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
467 | - $buffer = explode('\n',$buffer); |
|
468 | - foreach ($buffer as $line) { |
|
462 | + date_default_timezone_set('CET'); |
|
463 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
464 | + date_default_timezone_set('UTC'); |
|
465 | + if ($buffer != '') $reset = 0; |
|
466 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
467 | + $buffer = explode('\n',$buffer); |
|
468 | + foreach ($buffer as $line) { |
|
469 | 469 | if ($line != '') { |
470 | - //echo "'".$line."'\n"; |
|
471 | - $add = false; |
|
472 | - $ais_data = $AIS->parse_line(trim($line)); |
|
473 | - $data = array(); |
|
474 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
475 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
476 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
477 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
478 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
479 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
480 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
481 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
482 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
483 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
484 | - if (isset($ais_data['timestamp'])) { |
|
470 | + //echo "'".$line."'\n"; |
|
471 | + $add = false; |
|
472 | + $ais_data = $AIS->parse_line(trim($line)); |
|
473 | + $data = array(); |
|
474 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
475 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
476 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
477 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
478 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
479 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
480 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
481 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
482 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
483 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
484 | + if (isset($ais_data['timestamp'])) { |
|
485 | 485 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
486 | 486 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
487 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
488 | - $add = true; |
|
487 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
488 | + $add = true; |
|
489 | 489 | } |
490 | - } else { |
|
490 | + } else { |
|
491 | 491 | $data['datetime'] = date('Y-m-d H:i:s'); |
492 | 492 | $add = true; |
493 | - } |
|
494 | - $data['format_source'] = 'aisnmeatxt'; |
|
495 | - $data['id_source'] = $id_source; |
|
496 | - //print_r($data); |
|
497 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
498 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
499 | - unset($data); |
|
493 | + } |
|
494 | + $data['format_source'] = 'aisnmeatxt'; |
|
495 | + $data['id_source'] = $id_source; |
|
496 | + //print_r($data); |
|
497 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
498 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
499 | + unset($data); |
|
500 | 500 | } |
501 | - } |
|
502 | - $last_exec[$id]['last'] = time(); |
|
501 | + } |
|
502 | + $last_exec[$id]['last'] = time(); |
|
503 | 503 | } elseif ($value['format'] == 'aisnmeahttp') { |
504 | - $arr = $httpfeeds; |
|
505 | - $w = $e = null; |
|
504 | + $arr = $httpfeeds; |
|
505 | + $w = $e = null; |
|
506 | 506 | |
507 | - if (isset($arr[$id])) { |
|
507 | + if (isset($arr[$id])) { |
|
508 | 508 | $nn = stream_select($arr,$w,$e,$timeout); |
509 | 509 | if ($nn > 0) { |
510 | - foreach ($httpfeeds as $feed) { |
|
510 | + foreach ($httpfeeds as $feed) { |
|
511 | 511 | $buffer = stream_get_line($feed,2000,"\n"); |
512 | 512 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
513 | 513 | $buffer = explode('\n',$buffer); |
514 | 514 | foreach ($buffer as $line) { |
515 | - if ($line != '') { |
|
515 | + if ($line != '') { |
|
516 | 516 | $ais_data = $AIS->parse_line(trim($line)); |
517 | 517 | $data = array(); |
518 | 518 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -530,114 +530,114 @@ discard block |
||
530 | 530 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
531 | 531 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
532 | 532 | if (isset($ais_data['timestamp'])) { |
533 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
533 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
534 | 534 | } else { |
535 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
535 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
536 | 536 | } |
537 | 537 | $data['format_source'] = 'aisnmeahttp'; |
538 | 538 | $data['id_source'] = $id_source; |
539 | 539 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
540 | 540 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
541 | 541 | unset($data); |
542 | - } |
|
542 | + } |
|
543 | + } |
|
543 | 544 | } |
544 | - } |
|
545 | 545 | } else { |
546 | - $format = $value['format']; |
|
547 | - if (isset($tt[$format])) $tt[$format]++; |
|
548 | - else $tt[$format] = 0; |
|
549 | - if ($tt[$format] > 30) { |
|
546 | + $format = $value['format']; |
|
547 | + if (isset($tt[$format])) $tt[$format]++; |
|
548 | + else $tt[$format] = 0; |
|
549 | + if ($tt[$format] > 30) { |
|
550 | 550 | if ($globalDebug) echo 'Reconnect...'."\n"; |
551 | 551 | sleep(2); |
552 | 552 | $sourceeen[] = $value; |
553 | 553 | connect_all($sourceeen); |
554 | 554 | $sourceeen = array(); |
555 | - } |
|
555 | + } |
|
556 | + } |
|
556 | 557 | } |
557 | - } |
|
558 | 558 | } elseif ($value['format'] == 'myshiptracking' && |
559 | - ( |
|
559 | + ( |
|
560 | 560 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
561 | 561 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
562 | - ) |
|
562 | + ) |
|
563 | 563 | ) { |
564 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
565 | - if ($buffer != '') { |
|
564 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
565 | + if ($buffer != '') { |
|
566 | 566 | //echo $buffer; |
567 | 567 | $all_data = json_decode($buffer,true); |
568 | 568 | //print_r($all_data); |
569 | 569 | if (isset($all_data[0]['DATA'])) { |
570 | - foreach ($all_data[0]['DATA'] as $line) { |
|
570 | + foreach ($all_data[0]['DATA'] as $line) { |
|
571 | 571 | if ($line != '') { |
572 | - $data = array(); |
|
573 | - $data['ident'] = $line['NAME']; |
|
574 | - $data['mmsi'] = $line['MMSI']; |
|
575 | - if (strlen($data['mmsi']) > 9) { |
|
572 | + $data = array(); |
|
573 | + $data['ident'] = $line['NAME']; |
|
574 | + $data['mmsi'] = $line['MMSI']; |
|
575 | + if (strlen($data['mmsi']) > 9) { |
|
576 | 576 | $data['mmsi'] = substr($data['mmsi'],-9); |
577 | - } |
|
578 | - $data['speed'] = $line['SOG']; |
|
579 | - $data['heading'] = $line['COG']; |
|
580 | - $data['latitude'] = $line['LAT']; |
|
581 | - $data['longitude'] = $line['LNG']; |
|
582 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
583 | - $data['imo'] = $line['IMO']; |
|
584 | - //$data['arrival_code'] = $ais_data['destination']; |
|
585 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
586 | - $data['format_source'] = 'myshiptracking'; |
|
587 | - $data['id_source'] = $id_source; |
|
588 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
589 | - $MI->add($data); |
|
590 | - unset($data); |
|
577 | + } |
|
578 | + $data['speed'] = $line['SOG']; |
|
579 | + $data['heading'] = $line['COG']; |
|
580 | + $data['latitude'] = $line['LAT']; |
|
581 | + $data['longitude'] = $line['LNG']; |
|
582 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
583 | + $data['imo'] = $line['IMO']; |
|
584 | + //$data['arrival_code'] = $ais_data['destination']; |
|
585 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
586 | + $data['format_source'] = 'myshiptracking'; |
|
587 | + $data['id_source'] = $id_source; |
|
588 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
589 | + $MI->add($data); |
|
590 | + unset($data); |
|
591 | 591 | } |
592 | - } |
|
592 | + } |
|
593 | + } |
|
593 | 594 | } |
594 | - } |
|
595 | - $last_exec[$id]['last'] = time(); |
|
595 | + $last_exec[$id]['last'] = time(); |
|
596 | 596 | } elseif ($value['format'] == 'boatbeaconapp' && |
597 | - ( |
|
597 | + ( |
|
598 | 598 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
599 | 599 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
600 | - ) |
|
600 | + ) |
|
601 | 601 | ) { |
602 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
603 | - if ($buffer != '') { |
|
602 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
603 | + if ($buffer != '') { |
|
604 | 604 | $all_data = json_decode($buffer,true); |
605 | 605 | if (isset($all_data[0]['mmsi'])) { |
606 | - foreach ($all_data as $line) { |
|
606 | + foreach ($all_data as $line) { |
|
607 | 607 | if ($line != '') { |
608 | - $data = array(); |
|
609 | - $data['ident'] = $line['shipname']; |
|
610 | - $data['callsign'] = $line['callsign']; |
|
611 | - $data['mmsi'] = $line['mmsi']; |
|
612 | - $data['speed'] = $line['sog']; |
|
613 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
614 | - $data['latitude'] = $line['latitude']; |
|
615 | - $data['longitude'] = $line['longitude']; |
|
616 | - $data['type_id'] = $line['shiptype']; |
|
617 | - $data['arrival_code'] = $line['destination']; |
|
618 | - $data['datetime'] = $line['time']; |
|
619 | - $data['format_source'] = 'boatbeaconapp'; |
|
620 | - $data['id_source'] = $id_source; |
|
621 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
622 | - $MI->add($data); |
|
623 | - unset($data); |
|
608 | + $data = array(); |
|
609 | + $data['ident'] = $line['shipname']; |
|
610 | + $data['callsign'] = $line['callsign']; |
|
611 | + $data['mmsi'] = $line['mmsi']; |
|
612 | + $data['speed'] = $line['sog']; |
|
613 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
614 | + $data['latitude'] = $line['latitude']; |
|
615 | + $data['longitude'] = $line['longitude']; |
|
616 | + $data['type_id'] = $line['shiptype']; |
|
617 | + $data['arrival_code'] = $line['destination']; |
|
618 | + $data['datetime'] = $line['time']; |
|
619 | + $data['format_source'] = 'boatbeaconapp'; |
|
620 | + $data['id_source'] = $id_source; |
|
621 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
622 | + $MI->add($data); |
|
623 | + unset($data); |
|
624 | + } |
|
624 | 625 | } |
625 | - } |
|
626 | 626 | } |
627 | 627 | |
628 | - } |
|
629 | - $last_exec[$id]['last'] = time(); |
|
628 | + } |
|
629 | + $last_exec[$id]['last'] = time(); |
|
630 | 630 | } elseif ($value['format'] == 'boatnerd' && |
631 | - ( |
|
631 | + ( |
|
632 | 632 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
633 | 633 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
634 | - ) |
|
634 | + ) |
|
635 | 635 | ) { |
636 | - $buffer = $Common->getData($value['host']); |
|
637 | - if ($buffer != '') { |
|
636 | + $buffer = $Common->getData($value['host']); |
|
637 | + if ($buffer != '') { |
|
638 | 638 | $all_data = json_decode($buffer,true); |
639 | 639 | if (isset($all_data['features'][0]['id'])) { |
640 | - foreach ($all_data['features'] as $line) { |
|
640 | + foreach ($all_data['features'] as $line) { |
|
641 | 641 | $data = array(); |
642 | 642 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
643 | 643 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -656,78 +656,78 @@ discard block |
||
656 | 656 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
657 | 657 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
658 | 658 | unset($data); |
659 | - } |
|
659 | + } |
|
660 | 660 | } |
661 | 661 | |
662 | - } |
|
663 | - $last_exec[$id]['last'] = time(); |
|
662 | + } |
|
663 | + $last_exec[$id]['last'] = time(); |
|
664 | 664 | } elseif ($value['format'] == 'shipplotter' && |
665 | - ( |
|
665 | + ( |
|
666 | 666 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
667 | 667 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
668 | - ) |
|
668 | + ) |
|
669 | 669 | ) { |
670 | - echo 'download...'; |
|
671 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
672 | - echo 'done !'."\n"; |
|
673 | - if ($buffer != '') $reset = 0; |
|
674 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
675 | - $buffer = explode('\n',$buffer); |
|
676 | - foreach ($buffer as $line) { |
|
670 | + echo 'download...'; |
|
671 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
672 | + echo 'done !'."\n"; |
|
673 | + if ($buffer != '') $reset = 0; |
|
674 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
675 | + $buffer = explode('\n',$buffer); |
|
676 | + foreach ($buffer as $line) { |
|
677 | 677 | if ($line != '') { |
678 | - $data = array(); |
|
679 | - $data['mmsi'] = (int)substr($line,0,9); |
|
680 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
681 | - //$data['status'] = substr($line,21,2); |
|
682 | - //$data['type'] = substr($line,24,3); |
|
683 | - $data['latitude'] = substr($line,29,9); |
|
684 | - $data['longitude'] = substr($line,41,9); |
|
685 | - $data['speed'] = round(substr($line,51,5)); |
|
686 | - //$data['course'] = substr($line,57,5); |
|
687 | - $data['heading'] = round(substr($line,63,3)); |
|
688 | - //$data['draft'] = substr($line,67,4); |
|
689 | - //$data['length'] = substr($line,72,3); |
|
690 | - //$data['beam'] = substr($line,76,2); |
|
691 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
692 | - //$data['callsign'] = trim(substr($line,100,7); |
|
693 | - //$data['dest'] = substr($line,108,20); |
|
694 | - //$data['etaDate'] = substr($line,129,5); |
|
695 | - //$data['etaTime'] = substr($line,135,5); |
|
696 | - $data['format_source'] = 'shipplotter'; |
|
697 | - $data['id_source'] = $id_source; |
|
698 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
699 | - //print_r($data); |
|
700 | - echo 'Add...'."\n"; |
|
701 | - $MI->add($data); |
|
702 | - unset($data); |
|
678 | + $data = array(); |
|
679 | + $data['mmsi'] = (int)substr($line,0,9); |
|
680 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
681 | + //$data['status'] = substr($line,21,2); |
|
682 | + //$data['type'] = substr($line,24,3); |
|
683 | + $data['latitude'] = substr($line,29,9); |
|
684 | + $data['longitude'] = substr($line,41,9); |
|
685 | + $data['speed'] = round(substr($line,51,5)); |
|
686 | + //$data['course'] = substr($line,57,5); |
|
687 | + $data['heading'] = round(substr($line,63,3)); |
|
688 | + //$data['draft'] = substr($line,67,4); |
|
689 | + //$data['length'] = substr($line,72,3); |
|
690 | + //$data['beam'] = substr($line,76,2); |
|
691 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
692 | + //$data['callsign'] = trim(substr($line,100,7); |
|
693 | + //$data['dest'] = substr($line,108,20); |
|
694 | + //$data['etaDate'] = substr($line,129,5); |
|
695 | + //$data['etaTime'] = substr($line,135,5); |
|
696 | + $data['format_source'] = 'shipplotter'; |
|
697 | + $data['id_source'] = $id_source; |
|
698 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
699 | + //print_r($data); |
|
700 | + echo 'Add...'."\n"; |
|
701 | + $MI->add($data); |
|
702 | + unset($data); |
|
703 | 703 | } |
704 | - } |
|
705 | - $last_exec[$id]['last'] = time(); |
|
704 | + } |
|
705 | + $last_exec[$id]['last'] = time(); |
|
706 | 706 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
707 | 707 | } elseif ( |
708 | - ( |
|
708 | + ( |
|
709 | 709 | $value['format'] == 'whazzup' && |
710 | 710 | ( |
711 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
712 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
711 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
712 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
713 | 713 | ) |
714 | - ) || ( |
|
714 | + ) || ( |
|
715 | 715 | $value['format'] == 'vatsimtxt' && |
716 | 716 | ( |
717 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
718 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
717 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
718 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
719 | + ) |
|
719 | 720 | ) |
720 | - ) |
|
721 | 721 | ) { |
722 | - //$buffer = $Common->getData($hosts[$id]); |
|
723 | - $buffer = $Common->getData($value['host']); |
|
724 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
725 | - $buffer = explode('\n',$buffer); |
|
726 | - $reset = 0; |
|
727 | - foreach ($buffer as $line) { |
|
728 | - if ($line != '') { |
|
729 | - $line = explode(':', $line); |
|
730 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
722 | + //$buffer = $Common->getData($hosts[$id]); |
|
723 | + $buffer = $Common->getData($value['host']); |
|
724 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
725 | + $buffer = explode('\n',$buffer); |
|
726 | + $reset = 0; |
|
727 | + foreach ($buffer as $line) { |
|
728 | + if ($line != '') { |
|
729 | + $line = explode(':', $line); |
|
730 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
731 | 731 | $data = array(); |
732 | 732 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
733 | 733 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -740,37 +740,37 @@ discard block |
||
740 | 740 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
741 | 741 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
742 | 742 | $data['latitude'] = $line[5]; // lat |
743 | - $data['longitude'] = $line[6]; // long |
|
744 | - $data['verticalrate'] = ''; // vertical rate |
|
745 | - $data['squawk'] = ''; // squawk |
|
746 | - $data['emergency'] = ''; // emergency |
|
747 | - $data['waypoints'] = $line[30]; |
|
743 | + $data['longitude'] = $line[6]; // long |
|
744 | + $data['verticalrate'] = ''; // vertical rate |
|
745 | + $data['squawk'] = ''; // squawk |
|
746 | + $data['emergency'] = ''; // emergency |
|
747 | + $data['waypoints'] = $line[30]; |
|
748 | 748 | $data['datetime'] = date('Y-m-d H:i:s'); |
749 | 749 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
750 | 750 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
751 | - $data['departure_airport_icao'] = $line[11]; |
|
752 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
753 | - $data['arrival_airport_icao'] = $line[13]; |
|
751 | + $data['departure_airport_icao'] = $line[11]; |
|
752 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
753 | + $data['arrival_airport_icao'] = $line[13]; |
|
754 | 754 | $data['frequency'] = $line[4]; |
755 | 755 | $data['type'] = $line[18]; |
756 | 756 | $data['range'] = $line[19]; |
757 | 757 | if (isset($line[35])) $data['info'] = $line[35]; |
758 | - $data['id_source'] = $id_source; |
|
759 | - //$data['arrival_airport_time'] = ; |
|
760 | - if ($line[9] != '') { |
|
761 | - $aircraft_data = explode('/',$line[9]); |
|
762 | - if (isset($aircraft_data[1])) { |
|
763 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
764 | - } |
|
765 | - } |
|
766 | - /* |
|
758 | + $data['id_source'] = $id_source; |
|
759 | + //$data['arrival_airport_time'] = ; |
|
760 | + if ($line[9] != '') { |
|
761 | + $aircraft_data = explode('/',$line[9]); |
|
762 | + if (isset($aircraft_data[1])) { |
|
763 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
764 | + } |
|
765 | + } |
|
766 | + /* |
|
767 | 767 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
768 | 768 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
769 | 769 | */ |
770 | - $data['format_source'] = $value['format']; |
|
770 | + $data['format_source'] = $value['format']; |
|
771 | 771 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
772 | 772 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
773 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
773 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
774 | 774 | elseif ($line[3] == 'ATC') { |
775 | 775 | //print_r($data); |
776 | 776 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -791,21 +791,21 @@ discard block |
||
791 | 791 | else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
792 | 792 | } |
793 | 793 | } |
794 | - unset($data); |
|
795 | - } |
|
796 | - } |
|
797 | - } |
|
798 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
799 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
800 | - $last_exec[$id]['last'] = time(); |
|
801 | - } elseif ($value['format'] == 'airwhere' && |
|
802 | - ( |
|
803 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
804 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
805 | - ) |
|
806 | - ) { |
|
807 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
808 | - if ($buffer != '') { |
|
794 | + unset($data); |
|
795 | + } |
|
796 | + } |
|
797 | + } |
|
798 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
799 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
800 | + $last_exec[$id]['last'] = time(); |
|
801 | + } elseif ($value['format'] == 'airwhere' && |
|
802 | + ( |
|
803 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
804 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
805 | + ) |
|
806 | + ) { |
|
807 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
808 | + if ($buffer != '') { |
|
809 | 809 | $all_data = simplexml_load_string($buffer); |
810 | 810 | foreach($all_data->children() as $childdata) { |
811 | 811 | $data = array(); |
@@ -827,10 +827,10 @@ discard block |
||
827 | 827 | $SI->add($data); |
828 | 828 | unset($data); |
829 | 829 | } |
830 | - } |
|
831 | - $Source->deleteOldLocationByType('gs'); |
|
832 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
833 | - if ($buffer != '') { |
|
830 | + } |
|
831 | + $Source->deleteOldLocationByType('gs'); |
|
832 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
833 | + if ($buffer != '') { |
|
834 | 834 | $all_data = simplexml_load_string($buffer); |
835 | 835 | foreach($all_data->children() as $childdata) { |
836 | 836 | $data = array(); |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | } |
849 | 849 | unset($data); |
850 | 850 | } |
851 | - } |
|
852 | - $last_exec[$id]['last'] = time(); |
|
851 | + } |
|
852 | + $last_exec[$id]['last'] = time(); |
|
853 | 853 | /* |
854 | 854 | } if ($value['format'] == 'aircraftlistjson') { |
855 | 855 | print_r($globalSources); |
@@ -857,17 +857,17 @@ discard block |
||
857 | 857 | echo $globalMinFetch; |
858 | 858 | */ |
859 | 859 | } elseif ($value['format'] == 'aircraftlistjson' && |
860 | - ( |
|
860 | + ( |
|
861 | 861 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
862 | 862 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
863 | - ) |
|
863 | + ) |
|
864 | 864 | ) { |
865 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
866 | - if ($buffer != '') { |
|
867 | - $all_data = json_decode($buffer,true); |
|
865 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
866 | + if ($buffer != '') { |
|
867 | + $all_data = json_decode($buffer,true); |
|
868 | 868 | if (isset($all_data['acList'])) { |
869 | - $reset = 0; |
|
870 | - foreach ($all_data['acList'] as $line) { |
|
869 | + $reset = 0; |
|
870 | + foreach ($all_data['acList'] as $line) { |
|
871 | 871 | $data = array(); |
872 | 872 | $data['hex'] = $line['Icao']; // hex |
873 | 873 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -890,10 +890,10 @@ discard block |
||
890 | 890 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
891 | 891 | if (isset($data['latitude'])) $SI->add($data); |
892 | 892 | unset($data); |
893 | - } |
|
893 | + } |
|
894 | 894 | } elseif (is_array($all_data)) { |
895 | - $reset = 0; |
|
896 | - foreach ($all_data as $line) { |
|
895 | + $reset = 0; |
|
896 | + foreach ($all_data as $line) { |
|
897 | 897 | $data = array(); |
898 | 898 | $data['hex'] = $line['hex']; // hex |
899 | 899 | $data['ident'] = $line['flight']; // ident |
@@ -913,218 +913,218 @@ discard block |
||
913 | 913 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
914 | 914 | $SI->add($data); |
915 | 915 | unset($data); |
916 | - } |
|
916 | + } |
|
917 | 917 | } |
918 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
919 | - //$last_exec['aircraftlistjson'] = time(); |
|
920 | - $last_exec[$id]['last'] = time(); |
|
921 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
922 | - } elseif ($value['format'] == 'planeupdatefaa' && |
|
923 | - ( |
|
924 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
925 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
926 | - ) |
|
927 | - ) { |
|
928 | - $buffer = $Common->getData($value['host']); |
|
929 | - $all_data = json_decode($buffer,true); |
|
930 | - if (isset($all_data['planes'])) { |
|
918 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
919 | + //$last_exec['aircraftlistjson'] = time(); |
|
920 | + $last_exec[$id]['last'] = time(); |
|
921 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
922 | + } elseif ($value['format'] == 'planeupdatefaa' && |
|
923 | + ( |
|
924 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
925 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
926 | + ) |
|
927 | + ) { |
|
928 | + $buffer = $Common->getData($value['host']); |
|
929 | + $all_data = json_decode($buffer,true); |
|
930 | + if (isset($all_data['planes'])) { |
|
931 | 931 | $reset = 0; |
932 | 932 | foreach ($all_data['planes'] as $key => $line) { |
933 | - $data = array(); |
|
934 | - $data['hex'] = $key; // hex |
|
935 | - $data['ident'] = $line[3]; // ident |
|
936 | - $data['altitude'] = $line[6]; // altitude |
|
937 | - $data['speed'] = $line[8]; // speed |
|
938 | - $data['heading'] = $line[7]; // heading |
|
939 | - $data['latitude'] = $line[4]; // lat |
|
940 | - $data['longitude'] = $line[5]; // long |
|
941 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
942 | - $data['squawk'] = $line[10]; // squawk |
|
943 | - $data['emergency'] = ''; // emergency |
|
944 | - $data['registration'] = $line[2]; |
|
945 | - $data['aircraft_icao'] = $line[0]; |
|
946 | - $deparr = explode('-',$line[1]); |
|
947 | - if (count($deparr) == 2) { |
|
933 | + $data = array(); |
|
934 | + $data['hex'] = $key; // hex |
|
935 | + $data['ident'] = $line[3]; // ident |
|
936 | + $data['altitude'] = $line[6]; // altitude |
|
937 | + $data['speed'] = $line[8]; // speed |
|
938 | + $data['heading'] = $line[7]; // heading |
|
939 | + $data['latitude'] = $line[4]; // lat |
|
940 | + $data['longitude'] = $line[5]; // long |
|
941 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
942 | + $data['squawk'] = $line[10]; // squawk |
|
943 | + $data['emergency'] = ''; // emergency |
|
944 | + $data['registration'] = $line[2]; |
|
945 | + $data['aircraft_icao'] = $line[0]; |
|
946 | + $deparr = explode('-',$line[1]); |
|
947 | + if (count($deparr) == 2) { |
|
948 | 948 | $data['departure_airport_icao'] = $deparr[0]; |
949 | 949 | $data['arrival_airport_icao'] = $deparr[1]; |
950 | - } |
|
951 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
952 | - $data['format_source'] = 'planeupdatefaa'; |
|
953 | - $data['id_source'] = $id_source; |
|
954 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
955 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
956 | - $SI->add($data); |
|
957 | - unset($data); |
|
950 | + } |
|
951 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
952 | + $data['format_source'] = 'planeupdatefaa'; |
|
953 | + $data['id_source'] = $id_source; |
|
954 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
955 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
956 | + $SI->add($data); |
|
957 | + unset($data); |
|
958 | + } |
|
958 | 959 | } |
959 | - } |
|
960 | - //$last_exec['planeupdatefaa'] = time(); |
|
961 | - $last_exec[$id]['last'] = time(); |
|
960 | + //$last_exec['planeupdatefaa'] = time(); |
|
961 | + $last_exec[$id]['last'] = time(); |
|
962 | 962 | } elseif ($value['format'] == 'opensky' && |
963 | - ( |
|
963 | + ( |
|
964 | 964 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
965 | 965 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
966 | - ) |
|
966 | + ) |
|
967 | 967 | ) { |
968 | - $buffer = $Common->getData($value['host']); |
|
969 | - $all_data = json_decode($buffer,true); |
|
970 | - if (isset($all_data['states'])) { |
|
968 | + $buffer = $Common->getData($value['host']); |
|
969 | + $all_data = json_decode($buffer,true); |
|
970 | + if (isset($all_data['states'])) { |
|
971 | 971 | $reset = 0; |
972 | 972 | foreach ($all_data['states'] as $key => $line) { |
973 | - $data = array(); |
|
974 | - $data['hex'] = $line[0]; // hex |
|
975 | - $data['ident'] = trim($line[1]); // ident |
|
976 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
977 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
978 | - $data['heading'] = round($line[10]); // heading |
|
979 | - $data['latitude'] = $line[6]; // lat |
|
980 | - $data['longitude'] = $line[5]; // long |
|
981 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
982 | - //$data['squawk'] = $line[10]; // squawk |
|
983 | - //$data['emergency'] = ''; // emergency |
|
984 | - //$data['registration'] = $line[2]; |
|
985 | - //$data['aircraft_icao'] = $line[0]; |
|
986 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
987 | - $data['format_source'] = 'opensky'; |
|
988 | - $data['id_source'] = $id_source; |
|
989 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
990 | - $SI->add($data); |
|
991 | - unset($data); |
|
973 | + $data = array(); |
|
974 | + $data['hex'] = $line[0]; // hex |
|
975 | + $data['ident'] = trim($line[1]); // ident |
|
976 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
977 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
978 | + $data['heading'] = round($line[10]); // heading |
|
979 | + $data['latitude'] = $line[6]; // lat |
|
980 | + $data['longitude'] = $line[5]; // long |
|
981 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
982 | + //$data['squawk'] = $line[10]; // squawk |
|
983 | + //$data['emergency'] = ''; // emergency |
|
984 | + //$data['registration'] = $line[2]; |
|
985 | + //$data['aircraft_icao'] = $line[0]; |
|
986 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
987 | + $data['format_source'] = 'opensky'; |
|
988 | + $data['id_source'] = $id_source; |
|
989 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
990 | + $SI->add($data); |
|
991 | + unset($data); |
|
992 | 992 | } |
993 | - } |
|
994 | - //$last_exec['planeupdatefaa'] = time(); |
|
995 | - $last_exec[$id]['last'] = time(); |
|
993 | + } |
|
994 | + //$last_exec['planeupdatefaa'] = time(); |
|
995 | + $last_exec[$id]['last'] = time(); |
|
996 | 996 | //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
997 | 997 | } elseif ($value['format'] == 'fr24json' && |
998 | - ( |
|
998 | + ( |
|
999 | 999 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1000 | 1000 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1001 | - ) |
|
1001 | + ) |
|
1002 | 1002 | ) { |
1003 | - //$buffer = $Common->getData($hosts[$id]); |
|
1004 | - $buffer = $Common->getData($value['host']); |
|
1005 | - $all_data = json_decode($buffer,true); |
|
1006 | - if (!empty($all_data)) $reset = 0; |
|
1007 | - foreach ($all_data as $key => $line) { |
|
1003 | + //$buffer = $Common->getData($hosts[$id]); |
|
1004 | + $buffer = $Common->getData($value['host']); |
|
1005 | + $all_data = json_decode($buffer,true); |
|
1006 | + if (!empty($all_data)) $reset = 0; |
|
1007 | + foreach ($all_data as $key => $line) { |
|
1008 | 1008 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1009 | - $data = array(); |
|
1010 | - $data['hex'] = $line[0]; |
|
1011 | - $data['ident'] = $line[16]; //$line[13] |
|
1012 | - $data['altitude'] = $line[4]; // altitude |
|
1013 | - $data['speed'] = $line[5]; // speed |
|
1014 | - $data['heading'] = $line[3]; // heading |
|
1015 | - $data['latitude'] = $line[1]; // lat |
|
1016 | - $data['longitude'] = $line[2]; // long |
|
1017 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
1018 | - $data['squawk'] = $line[6]; // squawk |
|
1019 | - $data['aircraft_icao'] = $line[8]; |
|
1020 | - $data['registration'] = $line[9]; |
|
1021 | - $data['departure_airport_iata'] = $line[11]; |
|
1022 | - $data['arrival_airport_iata'] = $line[12]; |
|
1023 | - $data['emergency'] = ''; // emergency |
|
1024 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1025 | - $data['format_source'] = 'fr24json'; |
|
1026 | - $data['id_source'] = $id_source; |
|
1027 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1028 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1029 | - $SI->add($data); |
|
1030 | - unset($data); |
|
1009 | + $data = array(); |
|
1010 | + $data['hex'] = $line[0]; |
|
1011 | + $data['ident'] = $line[16]; //$line[13] |
|
1012 | + $data['altitude'] = $line[4]; // altitude |
|
1013 | + $data['speed'] = $line[5]; // speed |
|
1014 | + $data['heading'] = $line[3]; // heading |
|
1015 | + $data['latitude'] = $line[1]; // lat |
|
1016 | + $data['longitude'] = $line[2]; // long |
|
1017 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
1018 | + $data['squawk'] = $line[6]; // squawk |
|
1019 | + $data['aircraft_icao'] = $line[8]; |
|
1020 | + $data['registration'] = $line[9]; |
|
1021 | + $data['departure_airport_iata'] = $line[11]; |
|
1022 | + $data['arrival_airport_iata'] = $line[12]; |
|
1023 | + $data['emergency'] = ''; // emergency |
|
1024 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1025 | + $data['format_source'] = 'fr24json'; |
|
1026 | + $data['id_source'] = $id_source; |
|
1027 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1028 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1029 | + $SI->add($data); |
|
1030 | + unset($data); |
|
1031 | 1031 | } |
1032 | - } |
|
1033 | - //$last_exec['fr24json'] = time(); |
|
1034 | - $last_exec[$id]['last'] = time(); |
|
1032 | + } |
|
1033 | + //$last_exec['fr24json'] = time(); |
|
1034 | + $last_exec[$id]['last'] = time(); |
|
1035 | 1035 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
1036 | 1036 | } elseif ($value['format'] == 'radarvirtueljson' && |
1037 | - ( |
|
1037 | + ( |
|
1038 | 1038 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1039 | 1039 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1040 | - ) |
|
1040 | + ) |
|
1041 | 1041 | ) { |
1042 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1043 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1044 | - //echo $buffer; |
|
1045 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1046 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1047 | - $all_data = json_decode($buffer,true); |
|
1048 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1042 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1043 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1044 | + //echo $buffer; |
|
1045 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1046 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1047 | + $all_data = json_decode($buffer,true); |
|
1048 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1049 | 1049 | die(json_last_error_msg()); |
1050 | - } |
|
1051 | - if (isset($all_data['mrkrs'])) { |
|
1050 | + } |
|
1051 | + if (isset($all_data['mrkrs'])) { |
|
1052 | 1052 | $reset = 0; |
1053 | 1053 | foreach ($all_data['mrkrs'] as $key => $line) { |
1054 | - if (isset($line['inf'])) { |
|
1054 | + if (isset($line['inf'])) { |
|
1055 | 1055 | $data = array(); |
1056 | 1056 | $data['hex'] = $line['inf']['ia']; |
1057 | 1057 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1058 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1059 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1060 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1061 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1062 | - $data['longitude'] = $line['pt'][1]; // long |
|
1063 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1064 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1065 | - //$data['aircraft_icao'] = $line[8]; |
|
1066 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1058 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1059 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1060 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1061 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1062 | + $data['longitude'] = $line['pt'][1]; // long |
|
1063 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1064 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1065 | + //$data['aircraft_icao'] = $line[8]; |
|
1066 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1067 | 1067 | //$data['departure_airport_iata'] = $line[11]; |
1068 | 1068 | //$data['arrival_airport_iata'] = $line[12]; |
1069 | - //$data['emergency'] = ''; // emergency |
|
1069 | + //$data['emergency'] = ''; // emergency |
|
1070 | 1070 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1071 | - $data['format_source'] = 'radarvirtueljson'; |
|
1072 | - $data['id_source'] = $id_source; |
|
1071 | + $data['format_source'] = 'radarvirtueljson'; |
|
1072 | + $data['id_source'] = $id_source; |
|
1073 | 1073 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1074 | 1074 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1075 | 1075 | $SI->add($data); |
1076 | 1076 | unset($data); |
1077 | - } |
|
1077 | + } |
|
1078 | + } |
|
1078 | 1079 | } |
1079 | - } |
|
1080 | - //$last_exec['radarvirtueljson'] = time(); |
|
1081 | - $last_exec[$id]['last'] = time(); |
|
1080 | + //$last_exec['radarvirtueljson'] = time(); |
|
1081 | + $last_exec[$id]['last'] = time(); |
|
1082 | 1082 | //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1083 | 1083 | } elseif ($value['format'] == 'pirepsjson' && |
1084 | - ( |
|
1084 | + ( |
|
1085 | 1085 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1086 | 1086 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1087 | - ) |
|
1087 | + ) |
|
1088 | 1088 | ) { |
1089 | - //$buffer = $Common->getData($hosts[$id]); |
|
1090 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1091 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1089 | + //$buffer = $Common->getData($hosts[$id]); |
|
1090 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1091 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1092 | 1092 | |
1093 | - if (isset($all_data['pireps'])) { |
|
1093 | + if (isset($all_data['pireps'])) { |
|
1094 | 1094 | $reset = 0; |
1095 | - foreach ($all_data['pireps'] as $line) { |
|
1096 | - $data = array(); |
|
1097 | - $data['id'] = $line['id']; |
|
1098 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1099 | - $data['ident'] = $line['callsign']; // ident |
|
1100 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1101 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1102 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1103 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1104 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1105 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1106 | - $data['latitude'] = $line['lat']; // lat |
|
1107 | - $data['longitude'] = $line['lon']; // long |
|
1108 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1109 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1110 | - //$data['emergency'] = ''; // emergency |
|
1111 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1112 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1113 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1114 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1115 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1116 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1117 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1118 | - else $data['info'] = ''; |
|
1119 | - $data['format_source'] = 'pireps'; |
|
1120 | - $data['id_source'] = $id_source; |
|
1121 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1122 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1123 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1124 | - if ($line['icon'] == 'plane') { |
|
1095 | + foreach ($all_data['pireps'] as $line) { |
|
1096 | + $data = array(); |
|
1097 | + $data['id'] = $line['id']; |
|
1098 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1099 | + $data['ident'] = $line['callsign']; // ident |
|
1100 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1101 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1102 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1103 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1104 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1105 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1106 | + $data['latitude'] = $line['lat']; // lat |
|
1107 | + $data['longitude'] = $line['lon']; // long |
|
1108 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1109 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1110 | + //$data['emergency'] = ''; // emergency |
|
1111 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1112 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1113 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1114 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1115 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1116 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1117 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1118 | + else $data['info'] = ''; |
|
1119 | + $data['format_source'] = 'pireps'; |
|
1120 | + $data['id_source'] = $id_source; |
|
1121 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1122 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1123 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1124 | + if ($line['icon'] == 'plane') { |
|
1125 | 1125 | $SI->add($data); |
1126 | - // print_r($data); |
|
1127 | - } elseif ($line['icon'] == 'ct') { |
|
1126 | + // print_r($data); |
|
1127 | + } elseif ($line['icon'] == 'ct') { |
|
1128 | 1128 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1129 | 1129 | $data['info'] = str_replace('&sect;','',$data['info']); |
1130 | 1130 | $typec = substr($data['ident'],-3); |
@@ -1139,148 +1139,148 @@ discard block |
||
1139 | 1139 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1140 | 1140 | else $data['type'] = 'Observer'; |
1141 | 1141 | if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
1142 | - } |
|
1143 | - unset($data); |
|
1142 | + } |
|
1143 | + unset($data); |
|
1144 | + } |
|
1144 | 1145 | } |
1145 | - } |
|
1146 | - //$last_exec['pirepsjson'] = time(); |
|
1147 | - $last_exec[$id]['last'] = time(); |
|
1146 | + //$last_exec['pirepsjson'] = time(); |
|
1147 | + $last_exec[$id]['last'] = time(); |
|
1148 | 1148 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1149 | 1149 | } elseif ($value['format'] == 'phpvmacars' && |
1150 | - ( |
|
1150 | + ( |
|
1151 | 1151 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1152 | 1152 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1153 | - ) |
|
1153 | + ) |
|
1154 | 1154 | ) { |
1155 | - //$buffer = $Common->getData($hosts[$id]); |
|
1156 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1157 | - $buffer = $Common->getData($value['host']); |
|
1158 | - $all_data = json_decode($buffer,true); |
|
1159 | - if ($buffer != '' && is_array($all_data)) { |
|
1155 | + //$buffer = $Common->getData($hosts[$id]); |
|
1156 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1157 | + $buffer = $Common->getData($value['host']); |
|
1158 | + $all_data = json_decode($buffer,true); |
|
1159 | + if ($buffer != '' && is_array($all_data)) { |
|
1160 | 1160 | $reset = 0; |
1161 | 1161 | foreach ($all_data as $line) { |
1162 | - $data = array(); |
|
1163 | - //$data['id'] = $line['id']; // id not usable |
|
1164 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1165 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1166 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1167 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1168 | - $data['ident'] = $line['flightnum']; // ident |
|
1169 | - $data['altitude'] = $line['alt']; // altitude |
|
1170 | - $data['speed'] = $line['gs']; // speed |
|
1171 | - $data['heading'] = $line['heading']; // heading |
|
1172 | - $data['latitude'] = $line['lat']; // lat |
|
1173 | - $data['longitude'] = $line['lng']; // long |
|
1174 | - $data['verticalrate'] = ''; // verticale rate |
|
1175 | - $data['squawk'] = ''; // squawk |
|
1176 | - $data['emergency'] = ''; // emergency |
|
1177 | - //$data['datetime'] = $line['lastupdate']; |
|
1178 | - //$data['last_update'] = $line['lastupdate']; |
|
1179 | - if (isset($value['timezone'])) { |
|
1180 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1181 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1182 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1183 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1184 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1185 | - $data['departure_airport_time'] = $line['deptime']; |
|
1186 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1187 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1188 | - $data['registration'] = $line['aircraft']; |
|
1189 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1190 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1191 | - if (isset($line['aircraftname'])) { |
|
1162 | + $data = array(); |
|
1163 | + //$data['id'] = $line['id']; // id not usable |
|
1164 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1165 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1166 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1167 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1168 | + $data['ident'] = $line['flightnum']; // ident |
|
1169 | + $data['altitude'] = $line['alt']; // altitude |
|
1170 | + $data['speed'] = $line['gs']; // speed |
|
1171 | + $data['heading'] = $line['heading']; // heading |
|
1172 | + $data['latitude'] = $line['lat']; // lat |
|
1173 | + $data['longitude'] = $line['lng']; // long |
|
1174 | + $data['verticalrate'] = ''; // verticale rate |
|
1175 | + $data['squawk'] = ''; // squawk |
|
1176 | + $data['emergency'] = ''; // emergency |
|
1177 | + //$data['datetime'] = $line['lastupdate']; |
|
1178 | + //$data['last_update'] = $line['lastupdate']; |
|
1179 | + if (isset($value['timezone'])) { |
|
1180 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1181 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1182 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1183 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1184 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1185 | + $data['departure_airport_time'] = $line['deptime']; |
|
1186 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1187 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1188 | + $data['registration'] = $line['aircraft']; |
|
1189 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1190 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1191 | + if (isset($line['aircraftname'])) { |
|
1192 | 1192 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1193 | 1193 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1194 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1195 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1196 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1197 | - else { |
|
1198 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1199 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1200 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1201 | - } |
|
1202 | - } |
|
1203 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1204 | - $data['id_source'] = $id_source; |
|
1205 | - $data['format_source'] = 'phpvmacars'; |
|
1206 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1207 | - $SI->add($data); |
|
1208 | - unset($data); |
|
1194 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1195 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1196 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1197 | + else { |
|
1198 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1199 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1200 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1201 | + } |
|
1202 | + } |
|
1203 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1204 | + $data['id_source'] = $id_source; |
|
1205 | + $data['format_source'] = 'phpvmacars'; |
|
1206 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1207 | + $SI->add($data); |
|
1208 | + unset($data); |
|
1209 | 1209 | } |
1210 | 1210 | if ($globalDebug) echo 'No more data...'."\n"; |
1211 | 1211 | unset($buffer); |
1212 | 1212 | unset($all_data); |
1213 | - } |
|
1214 | - //$last_exec['phpvmacars'] = time(); |
|
1215 | - $last_exec[$id]['last'] = time(); |
|
1213 | + } |
|
1214 | + //$last_exec['phpvmacars'] = time(); |
|
1215 | + $last_exec[$id]['last'] = time(); |
|
1216 | 1216 | } elseif ($value['format'] == 'vam' && |
1217 | - ( |
|
1217 | + ( |
|
1218 | 1218 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1219 | 1219 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1220 | - ) |
|
1220 | + ) |
|
1221 | 1221 | ) { |
1222 | - //$buffer = $Common->getData($hosts[$id]); |
|
1223 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1224 | - $buffer = $Common->getData($value['host']); |
|
1225 | - $all_data = json_decode($buffer,true); |
|
1226 | - if ($buffer != '' && is_array($all_data)) { |
|
1222 | + //$buffer = $Common->getData($hosts[$id]); |
|
1223 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1224 | + $buffer = $Common->getData($value['host']); |
|
1225 | + $all_data = json_decode($buffer,true); |
|
1226 | + if ($buffer != '' && is_array($all_data)) { |
|
1227 | 1227 | $reset = 0; |
1228 | 1228 | foreach ($all_data as $line) { |
1229 | - $data = array(); |
|
1230 | - //$data['id'] = $line['id']; // id not usable |
|
1231 | - $data['id'] = trim($line['flight_id']); |
|
1232 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1233 | - $data['pilot_name'] = $line['pilot_name']; |
|
1234 | - $data['pilot_id'] = $line['pilot_id']; |
|
1235 | - $data['ident'] = trim($line['callsign']); // ident |
|
1236 | - $data['altitude'] = $line['altitude']; // altitude |
|
1237 | - $data['speed'] = $line['gs']; // speed |
|
1238 | - $data['heading'] = $line['heading']; // heading |
|
1239 | - $data['latitude'] = $line['latitude']; // lat |
|
1240 | - $data['longitude'] = $line['longitude']; // long |
|
1241 | - $data['verticalrate'] = ''; // verticale rate |
|
1242 | - $data['squawk'] = ''; // squawk |
|
1243 | - $data['emergency'] = ''; // emergency |
|
1244 | - //$data['datetime'] = $line['lastupdate']; |
|
1245 | - $data['last_update'] = $line['last_update']; |
|
1246 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1247 | - $data['departure_airport_icao'] = $line['departure']; |
|
1248 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1249 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1250 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1251 | - //$data['registration'] = $line['aircraft']; |
|
1252 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1253 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1254 | - $data['id_source'] = $id_source; |
|
1255 | - $data['format_source'] = 'vam'; |
|
1256 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1257 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1258 | - $SI->add($data); |
|
1259 | - unset($data); |
|
1229 | + $data = array(); |
|
1230 | + //$data['id'] = $line['id']; // id not usable |
|
1231 | + $data['id'] = trim($line['flight_id']); |
|
1232 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1233 | + $data['pilot_name'] = $line['pilot_name']; |
|
1234 | + $data['pilot_id'] = $line['pilot_id']; |
|
1235 | + $data['ident'] = trim($line['callsign']); // ident |
|
1236 | + $data['altitude'] = $line['altitude']; // altitude |
|
1237 | + $data['speed'] = $line['gs']; // speed |
|
1238 | + $data['heading'] = $line['heading']; // heading |
|
1239 | + $data['latitude'] = $line['latitude']; // lat |
|
1240 | + $data['longitude'] = $line['longitude']; // long |
|
1241 | + $data['verticalrate'] = ''; // verticale rate |
|
1242 | + $data['squawk'] = ''; // squawk |
|
1243 | + $data['emergency'] = ''; // emergency |
|
1244 | + //$data['datetime'] = $line['lastupdate']; |
|
1245 | + $data['last_update'] = $line['last_update']; |
|
1246 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1247 | + $data['departure_airport_icao'] = $line['departure']; |
|
1248 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1249 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1250 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1251 | + //$data['registration'] = $line['aircraft']; |
|
1252 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1253 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1254 | + $data['id_source'] = $id_source; |
|
1255 | + $data['format_source'] = 'vam'; |
|
1256 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1257 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1258 | + $SI->add($data); |
|
1259 | + unset($data); |
|
1260 | 1260 | } |
1261 | 1261 | if ($globalDebug) echo 'No more data...'."\n"; |
1262 | 1262 | unset($buffer); |
1263 | 1263 | unset($all_data); |
1264 | - } |
|
1265 | - //$last_exec['phpvmacars'] = time(); |
|
1266 | - $last_exec[$id]['last'] = time(); |
|
1264 | + } |
|
1265 | + //$last_exec['phpvmacars'] = time(); |
|
1266 | + $last_exec[$id]['last'] = time(); |
|
1267 | 1267 | } elseif ($value['format'] == 'blitzortung' && |
1268 | - ( |
|
1268 | + ( |
|
1269 | 1269 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1270 | 1270 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1271 | - ) |
|
1271 | + ) |
|
1272 | 1272 | ) { |
1273 | - //$buffer = $Common->getData($hosts[$id]); |
|
1274 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1275 | - $buffer = $Common->getData($value['host']); |
|
1276 | - $all_data = json_decode($buffer,true); |
|
1277 | - if ($buffer != '') { |
|
1273 | + //$buffer = $Common->getData($hosts[$id]); |
|
1274 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1275 | + $buffer = $Common->getData($value['host']); |
|
1276 | + $all_data = json_decode($buffer,true); |
|
1277 | + if ($buffer != '') { |
|
1278 | 1278 | $Source->deleteLocationBySource('blitzortung'); |
1279 | 1279 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1280 | 1280 | $buffer = explode('\n',$buffer); |
1281 | 1281 | foreach ($buffer as $buffer_line) { |
1282 | - $line = json_decode($buffer_line,true); |
|
1283 | - if (isset($line['time'])) { |
|
1282 | + $line = json_decode($buffer_line,true); |
|
1283 | + if (isset($line['time'])) { |
|
1284 | 1284 | $data = array(); |
1285 | 1285 | $data['altitude'] = $line['alt']; // altitude |
1286 | 1286 | $data['latitude'] = $line['lat']; // lat |
@@ -1292,94 +1292,94 @@ discard block |
||
1292 | 1292 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1293 | 1293 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1294 | 1294 | unset($data); |
1295 | - } |
|
1295 | + } |
|
1296 | 1296 | } |
1297 | 1297 | if ($globalDebug) echo 'No more data...'."\n"; |
1298 | 1298 | unset($buffer); |
1299 | - } |
|
1300 | - $last_exec[$id]['last'] = time(); |
|
1299 | + } |
|
1300 | + $last_exec[$id]['last'] = time(); |
|
1301 | 1301 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1302 | 1302 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1303 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1304 | - //$last_exec[$id]['last'] = time(); |
|
1303 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1304 | + //$last_exec[$id]['last'] = time(); |
|
1305 | 1305 | |
1306 | - //$read = array( $sockets[$id] ); |
|
1307 | - $read = $sockets; |
|
1308 | - $write = NULL; |
|
1309 | - $e = NULL; |
|
1310 | - $n = socket_select($read, $write, $e, $timeout); |
|
1311 | - if ($e != NULL) var_dump($e); |
|
1312 | - if ($n > 0) { |
|
1306 | + //$read = array( $sockets[$id] ); |
|
1307 | + $read = $sockets; |
|
1308 | + $write = NULL; |
|
1309 | + $e = NULL; |
|
1310 | + $n = socket_select($read, $write, $e, $timeout); |
|
1311 | + if ($e != NULL) var_dump($e); |
|
1312 | + if ($n > 0) { |
|
1313 | 1313 | $reset = 0; |
1314 | 1314 | foreach ($read as $nb => $r) { |
1315 | - //$value = $formats[$nb]; |
|
1316 | - $format = $globalSources[$nb]['format']; |
|
1317 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1315 | + //$value = $formats[$nb]; |
|
1316 | + $format = $globalSources[$nb]['format']; |
|
1317 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1318 | 1318 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1319 | - } elseif ($format == 'vrstcp') { |
|
1319 | + } elseif ($format == 'vrstcp') { |
|
1320 | 1320 | $buffer = @socket_read($r, 6000); |
1321 | - } else { |
|
1321 | + } else { |
|
1322 | 1322 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1323 | - } |
|
1324 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1325 | - //echo $buffer."\n"; |
|
1326 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1327 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1328 | - $error = false; |
|
1329 | - //$SI::del(); |
|
1330 | - if ($format == 'vrstcp') { |
|
1323 | + } |
|
1324 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1325 | + //echo $buffer."\n"; |
|
1326 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1327 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1328 | + $error = false; |
|
1329 | + //$SI::del(); |
|
1330 | + if ($format == 'vrstcp') { |
|
1331 | 1331 | $buffer = explode('},{',$buffer); |
1332 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1333 | - // SBS format is CSV format |
|
1334 | - if ($buffer !== FALSE && $buffer != '') { |
|
1332 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1333 | + // SBS format is CSV format |
|
1334 | + if ($buffer !== FALSE && $buffer != '') { |
|
1335 | 1335 | $tt[$format] = 0; |
1336 | 1336 | if ($format == 'acarssbs3') { |
1337 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1338 | - $ACARS->add(trim($buffer)); |
|
1339 | - $ACARS->deleteLiveAcarsData(); |
|
1337 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1338 | + $ACARS->add(trim($buffer)); |
|
1339 | + $ACARS->deleteLiveAcarsData(); |
|
1340 | 1340 | } elseif ($format == 'raw') { |
1341 | - // AVR format |
|
1342 | - $data = $SBS->parse($buffer); |
|
1343 | - if (is_array($data)) { |
|
1341 | + // AVR format |
|
1342 | + $data = $SBS->parse($buffer); |
|
1343 | + if (is_array($data)) { |
|
1344 | 1344 | $data['datetime'] = date('Y-m-d H:i:s'); |
1345 | 1345 | $data['format_source'] = 'raw'; |
1346 | 1346 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1347 | 1347 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1348 | 1348 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1349 | 1349 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1350 | - } |
|
1350 | + } |
|
1351 | 1351 | } elseif ($format == 'ais') { |
1352 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1353 | - $data = array(); |
|
1354 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1355 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1356 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1357 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1358 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1359 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1360 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1361 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1362 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1363 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1364 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1365 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1366 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1367 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1368 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1369 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1352 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1353 | + $data = array(); |
|
1354 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1355 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1356 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1357 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1358 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1359 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1360 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1361 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1362 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1363 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1364 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1365 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1366 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1367 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1368 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1369 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1370 | 1370 | |
1371 | - if (isset($ais_data['timestamp'])) { |
|
1371 | + if (isset($ais_data['timestamp'])) { |
|
1372 | 1372 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1373 | - } else { |
|
1373 | + } else { |
|
1374 | 1374 | $data['datetime'] = date('Y-m-d H:i:s'); |
1375 | - } |
|
1376 | - $data['format_source'] = 'aisnmea'; |
|
1377 | - $data['id_source'] = $id_source; |
|
1378 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1379 | - unset($data); |
|
1380 | - } elseif ($format == 'flightgearsp') { |
|
1381 | - //echo $buffer."\n"; |
|
1382 | - if (strlen($buffer) > 5) { |
|
1375 | + } |
|
1376 | + $data['format_source'] = 'aisnmea'; |
|
1377 | + $data['id_source'] = $id_source; |
|
1378 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1379 | + unset($data); |
|
1380 | + } elseif ($format == 'flightgearsp') { |
|
1381 | + //echo $buffer."\n"; |
|
1382 | + if (strlen($buffer) > 5) { |
|
1383 | 1383 | $line = explode(',',$buffer); |
1384 | 1384 | $data = array(); |
1385 | 1385 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1396,38 +1396,38 @@ discard block |
||
1396 | 1396 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1397 | 1397 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1398 | 1398 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1399 | - } |
|
1400 | - } elseif ($format == 'acars') { |
|
1401 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1402 | - $ACARS->add(trim($buffer)); |
|
1403 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1404 | - $ACARS->deleteLiveAcarsData(); |
|
1399 | + } |
|
1400 | + } elseif ($format == 'acars') { |
|
1401 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1402 | + $ACARS->add(trim($buffer)); |
|
1403 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1404 | + $ACARS->deleteLiveAcarsData(); |
|
1405 | 1405 | } elseif ($format == 'flightgearmp') { |
1406 | - if (substr($buffer,0,1) != '#') { |
|
1406 | + if (substr($buffer,0,1) != '#') { |
|
1407 | 1407 | $data = array(); |
1408 | 1408 | //echo $buffer."\n"; |
1409 | 1409 | $line = explode(' ',$buffer); |
1410 | 1410 | if (count($line) == 11) { |
1411 | - $userserver = explode('@',$line[0]); |
|
1412 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1413 | - $data['ident'] = $userserver[0]; |
|
1414 | - $data['registration'] = $userserver[0]; |
|
1415 | - $data['latitude'] = $line[4]; |
|
1416 | - $data['longitude'] = $line[5]; |
|
1417 | - $data['altitude'] = $line[6]; |
|
1418 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1419 | - $aircraft_type = $line[10]; |
|
1420 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1421 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1422 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1423 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1411 | + $userserver = explode('@',$line[0]); |
|
1412 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1413 | + $data['ident'] = $userserver[0]; |
|
1414 | + $data['registration'] = $userserver[0]; |
|
1415 | + $data['latitude'] = $line[4]; |
|
1416 | + $data['longitude'] = $line[5]; |
|
1417 | + $data['altitude'] = $line[6]; |
|
1418 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1419 | + $aircraft_type = $line[10]; |
|
1420 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1421 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1422 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1423 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1424 | + } |
|
1424 | 1425 | } |
1425 | - } |
|
1426 | 1426 | } elseif ($format == 'beast') { |
1427 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1428 | - die; |
|
1427 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1428 | + die; |
|
1429 | 1429 | } elseif ($format == 'vrstcp') { |
1430 | - foreach($buffer as $all_data) { |
|
1430 | + foreach($buffer as $all_data) { |
|
1431 | 1431 | $line = json_decode('{'.$all_data.'}',true); |
1432 | 1432 | $data = array(); |
1433 | 1433 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1447,152 +1447,152 @@ discard block |
||
1447 | 1447 | */ |
1448 | 1448 | $data['datetime'] = date('Y-m-d H:i:s'); |
1449 | 1449 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1450 | - $data['format_source'] = 'vrstcp'; |
|
1450 | + $data['format_source'] = 'vrstcp'; |
|
1451 | 1451 | $data['id_source'] = $id_source; |
1452 | 1452 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1453 | 1453 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1454 | 1454 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1455 | 1455 | unset($data); |
1456 | - } |
|
1456 | + } |
|
1457 | 1457 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1458 | - $line = explode("\t", $buffer); |
|
1459 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1458 | + $line = explode("\t", $buffer); |
|
1459 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1460 | 1460 | $key = $line[$k]; |
1461 | - $lined[$key] = $line[$k+1]; |
|
1462 | - } |
|
1463 | - if (count($lined) > 3) { |
|
1464 | - $data['hex'] = $lined['hexid']; |
|
1465 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1466 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1467 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1468 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1469 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1470 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1471 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1472 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1473 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1474 | - $data['id_source'] = $id_source; |
|
1475 | - $data['format_source'] = 'tsv'; |
|
1476 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1477 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1461 | + $lined[$key] = $line[$k+1]; |
|
1462 | + } |
|
1463 | + if (count($lined) > 3) { |
|
1464 | + $data['hex'] = $lined['hexid']; |
|
1465 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1466 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1467 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1468 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1469 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1470 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1471 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1472 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1473 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1474 | + $data['id_source'] = $id_source; |
|
1475 | + $data['format_source'] = 'tsv'; |
|
1476 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1477 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1478 | 1478 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1479 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1480 | - unset($lined); |
|
1481 | - unset($data); |
|
1482 | - } else $error = true; |
|
1479 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1480 | + unset($lined); |
|
1481 | + unset($data); |
|
1482 | + } else $error = true; |
|
1483 | 1483 | } elseif ($format == 'aprs' && $use_aprs) { |
1484 | - if ($aprs_connect == 0) { |
|
1484 | + if ($aprs_connect == 0) { |
|
1485 | 1485 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1486 | 1486 | $aprs_connect = 1; |
1487 | - } |
|
1487 | + } |
|
1488 | 1488 | |
1489 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1489 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1490 | 1490 | $aprs_last_tx = time(); |
1491 | 1491 | $data_aprs = "# Keep alive"; |
1492 | 1492 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1493 | - } |
|
1493 | + } |
|
1494 | 1494 | |
1495 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1496 | - //echo 'APRS data : '.$buffer."\n"; |
|
1497 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1498 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1499 | - //echo $buffer."\n"; |
|
1500 | - date_default_timezone_set('UTC'); |
|
1501 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1495 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1496 | + //echo 'APRS data : '.$buffer."\n"; |
|
1497 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1498 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1499 | + //echo $buffer."\n"; |
|
1500 | + date_default_timezone_set('UTC'); |
|
1501 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1502 | 1502 | $line = $APRS->parse($buffer); |
1503 | 1503 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1504 | 1504 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1505 | - $aprs_last_tx = time(); |
|
1506 | - $data = array(); |
|
1507 | - //print_r($line); |
|
1508 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1509 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1510 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1511 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1512 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1513 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1514 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1515 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1516 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1517 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1518 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1519 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1520 | - $data['latitude'] = $line['latitude']; |
|
1521 | - $data['longitude'] = $line['longitude']; |
|
1522 | - //$data['verticalrate'] = $line[16]; |
|
1523 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1524 | - //else $data['speed'] = 0; |
|
1525 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1526 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1527 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1528 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1505 | + $aprs_last_tx = time(); |
|
1506 | + $data = array(); |
|
1507 | + //print_r($line); |
|
1508 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1509 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1510 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1511 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1512 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1513 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1514 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1515 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1516 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1517 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1518 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1519 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1520 | + $data['latitude'] = $line['latitude']; |
|
1521 | + $data['longitude'] = $line['longitude']; |
|
1522 | + //$data['verticalrate'] = $line[16]; |
|
1523 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1524 | + //else $data['speed'] = 0; |
|
1525 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1526 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1527 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1528 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1529 | 1529 | |
1530 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1531 | - //else echo 'No heading...'."\n"; |
|
1532 | - //else $data['heading'] = 0; |
|
1533 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1534 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1535 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1536 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1537 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1538 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1539 | - $data['id_source'] = $id_source; |
|
1540 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1541 | - else $data['format_source'] = 'aprs'; |
|
1542 | - $data['source_name'] = $line['source']; |
|
1543 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1544 | - else $data['source_type'] = 'flarm'; |
|
1545 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1546 | - $currentdate = date('Y-m-d H:i:s'); |
|
1547 | - $aprsdate = strtotime($data['datetime']); |
|
1548 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1549 | - // Accept data if time <= system time + 20s |
|
1550 | - //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1551 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1530 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1531 | + //else echo 'No heading...'."\n"; |
|
1532 | + //else $data['heading'] = 0; |
|
1533 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1534 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1535 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1536 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1537 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1538 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1539 | + $data['id_source'] = $id_source; |
|
1540 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1541 | + else $data['format_source'] = 'aprs'; |
|
1542 | + $data['source_name'] = $line['source']; |
|
1543 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1544 | + else $data['source_type'] = 'flarm'; |
|
1545 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1546 | + $currentdate = date('Y-m-d H:i:s'); |
|
1547 | + $aprsdate = strtotime($data['datetime']); |
|
1548 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1549 | + // Accept data if time <= system time + 20s |
|
1550 | + //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1551 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1552 | 1552 | $send = $SI->add($data); |
1553 | - } elseif ($data['source_type'] == 'ais') { |
|
1553 | + } elseif ($data['source_type'] == 'ais') { |
|
1554 | 1554 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1555 | - } elseif (isset($line['stealth'])) { |
|
1555 | + } elseif (isset($line['stealth'])) { |
|
1556 | 1556 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1557 | 1557 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1558 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1559 | - //$line['symbol'] == 'Balloon' || |
|
1560 | - $line['symbol'] == 'Glider' || |
|
1561 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1562 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1563 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1564 | - $send = $SI->add($data); |
|
1565 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1566 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1567 | - $line['symbol'] == 'Ship (Power Boat)')) { |
|
1568 | - $send = $MI->add($data); |
|
1569 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1570 | - $line['symbol'] == 'Car' || |
|
1571 | - $line['symbol'] == 'Ambulance' || |
|
1572 | - $line['symbol'] == 'Van' || |
|
1573 | - $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1574 | - $line['symbol'] == 'Motorcycle' || |
|
1575 | - $line['symbol'] == 'Tractor' || |
|
1576 | - $line['symbol'] == 'Police' || |
|
1577 | - $line['symbol'] == 'Bike' || |
|
1578 | - $line['symbol'] == 'Jogger' || |
|
1579 | - $line['symbol'] == 'Horse' || |
|
1580 | - $line['symbol'] == 'Bus' || |
|
1581 | - $line['symbol'] == 'Jeep' || |
|
1582 | - $line['symbol'] == 'Recreational Vehicle' || |
|
1583 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1584 | - $line['symbol'] == 'Ship (Power Boat)' || |
|
1585 | - $line['symbol'] == 'Firetruck' || |
|
1586 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1587 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1588 | - $line['symbol'] == 'SUV' || |
|
1589 | - $line['symbol'] == 'Snowmobile' || |
|
1590 | - $line['symbol'] == 'Mobile Satellite Station')) { |
|
1591 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1558 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1559 | + //$line['symbol'] == 'Balloon' || |
|
1560 | + $line['symbol'] == 'Glider' || |
|
1561 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1562 | + if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1563 | + if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1564 | + $send = $SI->add($data); |
|
1565 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1566 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1567 | + $line['symbol'] == 'Ship (Power Boat)')) { |
|
1568 | + $send = $MI->add($data); |
|
1569 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1570 | + $line['symbol'] == 'Car' || |
|
1571 | + $line['symbol'] == 'Ambulance' || |
|
1572 | + $line['symbol'] == 'Van' || |
|
1573 | + $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1574 | + $line['symbol'] == 'Motorcycle' || |
|
1575 | + $line['symbol'] == 'Tractor' || |
|
1576 | + $line['symbol'] == 'Police' || |
|
1577 | + $line['symbol'] == 'Bike' || |
|
1578 | + $line['symbol'] == 'Jogger' || |
|
1579 | + $line['symbol'] == 'Horse' || |
|
1580 | + $line['symbol'] == 'Bus' || |
|
1581 | + $line['symbol'] == 'Jeep' || |
|
1582 | + $line['symbol'] == 'Recreational Vehicle' || |
|
1583 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1584 | + $line['symbol'] == 'Ship (Power Boat)' || |
|
1585 | + $line['symbol'] == 'Firetruck' || |
|
1586 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1587 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1588 | + $line['symbol'] == 'SUV' || |
|
1589 | + $line['symbol'] == 'Snowmobile' || |
|
1590 | + $line['symbol'] == 'Mobile Satellite Station')) { |
|
1591 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1592 | 1592 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
1593 | 1593 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1594 | 1594 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1595 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1595 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1596 | 1596 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1597 | 1597 | $Source->deleteOldLocationByType('gs'); |
1598 | 1598 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1600,7 +1600,7 @@ discard block |
||
1600 | 1600 | } else { |
1601 | 1601 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1602 | 1602 | } |
1603 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1603 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1604 | 1604 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1605 | 1605 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1606 | 1606 | $Source->deleteOldLocationByType('wx'); |
@@ -1610,7 +1610,7 @@ discard block |
||
1610 | 1610 | } else { |
1611 | 1611 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1612 | 1612 | } |
1613 | - } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
|
1613 | + } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
|
1614 | 1614 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1615 | 1615 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1616 | 1616 | $Source->deleteOldLocationByType('lightning'); |
@@ -1619,11 +1619,11 @@ discard block |
||
1619 | 1619 | } else { |
1620 | 1620 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1621 | 1621 | } |
1622 | - } elseif ($globalDebug) { |
|
1623 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1624 | - print_r($line); |
|
1625 | - } |
|
1626 | - unset($data); |
|
1622 | + } elseif ($globalDebug) { |
|
1623 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1624 | + print_r($line); |
|
1625 | + } |
|
1626 | + unset($data); |
|
1627 | 1627 | } |
1628 | 1628 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1629 | 1629 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1642,12 +1642,12 @@ discard block |
||
1642 | 1642 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1643 | 1643 | $globalSources[$nb]['last_weather_clean'] = time(); |
1644 | 1644 | } |
1645 | - } |
|
1645 | + } |
|
1646 | 1646 | } else { |
1647 | - $line = explode(',', $buffer); |
|
1648 | - if (count($line) > 20) { |
|
1649 | - $data['hex'] = $line[4]; |
|
1650 | - /* |
|
1647 | + $line = explode(',', $buffer); |
|
1648 | + if (count($line) > 20) { |
|
1649 | + $data['hex'] = $line[4]; |
|
1650 | + /* |
|
1651 | 1651 | $data['datetime'] = $line[6].' '.$line[7]; |
1652 | 1652 | date_default_timezone_set($globalTimezone); |
1653 | 1653 | $datetime = new DateTime($data['datetime']); |
@@ -1655,30 +1655,30 @@ discard block |
||
1655 | 1655 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1656 | 1656 | date_default_timezone_set('UTC'); |
1657 | 1657 | */ |
1658 | - // Force datetime to current UTC datetime |
|
1659 | - date_default_timezone_set('UTC'); |
|
1660 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1661 | - $data['ident'] = trim($line[10]); |
|
1662 | - $data['latitude'] = $line[14]; |
|
1663 | - $data['longitude'] = $line[15]; |
|
1664 | - $data['verticalrate'] = $line[16]; |
|
1665 | - $data['emergency'] = $line[20]; |
|
1666 | - $data['speed'] = $line[12]; |
|
1667 | - $data['squawk'] = $line[17]; |
|
1668 | - $data['altitude'] = $line[11]; |
|
1669 | - $data['heading'] = $line[13]; |
|
1670 | - $data['ground'] = $line[21]; |
|
1671 | - $data['emergency'] = $line[19]; |
|
1672 | - $data['format_source'] = 'sbs'; |
|
1658 | + // Force datetime to current UTC datetime |
|
1659 | + date_default_timezone_set('UTC'); |
|
1660 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1661 | + $data['ident'] = trim($line[10]); |
|
1662 | + $data['latitude'] = $line[14]; |
|
1663 | + $data['longitude'] = $line[15]; |
|
1664 | + $data['verticalrate'] = $line[16]; |
|
1665 | + $data['emergency'] = $line[20]; |
|
1666 | + $data['speed'] = $line[12]; |
|
1667 | + $data['squawk'] = $line[17]; |
|
1668 | + $data['altitude'] = $line[11]; |
|
1669 | + $data['heading'] = $line[13]; |
|
1670 | + $data['ground'] = $line[21]; |
|
1671 | + $data['emergency'] = $line[19]; |
|
1672 | + $data['format_source'] = 'sbs'; |
|
1673 | 1673 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1674 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1674 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1675 | 1675 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1676 | - $data['id_source'] = $id_source; |
|
1677 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1678 | - else $error = true; |
|
1679 | - unset($data); |
|
1680 | - } else $error = true; |
|
1681 | - if ($error) { |
|
1676 | + $data['id_source'] = $id_source; |
|
1677 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1678 | + else $error = true; |
|
1679 | + unset($data); |
|
1680 | + } else $error = true; |
|
1681 | + if ($error) { |
|
1682 | 1682 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1683 | 1683 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1684 | 1684 | } else { |
@@ -1694,13 +1694,13 @@ discard block |
||
1694 | 1694 | connect_all($sourceer); |
1695 | 1695 | $sourceer = array(); |
1696 | 1696 | } |
1697 | - } |
|
1697 | + } |
|
1698 | 1698 | } |
1699 | 1699 | // Sleep for xxx microseconds |
1700 | 1700 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1701 | - } else { |
|
1701 | + } else { |
|
1702 | 1702 | if ($format == 'flightgearmp') { |
1703 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1703 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1704 | 1704 | //@socket_close($r); |
1705 | 1705 | sleep($globalMinFetch); |
1706 | 1706 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1709,9 +1709,9 @@ discard block |
||
1709 | 1709 | break; |
1710 | 1710 | |
1711 | 1711 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1712 | - if (isset($tt[$format])) $tt[$format]++; |
|
1713 | - else $tt[$format] = 0; |
|
1714 | - if ($tt[$format] > 30) { |
|
1712 | + if (isset($tt[$format])) $tt[$format]++; |
|
1713 | + else $tt[$format] = 0; |
|
1714 | + if ($tt[$format] > 30) { |
|
1715 | 1715 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1716 | 1716 | //@socket_close($r); |
1717 | 1717 | sleep(2); |
@@ -1722,23 +1722,23 @@ discard block |
||
1722 | 1722 | //connect_all($globalSources); |
1723 | 1723 | $tt[$format]=0; |
1724 | 1724 | break; |
1725 | - } |
|
1725 | + } |
|
1726 | + } |
|
1726 | 1727 | } |
1727 | - } |
|
1728 | 1728 | } |
1729 | - } else { |
|
1729 | + } else { |
|
1730 | 1730 | $error = socket_strerror(socket_last_error()); |
1731 | 1731 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1732 | 1732 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1733 | 1733 | if (isset($globalDebug)) echo "Restarting...\n"; |
1734 | 1734 | // Restart the script if possible |
1735 | 1735 | if (is_array($sockets)) { |
1736 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1736 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1737 | 1737 | |
1738 | - foreach ($sockets as $sock) { |
|
1738 | + foreach ($sockets as $sock) { |
|
1739 | 1739 | @socket_shutdown($sock,2); |
1740 | 1740 | @socket_close($sock); |
1741 | - } |
|
1741 | + } |
|
1742 | 1742 | |
1743 | 1743 | } |
1744 | 1744 | if ($globalDebug) echo "Waiting..."; |
@@ -1753,15 +1753,15 @@ discard block |
||
1753 | 1753 | if ($globalDebug) echo "Restart all connections..."; |
1754 | 1754 | connect_all($globalSources); |
1755 | 1755 | } |
1756 | - } |
|
1756 | + } |
|
1757 | 1757 | } |
1758 | 1758 | if ($globalDaemon === false) { |
1759 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1760 | - if (isset($SI)) $SI->checkAll(); |
|
1761 | - if (isset($TI)) $TI->checkAll(); |
|
1762 | - if (isset($MI)) $MI->checkAll(); |
|
1759 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1760 | + if (isset($SI)) $SI->checkAll(); |
|
1761 | + if (isset($TI)) $TI->checkAll(); |
|
1762 | + if (isset($MI)) $MI->checkAll(); |
|
1763 | + } |
|
1763 | 1764 | } |
1764 | - } |
|
1765 | 1765 | } |
1766 | 1766 | |
1767 | 1767 | ?> |