@@ -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,189 +153,189 @@ 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,$date = '') |
|
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,$date = '') |
|
168 | 168 | { |
169 | - date_default_timezone_set('UTC'); |
|
170 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
171 | - if ($date == '') $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
172 | - else $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date"; |
|
169 | + date_default_timezone_set('UTC'); |
|
170 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
171 | + if ($date == '') $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
172 | + else $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date"; |
|
173 | 173 | |
174 | 174 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
175 | 175 | |
176 | - try { |
|
177 | - $sth = $this->db->prepare($query); |
|
178 | - $sth->execute(array(':id' => $id)); |
|
179 | - } catch(PDOException $e) { |
|
180 | - echo $e->getMessage(); |
|
181 | - die; |
|
182 | - } |
|
183 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
184 | - |
|
185 | - return $spotter_array; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Gets coordinate & time spotter information based on a particular id |
|
190 | - * |
|
191 | - * @return Array the spotter information |
|
192 | - * |
|
193 | - */ |
|
194 | - public function getCoordArchiveTrackerDataById($id) |
|
195 | - { |
|
196 | - date_default_timezone_set('UTC'); |
|
197 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
198 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
176 | + try { |
|
177 | + $sth = $this->db->prepare($query); |
|
178 | + $sth->execute(array(':id' => $id)); |
|
179 | + } catch(PDOException $e) { |
|
180 | + echo $e->getMessage(); |
|
181 | + die; |
|
182 | + } |
|
183 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
184 | + |
|
185 | + return $spotter_array; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Gets coordinate & time spotter information based on a particular id |
|
190 | + * |
|
191 | + * @return Array the spotter information |
|
192 | + * |
|
193 | + */ |
|
194 | + public function getCoordArchiveTrackerDataById($id) |
|
195 | + { |
|
196 | + date_default_timezone_set('UTC'); |
|
197 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
198 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
199 | 199 | |
200 | 200 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
201 | 201 | |
202 | - try { |
|
203 | - $sth = $this->db->prepare($query); |
|
204 | - $sth->execute(array(':id' => $id)); |
|
205 | - } catch(PDOException $e) { |
|
206 | - echo $e->getMessage(); |
|
207 | - die; |
|
208 | - } |
|
209 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
202 | + try { |
|
203 | + $sth = $this->db->prepare($query); |
|
204 | + $sth->execute(array(':id' => $id)); |
|
205 | + } catch(PDOException $e) { |
|
206 | + echo $e->getMessage(); |
|
207 | + die; |
|
208 | + } |
|
209 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
210 | 210 | |
211 | - return $spotter_array; |
|
212 | - } |
|
211 | + return $spotter_array; |
|
212 | + } |
|
213 | 213 | |
214 | 214 | |
215 | - /** |
|
216 | - * Gets altitude information based on a particular callsign |
|
217 | - * |
|
218 | - * @return Array the spotter information |
|
219 | - * |
|
220 | - */ |
|
221 | - public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
222 | - { |
|
215 | + /** |
|
216 | + * Gets altitude information based on a particular callsign |
|
217 | + * |
|
218 | + * @return Array the spotter information |
|
219 | + * |
|
220 | + */ |
|
221 | + public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
222 | + { |
|
223 | 223 | |
224 | - date_default_timezone_set('UTC'); |
|
224 | + date_default_timezone_set('UTC'); |
|
225 | 225 | |
226 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
227 | - $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"; |
|
226 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
227 | + $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"; |
|
228 | 228 | |
229 | - try { |
|
230 | - $sth = $this->db->prepare($query); |
|
231 | - $sth->execute(array(':ident' => $ident)); |
|
232 | - } catch(PDOException $e) { |
|
233 | - echo $e->getMessage(); |
|
234 | - die; |
|
235 | - } |
|
236 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
229 | + try { |
|
230 | + $sth = $this->db->prepare($query); |
|
231 | + $sth->execute(array(':ident' => $ident)); |
|
232 | + } catch(PDOException $e) { |
|
233 | + echo $e->getMessage(); |
|
234 | + die; |
|
235 | + } |
|
236 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
237 | 237 | |
238 | - return $spotter_array; |
|
239 | - } |
|
238 | + return $spotter_array; |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Gets altitude information based on a particular id |
|
243 | - * |
|
244 | - * @return Array the spotter information |
|
245 | - * |
|
246 | - */ |
|
247 | - public function getAltitudeArchiveTrackerDataById($id) |
|
248 | - { |
|
241 | + /** |
|
242 | + * Gets altitude information based on a particular id |
|
243 | + * |
|
244 | + * @return Array the spotter information |
|
245 | + * |
|
246 | + */ |
|
247 | + public function getAltitudeArchiveTrackerDataById($id) |
|
248 | + { |
|
249 | 249 | |
250 | - date_default_timezone_set('UTC'); |
|
250 | + date_default_timezone_set('UTC'); |
|
251 | 251 | |
252 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
253 | - $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"; |
|
252 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
253 | + $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"; |
|
254 | 254 | |
255 | - try { |
|
256 | - $sth = $this->db->prepare($query); |
|
257 | - $sth->execute(array(':id' => $id)); |
|
258 | - } catch(PDOException $e) { |
|
259 | - echo $e->getMessage(); |
|
260 | - die; |
|
261 | - } |
|
262 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
255 | + try { |
|
256 | + $sth = $this->db->prepare($query); |
|
257 | + $sth->execute(array(':id' => $id)); |
|
258 | + } catch(PDOException $e) { |
|
259 | + echo $e->getMessage(); |
|
260 | + die; |
|
261 | + } |
|
262 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
263 | 263 | |
264 | - return $spotter_array; |
|
265 | - } |
|
264 | + return $spotter_array; |
|
265 | + } |
|
266 | 266 | |
267 | - /** |
|
268 | - * Gets altitude & speed information based on a particular id |
|
269 | - * |
|
270 | - * @return Array the spotter information |
|
271 | - * |
|
272 | - */ |
|
273 | - public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
274 | - { |
|
267 | + /** |
|
268 | + * Gets altitude & speed information based on a particular id |
|
269 | + * |
|
270 | + * @return Array the spotter information |
|
271 | + * |
|
272 | + */ |
|
273 | + public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
274 | + { |
|
275 | 275 | |
276 | - date_default_timezone_set('UTC'); |
|
276 | + date_default_timezone_set('UTC'); |
|
277 | 277 | |
278 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
279 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
278 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
279 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
280 | 280 | |
281 | - try { |
|
282 | - $sth = $this->db->prepare($query); |
|
283 | - $sth->execute(array(':id' => $id)); |
|
284 | - } catch(PDOException $e) { |
|
285 | - echo $e->getMessage(); |
|
286 | - die; |
|
287 | - } |
|
288 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
281 | + try { |
|
282 | + $sth = $this->db->prepare($query); |
|
283 | + $sth->execute(array(':id' => $id)); |
|
284 | + } catch(PDOException $e) { |
|
285 | + echo $e->getMessage(); |
|
286 | + die; |
|
287 | + } |
|
288 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
289 | 289 | |
290 | - return $spotter_array; |
|
291 | - } |
|
290 | + return $spotter_array; |
|
291 | + } |
|
292 | 292 | |
293 | 293 | |
294 | - /** |
|
295 | - * Gets altitude information based on a particular callsign |
|
296 | - * |
|
297 | - * @return Array the spotter information |
|
298 | - * |
|
299 | - */ |
|
300 | - public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
301 | - { |
|
294 | + /** |
|
295 | + * Gets altitude information based on a particular callsign |
|
296 | + * |
|
297 | + * @return Array the spotter information |
|
298 | + * |
|
299 | + */ |
|
300 | + public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
301 | + { |
|
302 | 302 | |
303 | - date_default_timezone_set('UTC'); |
|
303 | + date_default_timezone_set('UTC'); |
|
304 | 304 | |
305 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
306 | - $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"; |
|
305 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
306 | + $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"; |
|
307 | 307 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
308 | 308 | |
309 | - try { |
|
310 | - $sth = $this->db->prepare($query); |
|
311 | - $sth->execute(array(':ident' => $ident)); |
|
312 | - } catch(PDOException $e) { |
|
313 | - echo $e->getMessage(); |
|
314 | - die; |
|
315 | - } |
|
316 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
309 | + try { |
|
310 | + $sth = $this->db->prepare($query); |
|
311 | + $sth->execute(array(':ident' => $ident)); |
|
312 | + } catch(PDOException $e) { |
|
313 | + echo $e->getMessage(); |
|
314 | + die; |
|
315 | + } |
|
316 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
317 | 317 | |
318 | - return $spotter_array; |
|
319 | - } |
|
318 | + return $spotter_array; |
|
319 | + } |
|
320 | 320 | |
321 | 321 | |
322 | 322 | |
323 | - /** |
|
324 | - * Gets all the archive spotter information |
|
325 | - * |
|
326 | - * @return Array the spotter information |
|
327 | - * |
|
328 | - */ |
|
329 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
330 | - { |
|
331 | - $Tracker = new Tracker($this->db); |
|
332 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
333 | - $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"; |
|
323 | + /** |
|
324 | + * Gets all the archive spotter information |
|
325 | + * |
|
326 | + * @return Array the spotter information |
|
327 | + * |
|
328 | + */ |
|
329 | + public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
330 | + { |
|
331 | + $Tracker = new Tracker($this->db); |
|
332 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
333 | + $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"; |
|
334 | 334 | |
335 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
335 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
336 | 336 | |
337 | - return $spotter_array; |
|
338 | - } |
|
337 | + return $spotter_array; |
|
338 | + } |
|
339 | 339 | |
340 | 340 | public function deleteTrackerArchiveTrackData() |
341 | 341 | { |
@@ -355,34 +355,34 @@ discard block |
||
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
358 | - * Gets Minimal Live Tracker data |
|
359 | - * |
|
360 | - * @return Array the spotter information |
|
361 | - * |
|
362 | - */ |
|
363 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
364 | - { |
|
365 | - global $globalDBdriver, $globalLiveInterval; |
|
366 | - date_default_timezone_set('UTC'); |
|
367 | - |
|
368 | - $filter_query = ''; |
|
369 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
370 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
371 | - } |
|
372 | - // Use spotter_output also ? |
|
373 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
374 | - $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 "; |
|
375 | - } |
|
376 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
377 | - $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 "; |
|
378 | - } |
|
379 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
380 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
381 | - } |
|
358 | + * Gets Minimal Live Tracker data |
|
359 | + * |
|
360 | + * @return Array the spotter information |
|
361 | + * |
|
362 | + */ |
|
363 | + public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
364 | + { |
|
365 | + global $globalDBdriver, $globalLiveInterval; |
|
366 | + date_default_timezone_set('UTC'); |
|
382 | 367 | |
383 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
384 | - if ($globalDBdriver == 'mysql') { |
|
385 | - /* |
|
368 | + $filter_query = ''; |
|
369 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
370 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
371 | + } |
|
372 | + // Use spotter_output also ? |
|
373 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
374 | + $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 "; |
|
375 | + } |
|
376 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
377 | + $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 "; |
|
378 | + } |
|
379 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
380 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
381 | + } |
|
382 | + |
|
383 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
384 | + if ($globalDBdriver == 'mysql') { |
|
385 | + /* |
|
386 | 386 | $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 |
387 | 387 | FROM tracker_archive |
388 | 388 | 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'; |
@@ -401,56 +401,56 @@ discard block |
||
401 | 401 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
402 | 402 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
403 | 403 | '.$filter_query.' ORDER BY famtrackid'; |
404 | - } else { |
|
405 | - //$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'; |
|
406 | - $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 |
|
404 | + } else { |
|
405 | + //$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'; |
|
406 | + $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 |
|
407 | 407 | FROM tracker_archive |
408 | 408 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
409 | 409 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
410 | 410 | '.$filter_query.' ORDER BY famtrackid'; |
411 | - } |
|
412 | - //echo $query; |
|
413 | - try { |
|
414 | - $sth = $this->db->prepare($query); |
|
415 | - $sth->execute(); |
|
416 | - } catch(PDOException $e) { |
|
417 | - echo $e->getMessage(); |
|
418 | - die; |
|
419 | - } |
|
420 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
411 | + } |
|
412 | + //echo $query; |
|
413 | + try { |
|
414 | + $sth = $this->db->prepare($query); |
|
415 | + $sth->execute(); |
|
416 | + } catch(PDOException $e) { |
|
417 | + echo $e->getMessage(); |
|
418 | + die; |
|
419 | + } |
|
420 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
421 | 421 | |
422 | - return $spotter_array; |
|
423 | - } |
|
422 | + return $spotter_array; |
|
423 | + } |
|
424 | 424 | |
425 | 425 | /** |
426 | - * Gets Minimal Live Tracker data |
|
427 | - * |
|
428 | - * @return Array the spotter information |
|
429 | - * |
|
430 | - */ |
|
431 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
432 | - { |
|
433 | - global $globalDBdriver, $globalLiveInterval; |
|
434 | - date_default_timezone_set('UTC'); |
|
435 | - |
|
436 | - $filter_query = ''; |
|
437 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
438 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
439 | - } |
|
440 | - // Should use spotter_output also ? |
|
441 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
442 | - $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 "; |
|
443 | - } |
|
444 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
445 | - $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 "; |
|
446 | - } |
|
447 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
448 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
449 | - } |
|
426 | + * Gets Minimal Live Tracker data |
|
427 | + * |
|
428 | + * @return Array the spotter information |
|
429 | + * |
|
430 | + */ |
|
431 | + public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
432 | + { |
|
433 | + global $globalDBdriver, $globalLiveInterval; |
|
434 | + date_default_timezone_set('UTC'); |
|
435 | + |
|
436 | + $filter_query = ''; |
|
437 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
438 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
439 | + } |
|
440 | + // Should use spotter_output also ? |
|
441 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
442 | + $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 "; |
|
443 | + } |
|
444 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
445 | + $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 "; |
|
446 | + } |
|
447 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
448 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
449 | + } |
|
450 | 450 | |
451 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
452 | - if ($globalDBdriver == 'mysql') { |
|
453 | - /* |
|
451 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
452 | + if ($globalDBdriver == 'mysql') { |
|
453 | + /* |
|
454 | 454 | $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 |
455 | 455 | FROM tracker_archive |
456 | 456 | 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'; |
@@ -461,95 +461,95 @@ discard block |
||
461 | 461 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
462 | 462 | '.$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'; |
463 | 463 | |
464 | - } else { |
|
465 | - //$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'; |
|
466 | - /* |
|
464 | + } else { |
|
465 | + //$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'; |
|
466 | + /* |
|
467 | 467 | $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 |
468 | 468 | FROM tracker_archive_output |
469 | 469 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
470 | 470 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
471 | 471 | '.$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'; |
472 | 472 | */ |
473 | - $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 | + $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 |
|
474 | 474 | FROM tracker_archive_output |
475 | 475 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
476 | 476 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
477 | 477 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
478 | 478 | // .' 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'; |
479 | 479 | |
480 | - } |
|
481 | - //echo $query; |
|
482 | - try { |
|
483 | - $sth = $this->db->prepare($query); |
|
484 | - $sth->execute(); |
|
485 | - } catch(PDOException $e) { |
|
486 | - echo $e->getMessage(); |
|
487 | - die; |
|
488 | - } |
|
489 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
480 | + } |
|
481 | + //echo $query; |
|
482 | + try { |
|
483 | + $sth = $this->db->prepare($query); |
|
484 | + $sth->execute(); |
|
485 | + } catch(PDOException $e) { |
|
486 | + echo $e->getMessage(); |
|
487 | + die; |
|
488 | + } |
|
489 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
490 | 490 | |
491 | - return $spotter_array; |
|
492 | - } |
|
491 | + return $spotter_array; |
|
492 | + } |
|
493 | 493 | |
494 | 494 | /** |
495 | - * Gets count Live Tracker data |
|
496 | - * |
|
497 | - * @return Array the spotter information |
|
498 | - * |
|
499 | - */ |
|
500 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
501 | - { |
|
502 | - global $globalDBdriver, $globalLiveInterval; |
|
503 | - date_default_timezone_set('UTC'); |
|
504 | - |
|
505 | - $filter_query = ''; |
|
506 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
507 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
508 | - } |
|
509 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
510 | - $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 "; |
|
511 | - } |
|
512 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
513 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
514 | - } |
|
515 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
516 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
517 | - } |
|
495 | + * Gets count Live Tracker data |
|
496 | + * |
|
497 | + * @return Array the spotter information |
|
498 | + * |
|
499 | + */ |
|
500 | + public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
501 | + { |
|
502 | + global $globalDBdriver, $globalLiveInterval; |
|
503 | + date_default_timezone_set('UTC'); |
|
518 | 504 | |
519 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
520 | - if ($globalDBdriver == 'mysql') { |
|
505 | + $filter_query = ''; |
|
506 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
507 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
508 | + } |
|
509 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
510 | + $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 "; |
|
511 | + } |
|
512 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
513 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
514 | + } |
|
515 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
516 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
517 | + } |
|
518 | + |
|
519 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
520 | + if ($globalDBdriver == 'mysql') { |
|
521 | 521 | $query = 'SELECT COUNT(DISTINCT famtrackid) as nb |
522 | 522 | FROM tracker_archive l |
523 | 523 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
524 | - } else { |
|
524 | + } else { |
|
525 | 525 | $query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
526 | - } |
|
527 | - //echo $query; |
|
528 | - try { |
|
529 | - $sth = $this->db->prepare($query); |
|
530 | - $sth->execute(); |
|
531 | - } catch(PDOException $e) { |
|
532 | - echo $e->getMessage(); |
|
533 | - die; |
|
534 | - } |
|
526 | + } |
|
527 | + //echo $query; |
|
528 | + try { |
|
529 | + $sth = $this->db->prepare($query); |
|
530 | + $sth->execute(); |
|
531 | + } catch(PDOException $e) { |
|
532 | + echo $e->getMessage(); |
|
533 | + die; |
|
534 | + } |
|
535 | 535 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
536 | 536 | $sth->closeCursor(); |
537 | - return $result['nb']; |
|
537 | + return $result['nb']; |
|
538 | 538 | |
539 | - } |
|
539 | + } |
|
540 | 540 | |
541 | 541 | |
542 | 542 | |
543 | 543 | // tracker_archive_output |
544 | 544 | |
545 | - /** |
|
546 | - * Gets all the spotter information |
|
547 | - * |
|
548 | - * @return Array the spotter information |
|
549 | - * |
|
550 | - */ |
|
551 | - 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()) |
|
552 | - { |
|
545 | + /** |
|
546 | + * Gets all the spotter information |
|
547 | + * |
|
548 | + * @return Array the spotter information |
|
549 | + * |
|
550 | + */ |
|
551 | + 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()) |
|
552 | + { |
|
553 | 553 | global $globalTimezone, $globalDBdriver; |
554 | 554 | require_once(dirname(__FILE__).'/class.Translation.php'); |
555 | 555 | $Translation = new Translation($this->db); |
@@ -563,159 +563,159 @@ discard block |
||
563 | 563 | $filter_query = $this->getFilter($filters); |
564 | 564 | if ($q != "") |
565 | 565 | { |
566 | - if (!is_string($q)) |
|
567 | - { |
|
566 | + if (!is_string($q)) |
|
567 | + { |
|
568 | 568 | return false; |
569 | - } else { |
|
569 | + } else { |
|
570 | 570 | |
571 | 571 | $q_array = explode(" ", $q); |
572 | 572 | |
573 | 573 | foreach ($q_array as $q_item){ |
574 | - $additional_query .= " AND ("; |
|
575 | - $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
576 | - $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
577 | - $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
578 | - $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
579 | - $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
580 | - $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
581 | - $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
582 | - $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
583 | - $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
584 | - $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
585 | - $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
586 | - $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
587 | - $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
588 | - $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
589 | - $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
590 | - $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
591 | - $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
592 | - $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
593 | - $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
594 | - $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
595 | - $translate = $Translation->ident2icao($q_item); |
|
596 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
597 | - $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
598 | - $additional_query .= ")"; |
|
574 | + $additional_query .= " AND ("; |
|
575 | + $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
576 | + $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
577 | + $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
578 | + $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
579 | + $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
580 | + $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
581 | + $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
582 | + $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
583 | + $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
584 | + $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
585 | + $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
586 | + $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
587 | + $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
588 | + $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
589 | + $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
590 | + $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
591 | + $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
592 | + $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
593 | + $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
594 | + $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
595 | + $translate = $Translation->ident2icao($q_item); |
|
596 | + if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
597 | + $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
598 | + $additional_query .= ")"; |
|
599 | + } |
|
599 | 600 | } |
600 | - } |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | if ($registration != "") |
604 | 604 | { |
605 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
606 | - if (!is_string($registration)) |
|
607 | - { |
|
605 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
606 | + if (!is_string($registration)) |
|
607 | + { |
|
608 | 608 | return false; |
609 | - } else { |
|
609 | + } else { |
|
610 | 610 | $additional_query .= " AND (tracker_archive_output.registration = '".$registration."')"; |
611 | - } |
|
611 | + } |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | if ($aircraft_icao != "") |
615 | 615 | { |
616 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
617 | - if (!is_string($aircraft_icao)) |
|
618 | - { |
|
616 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
617 | + if (!is_string($aircraft_icao)) |
|
618 | + { |
|
619 | 619 | return false; |
620 | - } else { |
|
620 | + } else { |
|
621 | 621 | $additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
622 | - } |
|
622 | + } |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | if ($aircraft_manufacturer != "") |
626 | 626 | { |
627 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
628 | - if (!is_string($aircraft_manufacturer)) |
|
629 | - { |
|
627 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
628 | + if (!is_string($aircraft_manufacturer)) |
|
629 | + { |
|
630 | 630 | return false; |
631 | - } else { |
|
631 | + } else { |
|
632 | 632 | $additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
633 | - } |
|
633 | + } |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | if ($highlights == "true") |
637 | 637 | { |
638 | - if (!is_string($highlights)) |
|
639 | - { |
|
638 | + if (!is_string($highlights)) |
|
639 | + { |
|
640 | 640 | return false; |
641 | - } else { |
|
641 | + } else { |
|
642 | 642 | $additional_query .= " AND (tracker_archive_output.highlight <> '')"; |
643 | - } |
|
643 | + } |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | if ($airline_icao != "") |
647 | 647 | { |
648 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
649 | - if (!is_string($airline_icao)) |
|
650 | - { |
|
648 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
649 | + if (!is_string($airline_icao)) |
|
650 | + { |
|
651 | 651 | return false; |
652 | - } else { |
|
652 | + } else { |
|
653 | 653 | $additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')"; |
654 | - } |
|
654 | + } |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | if ($airline_country != "") |
658 | 658 | { |
659 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
660 | - if (!is_string($airline_country)) |
|
661 | - { |
|
659 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
660 | + if (!is_string($airline_country)) |
|
661 | + { |
|
662 | 662 | return false; |
663 | - } else { |
|
663 | + } else { |
|
664 | 664 | $additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')"; |
665 | - } |
|
665 | + } |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | if ($airline_type != "") |
669 | 669 | { |
670 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
671 | - if (!is_string($airline_type)) |
|
672 | - { |
|
670 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
671 | + if (!is_string($airline_type)) |
|
672 | + { |
|
673 | 673 | return false; |
674 | - } else { |
|
674 | + } else { |
|
675 | 675 | if ($airline_type == "passenger") |
676 | 676 | { |
677 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
677 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
678 | 678 | } |
679 | 679 | if ($airline_type == "cargo") |
680 | 680 | { |
681 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
681 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
682 | 682 | } |
683 | 683 | if ($airline_type == "military") |
684 | 684 | { |
685 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
685 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
686 | + } |
|
686 | 687 | } |
687 | - } |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | if ($airport != "") |
691 | 691 | { |
692 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
693 | - if (!is_string($airport)) |
|
694 | - { |
|
692 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
693 | + if (!is_string($airport)) |
|
694 | + { |
|
695 | 695 | return false; |
696 | - } else { |
|
696 | + } else { |
|
697 | 697 | $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))"; |
698 | - } |
|
698 | + } |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | if ($airport_country != "") |
702 | 702 | { |
703 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
704 | - if (!is_string($airport_country)) |
|
705 | - { |
|
703 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
704 | + if (!is_string($airport_country)) |
|
705 | + { |
|
706 | 706 | return false; |
707 | - } else { |
|
707 | + } else { |
|
708 | 708 | $additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))"; |
709 | - } |
|
709 | + } |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | if ($callsign != "") |
713 | 713 | { |
714 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
715 | - if (!is_string($callsign)) |
|
716 | - { |
|
714 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
715 | + if (!is_string($callsign)) |
|
716 | + { |
|
717 | 717 | return false; |
718 | - } else { |
|
718 | + } else { |
|
719 | 719 | $translate = $Translation->ident2icao($callsign); |
720 | 720 | if ($translate != $callsign) { |
721 | 721 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
@@ -723,99 +723,99 @@ discard block |
||
723 | 723 | } else { |
724 | 724 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
725 | 725 | } |
726 | - } |
|
726 | + } |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | if ($owner != "") |
730 | 730 | { |
731 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
732 | - if (!is_string($owner)) |
|
733 | - { |
|
731 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
732 | + if (!is_string($owner)) |
|
733 | + { |
|
734 | 734 | return false; |
735 | - } else { |
|
735 | + } else { |
|
736 | 736 | $additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')"; |
737 | - } |
|
737 | + } |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | if ($pilot_name != "") |
741 | 741 | { |
742 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
743 | - if (!is_string($pilot_name)) |
|
744 | - { |
|
742 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
743 | + if (!is_string($pilot_name)) |
|
744 | + { |
|
745 | 745 | return false; |
746 | - } else { |
|
746 | + } else { |
|
747 | 747 | $additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')"; |
748 | - } |
|
748 | + } |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | if ($pilot_id != "") |
752 | 752 | { |
753 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
754 | - if (!is_string($pilot_id)) |
|
755 | - { |
|
753 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
754 | + if (!is_string($pilot_id)) |
|
755 | + { |
|
756 | 756 | return false; |
757 | - } else { |
|
757 | + } else { |
|
758 | 758 | $additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')"; |
759 | - } |
|
759 | + } |
|
760 | 760 | } |
761 | 761 | |
762 | 762 | if ($departure_airport_route != "") |
763 | 763 | { |
764 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
765 | - if (!is_string($departure_airport_route)) |
|
766 | - { |
|
764 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
765 | + if (!is_string($departure_airport_route)) |
|
766 | + { |
|
767 | 767 | return false; |
768 | - } else { |
|
768 | + } else { |
|
769 | 769 | $additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
770 | - } |
|
770 | + } |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | if ($arrival_airport_route != "") |
774 | 774 | { |
775 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
776 | - if (!is_string($arrival_airport_route)) |
|
777 | - { |
|
775 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
776 | + if (!is_string($arrival_airport_route)) |
|
777 | + { |
|
778 | 778 | return false; |
779 | - } else { |
|
779 | + } else { |
|
780 | 780 | $additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
781 | - } |
|
781 | + } |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | if ($altitude != "") |
785 | 785 | { |
786 | - $altitude_array = explode(",", $altitude); |
|
786 | + $altitude_array = explode(",", $altitude); |
|
787 | 787 | |
788 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
789 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
789 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
790 | 790 | |
791 | 791 | |
792 | - if ($altitude_array[1] != "") |
|
793 | - { |
|
792 | + if ($altitude_array[1] != "") |
|
793 | + { |
|
794 | 794 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
795 | 795 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
796 | 796 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
797 | - } else { |
|
797 | + } else { |
|
798 | 798 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
799 | 799 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
800 | - } |
|
800 | + } |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | if ($date_posted != "") |
804 | 804 | { |
805 | - $date_array = explode(",", $date_posted); |
|
805 | + $date_array = explode(",", $date_posted); |
|
806 | 806 | |
807 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
808 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
807 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
808 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
809 | 809 | |
810 | - if ($globalTimezone != '') { |
|
810 | + if ($globalTimezone != '') { |
|
811 | 811 | date_default_timezone_set($globalTimezone); |
812 | 812 | $datetime = new DateTime(); |
813 | 813 | $offset = $datetime->format('P'); |
814 | - } else $offset = '+00:00'; |
|
814 | + } else $offset = '+00:00'; |
|
815 | 815 | |
816 | 816 | |
817 | - if ($date_array[1] != "") |
|
818 | - { |
|
817 | + if ($date_array[1] != "") |
|
818 | + { |
|
819 | 819 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
820 | 820 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
821 | 821 | if ($globalDBdriver == 'mysql') { |
@@ -823,28 +823,28 @@ discard block |
||
823 | 823 | } else { |
824 | 824 | $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) "; |
825 | 825 | } |
826 | - } else { |
|
826 | + } else { |
|
827 | 827 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
828 | - if ($globalDBdriver == 'mysql') { |
|
828 | + if ($globalDBdriver == 'mysql') { |
|
829 | 829 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
830 | 830 | } else { |
831 | 831 | $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
832 | 832 | } |
833 | - } |
|
833 | + } |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | if ($limit != "") |
837 | 837 | { |
838 | - $limit_array = explode(",", $limit); |
|
838 | + $limit_array = explode(",", $limit); |
|
839 | 839 | |
840 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
841 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
840 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
841 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
842 | 842 | |
843 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
844 | - { |
|
843 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
844 | + { |
|
845 | 845 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
846 | 846 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
847 | - } |
|
847 | + } |
|
848 | 848 | } |
849 | 849 | |
850 | 850 | |
@@ -875,33 +875,33 @@ discard block |
||
875 | 875 | $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
876 | 876 | |
877 | 877 | return $spotter_array; |
878 | - } |
|
878 | + } |
|
879 | 879 | |
880 | - public function deleteTrackerArchiveData() |
|
881 | - { |
|
880 | + public function deleteTrackerArchiveData() |
|
881 | + { |
|
882 | 882 | global $globalArchiveKeepMonths, $globalDBdriver; |
883 | - date_default_timezone_set('UTC'); |
|
884 | - if ($globalDBdriver == 'mysql') { |
|
883 | + date_default_timezone_set('UTC'); |
|
884 | + if ($globalDBdriver == 'mysql') { |
|
885 | 885 | $query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
886 | 886 | } else { |
887 | 887 | $query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
888 | 888 | } |
889 | - try { |
|
890 | - $sth = $this->db->prepare($query); |
|
891 | - $sth->execute(); |
|
892 | - } catch(PDOException $e) { |
|
893 | - return "error"; |
|
894 | - } |
|
889 | + try { |
|
890 | + $sth = $this->db->prepare($query); |
|
891 | + $sth->execute(); |
|
892 | + } catch(PDOException $e) { |
|
893 | + return "error"; |
|
894 | + } |
|
895 | 895 | } |
896 | 896 | |
897 | - /** |
|
898 | - * Gets all the spotter information based on the callsign |
|
899 | - * |
|
900 | - * @return Array the spotter information |
|
901 | - * |
|
902 | - */ |
|
903 | - public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
904 | - { |
|
897 | + /** |
|
898 | + * Gets all the spotter information based on the callsign |
|
899 | + * |
|
900 | + * @return Array the spotter information |
|
901 | + * |
|
902 | + */ |
|
903 | + public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
904 | + { |
|
905 | 905 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
906 | 906 | |
907 | 907 | date_default_timezone_set('UTC'); |
@@ -913,35 +913,35 @@ discard block |
||
913 | 913 | |
914 | 914 | if ($ident != "") |
915 | 915 | { |
916 | - if (!is_string($ident)) |
|
917 | - { |
|
916 | + if (!is_string($ident)) |
|
917 | + { |
|
918 | 918 | return false; |
919 | - } else { |
|
919 | + } else { |
|
920 | 920 | $additional_query = " AND (tracker_archive_output.ident = :ident)"; |
921 | 921 | $query_values = array(':ident' => $ident); |
922 | - } |
|
922 | + } |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | if ($limit != "") |
926 | 926 | { |
927 | - $limit_array = explode(",", $limit); |
|
927 | + $limit_array = explode(",", $limit); |
|
928 | 928 | |
929 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
930 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
929 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
930 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
931 | 931 | |
932 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
933 | - { |
|
932 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
933 | + { |
|
934 | 934 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
935 | 935 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
936 | - } |
|
936 | + } |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | if ($sort != "") |
940 | 940 | { |
941 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
942 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
941 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
942 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
943 | 943 | } else { |
944 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
944 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
945 | 945 | } |
946 | 946 | |
947 | 947 | $query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -949,17 +949,17 @@ discard block |
||
949 | 949 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
950 | 950 | |
951 | 951 | return $spotter_array; |
952 | - } |
|
952 | + } |
|
953 | 953 | |
954 | 954 | |
955 | - /** |
|
956 | - * Gets all the spotter information based on the owner |
|
957 | - * |
|
958 | - * @return Array the spotter information |
|
959 | - * |
|
960 | - */ |
|
961 | - public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
962 | - { |
|
955 | + /** |
|
956 | + * Gets all the spotter information based on the owner |
|
957 | + * |
|
958 | + * @return Array the spotter information |
|
959 | + * |
|
960 | + */ |
|
961 | + public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
962 | + { |
|
963 | 963 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
964 | 964 | |
965 | 965 | date_default_timezone_set('UTC'); |
@@ -972,35 +972,35 @@ discard block |
||
972 | 972 | |
973 | 973 | if ($owner != "") |
974 | 974 | { |
975 | - if (!is_string($owner)) |
|
976 | - { |
|
975 | + if (!is_string($owner)) |
|
976 | + { |
|
977 | 977 | return false; |
978 | - } else { |
|
978 | + } else { |
|
979 | 979 | $additional_query = " AND (tracker_archive_output.owner_name = :owner)"; |
980 | 980 | $query_values = array(':owner' => $owner); |
981 | - } |
|
981 | + } |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | if ($limit != "") |
985 | 985 | { |
986 | - $limit_array = explode(",", $limit); |
|
986 | + $limit_array = explode(",", $limit); |
|
987 | 987 | |
988 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
989 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
988 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
989 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
990 | 990 | |
991 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
992 | - { |
|
991 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
992 | + { |
|
993 | 993 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
994 | 994 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
995 | - } |
|
995 | + } |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | if ($sort != "") |
999 | 999 | { |
1000 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
1001 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1000 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
1001 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1002 | 1002 | } else { |
1003 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1003 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | $query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1008,16 +1008,16 @@ discard block |
||
1008 | 1008 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
1009 | 1009 | |
1010 | 1010 | return $spotter_array; |
1011 | - } |
|
1012 | - |
|
1013 | - /** |
|
1014 | - * Gets all the spotter information based on the pilot |
|
1015 | - * |
|
1016 | - * @return Array the spotter information |
|
1017 | - * |
|
1018 | - */ |
|
1019 | - public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1020 | - { |
|
1011 | + } |
|
1012 | + |
|
1013 | + /** |
|
1014 | + * Gets all the spotter information based on the pilot |
|
1015 | + * |
|
1016 | + * @return Array the spotter information |
|
1017 | + * |
|
1018 | + */ |
|
1019 | + public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1020 | + { |
|
1021 | 1021 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
1022 | 1022 | |
1023 | 1023 | date_default_timezone_set('UTC'); |
@@ -1036,24 +1036,24 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | if ($limit != "") |
1038 | 1038 | { |
1039 | - $limit_array = explode(",", $limit); |
|
1039 | + $limit_array = explode(",", $limit); |
|
1040 | 1040 | |
1041 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1042 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1042 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1043 | 1043 | |
1044 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1045 | - { |
|
1044 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1045 | + { |
|
1046 | 1046 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1047 | 1047 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1048 | - } |
|
1048 | + } |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | if ($sort != "") |
1052 | 1052 | { |
1053 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
1054 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1053 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
1054 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1055 | 1055 | } else { |
1056 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1056 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | $query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1061,16 +1061,16 @@ discard block |
||
1061 | 1061 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
1062 | 1062 | |
1063 | 1063 | return $spotter_array; |
1064 | - } |
|
1065 | - |
|
1066 | - /** |
|
1067 | - * Gets all number of flight over countries |
|
1068 | - * |
|
1069 | - * @return Array the airline country list |
|
1070 | - * |
|
1071 | - */ |
|
1072 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1073 | - { |
|
1064 | + } |
|
1065 | + |
|
1066 | + /** |
|
1067 | + * Gets all number of flight over countries |
|
1068 | + * |
|
1069 | + * @return Array the airline country list |
|
1070 | + * |
|
1071 | + */ |
|
1072 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1073 | + { |
|
1074 | 1074 | global $globalDBdriver; |
1075 | 1075 | /* |
1076 | 1076 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1080,14 +1080,14 @@ discard block |
||
1080 | 1080 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1081 | 1081 | FROM countries c, tracker_archive s |
1082 | 1082 | WHERE c.iso2 = s.over_country "; |
1083 | - if ($olderthanmonths > 0) { |
|
1084 | - if ($globalDBdriver == 'mysql') { |
|
1083 | + if ($olderthanmonths > 0) { |
|
1084 | + if ($globalDBdriver == 'mysql') { |
|
1085 | 1085 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1086 | 1086 | } else { |
1087 | 1087 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1088 | 1088 | } |
1089 | 1089 | } |
1090 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1090 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1091 | 1091 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1092 | 1092 | if ($limit) $query .= " LIMIT 0,10"; |
1093 | 1093 | |
@@ -1100,23 +1100,23 @@ discard block |
||
1100 | 1100 | |
1101 | 1101 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1102 | 1102 | { |
1103 | - $temp_array['flight_count'] = $row['nb']; |
|
1104 | - $temp_array['flight_country'] = $row['name']; |
|
1105 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1106 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1107 | - $flight_array[] = $temp_array; |
|
1103 | + $temp_array['flight_count'] = $row['nb']; |
|
1104 | + $temp_array['flight_country'] = $row['name']; |
|
1105 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1106 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1107 | + $flight_array[] = $temp_array; |
|
1108 | 1108 | } |
1109 | 1109 | return $flight_array; |
1110 | - } |
|
1111 | - |
|
1112 | - /** |
|
1113 | - * Gets all number of flight over countries |
|
1114 | - * |
|
1115 | - * @return Array the airline country list |
|
1116 | - * |
|
1117 | - */ |
|
1118 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1119 | - { |
|
1110 | + } |
|
1111 | + |
|
1112 | + /** |
|
1113 | + * Gets all number of flight over countries |
|
1114 | + * |
|
1115 | + * @return Array the airline country list |
|
1116 | + * |
|
1117 | + */ |
|
1118 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1119 | + { |
|
1120 | 1120 | global $globalDBdriver; |
1121 | 1121 | /* |
1122 | 1122 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1126,14 +1126,14 @@ discard block |
||
1126 | 1126 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1127 | 1127 | FROM countries c, tracker_archive s, spotter_output o |
1128 | 1128 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.famtrackid = s.famtrackid "; |
1129 | - if ($olderthanmonths > 0) { |
|
1130 | - if ($globalDBdriver == 'mysql') { |
|
1129 | + if ($olderthanmonths > 0) { |
|
1130 | + if ($globalDBdriver == 'mysql') { |
|
1131 | 1131 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1132 | 1132 | } else { |
1133 | 1133 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1134 | 1134 | } |
1135 | 1135 | } |
1136 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1136 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1137 | 1137 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1138 | 1138 | if ($limit) $query .= " LIMIT 0,10"; |
1139 | 1139 | |
@@ -1146,24 +1146,24 @@ discard block |
||
1146 | 1146 | |
1147 | 1147 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1148 | 1148 | { |
1149 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1150 | - $temp_array['flight_count'] = $row['nb']; |
|
1151 | - $temp_array['flight_country'] = $row['name']; |
|
1152 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1153 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1154 | - $flight_array[] = $temp_array; |
|
1149 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1150 | + $temp_array['flight_count'] = $row['nb']; |
|
1151 | + $temp_array['flight_country'] = $row['name']; |
|
1152 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1153 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1154 | + $flight_array[] = $temp_array; |
|
1155 | 1155 | } |
1156 | 1156 | return $flight_array; |
1157 | - } |
|
1158 | - |
|
1159 | - /** |
|
1160 | - * Gets last spotter information based on a particular callsign |
|
1161 | - * |
|
1162 | - * @return Array the spotter information |
|
1163 | - * |
|
1164 | - */ |
|
1165 | - public function getDateArchiveTrackerDataById($id,$date) |
|
1166 | - { |
|
1157 | + } |
|
1158 | + |
|
1159 | + /** |
|
1160 | + * Gets last spotter information based on a particular callsign |
|
1161 | + * |
|
1162 | + * @return Array the spotter information |
|
1163 | + * |
|
1164 | + */ |
|
1165 | + public function getDateArchiveTrackerDataById($id,$date) |
|
1166 | + { |
|
1167 | 1167 | $Tracker = new Tracker($this->db); |
1168 | 1168 | date_default_timezone_set('UTC'); |
1169 | 1169 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1171,16 +1171,16 @@ discard block |
||
1171 | 1171 | $date = date('c',$date); |
1172 | 1172 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1173 | 1173 | return $spotter_array; |
1174 | - } |
|
1175 | - |
|
1176 | - /** |
|
1177 | - * Gets all the spotter information based on a particular callsign |
|
1178 | - * |
|
1179 | - * @return Array the spotter information |
|
1180 | - * |
|
1181 | - */ |
|
1182 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
1183 | - { |
|
1174 | + } |
|
1175 | + |
|
1176 | + /** |
|
1177 | + * Gets all the spotter information based on a particular callsign |
|
1178 | + * |
|
1179 | + * @return Array the spotter information |
|
1180 | + * |
|
1181 | + */ |
|
1182 | + public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
1183 | + { |
|
1184 | 1184 | $Tracker = new Tracker($this->db); |
1185 | 1185 | date_default_timezone_set('UTC'); |
1186 | 1186 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1188,16 +1188,16 @@ discard block |
||
1188 | 1188 | $date = date('c',$date); |
1189 | 1189 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1190 | 1190 | return $spotter_array; |
1191 | - } |
|
1192 | - |
|
1193 | - /** |
|
1194 | - * Gets all the spotter information based on the airport |
|
1195 | - * |
|
1196 | - * @return Array the spotter information |
|
1197 | - * |
|
1198 | - */ |
|
1199 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1200 | - { |
|
1191 | + } |
|
1192 | + |
|
1193 | + /** |
|
1194 | + * Gets all the spotter information based on the airport |
|
1195 | + * |
|
1196 | + * @return Array the spotter information |
|
1197 | + * |
|
1198 | + */ |
|
1199 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1200 | + { |
|
1201 | 1201 | global $global_query; |
1202 | 1202 | $Tracker = new Tracker($this->db); |
1203 | 1203 | date_default_timezone_set('UTC'); |
@@ -1208,35 +1208,35 @@ discard block |
||
1208 | 1208 | |
1209 | 1209 | if ($airport != "") |
1210 | 1210 | { |
1211 | - if (!is_string($airport)) |
|
1212 | - { |
|
1211 | + if (!is_string($airport)) |
|
1212 | + { |
|
1213 | 1213 | return false; |
1214 | - } else { |
|
1214 | + } else { |
|
1215 | 1215 | $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))"; |
1216 | 1216 | $query_values = array(':airport' => $airport); |
1217 | - } |
|
1217 | + } |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | if ($limit != "") |
1221 | 1221 | { |
1222 | - $limit_array = explode(",", $limit); |
|
1222 | + $limit_array = explode(",", $limit); |
|
1223 | 1223 | |
1224 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1225 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1224 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1225 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1226 | 1226 | |
1227 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1228 | - { |
|
1227 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1228 | + { |
|
1229 | 1229 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1230 | 1230 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1231 | - } |
|
1231 | + } |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | if ($sort != "") |
1235 | 1235 | { |
1236 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
1237 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1236 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
1237 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1238 | 1238 | } else { |
1239 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1239 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1240 | 1240 | } |
1241 | 1241 | |
1242 | 1242 | $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; |
@@ -1244,6 +1244,6 @@ discard block |
||
1244 | 1244 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
1245 | 1245 | |
1246 | 1246 | return $spotter_array; |
1247 | - } |
|
1247 | + } |
|
1248 | 1248 | } |
1249 | 1249 | ?> |
1250 | 1250 | \ No newline at end of file |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | <?php }; if (isset($globalSatellite) && $globalSatellite) { ?><td><div id="ibxsatellite"><h4><?php echo _("Satellites Displayed"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div></td><?php } ?> |
48 | 48 | </tr></table></div> |
49 | 49 | <?php |
50 | - if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
50 | + if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
51 | 51 | ?> |
52 | 52 | <script src="<?php echo $globalURL; ?>/js/map.3d.js.php<?php if (isset($tsk)) print '?tsk='.$tsk; ?>"></script> |
53 | 53 | <?php |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script> |
72 | 72 | <?php |
73 | 73 | } |
74 | - } |
|
74 | + } |
|
75 | 75 | ?> |
76 | 76 | |
77 | 77 | <div id="sidebar" class="sidebar collapsed"> |
@@ -82,34 +82,34 @@ discard block |
||
82 | 82 | <li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li> |
83 | 83 | <li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li> |
84 | 84 | <?php |
85 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
85 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
86 | 86 | if (isset($globalArchive) && $globalArchive == TRUE) { |
87 | 87 | ?> |
88 | 88 | <li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li> |
89 | 89 | <?php |
90 | 90 | } |
91 | - } |
|
91 | + } |
|
92 | 92 | ?> |
93 | 93 | <li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li> |
94 | 94 | <li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li> |
95 | 95 | <li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li> |
96 | 96 | <?php |
97 | - if (isset($globalMap3D) && $globalMap3D) { |
|
97 | + if (isset($globalMap3D) && $globalMap3D) { |
|
98 | 98 | if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
99 | 99 | ?> |
100 | 100 | <li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li> |
101 | 101 | <?php |
102 | 102 | } else { |
103 | - if (isset($globalSatellite) && $globalSatellite) { |
|
103 | + if (isset($globalSatellite) && $globalSatellite) { |
|
104 | 104 | ?> |
105 | 105 | <li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li> |
106 | 106 | <?php |
107 | - } |
|
107 | + } |
|
108 | 108 | ?> |
109 | 109 | <li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li> |
110 | 110 | <?php |
111 | 111 | } |
112 | - } |
|
112 | + } |
|
113 | 113 | ?> |
114 | 114 | </ul> |
115 | 115 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | ?> |
185 | 185 | </div> |
186 | 186 | <?php |
187 | - if (isset($globalArchive) && $globalArchive == TRUE) { |
|
187 | + if (isset($globalArchive) && $globalArchive == TRUE) { |
|
188 | 188 | ?> |
189 | 189 | <div class="sidebar-pane" id="archive"> |
190 | 190 | <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | </form> |
244 | 244 | </div> |
245 | 245 | <?php |
246 | - } |
|
246 | + } |
|
247 | 247 | ?> |
248 | 248 | <div class="sidebar-pane" id="settings"> |
249 | 249 | <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -254,72 +254,72 @@ discard block |
||
254 | 254 | <?php |
255 | 255 | if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider; |
256 | 256 | else $MapType = $_COOKIE['MapType']; |
257 | - ?> |
|
257 | + ?> |
|
258 | 258 | <?php |
259 | 259 | if (isset($globalMapOffline) && $globalMapOffline === TRUE) { |
260 | - ?> |
|
260 | + ?> |
|
261 | 261 | <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option> |
262 | 262 | <?php |
263 | 263 | } else { |
264 | - if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) { |
|
265 | - ?> |
|
264 | + if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) { |
|
265 | + ?> |
|
266 | 266 | <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option> |
267 | 267 | <?php |
268 | - } |
|
269 | - ?> |
|
268 | + } |
|
269 | + ?> |
|
270 | 270 | <option value="ArcGIS-Streetmap"<?php if ($MapType == 'ArcGIS-Streetmap') print ' selected'; ?>>ArcGIS Streetmap</option> |
271 | 271 | <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Satellite') print ' selected'; ?>>ArcGIS Satellite</option> |
272 | 272 | <?php |
273 | - if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
|
274 | - ?> |
|
273 | + if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
|
274 | + ?> |
|
275 | 275 | <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option> |
276 | 276 | <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option> |
277 | 277 | <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option> |
278 | 278 | <?php |
279 | - } |
|
280 | - ?> |
|
279 | + } |
|
280 | + ?> |
|
281 | 281 | <?php |
282 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
283 | - ?> |
|
282 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
283 | + ?> |
|
284 | 284 | <?php |
285 | 285 | if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
286 | - ?> |
|
286 | + ?> |
|
287 | 287 | <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option> |
288 | 288 | <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option> |
289 | 289 | <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option> |
290 | 290 | <?php |
291 | 291 | } |
292 | - ?> |
|
292 | + ?> |
|
293 | 293 | <?php |
294 | 294 | if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
295 | - ?> |
|
295 | + ?> |
|
296 | 296 | <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option> |
297 | 297 | <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option> |
298 | 298 | <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option> |
299 | 299 | <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option> |
300 | 300 | <?php |
301 | 301 | } |
302 | - ?> |
|
302 | + ?> |
|
303 | 303 | <?php |
304 | 304 | if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
305 | - ?> |
|
305 | + ?> |
|
306 | 306 | <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option> |
307 | 307 | <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option> |
308 | 308 | <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option> |
309 | 309 | <?php |
310 | 310 | } |
311 | - ?> |
|
311 | + ?> |
|
312 | 312 | <option value="NatGeo-Street"<?php if ($MapType == 'NatGeo-Street') print ' selected'; ?>>National Geographic Street</option> |
313 | 313 | <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option> |
314 | 314 | <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth</option> |
315 | 315 | <?php |
316 | - } |
|
317 | - ?> |
|
316 | + } |
|
317 | + ?> |
|
318 | 318 | <?php |
319 | - if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
319 | + if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
320 | 320 | if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default'; |
321 | 321 | else $MapBoxId = $_COOKIE['MapTypeId']; |
322 | - ?> |
|
322 | + ?> |
|
323 | 323 | <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') print ' selected'; ?>>Mapbox GL</option> |
324 | 324 | <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option> |
325 | 325 | <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option> |
@@ -334,16 +334,16 @@ discard block |
||
334 | 334 | <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option> |
335 | 335 | <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option> |
336 | 336 | <?php |
337 | - } |
|
338 | - ?> |
|
337 | + } |
|
338 | + ?> |
|
339 | 339 | <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option> |
340 | 340 | <?php |
341 | 341 | } |
342 | - ?> |
|
342 | + ?> |
|
343 | 343 | </select> |
344 | 344 | </li> |
345 | 345 | <?php |
346 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && (!isset($globalMapOffline) || $globalMapOffline === FALSE)) { |
|
346 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && (!isset($globalMapOffline) || $globalMapOffline === FALSE)) { |
|
347 | 347 | ?> |
348 | 348 | <li><?php echo _("Type of Terrain:"); ?> |
349 | 349 | <select class="selectpicker" onchange="terrainType(this);"> |
@@ -354,10 +354,10 @@ discard block |
||
354 | 354 | </select> |
355 | 355 | </li> |
356 | 356 | <?php |
357 | - } |
|
357 | + } |
|
358 | 358 | ?> |
359 | 359 | <?php |
360 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
360 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
361 | 361 | ?> |
362 | 362 | <li><div class="checkbox"><label><input type="checkbox" name="display2dbuildings" value="1" onclick="clickDisplay2DBuildings(this)" <?php if (isset($_COOKIE['Map2DBuildings']) && $_COOKIE['Map2DBuildings'] == 'true') print 'checked'; ?> ><?php echo _("Display 2.5D buidings on map"); ?></label></div></li> |
363 | 363 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | <li><div class="checkbox"><label><input type="checkbox" name="satelliteestimation" value="1" onclick="clickSatelliteEstimation(this)" <?php if ((isset($_COOKIE['satelliteestimation']) && $_COOKIE['satelliteestimation'] == 'true') || (!isset($_COOKIE['satelliteestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['satelliteestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Satellites animate between updates"); ?></label></div></li> |
381 | 381 | <?php |
382 | 382 | } |
383 | - } |
|
383 | + } |
|
384 | 384 | ?> |
385 | 385 | <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li> |
386 | 386 | <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li> |
@@ -392,81 +392,81 @@ discard block |
||
392 | 392 | <li><div class="checkbox"><label><input type="checkbox" name="displayfires" value="1" onclick="clickDisplayFires(this)" <?php if ((isset($_COOKIE['show_Fires']) && $_COOKIE['show_Fires'] == 'true') || (!isset($_COOKIE['show_Fires']) && (isset($globalMapFires) && $globalMapFires === TRUE))) print 'checked'; ?> ><?php echo _("Display fires on map"); ?></label></div></li> |
393 | 393 | <?php |
394 | 394 | } |
395 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
395 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
396 | 396 | ?> |
397 | 397 | <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
398 | 398 | <?php |
399 | - } |
|
400 | - if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
399 | + } |
|
400 | + if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
401 | 401 | ?> |
402 | 402 | <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li> |
403 | 403 | <?php |
404 | - } |
|
404 | + } |
|
405 | 405 | ?> |
406 | 406 | <?php |
407 | 407 | if (function_exists('array_column')) { |
408 | - if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
409 | - ?> |
|
408 | + if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
409 | + ?> |
|
410 | 410 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
411 | 411 | <?php |
412 | - } |
|
412 | + } |
|
413 | 413 | } elseif (isset($globalSources)) { |
414 | - $dispolar = false; |
|
415 | - foreach ($globalSources as $testsource) { |
|
416 | - if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
417 | - } |
|
418 | - if ($dispolar) { |
|
419 | - ?> |
|
414 | + $dispolar = false; |
|
415 | + foreach ($globalSources as $testsource) { |
|
416 | + if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
417 | + } |
|
418 | + if ($dispolar) { |
|
419 | + ?> |
|
420 | 420 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
421 | 421 | <?php |
422 | - } |
|
423 | - } |
|
424 | - ?> |
|
422 | + } |
|
423 | + } |
|
424 | + ?> |
|
425 | 425 | <?php |
426 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
426 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
427 | 427 | ?> |
428 | 428 | |
429 | 429 | <?php |
430 | 430 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
431 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
432 | - ?> |
|
431 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
432 | + ?> |
|
433 | 433 | <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
434 | 434 | <?php |
435 | 435 | if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') { |
436 | - ?> |
|
436 | + ?> |
|
437 | 437 | <li><?php echo _("Aircraft icon color:"); ?> |
438 | 438 | <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"> |
439 | 439 | </li> |
440 | 440 | <?php |
441 | 441 | } |
442 | - } |
|
443 | - } |
|
444 | - ?> |
|
442 | + } |
|
443 | + } |
|
444 | + ?> |
|
445 | 445 | <?php |
446 | 446 | if (isset($globalMarine) && $globalMarine === TRUE) { |
447 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
448 | - ?> |
|
447 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
448 | + ?> |
|
449 | 449 | <li><?php echo _("Marine icon color:"); ?> |
450 | 450 | <input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>"> |
451 | 451 | </li> |
452 | 452 | <?php |
453 | - } |
|
454 | - } |
|
455 | - ?> |
|
453 | + } |
|
454 | + } |
|
455 | + ?> |
|
456 | 456 | <?php |
457 | 457 | if (isset($globalTracker) && $globalTracker === TRUE) { |
458 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
459 | - ?> |
|
458 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
459 | + ?> |
|
460 | 460 | <li><?php echo _("Tracker icon color:"); ?> |
461 | 461 | <input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print '1a3151'; ?>"> |
462 | 462 | </li> |
463 | 463 | <?php |
464 | - } |
|
465 | - } |
|
466 | - ?> |
|
464 | + } |
|
465 | + } |
|
466 | + ?> |
|
467 | 467 | <?php |
468 | 468 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
469 | - ?> |
|
469 | + ?> |
|
470 | 470 | <li><?php echo _("Show airport icon at zoom level:"); ?> |
471 | 471 | <div class="range"> |
472 | 472 | <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>"> |
@@ -475,9 +475,9 @@ discard block |
||
475 | 475 | </li> |
476 | 476 | <?php |
477 | 477 | } |
478 | - ?> |
|
478 | + ?> |
|
479 | 479 | <?php |
480 | - } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
480 | + } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
481 | 481 | ?> |
482 | 482 | <?php |
483 | 483 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | </li> |
510 | 510 | <?php |
511 | 511 | } |
512 | - } |
|
512 | + } |
|
513 | 513 | ?> |
514 | 514 | <li><?php echo _("Distance unit:"); ?> |
515 | 515 | <select class="selectpicker" onchange="unitdistance(this);"> |
@@ -542,19 +542,19 @@ discard block |
||
542 | 542 | <ul> |
543 | 543 | <?php |
544 | 544 | if (!isset($globalAircraft) || $globalAircraft) { |
545 | - ?> |
|
545 | + ?> |
|
546 | 546 | <?php |
547 | 547 | if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) { |
548 | - ?> |
|
548 | + ?> |
|
549 | 549 | <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
550 | 550 | <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
551 | 551 | <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
552 | 552 | <?php |
553 | 553 | } |
554 | - ?> |
|
554 | + ?> |
|
555 | 555 | <?php |
556 | 556 | if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) { |
557 | - ?> |
|
557 | + ?> |
|
558 | 558 | <?php if (isset($globalSBS1) && $globalSBS1) { ?> |
559 | 559 | <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
560 | 560 | <?php } ?> |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | <?php } ?> |
564 | 564 | <?php |
565 | 565 | } |
566 | - ?> |
|
566 | + ?> |
|
567 | 567 | <li><?php echo _("Display airlines:"); ?> |
568 | 568 | <br/> |
569 | 569 | <select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines"> |
@@ -583,14 +583,14 @@ discard block |
||
583 | 583 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
584 | 584 | } |
585 | 585 | } |
586 | - ?> |
|
586 | + ?> |
|
587 | 587 | </select> |
588 | 588 | </li> |
589 | 589 | <?php |
590 | 590 | $Spotter = new Spotter(); |
591 | 591 | $allalliancenames = $Spotter->getAllAllianceNames(); |
592 | 592 | if (!empty($allalliancenames)) { |
593 | - ?> |
|
593 | + ?> |
|
594 | 594 | <li><?php echo _("Display alliance:"); ?> |
595 | 595 | <br/> |
596 | 596 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
@@ -604,18 +604,18 @@ discard block |
||
604 | 604 | echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>'; |
605 | 605 | } |
606 | 606 | } |
607 | - ?> |
|
607 | + ?> |
|
608 | 608 | </select> |
609 | 609 | </li> |
610 | 610 | <?php |
611 | 611 | } |
612 | - ?> |
|
612 | + ?> |
|
613 | 613 | <?php |
614 | 614 | } |
615 | - ?> |
|
615 | + ?> |
|
616 | 616 | <?php |
617 | 617 | if (isset($globalAPRS) && $globalAPRS) { |
618 | - ?> |
|
618 | + ?> |
|
619 | 619 | <li><?php echo _("Display APRS sources name:"); ?> |
620 | 620 | <select class="selectpicker" multiple onchange="sources(this);"> |
621 | 621 | <?php |
@@ -639,18 +639,18 @@ discard block |
||
639 | 639 | echo '<option value="'.$src['name'].'">'.$src['name'].'</option>'; |
640 | 640 | } |
641 | 641 | } |
642 | - ?> |
|
642 | + ?> |
|
643 | 643 | </select> |
644 | 644 | </li> |
645 | 645 | <?php |
646 | 646 | } |
647 | - ?> |
|
647 | + ?> |
|
648 | 648 | <?php |
649 | 649 | if (!isset($globalAircraft) || $globalAircraft) { |
650 | - ?> |
|
650 | + ?> |
|
651 | 651 | <?php |
652 | - if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) { |
|
653 | - ?> |
|
652 | + if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) { |
|
653 | + ?> |
|
654 | 654 | <li><?php echo _("Display airlines of type:"); ?><br/> |
655 | 655 | <select class="selectpicker" onchange="airlinestype(this);"> |
656 | 656 | <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
@@ -660,21 +660,21 @@ discard block |
||
660 | 660 | </select> |
661 | 661 | </li> |
662 | 662 | <?php |
663 | - } |
|
664 | - ?> |
|
663 | + } |
|
664 | + ?> |
|
665 | 665 | <?php |
666 | 666 | } |
667 | - ?> |
|
667 | + ?> |
|
668 | 668 | <?php |
669 | 669 | if (isset($globalMarine) && $globalMarine) { |
670 | - ?> |
|
670 | + ?> |
|
671 | 671 | <li> |
672 | 672 | <?php echo _("Display vessels with MMSI:"); ?> |
673 | 673 | <input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) print $_COOKIE['filter_mmsi']; ?>" /> |
674 | 674 | </li> |
675 | 675 | <?php |
676 | 676 | } |
677 | - ?> |
|
677 | + ?> |
|
678 | 678 | <li> |
679 | 679 | <?php echo _("Display with ident:"); ?> |
680 | 680 | <input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" /> |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | </form> |
688 | 688 | </div> |
689 | 689 | <?php |
690 | - if (isset($globalSatellite) && $globalSatellite) { |
|
690 | + if (isset($globalSatellite) && $globalSatellite) { |
|
691 | 691 | ?> |
692 | 692 | <div class="sidebar-pane" id="satellites"> |
693 | 693 | <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -727,14 +727,14 @@ discard block |
||
727 | 727 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |
728 | 728 | } |
729 | 729 | } |
730 | - ?> |
|
730 | + ?> |
|
731 | 731 | </select> |
732 | 732 | </li> |
733 | 733 | </ul> |
734 | 734 | </form> |
735 | 735 | </div> |
736 | 736 | <?php |
737 | - } |
|
737 | + } |
|
738 | 738 | ?> |
739 | 739 | </div> |
740 | 740 | </div> |
@@ -14,23 +14,23 @@ discard block |
||
14 | 14 | $usecoord = false; |
15 | 15 | if (isset($_GET['test'])) exit(); |
16 | 16 | if (isset($_GET['tracker'])) { |
17 | - $tracker = true; |
|
17 | + $tracker = true; |
|
18 | 18 | } |
19 | 19 | if (isset($_GET['marine'])) { |
20 | - $marine = true; |
|
20 | + $marine = true; |
|
21 | 21 | } |
22 | 22 | if ($tracker) { |
23 | - require_once('require/class.Tracker.php'); |
|
24 | - require_once('require/class.TrackerLive.php'); |
|
25 | - require_once('require/class.TrackerArchive.php'); |
|
23 | + require_once('require/class.Tracker.php'); |
|
24 | + require_once('require/class.TrackerLive.php'); |
|
25 | + require_once('require/class.TrackerArchive.php'); |
|
26 | 26 | } elseif ($marine) { |
27 | - require_once('require/class.Marine.php'); |
|
28 | - require_once('require/class.MarineLive.php'); |
|
29 | - require_once('require/class.MarineArchive.php'); |
|
27 | + require_once('require/class.Marine.php'); |
|
28 | + require_once('require/class.MarineLive.php'); |
|
29 | + require_once('require/class.MarineArchive.php'); |
|
30 | 30 | } else { |
31 | - require_once('require/class.Spotter.php'); |
|
32 | - require_once('require/class.SpotterLive.php'); |
|
33 | - require_once('require/class.SpotterArchive.php'); |
|
31 | + require_once('require/class.Spotter.php'); |
|
32 | + require_once('require/class.SpotterLive.php'); |
|
33 | + require_once('require/class.SpotterArchive.php'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | $begintime = microtime(true); |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | $Common = new Common(); |
51 | 51 | |
52 | 52 | if (isset($_GET['download'])) { |
53 | - if ($_GET['download'] == "true") |
|
54 | - { |
|
53 | + if ($_GET['download'] == "true") |
|
54 | + { |
|
55 | 55 | header('Content-disposition: attachment; filename="flightairmap.json"'); |
56 | - } |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | header('Content-Type: text/javascript'); |
59 | 59 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $usecoord = true; |
132 | 132 | $coord = explode(',',$_GET['coord']); |
133 | 133 | if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
134 | - && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) { |
|
134 | + && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) { |
|
135 | 135 | if ($tracker) { |
136 | 136 | $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter); |
137 | 137 | } elseif ($marine) { |
@@ -635,17 +635,17 @@ discard block |
||
635 | 635 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
636 | 636 | |
637 | 637 | if ( |
638 | - (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
639 | - || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
638 | + (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
639 | + || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
640 | 640 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
641 | 641 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
642 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
643 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
644 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
645 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
646 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
647 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
648 | - ) { |
|
642 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
643 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
644 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
645 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
646 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
647 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
648 | + ) { |
|
649 | 649 | if ($tracker) { |
650 | 650 | if ($from_archive || $globalArchive) { |
651 | 651 | $spotter_history_array = $TrackerArchive->getAllArchiveTrackerDataById($spotter_item['famtrackid']); |
@@ -653,9 +653,9 @@ discard block |
||
653 | 653 | $spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']); |
654 | 654 | } |
655 | 655 | if (((isset($_COOKIE['mapmatching']) && $_COOKIE['mapmatching'] == 'true') || |
656 | - (!isset($_COOKIE['mapmatching']) && $globalMapMatching === TRUE)) && |
|
657 | - isset($_GET['zoom']) && $_GET['zoom'] > 12 && |
|
658 | - isset($spotter_item['type']) && ( |
|
656 | + (!isset($_COOKIE['mapmatching']) && $globalMapMatching === TRUE)) && |
|
657 | + isset($_GET['zoom']) && $_GET['zoom'] > 12 && |
|
658 | + isset($spotter_item['type']) && ( |
|
659 | 659 | $spotter_item['type'] == 'Firetruck' || |
660 | 660 | $spotter_item['type'] == 'Ambulance' || |
661 | 661 | $spotter_item['type'] == 'Truck (18 Wheeler)' || |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | $spotter_item['type'] == 'Jeep' || |
668 | 668 | $spotter_item['type'] == 'Motorcycle' || |
669 | 669 | $spotter_item['type'] == 'Car' |
670 | - ) |
|
670 | + ) |
|
671 | 671 | ) { |
672 | 672 | require(dirname(__FILE__).'/require/class.MapMatching.php'); |
673 | 673 | $MapMatching = new MapMatching(); |
@@ -770,65 +770,65 @@ discard block |
||
770 | 770 | } |
771 | 771 | |
772 | 772 | if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
773 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
774 | - && (isset($spotter_item['departure_airport']) |
|
775 | - && $spotter_item['departure_airport'] != 'NA' |
|
776 | - && isset($spotter_item['arrival_airport']) |
|
777 | - && $spotter_item['arrival_airport'] != 'NA' |
|
778 | - && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
|
779 | - || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
|
780 | - if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
781 | - else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
782 | - if (isset($spotter_item['departure_airport_latitude'])) { |
|
773 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
774 | + && (isset($spotter_item['departure_airport']) |
|
775 | + && $spotter_item['departure_airport'] != 'NA' |
|
776 | + && isset($spotter_item['arrival_airport']) |
|
777 | + && $spotter_item['arrival_airport'] != 'NA' |
|
778 | + && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
|
779 | + || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
|
780 | + if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
781 | + else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
782 | + if (isset($spotter_item['departure_airport_latitude'])) { |
|
783 | 783 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
784 | - } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
784 | + } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
785 | 785 | $dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']); |
786 | 786 | if (isset($dairport[0]['latitude'])) { |
787 | - $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
787 | + $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
788 | 788 | } |
789 | - } |
|
790 | - if (isset($spotter_item['arrival_airport_latitude'])) { |
|
789 | + } |
|
790 | + if (isset($spotter_item['arrival_airport_latitude'])) { |
|
791 | 791 | $output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].'],'; |
792 | - } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
792 | + } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
793 | 793 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
794 | 794 | if (isset($aairport[0]['latitude'])) { |
795 | - $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],'; |
|
795 | + $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],'; |
|
796 | 796 | } |
797 | - } |
|
798 | - $output_air = substr($output_air, 0, -1); |
|
799 | - $output_air .= ']}},'; |
|
800 | - $output .= $output_air; |
|
801 | - unset($output_air); |
|
797 | + } |
|
798 | + $output_air = substr($output_air, 0, -1); |
|
799 | + $output_air .= ']}},'; |
|
800 | + $output .= $output_air; |
|
801 | + unset($output_air); |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
805 | 805 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
806 | 806 | if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
807 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
808 | - && (isset($spotter_item['arrival_airport']) |
|
809 | - && $spotter_item['arrival_airport'] != 'NA' |
|
810 | - && ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") |
|
811 | - || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) |
|
812 | - || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
|
813 | - $havedata = false; |
|
814 | - if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
815 | - else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
816 | - $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
|
807 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
808 | + && (isset($spotter_item['arrival_airport']) |
|
809 | + && $spotter_item['arrival_airport'] != 'NA' |
|
810 | + && ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") |
|
811 | + || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) |
|
812 | + || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
|
813 | + $havedata = false; |
|
814 | + if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
815 | + else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
816 | + $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
|
817 | 817 | |
818 | - if (isset($spotter_item['arrival_airport_latitude'])) { |
|
818 | + if (isset($spotter_item['arrival_airport_latitude'])) { |
|
819 | 819 | $output_dest .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']'; |
820 | 820 | $havedata = true; |
821 | - } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
821 | + } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
822 | 822 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
823 | 823 | if (isset($aairport[0]['latitude'])) { |
824 | - $output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
825 | - $havedata = true; |
|
824 | + $output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
825 | + $havedata = true; |
|
826 | 826 | } |
827 | - } |
|
828 | - //$output_dest = substr($output_dest, 0, -1); |
|
829 | - $output_dest .= ']}},'; |
|
830 | - if ($havedata) $output .= $output_dest; |
|
831 | - unset($output_dest); |
|
827 | + } |
|
828 | + //$output_dest = substr($output_dest, 0, -1); |
|
829 | + $output_dest .= ']}},'; |
|
830 | + if ($havedata) $output .= $output_dest; |
|
831 | + unset($output_dest); |
|
832 | 832 | } |
833 | 833 | } |
834 | 834 | $output = substr($output, 0, -1); |
@@ -85,38 +85,38 @@ discard block |
||
85 | 85 | try { |
86 | 86 | //$Connection = new Connection(); |
87 | 87 | $sth = $Connection->db->prepare($query); |
88 | - $sth->execute(array(':source' => $database_file)); |
|
89 | - } catch(PDOException $e) { |
|
90 | - return "error : ".$e->getMessage(); |
|
91 | - } |
|
88 | + $sth->execute(array(':source' => $database_file)); |
|
89 | + } catch(PDOException $e) { |
|
90 | + return "error : ".$e->getMessage(); |
|
91 | + } |
|
92 | 92 | |
93 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
94 | - update_db::connect_sqlite($database_file); |
|
93 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
94 | + update_db::connect_sqlite($database_file); |
|
95 | 95 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
96 | 96 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
97 | 97 | try { |
98 | - $sth = update_db::$db_sqlite->prepare($query); |
|
99 | - $sth->execute(); |
|
100 | - } catch(PDOException $e) { |
|
101 | - return "error : ".$e->getMessage(); |
|
102 | - } |
|
98 | + $sth = update_db::$db_sqlite->prepare($query); |
|
99 | + $sth->execute(); |
|
100 | + } catch(PDOException $e) { |
|
101 | + return "error : ".$e->getMessage(); |
|
102 | + } |
|
103 | 103 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
104 | 104 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
105 | 105 | $Connection = new Connection(); |
106 | 106 | $sth_dest = $Connection->db->prepare($query_dest); |
107 | 107 | try { |
108 | 108 | if ($globalTransaction) $Connection->db->beginTransaction(); |
109 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
109 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
110 | 110 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
111 | 111 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
112 | 112 | $sth_dest->execute($query_dest_values); |
113 | - } |
|
113 | + } |
|
114 | 114 | if ($globalTransaction) $Connection->db->commit(); |
115 | 115 | } catch(PDOException $e) { |
116 | 116 | if ($globalTransaction) $Connection->db->rollBack(); |
117 | 117 | return "error : ".$e->getMessage(); |
118 | 118 | } |
119 | - return ''; |
|
119 | + return ''; |
|
120 | 120 | } |
121 | 121 | public static function retrieve_route_oneworld($database_file) { |
122 | 122 | global $globalDebug, $globalTransaction; |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | try { |
128 | 128 | //$Connection = new Connection(); |
129 | 129 | $sth = $Connection->db->prepare($query); |
130 | - $sth->execute(array(':source' => 'oneworld')); |
|
131 | - } catch(PDOException $e) { |
|
132 | - return "error : ".$e->getMessage(); |
|
133 | - } |
|
130 | + $sth->execute(array(':source' => 'oneworld')); |
|
131 | + } catch(PDOException $e) { |
|
132 | + return "error : ".$e->getMessage(); |
|
133 | + } |
|
134 | 134 | |
135 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
135 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
136 | 136 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
137 | 137 | $Spotter = new Spotter(); |
138 | 138 | if ($fh = fopen($database_file,"r")) { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | if ($globalTransaction) $Connection->db->commit(); |
158 | 158 | } |
159 | - return ''; |
|
159 | + return ''; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | public static function retrieve_route_skyteam($database_file) { |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | try { |
169 | 169 | //$Connection = new Connection(); |
170 | 170 | $sth = $Connection->db->prepare($query); |
171 | - $sth->execute(array(':source' => 'skyteam')); |
|
172 | - } catch(PDOException $e) { |
|
173 | - return "error : ".$e->getMessage(); |
|
174 | - } |
|
171 | + $sth->execute(array(':source' => 'skyteam')); |
|
172 | + } catch(PDOException $e) { |
|
173 | + return "error : ".$e->getMessage(); |
|
174 | + } |
|
175 | 175 | |
176 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
176 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
177 | 177 | |
178 | 178 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
179 | 179 | $Spotter = new Spotter(); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | return "error : ".$e->getMessage(); |
200 | 200 | } |
201 | 201 | } |
202 | - return ''; |
|
202 | + return ''; |
|
203 | 203 | } |
204 | 204 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
205 | 205 | global $globalTransaction; |
@@ -208,27 +208,27 @@ discard block |
||
208 | 208 | try { |
209 | 209 | $Connection = new Connection(); |
210 | 210 | $sth = $Connection->db->prepare($query); |
211 | - $sth->execute(array(':source' => $database_file)); |
|
212 | - } catch(PDOException $e) { |
|
213 | - return "error : ".$e->getMessage(); |
|
214 | - } |
|
211 | + $sth->execute(array(':source' => $database_file)); |
|
212 | + } catch(PDOException $e) { |
|
213 | + return "error : ".$e->getMessage(); |
|
214 | + } |
|
215 | 215 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
216 | 216 | try { |
217 | 217 | $Connection = new Connection(); |
218 | 218 | $sth = $Connection->db->prepare($query); |
219 | - $sth->execute(array(':source' => $database_file)); |
|
220 | - } catch(PDOException $e) { |
|
221 | - return "error : ".$e->getMessage(); |
|
222 | - } |
|
219 | + $sth->execute(array(':source' => $database_file)); |
|
220 | + } catch(PDOException $e) { |
|
221 | + return "error : ".$e->getMessage(); |
|
222 | + } |
|
223 | 223 | |
224 | - update_db::connect_sqlite($database_file); |
|
224 | + update_db::connect_sqlite($database_file); |
|
225 | 225 | $query = 'select * from Aircraft'; |
226 | 226 | try { |
227 | - $sth = update_db::$db_sqlite->prepare($query); |
|
228 | - $sth->execute(); |
|
229 | - } catch(PDOException $e) { |
|
230 | - return "error : ".$e->getMessage(); |
|
231 | - } |
|
227 | + $sth = update_db::$db_sqlite->prepare($query); |
|
228 | + $sth->execute(); |
|
229 | + } catch(PDOException $e) { |
|
230 | + return "error : ".$e->getMessage(); |
|
231 | + } |
|
232 | 232 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
233 | 233 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
234 | 234 | |
@@ -239,17 +239,17 @@ discard block |
||
239 | 239 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
240 | 240 | try { |
241 | 241 | if ($globalTransaction) $Connection->db->beginTransaction(); |
242 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
242 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
243 | 243 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
244 | 244 | if ($values['UserString4'] == 'M') $type = 'military'; |
245 | 245 | else $type = null; |
246 | 246 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
247 | 247 | $sth_dest->execute($query_dest_values); |
248 | 248 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
249 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
250 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
249 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
250 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
251 | 251 | } |
252 | - } |
|
252 | + } |
|
253 | 253 | if ($globalTransaction) $Connection->db->commit(); |
254 | 254 | } catch(PDOException $e) { |
255 | 255 | return "error : ".$e->getMessage(); |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | try { |
261 | 261 | $Connection = new Connection(); |
262 | 262 | $sth = $Connection->db->prepare($query); |
263 | - $sth->execute(array(':source' => $database_file)); |
|
264 | - } catch(PDOException $e) { |
|
265 | - return "error : ".$e->getMessage(); |
|
266 | - } |
|
263 | + $sth->execute(array(':source' => $database_file)); |
|
264 | + } catch(PDOException $e) { |
|
265 | + return "error : ".$e->getMessage(); |
|
266 | + } |
|
267 | 267 | return ''; |
268 | 268 | } |
269 | 269 | |
@@ -275,10 +275,10 @@ discard block |
||
275 | 275 | try { |
276 | 276 | $Connection = new Connection(); |
277 | 277 | $sth = $Connection->db->prepare($query); |
278 | - $sth->execute(array(':source' => $database_file)); |
|
279 | - } catch(PDOException $e) { |
|
280 | - return "error : ".$e->getMessage(); |
|
281 | - } |
|
278 | + $sth->execute(array(':source' => $database_file)); |
|
279 | + } catch(PDOException $e) { |
|
280 | + return "error : ".$e->getMessage(); |
|
281 | + } |
|
282 | 282 | |
283 | 283 | if ($fh = fopen($database_file,"r")) { |
284 | 284 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -288,26 +288,26 @@ discard block |
||
288 | 288 | $sth_dest = $Connection->db->prepare($query_dest); |
289 | 289 | try { |
290 | 290 | if ($globalTransaction) $Connection->db->beginTransaction(); |
291 | - while (!feof($fh)) { |
|
292 | - $values = array(); |
|
293 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
291 | + while (!feof($fh)) { |
|
292 | + $values = array(); |
|
293 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
294 | 294 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
295 | - $values['ModeS'] = substr($line,0,6); |
|
296 | - $values['Registration'] = trim(substr($line,69,6)); |
|
297 | - $aircraft_name = trim(substr($line,48,6)); |
|
298 | - // Check if we can find ICAO, else set it to GLID |
|
299 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
300 | - $search_more = ''; |
|
301 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
302 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
303 | - $sth_search = $Connection->db->prepare($query_search); |
|
295 | + $values['ModeS'] = substr($line,0,6); |
|
296 | + $values['Registration'] = trim(substr($line,69,6)); |
|
297 | + $aircraft_name = trim(substr($line,48,6)); |
|
298 | + // Check if we can find ICAO, else set it to GLID |
|
299 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
300 | + $search_more = ''; |
|
301 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
302 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
303 | + $sth_search = $Connection->db->prepare($query_search); |
|
304 | 304 | try { |
305 | - $sth_search->execute(); |
|
306 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
307 | - //if (count($result) > 0) { |
|
308 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
309 | - $values['ICAOTypeCode'] = $result['icao']; |
|
310 | - } |
|
305 | + $sth_search->execute(); |
|
306 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
307 | + //if (count($result) > 0) { |
|
308 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
309 | + $values['ICAOTypeCode'] = $result['icao']; |
|
310 | + } |
|
311 | 311 | } catch(PDOException $e) { |
312 | 312 | return "error : ".$e->getMessage(); |
313 | 313 | } |
@@ -330,10 +330,10 @@ discard block |
||
330 | 330 | try { |
331 | 331 | $Connection = new Connection(); |
332 | 332 | $sth = $Connection->db->prepare($query); |
333 | - $sth->execute(array(':source' => $database_file)); |
|
334 | - } catch(PDOException $e) { |
|
335 | - return "error : ".$e->getMessage(); |
|
336 | - } |
|
333 | + $sth->execute(array(':source' => $database_file)); |
|
334 | + } catch(PDOException $e) { |
|
335 | + return "error : ".$e->getMessage(); |
|
336 | + } |
|
337 | 337 | return ''; |
338 | 338 | } |
339 | 339 | |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | try { |
345 | 345 | $Connection = new Connection(); |
346 | 346 | $sth = $Connection->db->prepare($query); |
347 | - $sth->execute(array(':source' => $database_file)); |
|
348 | - } catch(PDOException $e) { |
|
349 | - return "error : ".$e->getMessage(); |
|
350 | - } |
|
347 | + $sth->execute(array(':source' => $database_file)); |
|
348 | + } catch(PDOException $e) { |
|
349 | + return "error : ".$e->getMessage(); |
|
350 | + } |
|
351 | 351 | |
352 | 352 | if ($fh = fopen($database_file,"r")) { |
353 | 353 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -358,25 +358,25 @@ discard block |
||
358 | 358 | try { |
359 | 359 | if ($globalTransaction) $Connection->db->beginTransaction(); |
360 | 360 | $tmp = fgetcsv($fh,9999,',',"'"); |
361 | - while (!feof($fh)) { |
|
362 | - $line = fgetcsv($fh,9999,',',"'"); |
|
361 | + while (!feof($fh)) { |
|
362 | + $line = fgetcsv($fh,9999,',',"'"); |
|
363 | 363 | |
364 | 364 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
365 | 365 | //print_r($line); |
366 | - $values['ModeS'] = $line[1]; |
|
367 | - $values['Registration'] = $line[3]; |
|
368 | - $values['ICAOTypeCode'] = ''; |
|
369 | - $aircraft_name = $line[2]; |
|
370 | - // Check if we can find ICAO, else set it to GLID |
|
371 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
372 | - $search_more = ''; |
|
373 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
374 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
375 | - $sth_search = $Connection->db->prepare($query_search); |
|
366 | + $values['ModeS'] = $line[1]; |
|
367 | + $values['Registration'] = $line[3]; |
|
368 | + $values['ICAOTypeCode'] = ''; |
|
369 | + $aircraft_name = $line[2]; |
|
370 | + // Check if we can find ICAO, else set it to GLID |
|
371 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
372 | + $search_more = ''; |
|
373 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
374 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
375 | + $sth_search = $Connection->db->prepare($query_search); |
|
376 | 376 | try { |
377 | - $sth_search->execute(); |
|
378 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
379 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
377 | + $sth_search->execute(); |
|
378 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
379 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
380 | 380 | } catch(PDOException $e) { |
381 | 381 | return "error : ".$e->getMessage(); |
382 | 382 | } |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | try { |
400 | 400 | $Connection = new Connection(); |
401 | 401 | $sth = $Connection->db->prepare($query); |
402 | - $sth->execute(array(':source' => $database_file)); |
|
403 | - } catch(PDOException $e) { |
|
404 | - return "error : ".$e->getMessage(); |
|
405 | - } |
|
402 | + $sth->execute(array(':source' => $database_file)); |
|
403 | + } catch(PDOException $e) { |
|
404 | + return "error : ".$e->getMessage(); |
|
405 | + } |
|
406 | 406 | return ''; |
407 | 407 | } |
408 | 408 | |
@@ -413,16 +413,16 @@ discard block |
||
413 | 413 | try { |
414 | 414 | $Connection = new Connection(); |
415 | 415 | $sth = $Connection->db->prepare($query); |
416 | - $sth->execute(array(':source' => $database_file)); |
|
417 | - } catch(PDOException $e) { |
|
418 | - return "error : ".$e->getMessage(); |
|
419 | - } |
|
416 | + $sth->execute(array(':source' => $database_file)); |
|
417 | + } catch(PDOException $e) { |
|
418 | + return "error : ".$e->getMessage(); |
|
419 | + } |
|
420 | 420 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
421 | 421 | $Spotter = new Spotter(); |
422 | 422 | if ($fh = fopen($database_file,"r")) { |
423 | 423 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
424 | 424 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
425 | - $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
425 | + $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
426 | 426 | |
427 | 427 | $Connection = new Connection(); |
428 | 428 | $sth_dest = $Connection->db->prepare($query_dest); |
@@ -430,126 +430,126 @@ discard block |
||
430 | 430 | try { |
431 | 431 | if ($globalTransaction) $Connection->db->beginTransaction(); |
432 | 432 | $tmp = fgetcsv($fh,9999,',','"'); |
433 | - while (!feof($fh)) { |
|
434 | - $line = fgetcsv($fh,9999,',','"'); |
|
435 | - $values = array(); |
|
436 | - //print_r($line); |
|
437 | - if ($country == 'F') { |
|
438 | - $values['registration'] = $line[0]; |
|
439 | - $values['base'] = $line[4]; |
|
440 | - $values['owner'] = $line[5]; |
|
441 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
442 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
443 | - $values['cancel'] = $line[7]; |
|
433 | + while (!feof($fh)) { |
|
434 | + $line = fgetcsv($fh,9999,',','"'); |
|
435 | + $values = array(); |
|
436 | + //print_r($line); |
|
437 | + if ($country == 'F') { |
|
438 | + $values['registration'] = $line[0]; |
|
439 | + $values['base'] = $line[4]; |
|
440 | + $values['owner'] = $line[5]; |
|
441 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
442 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
443 | + $values['cancel'] = $line[7]; |
|
444 | 444 | } elseif ($country == 'EI') { |
445 | - // TODO : add modeS & reg to aircraft_modes |
|
446 | - $values['registration'] = $line[0]; |
|
447 | - $values['base'] = $line[3]; |
|
448 | - $values['owner'] = $line[2]; |
|
449 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
451 | - $values['cancel'] = ''; |
|
452 | - $values['modes'] = $line[7]; |
|
453 | - $values['icao'] = $line[8]; |
|
445 | + // TODO : add modeS & reg to aircraft_modes |
|
446 | + $values['registration'] = $line[0]; |
|
447 | + $values['base'] = $line[3]; |
|
448 | + $values['owner'] = $line[2]; |
|
449 | + if ($line[1] == '') $values['date_first_reg'] = null; |
|
450 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
451 | + $values['cancel'] = ''; |
|
452 | + $values['modes'] = $line[7]; |
|
453 | + $values['icao'] = $line[8]; |
|
454 | 454 | |
455 | 455 | } elseif ($country == 'HB') { |
456 | - // TODO : add modeS & reg to aircraft_modes |
|
457 | - $values['registration'] = $line[0]; |
|
458 | - $values['base'] = null; |
|
459 | - $values['owner'] = $line[5]; |
|
460 | - $values['date_first_reg'] = null; |
|
461 | - $values['cancel'] = ''; |
|
462 | - $values['modes'] = $line[4]; |
|
463 | - $values['icao'] = $line[7]; |
|
456 | + // TODO : add modeS & reg to aircraft_modes |
|
457 | + $values['registration'] = $line[0]; |
|
458 | + $values['base'] = null; |
|
459 | + $values['owner'] = $line[5]; |
|
460 | + $values['date_first_reg'] = null; |
|
461 | + $values['cancel'] = ''; |
|
462 | + $values['modes'] = $line[4]; |
|
463 | + $values['icao'] = $line[7]; |
|
464 | 464 | } elseif ($country == 'OK') { |
465 | - // TODO : add modeS & reg to aircraft_modes |
|
466 | - $values['registration'] = $line[3]; |
|
467 | - $values['base'] = null; |
|
468 | - $values['owner'] = $line[5]; |
|
469 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
470 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
471 | - $values['cancel'] = ''; |
|
465 | + // TODO : add modeS & reg to aircraft_modes |
|
466 | + $values['registration'] = $line[3]; |
|
467 | + $values['base'] = null; |
|
468 | + $values['owner'] = $line[5]; |
|
469 | + if ($line[18] == '') $values['date_first_reg'] = null; |
|
470 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
471 | + $values['cancel'] = ''; |
|
472 | 472 | } elseif ($country == 'VH') { |
473 | - // TODO : add modeS & reg to aircraft_modes |
|
474 | - $values['registration'] = $line[0]; |
|
475 | - $values['base'] = null; |
|
476 | - $values['owner'] = $line[12]; |
|
477 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
479 | - |
|
480 | - $values['cancel'] = $line[39]; |
|
473 | + // TODO : add modeS & reg to aircraft_modes |
|
474 | + $values['registration'] = $line[0]; |
|
475 | + $values['base'] = null; |
|
476 | + $values['owner'] = $line[12]; |
|
477 | + if ($line[28] == '') $values['date_first_reg'] = null; |
|
478 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
479 | + |
|
480 | + $values['cancel'] = $line[39]; |
|
481 | 481 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
482 | - $values['registration'] = $line[0]; |
|
483 | - $values['base'] = null; |
|
484 | - $values['owner'] = $line[4]; |
|
485 | - $values['date_first_reg'] = null; |
|
486 | - $values['cancel'] = ''; |
|
482 | + $values['registration'] = $line[0]; |
|
483 | + $values['base'] = null; |
|
484 | + $values['owner'] = $line[4]; |
|
485 | + $values['date_first_reg'] = null; |
|
486 | + $values['cancel'] = ''; |
|
487 | 487 | } elseif ($country == 'CC') { |
488 | - $values['registration'] = $line[0]; |
|
489 | - $values['base'] = null; |
|
490 | - $values['owner'] = $line[6]; |
|
491 | - $values['date_first_reg'] = null; |
|
492 | - $values['cancel'] = ''; |
|
488 | + $values['registration'] = $line[0]; |
|
489 | + $values['base'] = null; |
|
490 | + $values['owner'] = $line[6]; |
|
491 | + $values['date_first_reg'] = null; |
|
492 | + $values['cancel'] = ''; |
|
493 | 493 | } elseif ($country == 'HJ') { |
494 | - $values['registration'] = $line[0]; |
|
495 | - $values['base'] = null; |
|
496 | - $values['owner'] = $line[8]; |
|
497 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
498 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
499 | - $values['cancel'] = ''; |
|
494 | + $values['registration'] = $line[0]; |
|
495 | + $values['base'] = null; |
|
496 | + $values['owner'] = $line[8]; |
|
497 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
498 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
499 | + $values['cancel'] = ''; |
|
500 | 500 | } elseif ($country == 'PP') { |
501 | - $values['registration'] = $line[0]; |
|
502 | - $values['base'] = null; |
|
503 | - $values['owner'] = $line[4]; |
|
504 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
505 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
506 | - $values['cancel'] = $line[7]; |
|
501 | + $values['registration'] = $line[0]; |
|
502 | + $values['base'] = null; |
|
503 | + $values['owner'] = $line[4]; |
|
504 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
505 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
506 | + $values['cancel'] = $line[7]; |
|
507 | 507 | } elseif ($country == 'E7') { |
508 | - $values['registration'] = $line[0]; |
|
509 | - $values['base'] = null; |
|
510 | - $values['owner'] = $line[4]; |
|
511 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
512 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
513 | - $values['cancel'] = ''; |
|
508 | + $values['registration'] = $line[0]; |
|
509 | + $values['base'] = null; |
|
510 | + $values['owner'] = $line[4]; |
|
511 | + if ($line[5] == '') $values['date_first_reg'] = null; |
|
512 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
513 | + $values['cancel'] = ''; |
|
514 | 514 | } elseif ($country == '8Q') { |
515 | - $values['registration'] = $line[0]; |
|
516 | - $values['base'] = null; |
|
517 | - $values['owner'] = $line[3]; |
|
518 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
519 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
520 | - $values['cancel'] = ''; |
|
515 | + $values['registration'] = $line[0]; |
|
516 | + $values['base'] = null; |
|
517 | + $values['owner'] = $line[3]; |
|
518 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
519 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
520 | + $values['cancel'] = ''; |
|
521 | 521 | } elseif ($country == 'ZK') { |
522 | - $values['registration'] = $line[0]; |
|
523 | - $values['base'] = null; |
|
524 | - $values['owner'] = $line[3]; |
|
525 | - $values['date_first_reg'] = null; |
|
526 | - $values['cancel'] = ''; |
|
527 | - $values['modes'] = $line[5]; |
|
528 | - $values['icao'] = $line[9]; |
|
522 | + $values['registration'] = $line[0]; |
|
523 | + $values['base'] = null; |
|
524 | + $values['owner'] = $line[3]; |
|
525 | + $values['date_first_reg'] = null; |
|
526 | + $values['cancel'] = ''; |
|
527 | + $values['modes'] = $line[5]; |
|
528 | + $values['icao'] = $line[9]; |
|
529 | 529 | } elseif ($country == 'M') { |
530 | - $values['registration'] = $line[0]; |
|
531 | - $values['base'] = null; |
|
532 | - $values['owner'] = $line[6]; |
|
533 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
534 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
535 | - $values['modes'] = $line[4]; |
|
536 | - $values['icao'] = $line[10]; |
|
530 | + $values['registration'] = $line[0]; |
|
531 | + $values['base'] = null; |
|
532 | + $values['owner'] = $line[6]; |
|
533 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
534 | + $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
535 | + $values['modes'] = $line[4]; |
|
536 | + $values['icao'] = $line[10]; |
|
537 | 537 | } elseif ($country == 'OY') { |
538 | - $values['registration'] = $line[0]; |
|
539 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
540 | - $values['modes'] = $line[5]; |
|
541 | - $values['icao'] = $line[6]; |
|
538 | + $values['registration'] = $line[0]; |
|
539 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
540 | + $values['modes'] = $line[5]; |
|
541 | + $values['icao'] = $line[6]; |
|
542 | 542 | } elseif ($country == 'PH') { |
543 | - $values['registration'] = $line[0]; |
|
544 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
545 | - $values['modes'] = $line[4]; |
|
546 | - $values['icao'] = $line[5]; |
|
543 | + $values['registration'] = $line[0]; |
|
544 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
545 | + $values['modes'] = $line[4]; |
|
546 | + $values['icao'] = $line[5]; |
|
547 | 547 | } elseif ($country == 'OM' || $country == 'TF') { |
548 | - $values['registration'] = $line[0]; |
|
549 | - $values['base'] = null; |
|
550 | - $values['owner'] = $line[3]; |
|
551 | - $values['date_first_reg'] = null; |
|
552 | - $values['cancel'] = ''; |
|
548 | + $values['registration'] = $line[0]; |
|
549 | + $values['base'] = null; |
|
550 | + $values['owner'] = $line[3]; |
|
551 | + $values['date_first_reg'] = null; |
|
552 | + $values['cancel'] = ''; |
|
553 | 553 | } |
554 | 554 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
555 | 555 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | return "error : ".$e->getMessage(); |
683 | 683 | } |
684 | 684 | */ |
685 | - /* |
|
685 | + /* |
|
686 | 686 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
687 | 687 | try { |
688 | 688 | $Connection = new Connection(); |
@@ -927,10 +927,10 @@ discard block |
||
927 | 927 | try { |
928 | 928 | $Connection = new Connection(); |
929 | 929 | $sth = $Connection->db->prepare($query); |
930 | - $sth->execute(array(':source' => 'translation.csv')); |
|
931 | - } catch(PDOException $e) { |
|
932 | - return "error : ".$e->getMessage(); |
|
933 | - } |
|
930 | + $sth->execute(array(':source' => 'translation.csv')); |
|
931 | + } catch(PDOException $e) { |
|
932 | + return "error : ".$e->getMessage(); |
|
933 | + } |
|
934 | 934 | |
935 | 935 | |
936 | 936 | //update_db::unzip($out_file); |
@@ -949,21 +949,21 @@ discard block |
||
949 | 949 | $data = $row; |
950 | 950 | $operator = $data[2]; |
951 | 951 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
952 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
953 | - //echo substr($operator, 0, 2)."\n";; |
|
954 | - if (count($airline_array) > 0) { |
|
952 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
953 | + //echo substr($operator, 0, 2)."\n";; |
|
954 | + if (count($airline_array) > 0) { |
|
955 | 955 | //print_r($airline_array); |
956 | 956 | $operator = $airline_array[0]['icao'].substr($operator,2); |
957 | - } |
|
958 | - } |
|
957 | + } |
|
958 | + } |
|
959 | 959 | |
960 | 960 | $operator_correct = $data[3]; |
961 | 961 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
962 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
963 | - if (count($airline_array) > 0) { |
|
964 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
965 | - } |
|
966 | - } |
|
962 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
963 | + if (count($airline_array) > 0) { |
|
964 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
965 | + } |
|
966 | + } |
|
967 | 967 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
968 | 968 | try { |
969 | 969 | $sth = $Connection->db->prepare($query); |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | //$Connection->db->commit(); |
978 | 978 | } |
979 | 979 | return ''; |
980 | - } |
|
980 | + } |
|
981 | 981 | |
982 | 982 | public static function translation_fam() { |
983 | 983 | global $tmp_dir, $globalTransaction; |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | //$Connection->db->commit(); |
1016 | 1016 | } |
1017 | 1017 | return ''; |
1018 | - } |
|
1018 | + } |
|
1019 | 1019 | |
1020 | 1020 | /* |
1021 | 1021 | * This function use FAA public data. |
@@ -1027,19 +1027,19 @@ discard block |
||
1027 | 1027 | try { |
1028 | 1028 | $Connection = new Connection(); |
1029 | 1029 | $sth = $Connection->db->prepare($query); |
1030 | - $sth->execute(array(':source' => 'website_faa')); |
|
1031 | - } catch(PDOException $e) { |
|
1032 | - return "error : ".$e->getMessage(); |
|
1033 | - } |
|
1030 | + $sth->execute(array(':source' => 'website_faa')); |
|
1031 | + } catch(PDOException $e) { |
|
1032 | + return "error : ".$e->getMessage(); |
|
1033 | + } |
|
1034 | 1034 | |
1035 | 1035 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; |
1036 | 1036 | try { |
1037 | 1037 | $Connection = new Connection(); |
1038 | 1038 | $sth = $Connection->db->prepare($query); |
1039 | - $sth->execute(array(':source' => 'website_faa')); |
|
1040 | - } catch(PDOException $e) { |
|
1041 | - return "error : ".$e->getMessage(); |
|
1042 | - } |
|
1039 | + $sth->execute(array(':source' => 'website_faa')); |
|
1040 | + } catch(PDOException $e) { |
|
1041 | + return "error : ".$e->getMessage(); |
|
1042 | + } |
|
1043 | 1043 | |
1044 | 1044 | $delimiter = ","; |
1045 | 1045 | $mfr = array(); |
@@ -1207,7 +1207,7 @@ discard block |
||
1207 | 1207 | } |
1208 | 1208 | */ |
1209 | 1209 | return ''; |
1210 | - } |
|
1210 | + } |
|
1211 | 1211 | |
1212 | 1212 | public static function owner_fam() { |
1213 | 1213 | global $tmp_dir, $globalTransaction; |
@@ -1215,10 +1215,10 @@ discard block |
||
1215 | 1215 | try { |
1216 | 1216 | $Connection = new Connection(); |
1217 | 1217 | $sth = $Connection->db->prepare($query); |
1218 | - $sth->execute(array(':source' => 'website_fam')); |
|
1219 | - } catch(PDOException $e) { |
|
1220 | - return "error : ".$e->getMessage(); |
|
1221 | - } |
|
1218 | + $sth->execute(array(':source' => 'website_fam')); |
|
1219 | + } catch(PDOException $e) { |
|
1220 | + return "error : ".$e->getMessage(); |
|
1221 | + } |
|
1222 | 1222 | |
1223 | 1223 | $delimiter = "\t"; |
1224 | 1224 | $Connection = new Connection(); |
@@ -1244,7 +1244,7 @@ discard block |
||
1244 | 1244 | if ($globalTransaction) $Connection->db->commit(); |
1245 | 1245 | } |
1246 | 1246 | return ''; |
1247 | - } |
|
1247 | + } |
|
1248 | 1248 | |
1249 | 1249 | public static function routes_fam() { |
1250 | 1250 | global $tmp_dir, $globalTransaction, $globalDebug; |
@@ -1286,7 +1286,7 @@ discard block |
||
1286 | 1286 | if ($globalTransaction) $Connection->db->commit(); |
1287 | 1287 | } |
1288 | 1288 | return ''; |
1289 | - } |
|
1289 | + } |
|
1290 | 1290 | |
1291 | 1291 | public static function marine_identity_fam() { |
1292 | 1292 | global $tmp_dir, $globalTransaction; |
@@ -1294,10 +1294,10 @@ discard block |
||
1294 | 1294 | try { |
1295 | 1295 | $Connection = new Connection(); |
1296 | 1296 | $sth = $Connection->db->prepare($query); |
1297 | - $sth->execute(); |
|
1298 | - } catch(PDOException $e) { |
|
1299 | - return "error : ".$e->getMessage(); |
|
1300 | - } |
|
1297 | + $sth->execute(); |
|
1298 | + } catch(PDOException $e) { |
|
1299 | + return "error : ".$e->getMessage(); |
|
1300 | + } |
|
1301 | 1301 | |
1302 | 1302 | |
1303 | 1303 | //update_db::unzip($out_file); |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | if ($globalTransaction) $Connection->db->commit(); |
1328 | 1328 | } |
1329 | 1329 | return ''; |
1330 | - } |
|
1330 | + } |
|
1331 | 1331 | |
1332 | 1332 | public static function satellite_fam() { |
1333 | 1333 | global $tmp_dir, $globalTransaction; |
@@ -1398,7 +1398,7 @@ discard block |
||
1398 | 1398 | if ($globalTransaction) $Connection->db->commit(); |
1399 | 1399 | } |
1400 | 1400 | return ''; |
1401 | - } |
|
1401 | + } |
|
1402 | 1402 | |
1403 | 1403 | public static function tle($filename,$tletype) { |
1404 | 1404 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1409,10 +1409,10 @@ discard block |
||
1409 | 1409 | try { |
1410 | 1410 | $Connection = new Connection(); |
1411 | 1411 | $sth = $Connection->db->prepare($query); |
1412 | - $sth->execute(array(':source' => $filename)); |
|
1413 | - } catch(PDOException $e) { |
|
1414 | - return "error : ".$e->getMessage(); |
|
1415 | - } |
|
1412 | + $sth->execute(array(':source' => $filename)); |
|
1413 | + } catch(PDOException $e) { |
|
1414 | + return "error : ".$e->getMessage(); |
|
1415 | + } |
|
1416 | 1416 | |
1417 | 1417 | $Connection = new Connection(); |
1418 | 1418 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -1447,7 +1447,7 @@ discard block |
||
1447 | 1447 | //$Connection->db->commit(); |
1448 | 1448 | } |
1449 | 1449 | return ''; |
1450 | - } |
|
1450 | + } |
|
1451 | 1451 | |
1452 | 1452 | public static function satellite_ucsdb($filename) { |
1453 | 1453 | global $tmp_dir, $globalTransaction; |
@@ -1706,11 +1706,11 @@ discard block |
||
1706 | 1706 | try { |
1707 | 1707 | $sth = $Connection->db->prepare($query); |
1708 | 1708 | $sth->execute(array( |
1709 | - ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'], |
|
1710 | - ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'], |
|
1711 | - ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], |
|
1712 | - ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
1713 | - ) |
|
1709 | + ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'], |
|
1710 | + ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'], |
|
1711 | + ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], |
|
1712 | + ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
1713 | + ) |
|
1714 | 1714 | ); |
1715 | 1715 | } catch(PDOException $e) { |
1716 | 1716 | return "error : ".$e->getMessage(); |
@@ -1734,13 +1734,13 @@ discard block |
||
1734 | 1734 | //$Connection->db->commit(); |
1735 | 1735 | } |
1736 | 1736 | return ''; |
1737 | - } |
|
1737 | + } |
|
1738 | 1738 | |
1739 | 1739 | /** |
1740 | - * Convert a HTML table to an array |
|
1741 | - * @param String $data HTML page |
|
1742 | - * @return Array array of the tables in HTML page |
|
1743 | - */ |
|
1740 | + * Convert a HTML table to an array |
|
1741 | + * @param String $data HTML page |
|
1742 | + * @return Array array of the tables in HTML page |
|
1743 | + */ |
|
1744 | 1744 | /* |
1745 | 1745 | private static function table2array($data) { |
1746 | 1746 | $html = str_get_html($data); |
@@ -1770,11 +1770,11 @@ discard block |
||
1770 | 1770 | return(array_filter($tabledata)); |
1771 | 1771 | } |
1772 | 1772 | */ |
1773 | - /** |
|
1774 | - * Get data from form result |
|
1775 | - * @param String $url form URL |
|
1776 | - * @return String the result |
|
1777 | - */ |
|
1773 | + /** |
|
1774 | + * Get data from form result |
|
1775 | + * @param String $url form URL |
|
1776 | + * @return String the result |
|
1777 | + */ |
|
1778 | 1778 | /* |
1779 | 1779 | private static function getData($url) { |
1780 | 1780 | $ch = curl_init(); |
@@ -1924,7 +1924,7 @@ discard block |
||
1924 | 1924 | if ($globalTransaction) $Connection->db->commit(); |
1925 | 1925 | } |
1926 | 1926 | return ''; |
1927 | - } |
|
1927 | + } |
|
1928 | 1928 | |
1929 | 1929 | public static function update_airspace() { |
1930 | 1930 | global $tmp_dir, $globalDBdriver; |
@@ -1934,11 +1934,11 @@ discard block |
||
1934 | 1934 | $query = 'DROP TABLE airspace'; |
1935 | 1935 | try { |
1936 | 1936 | $sth = $Connection->db->prepare($query); |
1937 | - $sth->execute(); |
|
1938 | - } catch(PDOException $e) { |
|
1937 | + $sth->execute(); |
|
1938 | + } catch(PDOException $e) { |
|
1939 | 1939 | return "error : ".$e->getMessage(); |
1940 | - } |
|
1941 | - } |
|
1940 | + } |
|
1941 | + } |
|
1942 | 1942 | |
1943 | 1943 | |
1944 | 1944 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -2003,10 +2003,10 @@ discard block |
||
2003 | 2003 | $query = 'DROP TABLE countries'; |
2004 | 2004 | try { |
2005 | 2005 | $sth = $Connection->db->prepare($query); |
2006 | - $sth->execute(); |
|
2007 | - } catch(PDOException $e) { |
|
2008 | - echo "error : ".$e->getMessage(); |
|
2009 | - } |
|
2006 | + $sth->execute(); |
|
2007 | + } catch(PDOException $e) { |
|
2008 | + echo "error : ".$e->getMessage(); |
|
2009 | + } |
|
2010 | 2010 | } |
2011 | 2011 | if ($globalDBdriver == 'mysql') { |
2012 | 2012 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -2465,7 +2465,7 @@ discard block |
||
2465 | 2465 | $error = update_db::airlines_fam(); |
2466 | 2466 | update_db::insert_airlines_version($airlines_md5); |
2467 | 2467 | } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
2468 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
2468 | + } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
2469 | 2469 | } elseif ($globalDebug) echo "No update."; |
2470 | 2470 | } else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
2471 | 2471 | if ($error != '') { |
@@ -2956,10 +2956,10 @@ discard block |
||
2956 | 2956 | try { |
2957 | 2957 | $Connection = new Connection(); |
2958 | 2958 | $sth = $Connection->db->prepare($query); |
2959 | - $sth->execute(); |
|
2960 | - } catch(PDOException $e) { |
|
2961 | - return "error : ".$e->getMessage(); |
|
2962 | - } |
|
2959 | + $sth->execute(); |
|
2960 | + } catch(PDOException $e) { |
|
2961 | + return "error : ".$e->getMessage(); |
|
2962 | + } |
|
2963 | 2963 | |
2964 | 2964 | $error = ''; |
2965 | 2965 | if ($globalDebug) echo "Notam : Download..."; |
@@ -3015,8 +3015,8 @@ discard block |
||
3015 | 3015 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
3016 | 3016 | $data['permanent'] = 0; |
3017 | 3017 | } else { |
3018 | - $data['date_end'] = NULL; |
|
3019 | - $data['permanent'] = 1; |
|
3018 | + $data['date_end'] = NULL; |
|
3019 | + $data['permanent'] = 1; |
|
3020 | 3020 | } |
3021 | 3021 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
3022 | 3022 | $NOTAM = new NOTAM(); |
@@ -3090,13 +3090,13 @@ discard block |
||
3090 | 3090 | try { |
3091 | 3091 | $Connection = new Connection(); |
3092 | 3092 | $sth = $Connection->db->prepare($query); |
3093 | - $sth->execute(); |
|
3094 | - } catch(PDOException $e) { |
|
3095 | - return "error : ".$e->getMessage(); |
|
3096 | - } |
|
3097 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3098 | - if ($row['nb'] > 0) return false; |
|
3099 | - else return true; |
|
3093 | + $sth->execute(); |
|
3094 | + } catch(PDOException $e) { |
|
3095 | + return "error : ".$e->getMessage(); |
|
3096 | + } |
|
3097 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3098 | + if ($row['nb'] > 0) return false; |
|
3099 | + else return true; |
|
3100 | 3100 | } |
3101 | 3101 | |
3102 | 3102 | public static function insert_last_update() { |
@@ -3105,10 +3105,10 @@ discard block |
||
3105 | 3105 | try { |
3106 | 3106 | $Connection = new Connection(); |
3107 | 3107 | $sth = $Connection->db->prepare($query); |
3108 | - $sth->execute(); |
|
3109 | - } catch(PDOException $e) { |
|
3110 | - return "error : ".$e->getMessage(); |
|
3111 | - } |
|
3108 | + $sth->execute(); |
|
3109 | + } catch(PDOException $e) { |
|
3110 | + return "error : ".$e->getMessage(); |
|
3111 | + } |
|
3112 | 3112 | } |
3113 | 3113 | |
3114 | 3114 | public static function check_airspace_version($version) { |
@@ -3116,13 +3116,13 @@ discard block |
||
3116 | 3116 | try { |
3117 | 3117 | $Connection = new Connection(); |
3118 | 3118 | $sth = $Connection->db->prepare($query); |
3119 | - $sth->execute(array(':version' => $version)); |
|
3120 | - } catch(PDOException $e) { |
|
3121 | - return "error : ".$e->getMessage(); |
|
3122 | - } |
|
3123 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3124 | - if ($row['nb'] > 0) return true; |
|
3125 | - else return false; |
|
3119 | + $sth->execute(array(':version' => $version)); |
|
3120 | + } catch(PDOException $e) { |
|
3121 | + return "error : ".$e->getMessage(); |
|
3122 | + } |
|
3123 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3124 | + if ($row['nb'] > 0) return true; |
|
3125 | + else return false; |
|
3126 | 3126 | } |
3127 | 3127 | |
3128 | 3128 | public static function check_geoid_version($version) { |
@@ -3130,13 +3130,13 @@ discard block |
||
3130 | 3130 | try { |
3131 | 3131 | $Connection = new Connection(); |
3132 | 3132 | $sth = $Connection->db->prepare($query); |
3133 | - $sth->execute(array(':version' => $version)); |
|
3134 | - } catch(PDOException $e) { |
|
3135 | - return "error : ".$e->getMessage(); |
|
3136 | - } |
|
3137 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3138 | - if ($row['nb'] > 0) return true; |
|
3139 | - else return false; |
|
3133 | + $sth->execute(array(':version' => $version)); |
|
3134 | + } catch(PDOException $e) { |
|
3135 | + return "error : ".$e->getMessage(); |
|
3136 | + } |
|
3137 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3138 | + if ($row['nb'] > 0) return true; |
|
3139 | + else return false; |
|
3140 | 3140 | } |
3141 | 3141 | |
3142 | 3142 | public static function check_marine_identity_version($version) { |
@@ -3237,10 +3237,10 @@ discard block |
||
3237 | 3237 | try { |
3238 | 3238 | $Connection = new Connection(); |
3239 | 3239 | $sth = $Connection->db->prepare($query); |
3240 | - $sth->execute(array(':version' => $version)); |
|
3241 | - } catch(PDOException $e) { |
|
3242 | - return "error : ".$e->getMessage(); |
|
3243 | - } |
|
3240 | + $sth->execute(array(':version' => $version)); |
|
3241 | + } catch(PDOException $e) { |
|
3242 | + return "error : ".$e->getMessage(); |
|
3243 | + } |
|
3244 | 3244 | } |
3245 | 3245 | |
3246 | 3246 | public static function insert_marine_identity_version($version) { |
@@ -3277,13 +3277,13 @@ discard block |
||
3277 | 3277 | try { |
3278 | 3278 | $Connection = new Connection(); |
3279 | 3279 | $sth = $Connection->db->prepare($query); |
3280 | - $sth->execute(); |
|
3281 | - } catch(PDOException $e) { |
|
3282 | - return "error : ".$e->getMessage(); |
|
3283 | - } |
|
3284 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3285 | - if ($row['nb'] > 0) return false; |
|
3286 | - else return true; |
|
3280 | + $sth->execute(); |
|
3281 | + } catch(PDOException $e) { |
|
3282 | + return "error : ".$e->getMessage(); |
|
3283 | + } |
|
3284 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3285 | + if ($row['nb'] > 0) return false; |
|
3286 | + else return true; |
|
3287 | 3287 | } |
3288 | 3288 | |
3289 | 3289 | public static function insert_last_notam_update() { |
@@ -3292,10 +3292,10 @@ discard block |
||
3292 | 3292 | try { |
3293 | 3293 | $Connection = new Connection(); |
3294 | 3294 | $sth = $Connection->db->prepare($query); |
3295 | - $sth->execute(); |
|
3296 | - } catch(PDOException $e) { |
|
3297 | - return "error : ".$e->getMessage(); |
|
3298 | - } |
|
3295 | + $sth->execute(); |
|
3296 | + } catch(PDOException $e) { |
|
3297 | + return "error : ".$e->getMessage(); |
|
3298 | + } |
|
3299 | 3299 | } |
3300 | 3300 | |
3301 | 3301 | public static function check_last_airspace_update() { |
@@ -3308,13 +3308,13 @@ discard block |
||
3308 | 3308 | try { |
3309 | 3309 | $Connection = new Connection(); |
3310 | 3310 | $sth = $Connection->db->prepare($query); |
3311 | - $sth->execute(); |
|
3312 | - } catch(PDOException $e) { |
|
3313 | - return "error : ".$e->getMessage(); |
|
3314 | - } |
|
3315 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3316 | - if ($row['nb'] > 0) return false; |
|
3317 | - else return true; |
|
3311 | + $sth->execute(); |
|
3312 | + } catch(PDOException $e) { |
|
3313 | + return "error : ".$e->getMessage(); |
|
3314 | + } |
|
3315 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3316 | + if ($row['nb'] > 0) return false; |
|
3317 | + else return true; |
|
3318 | 3318 | } |
3319 | 3319 | |
3320 | 3320 | public static function insert_last_airspace_update() { |
@@ -3323,10 +3323,10 @@ discard block |
||
3323 | 3323 | try { |
3324 | 3324 | $Connection = new Connection(); |
3325 | 3325 | $sth = $Connection->db->prepare($query); |
3326 | - $sth->execute(); |
|
3327 | - } catch(PDOException $e) { |
|
3328 | - return "error : ".$e->getMessage(); |
|
3329 | - } |
|
3326 | + $sth->execute(); |
|
3327 | + } catch(PDOException $e) { |
|
3328 | + return "error : ".$e->getMessage(); |
|
3329 | + } |
|
3330 | 3330 | } |
3331 | 3331 | |
3332 | 3332 | public static function check_last_geoid_update() { |
@@ -3339,13 +3339,13 @@ discard block |
||
3339 | 3339 | try { |
3340 | 3340 | $Connection = new Connection(); |
3341 | 3341 | $sth = $Connection->db->prepare($query); |
3342 | - $sth->execute(); |
|
3343 | - } catch(PDOException $e) { |
|
3344 | - return "error : ".$e->getMessage(); |
|
3345 | - } |
|
3346 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3347 | - if ($row['nb'] > 0) return false; |
|
3348 | - else return true; |
|
3342 | + $sth->execute(); |
|
3343 | + } catch(PDOException $e) { |
|
3344 | + return "error : ".$e->getMessage(); |
|
3345 | + } |
|
3346 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3347 | + if ($row['nb'] > 0) return false; |
|
3348 | + else return true; |
|
3349 | 3349 | } |
3350 | 3350 | |
3351 | 3351 | public static function insert_last_geoid_update() { |
@@ -3354,10 +3354,10 @@ discard block |
||
3354 | 3354 | try { |
3355 | 3355 | $Connection = new Connection(); |
3356 | 3356 | $sth = $Connection->db->prepare($query); |
3357 | - $sth->execute(); |
|
3358 | - } catch(PDOException $e) { |
|
3359 | - return "error : ".$e->getMessage(); |
|
3360 | - } |
|
3357 | + $sth->execute(); |
|
3358 | + } catch(PDOException $e) { |
|
3359 | + return "error : ".$e->getMessage(); |
|
3360 | + } |
|
3361 | 3361 | } |
3362 | 3362 | |
3363 | 3363 | public static function check_last_owner_update() { |
@@ -3463,13 +3463,13 @@ discard block |
||
3463 | 3463 | try { |
3464 | 3464 | $Connection = new Connection(); |
3465 | 3465 | $sth = $Connection->db->prepare($query); |
3466 | - $sth->execute(); |
|
3467 | - } catch(PDOException $e) { |
|
3468 | - return "error : ".$e->getMessage(); |
|
3469 | - } |
|
3470 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3471 | - if ($row['nb'] > 0) return false; |
|
3472 | - else return true; |
|
3466 | + $sth->execute(); |
|
3467 | + } catch(PDOException $e) { |
|
3468 | + return "error : ".$e->getMessage(); |
|
3469 | + } |
|
3470 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
3471 | + if ($row['nb'] > 0) return false; |
|
3472 | + else return true; |
|
3473 | 3473 | } |
3474 | 3474 | |
3475 | 3475 | public static function insert_last_schedules_update() { |
@@ -3649,10 +3649,10 @@ discard block |
||
3649 | 3649 | try { |
3650 | 3650 | $Connection = new Connection(); |
3651 | 3651 | $sth = $Connection->db->prepare($query); |
3652 | - $sth->execute(); |
|
3653 | - } catch(PDOException $e) { |
|
3654 | - return "error : ".$e->getMessage(); |
|
3655 | - } |
|
3652 | + $sth->execute(); |
|
3653 | + } catch(PDOException $e) { |
|
3654 | + return "error : ".$e->getMessage(); |
|
3655 | + } |
|
3656 | 3656 | } |
3657 | 3657 | public static function delete_duplicateowner() { |
3658 | 3658 | global $globalDBdriver; |
@@ -3664,10 +3664,10 @@ discard block |
||
3664 | 3664 | try { |
3665 | 3665 | $Connection = new Connection(); |
3666 | 3666 | $sth = $Connection->db->prepare($query); |
3667 | - $sth->execute(); |
|
3668 | - } catch(PDOException $e) { |
|
3669 | - return "error : ".$e->getMessage(); |
|
3670 | - } |
|
3667 | + $sth->execute(); |
|
3668 | + } catch(PDOException $e) { |
|
3669 | + return "error : ".$e->getMessage(); |
|
3670 | + } |
|
3671 | 3671 | } |
3672 | 3672 | |
3673 | 3673 | public static function update_all() { |
@@ -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,41 +149,41 @@ 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('/aircraft.json$/i',$host)) { |
|
177 | - //$formats[$id] = 'aircraftjson'; |
|
178 | - $globalSources[$id]['format'] = 'aircraftjson'; |
|
179 | - //$last_exec['aircraftlistjson'] = 0; |
|
180 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
181 | - } else if (preg_match('/opensky/i',$host)) { |
|
182 | - //$formats[$id] = 'aircraftlistjson'; |
|
183 | - $globalSources[$id]['format'] = 'opensky'; |
|
184 | - //$last_exec['aircraftlistjson'] = 0; |
|
185 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
186 | - /* |
|
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('/aircraft.json$/i',$host)) { |
|
177 | + //$formats[$id] = 'aircraftjson'; |
|
178 | + $globalSources[$id]['format'] = 'aircraftjson'; |
|
179 | + //$last_exec['aircraftlistjson'] = 0; |
|
180 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
181 | + } else if (preg_match('/opensky/i',$host)) { |
|
182 | + //$formats[$id] = 'aircraftlistjson'; |
|
183 | + $globalSources[$id]['format'] = 'opensky'; |
|
184 | + //$last_exec['aircraftlistjson'] = 0; |
|
185 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
186 | + /* |
|
187 | 187 | // Disabled for now, site change source format |
188 | 188 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
189 | 189 | //$formats[$id] = 'radarvirtueljson'; |
@@ -195,125 +195,125 @@ discard block |
||
195 | 195 | exit(0); |
196 | 196 | } |
197 | 197 | */ |
198 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
199 | - //$formats[$id] = 'planeupdatefaa'; |
|
200 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
201 | - //$last_exec['planeupdatefaa'] = 0; |
|
202 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
203 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
204 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
205 | - exit(0); |
|
206 | - } |
|
207 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
208 | - //$formats[$id] = 'phpvmacars'; |
|
209 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
210 | - //$last_exec['phpvmacars'] = 0; |
|
211 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
212 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
213 | - //$formats[$id] = 'phpvmacars'; |
|
214 | - $globalSources[$id]['format'] = 'vaos'; |
|
215 | - //$last_exec['phpvmacars'] = 0; |
|
216 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
217 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
218 | - //$formats[$id] = 'phpvmacars'; |
|
219 | - $globalSources[$id]['format'] = 'vam'; |
|
220 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
221 | - } else if (preg_match('/whazzup/i',$host)) { |
|
222 | - //$formats[$id] = 'whazzup'; |
|
223 | - $globalSources[$id]['format'] = 'whazzup'; |
|
224 | - //$last_exec['whazzup'] = 0; |
|
225 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
226 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
227 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
228 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
229 | - } else if (preg_match('/airwhere/i',$host)) { |
|
230 | - $globalSources[$id]['format'] = 'airwhere'; |
|
231 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
232 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
233 | - //$formats[$id] = 'pirepsjson'; |
|
234 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
235 | - //$last_exec['pirepsjson'] = 0; |
|
236 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
237 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
238 | - //$formats[$id] = 'fr24json'; |
|
239 | - $globalSources[$id]['format'] = 'fr24json'; |
|
240 | - //$last_exec['fr24json'] = 0; |
|
241 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
242 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
243 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
244 | - exit(0); |
|
245 | - } |
|
246 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
247 | - //$formats[$id] = 'fr24json'; |
|
248 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
249 | - //$last_exec['fr24json'] = 0; |
|
250 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
251 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
252 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
253 | - exit(0); |
|
254 | - } |
|
255 | - //} else if (preg_match('/10001/',$host)) { |
|
256 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
257 | - //$formats[$id] = 'tsv'; |
|
258 | - $globalSources[$id]['format'] = 'tsv'; |
|
259 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
260 | - } |
|
261 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
262 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
263 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
264 | - if ($idf !== false) { |
|
265 | - $httpfeeds[$id] = $idf; |
|
266 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
267 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
268 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
269 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
270 | - $hostport = explode(':',$host); |
|
271 | - if (isset($hostport[1])) { |
|
198 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
199 | + //$formats[$id] = 'planeupdatefaa'; |
|
200 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
201 | + //$last_exec['planeupdatefaa'] = 0; |
|
202 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
203 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
204 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
205 | + exit(0); |
|
206 | + } |
|
207 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
208 | + //$formats[$id] = 'phpvmacars'; |
|
209 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
210 | + //$last_exec['phpvmacars'] = 0; |
|
211 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
212 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
213 | + //$formats[$id] = 'phpvmacars'; |
|
214 | + $globalSources[$id]['format'] = 'vaos'; |
|
215 | + //$last_exec['phpvmacars'] = 0; |
|
216 | + if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
217 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
218 | + //$formats[$id] = 'phpvmacars'; |
|
219 | + $globalSources[$id]['format'] = 'vam'; |
|
220 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
221 | + } else if (preg_match('/whazzup/i',$host)) { |
|
222 | + //$formats[$id] = 'whazzup'; |
|
223 | + $globalSources[$id]['format'] = 'whazzup'; |
|
224 | + //$last_exec['whazzup'] = 0; |
|
225 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
226 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
227 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
228 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
229 | + } else if (preg_match('/airwhere/i',$host)) { |
|
230 | + $globalSources[$id]['format'] = 'airwhere'; |
|
231 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
232 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
233 | + //$formats[$id] = 'pirepsjson'; |
|
234 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
235 | + //$last_exec['pirepsjson'] = 0; |
|
236 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
237 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
238 | + //$formats[$id] = 'fr24json'; |
|
239 | + $globalSources[$id]['format'] = 'fr24json'; |
|
240 | + //$last_exec['fr24json'] = 0; |
|
241 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
242 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
243 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
244 | + exit(0); |
|
245 | + } |
|
246 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
247 | + //$formats[$id] = 'fr24json'; |
|
248 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
249 | + //$last_exec['fr24json'] = 0; |
|
250 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
251 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
252 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
253 | + exit(0); |
|
254 | + } |
|
255 | + //} else if (preg_match('/10001/',$host)) { |
|
256 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
257 | + //$formats[$id] = 'tsv'; |
|
258 | + $globalSources[$id]['format'] = 'tsv'; |
|
259 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
260 | + } |
|
261 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
262 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
263 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
264 | + if ($idf !== false) { |
|
265 | + $httpfeeds[$id] = $idf; |
|
266 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
267 | + } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
268 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
269 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
270 | + $hostport = explode(':',$host); |
|
271 | + if (isset($hostport[1])) { |
|
272 | 272 | $port = $hostport[1]; |
273 | 273 | $hostn = $hostport[0]; |
274 | - } else { |
|
274 | + } else { |
|
275 | 275 | $port = $globalSources[$id]['port']; |
276 | 276 | $hostn = $globalSources[$id]['host']; |
277 | - } |
|
278 | - $Common = new Common(); |
|
279 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
280 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
281 | - } else { |
|
282 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
283 | - } |
|
284 | - if ($s) { |
|
285 | - $sockets[$id] = $s; |
|
286 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
287 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
277 | + } |
|
278 | + $Common = new Common(); |
|
279 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
280 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
281 | + } else { |
|
282 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
283 | + } |
|
284 | + if ($s) { |
|
285 | + $sockets[$id] = $s; |
|
286 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
287 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
288 | 288 | //$formats[$id] = 'aprs'; |
289 | 289 | $globalSources[$id]['format'] = 'aprs'; |
290 | 290 | //$aprs_connect = 0; |
291 | 291 | //$use_aprs = true; |
292 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
292 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
293 | 293 | $globalSources[$id]['format'] = 'vrstcp'; |
294 | - } elseif ($port == '10001') { |
|
295 | - //$formats[$id] = 'tsv'; |
|
296 | - $globalSources[$id]['format'] = 'tsv'; |
|
297 | - } elseif ($port == '30002') { |
|
298 | - //$formats[$id] = 'raw'; |
|
299 | - $globalSources[$id]['format'] = 'raw'; |
|
300 | - } elseif ($port == '5001') { |
|
301 | - //$formats[$id] = 'raw'; |
|
302 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
303 | - } elseif ($port == '30005') { |
|
294 | + } elseif ($port == '10001') { |
|
295 | + //$formats[$id] = 'tsv'; |
|
296 | + $globalSources[$id]['format'] = 'tsv'; |
|
297 | + } elseif ($port == '30002') { |
|
298 | + //$formats[$id] = 'raw'; |
|
299 | + $globalSources[$id]['format'] = 'raw'; |
|
300 | + } elseif ($port == '5001') { |
|
301 | + //$formats[$id] = 'raw'; |
|
302 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
303 | + } elseif ($port == '30005') { |
|
304 | 304 | // Not yet supported |
305 | - //$formats[$id] = 'beast'; |
|
306 | - $globalSources[$id]['format'] = 'beast'; |
|
307 | - //} else $formats[$id] = 'sbs'; |
|
308 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
309 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
305 | + //$formats[$id] = 'beast'; |
|
306 | + $globalSources[$id]['format'] = 'beast'; |
|
307 | + //} else $formats[$id] = 'sbs'; |
|
308 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
309 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
310 | 310 | } |
311 | 311 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
312 | - } else { |
|
312 | + } else { |
|
313 | 313 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
314 | - } |
|
315 | - } |
|
316 | - } |
|
314 | + } |
|
315 | + } |
|
316 | + } |
|
317 | 317 | } |
318 | 318 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
319 | 319 | |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | //connect_all($globalSources); |
337 | 337 | |
338 | 338 | if (isset($globalProxy) && $globalProxy) { |
339 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
339 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
340 | 340 | } else { |
341 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
341 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | // APRS Configuration |
@@ -347,21 +347,21 @@ discard block |
||
347 | 347 | die; |
348 | 348 | } |
349 | 349 | foreach ($globalSources as $key => $source) { |
350 | - if (!isset($source['format'])) { |
|
351 | - $globalSources[$key]['format'] = 'auto'; |
|
352 | - } |
|
353 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
354 | - unset($globalSources[$key]); |
|
355 | - } |
|
350 | + if (!isset($source['format'])) { |
|
351 | + $globalSources[$key]['format'] = 'auto'; |
|
352 | + } |
|
353 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
354 | + unset($globalSources[$key]); |
|
355 | + } |
|
356 | 356 | } |
357 | 357 | connect_all($globalSources); |
358 | 358 | foreach ($globalSources as $key => $source) { |
359 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
359 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
360 | 360 | $aprs_connect = 0; |
361 | 361 | $use_aprs = true; |
362 | 362 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
363 | 363 | break; |
364 | - } |
|
364 | + } |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | if ($use_aprs) { |
@@ -402,133 +402,133 @@ discard block |
||
402 | 402 | |
403 | 403 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
404 | 404 | while ($i > 0) { |
405 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
405 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
406 | 406 | |
407 | - if (!$globalDaemon) $i = $endtime-time(); |
|
408 | - // Delete old ATC |
|
409 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
407 | + if (!$globalDaemon) $i = $endtime-time(); |
|
408 | + // Delete old ATC |
|
409 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
410 | 410 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
411 | - $ATC->deleteOldATC(); |
|
412 | - } |
|
411 | + $ATC->deleteOldATC(); |
|
412 | + } |
|
413 | 413 | |
414 | - if (count($last_exec) == count($globalSources)) { |
|
414 | + if (count($last_exec) == count($globalSources)) { |
|
415 | 415 | $max = $globalMinFetch; |
416 | 416 | foreach ($last_exec as $last) { |
417 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
417 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
418 | 418 | } |
419 | 419 | if ($max < $globalMinFetch) { |
420 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
421 | - sleep($globalMinFetch-$max+2); |
|
420 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
421 | + sleep($globalMinFetch-$max+2); |
|
422 | + } |
|
422 | 423 | } |
423 | - } |
|
424 | 424 | |
425 | 425 | |
426 | - //foreach ($formats as $id => $value) { |
|
427 | - foreach ($globalSources as $id => $value) { |
|
426 | + //foreach ($formats as $id => $value) { |
|
427 | + foreach ($globalSources as $id => $value) { |
|
428 | 428 | date_default_timezone_set('UTC'); |
429 | 429 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
430 | 430 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
431 | 431 | if ($value['format'] === 'deltadbtxt' && |
432 | - ( |
|
432 | + ( |
|
433 | 433 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
434 | 434 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
435 | - ) |
|
435 | + ) |
|
436 | 436 | ) { |
437 | - //$buffer = $Common->getData($hosts[$id]); |
|
438 | - $buffer = $Common->getData($value['host']); |
|
439 | - if ($buffer != '') $reset = 0; |
|
440 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
441 | - $buffer = explode('\n',$buffer); |
|
442 | - foreach ($buffer as $line) { |
|
443 | - if ($line != '' && count($line) > 7) { |
|
444 | - $line = explode(',', $line); |
|
445 | - $data = array(); |
|
446 | - $data['hex'] = $line[1]; // hex |
|
447 | - $data['ident'] = $line[2]; // ident |
|
448 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
449 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
450 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
451 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
452 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
453 | - $data['verticalrate'] = ''; // vertical rate |
|
454 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
455 | - $data['emergency'] = ''; // emergency |
|
456 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
457 | - $data['format_source'] = 'deltadbtxt'; |
|
458 | - $data['id_source'] = $id_source; |
|
459 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
460 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
461 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
462 | - $SI->add($data); |
|
463 | - unset($data); |
|
464 | - } |
|
465 | - } |
|
466 | - $last_exec[$id]['last'] = time(); |
|
437 | + //$buffer = $Common->getData($hosts[$id]); |
|
438 | + $buffer = $Common->getData($value['host']); |
|
439 | + if ($buffer != '') $reset = 0; |
|
440 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
441 | + $buffer = explode('\n',$buffer); |
|
442 | + foreach ($buffer as $line) { |
|
443 | + if ($line != '' && count($line) > 7) { |
|
444 | + $line = explode(',', $line); |
|
445 | + $data = array(); |
|
446 | + $data['hex'] = $line[1]; // hex |
|
447 | + $data['ident'] = $line[2]; // ident |
|
448 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
449 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
450 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
451 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
452 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
453 | + $data['verticalrate'] = ''; // vertical rate |
|
454 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
455 | + $data['emergency'] = ''; // emergency |
|
456 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
457 | + $data['format_source'] = 'deltadbtxt'; |
|
458 | + $data['id_source'] = $id_source; |
|
459 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
460 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
461 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
462 | + $SI->add($data); |
|
463 | + unset($data); |
|
464 | + } |
|
465 | + } |
|
466 | + $last_exec[$id]['last'] = time(); |
|
467 | 467 | } elseif ($value['format'] === 'aisnmeatxt' && |
468 | - ( |
|
468 | + ( |
|
469 | 469 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
470 | 470 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
471 | - ) |
|
471 | + ) |
|
472 | 472 | ) { |
473 | - date_default_timezone_set('CET'); |
|
474 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
475 | - date_default_timezone_set('UTC'); |
|
476 | - if ($buffer != '') $reset = 0; |
|
477 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
478 | - $buffer = explode('\n',$buffer); |
|
479 | - foreach ($buffer as $line) { |
|
473 | + date_default_timezone_set('CET'); |
|
474 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
475 | + date_default_timezone_set('UTC'); |
|
476 | + if ($buffer != '') $reset = 0; |
|
477 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
478 | + $buffer = explode('\n',$buffer); |
|
479 | + foreach ($buffer as $line) { |
|
480 | 480 | if ($line != '') { |
481 | - //echo "'".$line."'\n"; |
|
482 | - $add = false; |
|
483 | - $ais_data = $AIS->parse_line(trim($line)); |
|
484 | - $data = array(); |
|
485 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
486 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
487 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
488 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
489 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
490 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
491 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
492 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
493 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
494 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
495 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
496 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
497 | - if (isset($ais_data['timestamp'])) { |
|
481 | + //echo "'".$line."'\n"; |
|
482 | + $add = false; |
|
483 | + $ais_data = $AIS->parse_line(trim($line)); |
|
484 | + $data = array(); |
|
485 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
486 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
487 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
488 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
489 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
490 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
491 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
492 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
493 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
494 | + if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
495 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
496 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
497 | + if (isset($ais_data['timestamp'])) { |
|
498 | 498 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
499 | 499 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
500 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
501 | - $add = true; |
|
500 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
501 | + $add = true; |
|
502 | 502 | } |
503 | - } else { |
|
503 | + } else { |
|
504 | 504 | $data['datetime'] = date('Y-m-d H:i:s'); |
505 | 505 | $add = true; |
506 | - } |
|
507 | - $data['format_source'] = 'aisnmeatxt'; |
|
508 | - $data['id_source'] = $id_source; |
|
509 | - //print_r($data); |
|
510 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
511 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
512 | - unset($data); |
|
506 | + } |
|
507 | + $data['format_source'] = 'aisnmeatxt'; |
|
508 | + $data['id_source'] = $id_source; |
|
509 | + //print_r($data); |
|
510 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
511 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
512 | + unset($data); |
|
513 | 513 | } |
514 | - } |
|
515 | - $last_exec[$id]['last'] = time(); |
|
514 | + } |
|
515 | + $last_exec[$id]['last'] = time(); |
|
516 | 516 | } elseif ($value['format'] === 'aisnmeahttp') { |
517 | - $arr = $httpfeeds; |
|
518 | - $w = $e = null; |
|
517 | + $arr = $httpfeeds; |
|
518 | + $w = $e = null; |
|
519 | 519 | |
520 | - if (isset($arr[$id])) { |
|
520 | + if (isset($arr[$id])) { |
|
521 | 521 | $nn = stream_select($arr,$w,$e,$timeout); |
522 | 522 | if ($nn > 0) { |
523 | - foreach ($httpfeeds as $feed) { |
|
523 | + foreach ($httpfeeds as $feed) { |
|
524 | 524 | $buffer = stream_get_line($feed,2000,"\n"); |
525 | 525 | if ($buffer === FALSE) { |
526 | - connect_all($globalSources); |
|
526 | + connect_all($globalSources); |
|
527 | 527 | } |
528 | 528 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
529 | 529 | $buffer = explode('\n',$buffer); |
530 | 530 | foreach ($buffer as $line) { |
531 | - if ($line != '') { |
|
531 | + if ($line != '') { |
|
532 | 532 | $ais_data = $AIS->parse_line(trim($line)); |
533 | 533 | $data = array(); |
534 | 534 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -546,117 +546,117 @@ discard block |
||
546 | 546 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
547 | 547 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
548 | 548 | if (isset($ais_data['timestamp'])) { |
549 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
549 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
550 | 550 | } else { |
551 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
551 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
552 | 552 | } |
553 | 553 | $data['format_source'] = 'aisnmeahttp'; |
554 | 554 | $data['id_source'] = $id_source; |
555 | 555 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
556 | 556 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
557 | 557 | unset($data); |
558 | - } |
|
558 | + } |
|
559 | + } |
|
559 | 560 | } |
560 | - } |
|
561 | 561 | } else { |
562 | - $format = $value['format']; |
|
563 | - if (isset($tt[$format])) $tt[$format]++; |
|
564 | - else $tt[$format] = 0; |
|
565 | - if ($tt[$format] > 30) { |
|
562 | + $format = $value['format']; |
|
563 | + if (isset($tt[$format])) $tt[$format]++; |
|
564 | + else $tt[$format] = 0; |
|
565 | + if ($tt[$format] > 30) { |
|
566 | 566 | if ($globalDebug) echo 'Reconnect...'."\n"; |
567 | 567 | sleep(2); |
568 | 568 | //$sourceeen[] = $value; |
569 | 569 | //connect_all($sourceeen); |
570 | 570 | //$sourceeen = array(); |
571 | 571 | connect_all($globalSources); |
572 | - } |
|
572 | + } |
|
573 | + } |
|
573 | 574 | } |
574 | - } |
|
575 | 575 | } elseif ($value['format'] === 'myshiptracking' && |
576 | - ( |
|
576 | + ( |
|
577 | 577 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
578 | 578 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
579 | - ) |
|
579 | + ) |
|
580 | 580 | ) { |
581 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
582 | - if ($buffer != '') { |
|
581 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
582 | + if ($buffer != '') { |
|
583 | 583 | //echo $buffer; |
584 | 584 | $all_data = json_decode($buffer,true); |
585 | 585 | //print_r($all_data); |
586 | 586 | if (isset($all_data[0]['DATA'])) { |
587 | - foreach ($all_data[0]['DATA'] as $line) { |
|
587 | + foreach ($all_data[0]['DATA'] as $line) { |
|
588 | 588 | if ($line != '') { |
589 | - $data = array(); |
|
590 | - $data['ident'] = $line['NAME']; |
|
591 | - $data['mmsi'] = $line['MMSI']; |
|
592 | - if (strlen($data['mmsi']) > 9) { |
|
589 | + $data = array(); |
|
590 | + $data['ident'] = $line['NAME']; |
|
591 | + $data['mmsi'] = $line['MMSI']; |
|
592 | + if (strlen($data['mmsi']) > 9) { |
|
593 | 593 | $data['mmsi'] = substr($data['mmsi'],-9); |
594 | - } |
|
595 | - $data['speed'] = $line['SOG']; |
|
596 | - $data['heading'] = $line['COG']; |
|
597 | - $data['latitude'] = $line['LAT']; |
|
598 | - $data['longitude'] = $line['LNG']; |
|
599 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
600 | - //$data['type_id'] = $line['TYPE']; |
|
601 | - $data['imo'] = $line['IMO']; |
|
602 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
603 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
604 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
605 | - $data['format_source'] = 'myshiptracking'; |
|
606 | - $data['id_source'] = $id_source; |
|
607 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
608 | - $MI->add($data); |
|
609 | - unset($data); |
|
594 | + } |
|
595 | + $data['speed'] = $line['SOG']; |
|
596 | + $data['heading'] = $line['COG']; |
|
597 | + $data['latitude'] = $line['LAT']; |
|
598 | + $data['longitude'] = $line['LNG']; |
|
599 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
600 | + //$data['type_id'] = $line['TYPE']; |
|
601 | + $data['imo'] = $line['IMO']; |
|
602 | + if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
603 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
604 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
605 | + $data['format_source'] = 'myshiptracking'; |
|
606 | + $data['id_source'] = $id_source; |
|
607 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
608 | + $MI->add($data); |
|
609 | + unset($data); |
|
610 | 610 | } |
611 | - } |
|
611 | + } |
|
612 | + } |
|
612 | 613 | } |
613 | - } |
|
614 | - $last_exec[$id]['last'] = time(); |
|
614 | + $last_exec[$id]['last'] = time(); |
|
615 | 615 | } elseif ($value['format'] === 'boatbeaconapp' && |
616 | - ( |
|
616 | + ( |
|
617 | 617 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
618 | 618 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
619 | - ) |
|
619 | + ) |
|
620 | 620 | ) { |
621 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
622 | - if ($buffer != '') { |
|
621 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
622 | + if ($buffer != '') { |
|
623 | 623 | $all_data = json_decode($buffer,true); |
624 | 624 | if (isset($all_data[0]['mmsi'])) { |
625 | - foreach ($all_data as $line) { |
|
625 | + foreach ($all_data as $line) { |
|
626 | 626 | if ($line != '') { |
627 | - $data = array(); |
|
628 | - $data['ident'] = $line['shipname']; |
|
629 | - $data['callsign'] = $line['callsign']; |
|
630 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
631 | - $data['speed'] = $line['sog']; |
|
632 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
633 | - $data['latitude'] = $line['latitude']; |
|
634 | - $data['longitude'] = $line['longitude']; |
|
635 | - $data['type_id'] = $line['shiptype']; |
|
636 | - $data['arrival_code'] = $line['destination']; |
|
637 | - $data['datetime'] = $line['time']; |
|
638 | - $data['format_source'] = 'boatbeaconapp'; |
|
639 | - $data['id_source'] = $id_source; |
|
640 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
641 | - $MI->add($data); |
|
642 | - unset($data); |
|
627 | + $data = array(); |
|
628 | + $data['ident'] = $line['shipname']; |
|
629 | + $data['callsign'] = $line['callsign']; |
|
630 | + $data['mmsi'] = substr($line['mmsi'],-9); |
|
631 | + $data['speed'] = $line['sog']; |
|
632 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
633 | + $data['latitude'] = $line['latitude']; |
|
634 | + $data['longitude'] = $line['longitude']; |
|
635 | + $data['type_id'] = $line['shiptype']; |
|
636 | + $data['arrival_code'] = $line['destination']; |
|
637 | + $data['datetime'] = $line['time']; |
|
638 | + $data['format_source'] = 'boatbeaconapp'; |
|
639 | + $data['id_source'] = $id_source; |
|
640 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
641 | + $MI->add($data); |
|
642 | + unset($data); |
|
643 | + } |
|
643 | 644 | } |
644 | - } |
|
645 | 645 | } |
646 | 646 | |
647 | - } |
|
648 | - $last_exec[$id]['last'] = time(); |
|
647 | + } |
|
648 | + $last_exec[$id]['last'] = time(); |
|
649 | 649 | } elseif ($value['format'] === 'boatnerd' && |
650 | - ( |
|
650 | + ( |
|
651 | 651 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
652 | 652 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
653 | - ) |
|
653 | + ) |
|
654 | 654 | ) { |
655 | - $buffer = $Common->getData($value['host']); |
|
656 | - if ($buffer != '') { |
|
655 | + $buffer = $Common->getData($value['host']); |
|
656 | + if ($buffer != '') { |
|
657 | 657 | $all_data = json_decode($buffer,true); |
658 | 658 | if (isset($all_data['features'][0]['id'])) { |
659 | - foreach ($all_data['features'] as $line) { |
|
659 | + foreach ($all_data['features'] as $line) { |
|
660 | 660 | print_r($line); |
661 | 661 | $data = array(); |
662 | 662 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
@@ -676,80 +676,80 @@ discard block |
||
676 | 676 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
677 | 677 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
678 | 678 | unset($data); |
679 | - } |
|
679 | + } |
|
680 | 680 | } |
681 | 681 | |
682 | - } |
|
683 | - $last_exec[$id]['last'] = time(); |
|
682 | + } |
|
683 | + $last_exec[$id]['last'] = time(); |
|
684 | 684 | } elseif ($value['format'] === 'shipplotter' && |
685 | - ( |
|
685 | + ( |
|
686 | 686 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
687 | 687 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
688 | - ) |
|
688 | + ) |
|
689 | 689 | ) { |
690 | - echo 'download...'; |
|
691 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
692 | - echo 'done !'."\n"; |
|
693 | - // FIXME: Need more work |
|
694 | - if ($buffer != '') $reset = 0; |
|
695 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
696 | - $buffer = explode('\n',$buffer); |
|
697 | - foreach ($buffer as $line) { |
|
690 | + echo 'download...'; |
|
691 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
692 | + echo 'done !'."\n"; |
|
693 | + // FIXME: Need more work |
|
694 | + if ($buffer != '') $reset = 0; |
|
695 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
696 | + $buffer = explode('\n',$buffer); |
|
697 | + foreach ($buffer as $line) { |
|
698 | 698 | if ($line != '') { |
699 | - $data = array(); |
|
700 | - echo $line."\n"; |
|
701 | - $data['mmsi'] = (int)substr($line,0,9); |
|
702 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
703 | - $data['status_id'] = substr($line,21,2); |
|
704 | - $data['type_id'] = substr($line,24,3); |
|
705 | - $data['latitude'] = substr($line,29,9); |
|
706 | - $data['longitude'] = substr($line,41,9); |
|
707 | - $data['speed'] = round(substr($line,51,5)); |
|
708 | - //$data['course'] = substr($line,57,5); |
|
709 | - $data['heading'] = round(substr($line,63,3)); |
|
710 | - //$data['draft'] = substr($line,67,4); |
|
711 | - //$data['length'] = substr($line,72,3); |
|
712 | - //$data['beam'] = substr($line,76,2); |
|
713 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
714 | - //$data['callsign'] = trim(substr($line,100,7); |
|
715 | - $data['arrival_code'] = substr($line,108,20); |
|
716 | - //$data['etaDate'] = substr($line,129,5); |
|
717 | - //$data['etaTime'] = substr($line,135,5); |
|
718 | - $data['format_source'] = 'shipplotter'; |
|
719 | - $data['id_source'] = $id_source; |
|
720 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
721 | - //print_r($data); |
|
722 | - echo 'Add...'."\n"; |
|
723 | - $MI->add($data); |
|
724 | - unset($data); |
|
699 | + $data = array(); |
|
700 | + echo $line."\n"; |
|
701 | + $data['mmsi'] = (int)substr($line,0,9); |
|
702 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
703 | + $data['status_id'] = substr($line,21,2); |
|
704 | + $data['type_id'] = substr($line,24,3); |
|
705 | + $data['latitude'] = substr($line,29,9); |
|
706 | + $data['longitude'] = substr($line,41,9); |
|
707 | + $data['speed'] = round(substr($line,51,5)); |
|
708 | + //$data['course'] = substr($line,57,5); |
|
709 | + $data['heading'] = round(substr($line,63,3)); |
|
710 | + //$data['draft'] = substr($line,67,4); |
|
711 | + //$data['length'] = substr($line,72,3); |
|
712 | + //$data['beam'] = substr($line,76,2); |
|
713 | + $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
714 | + //$data['callsign'] = trim(substr($line,100,7); |
|
715 | + $data['arrival_code'] = substr($line,108,20); |
|
716 | + //$data['etaDate'] = substr($line,129,5); |
|
717 | + //$data['etaTime'] = substr($line,135,5); |
|
718 | + $data['format_source'] = 'shipplotter'; |
|
719 | + $data['id_source'] = $id_source; |
|
720 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
721 | + //print_r($data); |
|
722 | + echo 'Add...'."\n"; |
|
723 | + $MI->add($data); |
|
724 | + unset($data); |
|
725 | 725 | } |
726 | - } |
|
727 | - $last_exec[$id]['last'] = time(); |
|
726 | + } |
|
727 | + $last_exec[$id]['last'] = time(); |
|
728 | 728 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
729 | 729 | } elseif ( |
730 | - ( |
|
730 | + ( |
|
731 | 731 | $value['format'] === 'whazzup' && |
732 | 732 | ( |
733 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
734 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
733 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
734 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
735 | 735 | ) |
736 | - ) || ( |
|
736 | + ) || ( |
|
737 | 737 | $value['format'] === 'vatsimtxt' && |
738 | 738 | ( |
739 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
740 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
739 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
740 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
741 | + ) |
|
741 | 742 | ) |
742 | - ) |
|
743 | 743 | ) { |
744 | - //$buffer = $Common->getData($hosts[$id]); |
|
745 | - $buffer = $Common->getData($value['host']); |
|
746 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
747 | - $buffer = explode('\n',$buffer); |
|
748 | - $reset = 0; |
|
749 | - foreach ($buffer as $line) { |
|
750 | - if ($line != '') { |
|
751 | - $line = explode(':', $line); |
|
752 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
744 | + //$buffer = $Common->getData($hosts[$id]); |
|
745 | + $buffer = $Common->getData($value['host']); |
|
746 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
747 | + $buffer = explode('\n',$buffer); |
|
748 | + $reset = 0; |
|
749 | + foreach ($buffer as $line) { |
|
750 | + if ($line != '') { |
|
751 | + $line = explode(':', $line); |
|
752 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
753 | 753 | $data = array(); |
754 | 754 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
755 | 755 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -762,37 +762,37 @@ discard block |
||
762 | 762 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
763 | 763 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
764 | 764 | $data['latitude'] = $line[5]; // lat |
765 | - $data['longitude'] = $line[6]; // long |
|
766 | - $data['verticalrate'] = ''; // vertical rate |
|
767 | - $data['squawk'] = ''; // squawk |
|
768 | - $data['emergency'] = ''; // emergency |
|
769 | - $data['waypoints'] = $line[30]; |
|
765 | + $data['longitude'] = $line[6]; // long |
|
766 | + $data['verticalrate'] = ''; // vertical rate |
|
767 | + $data['squawk'] = ''; // squawk |
|
768 | + $data['emergency'] = ''; // emergency |
|
769 | + $data['waypoints'] = $line[30]; |
|
770 | 770 | $data['datetime'] = date('Y-m-d H:i:s'); |
771 | 771 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
772 | 772 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
773 | - $data['departure_airport_icao'] = $line[11]; |
|
774 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
775 | - $data['arrival_airport_icao'] = $line[13]; |
|
773 | + $data['departure_airport_icao'] = $line[11]; |
|
774 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
775 | + $data['arrival_airport_icao'] = $line[13]; |
|
776 | 776 | $data['frequency'] = $line[4]; |
777 | 777 | $data['type'] = $line[18]; |
778 | 778 | $data['range'] = $line[19]; |
779 | 779 | if (isset($line[35])) $data['info'] = $line[35]; |
780 | - $data['id_source'] = $id_source; |
|
781 | - //$data['arrival_airport_time'] = ; |
|
782 | - if ($line[9] != '') { |
|
783 | - $aircraft_data = explode('/',$line[9]); |
|
784 | - if (isset($aircraft_data[1])) { |
|
785 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
786 | - } |
|
787 | - } |
|
788 | - /* |
|
780 | + $data['id_source'] = $id_source; |
|
781 | + //$data['arrival_airport_time'] = ; |
|
782 | + if ($line[9] != '') { |
|
783 | + $aircraft_data = explode('/',$line[9]); |
|
784 | + if (isset($aircraft_data[1])) { |
|
785 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
786 | + } |
|
787 | + } |
|
788 | + /* |
|
789 | 789 | if ($value === 'whazzup') $data['format_source'] = 'whazzup'; |
790 | 790 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
791 | 791 | */ |
792 | - $data['format_source'] = $value['format']; |
|
792 | + $data['format_source'] = $value['format']; |
|
793 | 793 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
794 | 794 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
795 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
795 | + if ($line[3] === 'PILOT') $SI->add($data); |
|
796 | 796 | elseif ($line[3] === 'ATC') { |
797 | 797 | //print_r($data); |
798 | 798 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -813,21 +813,21 @@ discard block |
||
813 | 813 | 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']); |
814 | 814 | } |
815 | 815 | } |
816 | - unset($data); |
|
817 | - } |
|
818 | - } |
|
819 | - } |
|
820 | - //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
821 | - //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
822 | - $last_exec[$id]['last'] = time(); |
|
823 | - } elseif ($value['format'] === 'airwhere' && |
|
824 | - ( |
|
825 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
826 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
827 | - ) |
|
828 | - ) { |
|
829 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
830 | - if ($buffer != '') { |
|
816 | + unset($data); |
|
817 | + } |
|
818 | + } |
|
819 | + } |
|
820 | + //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
821 | + //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
822 | + $last_exec[$id]['last'] = time(); |
|
823 | + } elseif ($value['format'] === 'airwhere' && |
|
824 | + ( |
|
825 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
826 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
827 | + ) |
|
828 | + ) { |
|
829 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
830 | + if ($buffer != '') { |
|
831 | 831 | $all_data = simplexml_load_string($buffer); |
832 | 832 | foreach($all_data->children() as $childdata) { |
833 | 833 | $data = array(); |
@@ -849,10 +849,10 @@ discard block |
||
849 | 849 | $SI->add($data); |
850 | 850 | unset($data); |
851 | 851 | } |
852 | - } |
|
853 | - $Source->deleteOldLocationByType('gs'); |
|
854 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
855 | - if ($buffer != '') { |
|
852 | + } |
|
853 | + $Source->deleteOldLocationByType('gs'); |
|
854 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
855 | + if ($buffer != '') { |
|
856 | 856 | $all_data = simplexml_load_string($buffer); |
857 | 857 | foreach($all_data->children() as $childdata) { |
858 | 858 | $data = array(); |
@@ -870,8 +870,8 @@ discard block |
||
870 | 870 | } |
871 | 871 | unset($data); |
872 | 872 | } |
873 | - } |
|
874 | - $last_exec[$id]['last'] = time(); |
|
873 | + } |
|
874 | + $last_exec[$id]['last'] = time(); |
|
875 | 875 | /* |
876 | 876 | } if ($value['format'] === 'aircraftlistjson') { |
877 | 877 | print_r($globalSources); |
@@ -879,17 +879,17 @@ discard block |
||
879 | 879 | echo $globalMinFetch; |
880 | 880 | */ |
881 | 881 | } elseif ($value['format'] === 'aircraftlistjson' && |
882 | - ( |
|
882 | + ( |
|
883 | 883 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
884 | 884 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
885 | - ) |
|
885 | + ) |
|
886 | 886 | ) { |
887 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
888 | - if ($buffer != '') { |
|
889 | - $all_data = json_decode($buffer,true); |
|
887 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
888 | + if ($buffer != '') { |
|
889 | + $all_data = json_decode($buffer,true); |
|
890 | 890 | if (isset($all_data['acList'])) { |
891 | - $reset = 0; |
|
892 | - foreach ($all_data['acList'] as $line) { |
|
891 | + $reset = 0; |
|
892 | + foreach ($all_data['acList'] as $line) { |
|
893 | 893 | $data = array(); |
894 | 894 | $data['hex'] = $line['Icao']; // hex |
895 | 895 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -912,10 +912,10 @@ discard block |
||
912 | 912 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
913 | 913 | if (isset($data['latitude'])) $SI->add($data); |
914 | 914 | unset($data); |
915 | - } |
|
915 | + } |
|
916 | 916 | } elseif (is_array($all_data)) { |
917 | - $reset = 0; |
|
918 | - foreach ($all_data as $line) { |
|
917 | + $reset = 0; |
|
918 | + foreach ($all_data as $line) { |
|
919 | 919 | $data = array(); |
920 | 920 | $data['hex'] = $line['hex']; // hex |
921 | 921 | $data['ident'] = $line['flight']; // ident |
@@ -935,256 +935,256 @@ discard block |
||
935 | 935 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
936 | 936 | $SI->add($data); |
937 | 937 | unset($data); |
938 | - } |
|
938 | + } |
|
939 | 939 | } |
940 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
941 | - //$last_exec['aircraftlistjson'] = time(); |
|
942 | - $last_exec[$id]['last'] = time(); |
|
943 | - //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
944 | - } elseif ($value['format'] === 'planeupdatefaa' && |
|
945 | - ( |
|
946 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
947 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
948 | - ) |
|
949 | - ) { |
|
950 | - $buffer = $Common->getData($value['host']); |
|
951 | - $all_data = json_decode($buffer,true); |
|
952 | - if (isset($all_data['planes'])) { |
|
940 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
941 | + //$last_exec['aircraftlistjson'] = time(); |
|
942 | + $last_exec[$id]['last'] = time(); |
|
943 | + //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
944 | + } elseif ($value['format'] === 'planeupdatefaa' && |
|
945 | + ( |
|
946 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
947 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
948 | + ) |
|
949 | + ) { |
|
950 | + $buffer = $Common->getData($value['host']); |
|
951 | + $all_data = json_decode($buffer,true); |
|
952 | + if (isset($all_data['planes'])) { |
|
953 | 953 | $reset = 0; |
954 | 954 | foreach ($all_data['planes'] as $key => $line) { |
955 | - $data = array(); |
|
956 | - $data['hex'] = $key; // hex |
|
957 | - $data['ident'] = $line[3]; // ident |
|
958 | - $data['altitude'] = $line[6]; // altitude |
|
959 | - $data['speed'] = $line[8]; // speed |
|
960 | - $data['heading'] = $line[7]; // heading |
|
961 | - $data['latitude'] = $line[4]; // lat |
|
962 | - $data['longitude'] = $line[5]; // long |
|
963 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
964 | - $data['squawk'] = $line[10]; // squawk |
|
965 | - $data['emergency'] = ''; // emergency |
|
966 | - $data['registration'] = $line[2]; |
|
967 | - $data['aircraft_icao'] = $line[0]; |
|
968 | - $deparr = explode('-',$line[1]); |
|
969 | - if (count($deparr) === 2) { |
|
955 | + $data = array(); |
|
956 | + $data['hex'] = $key; // hex |
|
957 | + $data['ident'] = $line[3]; // ident |
|
958 | + $data['altitude'] = $line[6]; // altitude |
|
959 | + $data['speed'] = $line[8]; // speed |
|
960 | + $data['heading'] = $line[7]; // heading |
|
961 | + $data['latitude'] = $line[4]; // lat |
|
962 | + $data['longitude'] = $line[5]; // long |
|
963 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
964 | + $data['squawk'] = $line[10]; // squawk |
|
965 | + $data['emergency'] = ''; // emergency |
|
966 | + $data['registration'] = $line[2]; |
|
967 | + $data['aircraft_icao'] = $line[0]; |
|
968 | + $deparr = explode('-',$line[1]); |
|
969 | + if (count($deparr) === 2) { |
|
970 | 970 | $data['departure_airport_icao'] = $deparr[0]; |
971 | 971 | $data['arrival_airport_icao'] = $deparr[1]; |
972 | - } |
|
973 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
974 | - $data['format_source'] = 'planeupdatefaa'; |
|
975 | - $data['id_source'] = $id_source; |
|
976 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
977 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
978 | - $SI->add($data); |
|
979 | - unset($data); |
|
972 | + } |
|
973 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
974 | + $data['format_source'] = 'planeupdatefaa'; |
|
975 | + $data['id_source'] = $id_source; |
|
976 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
977 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
978 | + $SI->add($data); |
|
979 | + unset($data); |
|
980 | 980 | } |
981 | - } |
|
982 | - //$last_exec['planeupdatefaa'] = time(); |
|
983 | - $last_exec[$id]['last'] = time(); |
|
981 | + } |
|
982 | + //$last_exec['planeupdatefaa'] = time(); |
|
983 | + $last_exec[$id]['last'] = time(); |
|
984 | 984 | } elseif ($value['format'] === 'opensky' && |
985 | - ( |
|
985 | + ( |
|
986 | 986 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
987 | 987 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
988 | - ) |
|
988 | + ) |
|
989 | 989 | ) { |
990 | - $buffer = $Common->getData($value['host']); |
|
991 | - $all_data = json_decode($buffer,true); |
|
992 | - if (isset($all_data['states'])) { |
|
990 | + $buffer = $Common->getData($value['host']); |
|
991 | + $all_data = json_decode($buffer,true); |
|
992 | + if (isset($all_data['states'])) { |
|
993 | 993 | $reset = 0; |
994 | 994 | foreach ($all_data['states'] as $key => $line) { |
995 | - $data = array(); |
|
996 | - $data['hex'] = $line[0]; // hex |
|
997 | - $data['ident'] = trim($line[1]); // ident |
|
998 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
999 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
1000 | - $data['heading'] = round($line[10]); // heading |
|
1001 | - $data['latitude'] = $line[6]; // lat |
|
1002 | - $data['longitude'] = $line[5]; // long |
|
1003 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
1004 | - //$data['squawk'] = $line[10]; // squawk |
|
1005 | - //$data['emergency'] = ''; // emergency |
|
1006 | - //$data['registration'] = $line[2]; |
|
1007 | - //$data['aircraft_icao'] = $line[0]; |
|
1008 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1009 | - $data['format_source'] = 'opensky'; |
|
1010 | - $data['id_source'] = $id_source; |
|
1011 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1012 | - $SI->add($data); |
|
1013 | - unset($data); |
|
995 | + $data = array(); |
|
996 | + $data['hex'] = $line[0]; // hex |
|
997 | + $data['ident'] = trim($line[1]); // ident |
|
998 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
999 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
1000 | + $data['heading'] = round($line[10]); // heading |
|
1001 | + $data['latitude'] = $line[6]; // lat |
|
1002 | + $data['longitude'] = $line[5]; // long |
|
1003 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
1004 | + //$data['squawk'] = $line[10]; // squawk |
|
1005 | + //$data['emergency'] = ''; // emergency |
|
1006 | + //$data['registration'] = $line[2]; |
|
1007 | + //$data['aircraft_icao'] = $line[0]; |
|
1008 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1009 | + $data['format_source'] = 'opensky'; |
|
1010 | + $data['id_source'] = $id_source; |
|
1011 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1012 | + $SI->add($data); |
|
1013 | + unset($data); |
|
1014 | 1014 | } |
1015 | - } |
|
1016 | - //$last_exec['planeupdatefaa'] = time(); |
|
1017 | - $last_exec[$id]['last'] = time(); |
|
1015 | + } |
|
1016 | + //$last_exec['planeupdatefaa'] = time(); |
|
1017 | + $last_exec[$id]['last'] = time(); |
|
1018 | 1018 | } elseif ($value['format'] === 'aircraftjson' && |
1019 | - ( |
|
1019 | + ( |
|
1020 | 1020 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1021 | 1021 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1022 | - ) |
|
1022 | + ) |
|
1023 | 1023 | ) { |
1024 | - $buffer = $Common->getData($value['host']); |
|
1025 | - $all_data = json_decode($buffer,true); |
|
1026 | - if (isset($all_data['aircraft'])) { |
|
1024 | + $buffer = $Common->getData($value['host']); |
|
1025 | + $all_data = json_decode($buffer,true); |
|
1026 | + if (isset($all_data['aircraft'])) { |
|
1027 | 1027 | $reset = 0; |
1028 | 1028 | foreach ($all_data['aircraft'] as $key => $line) { |
1029 | - $data = array(); |
|
1030 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1031 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1032 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1033 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1034 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1035 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1036 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1037 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1038 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1039 | - //$data['emergency'] = ''; // emergency |
|
1040 | - //$data['registration'] = $line[2]; |
|
1041 | - //$data['aircraft_icao'] = $line[0]; |
|
1042 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1043 | - $data['format_source'] = 'aircraftjson'; |
|
1044 | - $data['id_source'] = $id_source; |
|
1045 | - if (isset($value['name']) && $value['name'] != '') { |
|
1046 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1047 | - else $data['source_name'] = $value['name']; |
|
1048 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1049 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1050 | - $SI->add($data); |
|
1051 | - unset($data); |
|
1029 | + $data = array(); |
|
1030 | + if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1031 | + if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1032 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1033 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1034 | + if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1035 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1036 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1037 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1038 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1039 | + //$data['emergency'] = ''; // emergency |
|
1040 | + //$data['registration'] = $line[2]; |
|
1041 | + //$data['aircraft_icao'] = $line[0]; |
|
1042 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1043 | + $data['format_source'] = 'aircraftjson'; |
|
1044 | + $data['id_source'] = $id_source; |
|
1045 | + if (isset($value['name']) && $value['name'] != '') { |
|
1046 | + if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1047 | + else $data['source_name'] = $value['name']; |
|
1048 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1049 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1050 | + $SI->add($data); |
|
1051 | + unset($data); |
|
1052 | 1052 | } |
1053 | - } |
|
1054 | - //$last_exec['planeupdatefaa'] = time(); |
|
1055 | - $last_exec[$id]['last'] = time(); |
|
1053 | + } |
|
1054 | + //$last_exec['planeupdatefaa'] = time(); |
|
1055 | + $last_exec[$id]['last'] = time(); |
|
1056 | 1056 | //} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
1057 | 1057 | } elseif ($value['format'] === 'fr24json' && |
1058 | - ( |
|
1058 | + ( |
|
1059 | 1059 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1060 | 1060 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1061 | - ) |
|
1061 | + ) |
|
1062 | 1062 | ) { |
1063 | - //$buffer = $Common->getData($hosts[$id]); |
|
1064 | - $buffer = $Common->getData($value['host']); |
|
1065 | - $all_data = json_decode($buffer,true); |
|
1066 | - if (!empty($all_data)) $reset = 0; |
|
1067 | - foreach ($all_data as $key => $line) { |
|
1063 | + //$buffer = $Common->getData($hosts[$id]); |
|
1064 | + $buffer = $Common->getData($value['host']); |
|
1065 | + $all_data = json_decode($buffer,true); |
|
1066 | + if (!empty($all_data)) $reset = 0; |
|
1067 | + foreach ($all_data as $key => $line) { |
|
1068 | 1068 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1069 | - $data = array(); |
|
1070 | - $data['hex'] = $line[0]; |
|
1071 | - $data['ident'] = $line[16]; //$line[13] |
|
1072 | - $data['altitude'] = $line[4]; // altitude |
|
1073 | - $data['speed'] = $line[5]; // speed |
|
1074 | - $data['heading'] = $line[3]; // heading |
|
1075 | - $data['latitude'] = $line[1]; // lat |
|
1076 | - $data['longitude'] = $line[2]; // long |
|
1077 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
1078 | - $data['squawk'] = $line[6]; // squawk |
|
1079 | - $data['aircraft_icao'] = $line[8]; |
|
1080 | - $data['registration'] = $line[9]; |
|
1081 | - $data['departure_airport_iata'] = $line[11]; |
|
1082 | - $data['arrival_airport_iata'] = $line[12]; |
|
1083 | - $data['emergency'] = ''; // emergency |
|
1084 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1085 | - $data['format_source'] = 'fr24json'; |
|
1086 | - $data['id_source'] = $id_source; |
|
1087 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1088 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1089 | - $SI->add($data); |
|
1090 | - unset($data); |
|
1069 | + $data = array(); |
|
1070 | + $data['hex'] = $line[0]; |
|
1071 | + $data['ident'] = $line[16]; //$line[13] |
|
1072 | + $data['altitude'] = $line[4]; // altitude |
|
1073 | + $data['speed'] = $line[5]; // speed |
|
1074 | + $data['heading'] = $line[3]; // heading |
|
1075 | + $data['latitude'] = $line[1]; // lat |
|
1076 | + $data['longitude'] = $line[2]; // long |
|
1077 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
1078 | + $data['squawk'] = $line[6]; // squawk |
|
1079 | + $data['aircraft_icao'] = $line[8]; |
|
1080 | + $data['registration'] = $line[9]; |
|
1081 | + $data['departure_airport_iata'] = $line[11]; |
|
1082 | + $data['arrival_airport_iata'] = $line[12]; |
|
1083 | + $data['emergency'] = ''; // emergency |
|
1084 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1085 | + $data['format_source'] = 'fr24json'; |
|
1086 | + $data['id_source'] = $id_source; |
|
1087 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1088 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1089 | + $SI->add($data); |
|
1090 | + unset($data); |
|
1091 | + } |
|
1091 | 1092 | } |
1092 | - } |
|
1093 | - //$last_exec['fr24json'] = time(); |
|
1094 | - $last_exec[$id]['last'] = time(); |
|
1093 | + //$last_exec['fr24json'] = time(); |
|
1094 | + $last_exec[$id]['last'] = time(); |
|
1095 | 1095 | //} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
1096 | 1096 | } elseif ($value['format'] === 'radarvirtueljson' && |
1097 | - ( |
|
1097 | + ( |
|
1098 | 1098 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1099 | 1099 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1100 | - ) |
|
1100 | + ) |
|
1101 | 1101 | ) { |
1102 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1103 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1104 | - //echo $buffer; |
|
1105 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1106 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1107 | - $all_data = json_decode($buffer,true); |
|
1108 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1102 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1103 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1104 | + //echo $buffer; |
|
1105 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1106 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1107 | + $all_data = json_decode($buffer,true); |
|
1108 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1109 | 1109 | die(json_last_error_msg()); |
1110 | - } |
|
1111 | - if (isset($all_data['mrkrs'])) { |
|
1110 | + } |
|
1111 | + if (isset($all_data['mrkrs'])) { |
|
1112 | 1112 | $reset = 0; |
1113 | 1113 | foreach ($all_data['mrkrs'] as $key => $line) { |
1114 | - if (isset($line['inf'])) { |
|
1114 | + if (isset($line['inf'])) { |
|
1115 | 1115 | $data = array(); |
1116 | 1116 | $data['hex'] = $line['inf']['ia']; |
1117 | 1117 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1118 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1119 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1120 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1121 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1122 | - $data['longitude'] = $line['pt'][1]; // long |
|
1123 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1124 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1125 | - //$data['aircraft_icao'] = $line[8]; |
|
1126 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1118 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1119 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1120 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1121 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1122 | + $data['longitude'] = $line['pt'][1]; // long |
|
1123 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1124 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1125 | + //$data['aircraft_icao'] = $line[8]; |
|
1126 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1127 | 1127 | //$data['departure_airport_iata'] = $line[11]; |
1128 | 1128 | //$data['arrival_airport_iata'] = $line[12]; |
1129 | - //$data['emergency'] = ''; // emergency |
|
1129 | + //$data['emergency'] = ''; // emergency |
|
1130 | 1130 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1131 | - $data['format_source'] = 'radarvirtueljson'; |
|
1132 | - $data['id_source'] = $id_source; |
|
1131 | + $data['format_source'] = 'radarvirtueljson'; |
|
1132 | + $data['id_source'] = $id_source; |
|
1133 | 1133 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1134 | 1134 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1135 | 1135 | $SI->add($data); |
1136 | 1136 | unset($data); |
1137 | - } |
|
1137 | + } |
|
1138 | + } |
|
1138 | 1139 | } |
1139 | - } |
|
1140 | - //$last_exec['radarvirtueljson'] = time(); |
|
1141 | - $last_exec[$id]['last'] = time(); |
|
1140 | + //$last_exec['radarvirtueljson'] = time(); |
|
1141 | + $last_exec[$id]['last'] = time(); |
|
1142 | 1142 | //} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1143 | 1143 | } elseif ($value['format'] === 'pirepsjson' && |
1144 | - ( |
|
1144 | + ( |
|
1145 | 1145 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1146 | 1146 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1147 | - ) |
|
1147 | + ) |
|
1148 | 1148 | ) { |
1149 | - //$buffer = $Common->getData($hosts[$id]); |
|
1150 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1151 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1149 | + //$buffer = $Common->getData($hosts[$id]); |
|
1150 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1151 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1152 | 1152 | |
1153 | - if (isset($all_data['pireps'])) { |
|
1153 | + if (isset($all_data['pireps'])) { |
|
1154 | 1154 | $reset = 0; |
1155 | - foreach ($all_data['pireps'] as $line) { |
|
1156 | - $data = array(); |
|
1157 | - $data['id'] = $line['id']; |
|
1158 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1159 | - $data['ident'] = $line['callsign']; // ident |
|
1160 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1161 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1162 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1163 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1164 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1165 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1166 | - $data['latitude'] = $line['lat']; // lat |
|
1167 | - $data['longitude'] = $line['lon']; // long |
|
1168 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1169 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1170 | - //$data['emergency'] = ''; // emergency |
|
1171 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1172 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1173 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1174 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1175 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1176 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1177 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1178 | - else $data['info'] = ''; |
|
1179 | - $data['format_source'] = 'pireps'; |
|
1180 | - $data['id_source'] = $id_source; |
|
1181 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1182 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1183 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1184 | - if ($line['icon'] === 'plane') { |
|
1155 | + foreach ($all_data['pireps'] as $line) { |
|
1156 | + $data = array(); |
|
1157 | + $data['id'] = $line['id']; |
|
1158 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1159 | + $data['ident'] = $line['callsign']; // ident |
|
1160 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1161 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1162 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1163 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1164 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1165 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1166 | + $data['latitude'] = $line['lat']; // lat |
|
1167 | + $data['longitude'] = $line['lon']; // long |
|
1168 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1169 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1170 | + //$data['emergency'] = ''; // emergency |
|
1171 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1172 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1173 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1174 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1175 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1176 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1177 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1178 | + else $data['info'] = ''; |
|
1179 | + $data['format_source'] = 'pireps'; |
|
1180 | + $data['id_source'] = $id_source; |
|
1181 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1182 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1183 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1184 | + if ($line['icon'] === 'plane') { |
|
1185 | 1185 | $SI->add($data); |
1186 | - // print_r($data); |
|
1187 | - } elseif ($line['icon'] === 'ct') { |
|
1186 | + // print_r($data); |
|
1187 | + } elseif ($line['icon'] === 'ct') { |
|
1188 | 1188 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1189 | 1189 | $data['info'] = str_replace('&sect;','',$data['info']); |
1190 | 1190 | $typec = substr($data['ident'],-3); |
@@ -1199,209 +1199,209 @@ discard block |
||
1199 | 1199 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
1200 | 1200 | else $data['type'] = 'Observer'; |
1201 | 1201 | 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']); |
1202 | - } |
|
1203 | - unset($data); |
|
1202 | + } |
|
1203 | + unset($data); |
|
1204 | + } |
|
1204 | 1205 | } |
1205 | - } |
|
1206 | - //$last_exec['pirepsjson'] = time(); |
|
1207 | - $last_exec[$id]['last'] = time(); |
|
1206 | + //$last_exec['pirepsjson'] = time(); |
|
1207 | + $last_exec[$id]['last'] = time(); |
|
1208 | 1208 | //} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1209 | 1209 | } elseif ($value['format'] === 'phpvmacars' && |
1210 | - ( |
|
1210 | + ( |
|
1211 | 1211 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1212 | 1212 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1213 | - ) |
|
1213 | + ) |
|
1214 | 1214 | ) { |
1215 | - //$buffer = $Common->getData($hosts[$id]); |
|
1216 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1217 | - $buffer = $Common->getData($value['host']); |
|
1218 | - $all_data = json_decode($buffer,true); |
|
1219 | - if ($buffer != '' && is_array($all_data)) { |
|
1215 | + //$buffer = $Common->getData($hosts[$id]); |
|
1216 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1217 | + $buffer = $Common->getData($value['host']); |
|
1218 | + $all_data = json_decode($buffer,true); |
|
1219 | + if ($buffer != '' && is_array($all_data)) { |
|
1220 | 1220 | $reset = 0; |
1221 | 1221 | foreach ($all_data as $line) { |
1222 | - $data = array(); |
|
1223 | - //$data['id'] = $line['id']; // id not usable |
|
1224 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1225 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1226 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1227 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1228 | - $data['ident'] = $line['flightnum']; // ident |
|
1229 | - $data['altitude'] = $line['alt']; // altitude |
|
1230 | - $data['speed'] = $line['gs']; // speed |
|
1231 | - $data['heading'] = $line['heading']; // heading |
|
1232 | - $data['latitude'] = $line['lat']; // lat |
|
1233 | - $data['longitude'] = $line['lng']; // long |
|
1234 | - $data['verticalrate'] = ''; // verticale rate |
|
1235 | - $data['squawk'] = ''; // squawk |
|
1236 | - $data['emergency'] = ''; // emergency |
|
1237 | - //$data['datetime'] = $line['lastupdate']; |
|
1238 | - //$data['last_update'] = $line['lastupdate']; |
|
1239 | - if (isset($value['timezone'])) { |
|
1240 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1241 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1242 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1243 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1244 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1245 | - $data['departure_airport_time'] = $line['deptime']; |
|
1246 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1247 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1248 | - if (isset($line['registration'])) { |
|
1249 | - $data['registration'] = $line['registration']; |
|
1250 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1251 | - } else $data['registration'] = $line['aircraft']; |
|
1252 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1253 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1254 | - if (isset($line['aircraftname'])) { |
|
1222 | + $data = array(); |
|
1223 | + //$data['id'] = $line['id']; // id not usable |
|
1224 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1225 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1226 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1227 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1228 | + $data['ident'] = $line['flightnum']; // ident |
|
1229 | + $data['altitude'] = $line['alt']; // altitude |
|
1230 | + $data['speed'] = $line['gs']; // speed |
|
1231 | + $data['heading'] = $line['heading']; // heading |
|
1232 | + $data['latitude'] = $line['lat']; // lat |
|
1233 | + $data['longitude'] = $line['lng']; // long |
|
1234 | + $data['verticalrate'] = ''; // verticale rate |
|
1235 | + $data['squawk'] = ''; // squawk |
|
1236 | + $data['emergency'] = ''; // emergency |
|
1237 | + //$data['datetime'] = $line['lastupdate']; |
|
1238 | + //$data['last_update'] = $line['lastupdate']; |
|
1239 | + if (isset($value['timezone'])) { |
|
1240 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1241 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1242 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1243 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1244 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1245 | + $data['departure_airport_time'] = $line['deptime']; |
|
1246 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1247 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1248 | + if (isset($line['registration'])) { |
|
1249 | + $data['registration'] = $line['registration']; |
|
1250 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1251 | + } else $data['registration'] = $line['aircraft']; |
|
1252 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1253 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1254 | + if (isset($line['aircraftname'])) { |
|
1255 | 1255 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1256 | 1256 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1257 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1258 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1259 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1260 | - else { |
|
1261 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1262 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1263 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1264 | - } |
|
1265 | - } |
|
1266 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1267 | - $data['id_source'] = $id_source; |
|
1268 | - $data['format_source'] = 'phpvmacars'; |
|
1269 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1270 | - $SI->add($data); |
|
1271 | - unset($data); |
|
1257 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1258 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1259 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1260 | + else { |
|
1261 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1262 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1263 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1264 | + } |
|
1265 | + } |
|
1266 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1267 | + $data['id_source'] = $id_source; |
|
1268 | + $data['format_source'] = 'phpvmacars'; |
|
1269 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1270 | + $SI->add($data); |
|
1271 | + unset($data); |
|
1272 | 1272 | } |
1273 | 1273 | if ($globalDebug) echo 'No more data...'."\n"; |
1274 | 1274 | unset($buffer); |
1275 | 1275 | unset($all_data); |
1276 | - } |
|
1277 | - //$last_exec['phpvmacars'] = time(); |
|
1278 | - $last_exec[$id]['last'] = time(); |
|
1276 | + } |
|
1277 | + //$last_exec['phpvmacars'] = time(); |
|
1278 | + $last_exec[$id]['last'] = time(); |
|
1279 | 1279 | } elseif ($value['format'] === 'vaos' && |
1280 | - ( |
|
1280 | + ( |
|
1281 | 1281 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1282 | 1282 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1283 | - ) |
|
1283 | + ) |
|
1284 | 1284 | ) { |
1285 | - //$buffer = $Common->getData($hosts[$id]); |
|
1286 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1287 | - $buffer = $Common->getData($value['host']); |
|
1288 | - $all_data = json_decode($buffer,true); |
|
1289 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1285 | + //$buffer = $Common->getData($hosts[$id]); |
|
1286 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1287 | + $buffer = $Common->getData($value['host']); |
|
1288 | + $all_data = json_decode($buffer,true); |
|
1289 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1290 | 1290 | $reset = 0; |
1291 | 1291 | foreach ($all_data['ACARSData'] as $line) { |
1292 | - //print_r($line); |
|
1293 | - $data = array(); |
|
1294 | - //$data['id'] = $line['id']; // id not usable |
|
1295 | - $data['id'] = $line['id']; |
|
1296 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1297 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1298 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1299 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1300 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1301 | - $data['altitude'] = $line['altitude']; // altitude |
|
1302 | - $data['speed'] = $line['groundspeed']; // speed |
|
1303 | - $data['heading'] = $line['heading']; // heading |
|
1304 | - $data['latitude'] = $line['lat']; // lat |
|
1305 | - $data['longitude'] = $line['lon']; // long |
|
1306 | - //$data['verticalrate'] = ''; // verticale rate |
|
1307 | - //$data['squawk'] = ''; // squawk |
|
1308 | - //$data['emergency'] = ''; // emergency |
|
1309 | - if (isset($value['timezone'])) { |
|
1310 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1311 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1312 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1313 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1292 | + //print_r($line); |
|
1293 | + $data = array(); |
|
1294 | + //$data['id'] = $line['id']; // id not usable |
|
1295 | + $data['id'] = $line['id']; |
|
1296 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1297 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1298 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1299 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1300 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1301 | + $data['altitude'] = $line['altitude']; // altitude |
|
1302 | + $data['speed'] = $line['groundspeed']; // speed |
|
1303 | + $data['heading'] = $line['heading']; // heading |
|
1304 | + $data['latitude'] = $line['lat']; // lat |
|
1305 | + $data['longitude'] = $line['lon']; // long |
|
1306 | + //$data['verticalrate'] = ''; // verticale rate |
|
1307 | + //$data['squawk'] = ''; // squawk |
|
1308 | + //$data['emergency'] = ''; // emergency |
|
1309 | + if (isset($value['timezone'])) { |
|
1310 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1311 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1312 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1313 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1314 | 1314 | |
1315 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1316 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1317 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1318 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1319 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1315 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1316 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1317 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1318 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1319 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1320 | 1320 | |
1321 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1322 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1323 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1321 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1322 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1323 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1324 | 1324 | |
1325 | - $data['id_source'] = $id_source; |
|
1326 | - $data['format_source'] = 'vaos'; |
|
1327 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1328 | - $SI->add($data); |
|
1329 | - unset($data); |
|
1325 | + $data['id_source'] = $id_source; |
|
1326 | + $data['format_source'] = 'vaos'; |
|
1327 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1328 | + $SI->add($data); |
|
1329 | + unset($data); |
|
1330 | 1330 | } |
1331 | 1331 | if ($globalDebug) echo 'No more data...'."\n"; |
1332 | 1332 | unset($buffer); |
1333 | 1333 | unset($all_data); |
1334 | - } |
|
1335 | - //$last_exec['phpvmacars'] = time(); |
|
1336 | - $last_exec[$id]['last'] = time(); |
|
1334 | + } |
|
1335 | + //$last_exec['phpvmacars'] = time(); |
|
1336 | + $last_exec[$id]['last'] = time(); |
|
1337 | 1337 | } elseif ($value['format'] === 'vam' && |
1338 | - ( |
|
1338 | + ( |
|
1339 | 1339 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1340 | 1340 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1341 | - ) |
|
1341 | + ) |
|
1342 | 1342 | ) { |
1343 | - //$buffer = $Common->getData($hosts[$id]); |
|
1344 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1345 | - $buffer = $Common->getData($value['host']); |
|
1346 | - $all_data = json_decode($buffer,true); |
|
1347 | - if ($buffer != '' && is_array($all_data)) { |
|
1343 | + //$buffer = $Common->getData($hosts[$id]); |
|
1344 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1345 | + $buffer = $Common->getData($value['host']); |
|
1346 | + $all_data = json_decode($buffer,true); |
|
1347 | + if ($buffer != '' && is_array($all_data)) { |
|
1348 | 1348 | $reset = 0; |
1349 | 1349 | foreach ($all_data as $line) { |
1350 | - $data = array(); |
|
1351 | - //$data['id'] = $line['id']; // id not usable |
|
1352 | - $data['id'] = trim($line['flight_id']); |
|
1353 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1354 | - $data['pilot_name'] = $line['pilot_name']; |
|
1355 | - $data['pilot_id'] = $line['pilot_id']; |
|
1356 | - $data['ident'] = trim($line['callsign']); // ident |
|
1357 | - $data['altitude'] = $line['altitude']; // altitude |
|
1358 | - $data['speed'] = $line['gs']; // speed |
|
1359 | - $data['heading'] = $line['heading']; // heading |
|
1360 | - $data['latitude'] = $line['latitude']; // lat |
|
1361 | - $data['longitude'] = $line['longitude']; // long |
|
1362 | - $data['verticalrate'] = ''; // verticale rate |
|
1363 | - $data['squawk'] = ''; // squawk |
|
1364 | - $data['emergency'] = ''; // emergency |
|
1365 | - //$data['datetime'] = $line['lastupdate']; |
|
1366 | - $data['last_update'] = $line['last_update']; |
|
1367 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1368 | - $data['departure_airport_icao'] = $line['departure']; |
|
1369 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1370 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1371 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1372 | - //$data['registration'] = $line['aircraft']; |
|
1373 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1374 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1375 | - $data['id_source'] = $id_source; |
|
1376 | - $data['format_source'] = 'vam'; |
|
1377 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1378 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1379 | - $SI->add($data); |
|
1380 | - unset($data); |
|
1350 | + $data = array(); |
|
1351 | + //$data['id'] = $line['id']; // id not usable |
|
1352 | + $data['id'] = trim($line['flight_id']); |
|
1353 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1354 | + $data['pilot_name'] = $line['pilot_name']; |
|
1355 | + $data['pilot_id'] = $line['pilot_id']; |
|
1356 | + $data['ident'] = trim($line['callsign']); // ident |
|
1357 | + $data['altitude'] = $line['altitude']; // altitude |
|
1358 | + $data['speed'] = $line['gs']; // speed |
|
1359 | + $data['heading'] = $line['heading']; // heading |
|
1360 | + $data['latitude'] = $line['latitude']; // lat |
|
1361 | + $data['longitude'] = $line['longitude']; // long |
|
1362 | + $data['verticalrate'] = ''; // verticale rate |
|
1363 | + $data['squawk'] = ''; // squawk |
|
1364 | + $data['emergency'] = ''; // emergency |
|
1365 | + //$data['datetime'] = $line['lastupdate']; |
|
1366 | + $data['last_update'] = $line['last_update']; |
|
1367 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1368 | + $data['departure_airport_icao'] = $line['departure']; |
|
1369 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1370 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1371 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1372 | + //$data['registration'] = $line['aircraft']; |
|
1373 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1374 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1375 | + $data['id_source'] = $id_source; |
|
1376 | + $data['format_source'] = 'vam'; |
|
1377 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1378 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1379 | + $SI->add($data); |
|
1380 | + unset($data); |
|
1381 | 1381 | } |
1382 | 1382 | if ($globalDebug) echo 'No more data...'."\n"; |
1383 | 1383 | unset($buffer); |
1384 | 1384 | unset($all_data); |
1385 | - } |
|
1386 | - //$last_exec['phpvmacars'] = time(); |
|
1387 | - $last_exec[$id]['last'] = time(); |
|
1385 | + } |
|
1386 | + //$last_exec['phpvmacars'] = time(); |
|
1387 | + $last_exec[$id]['last'] = time(); |
|
1388 | 1388 | } elseif ($value['format'] === 'blitzortung' && |
1389 | - ( |
|
1389 | + ( |
|
1390 | 1390 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1391 | 1391 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1392 | - ) |
|
1392 | + ) |
|
1393 | 1393 | ) { |
1394 | - //$buffer = $Common->getData($hosts[$id]); |
|
1395 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1396 | - $buffer = $Common->getData($value['host']); |
|
1397 | - $all_data = json_decode($buffer,true); |
|
1398 | - if ($buffer != '') { |
|
1394 | + //$buffer = $Common->getData($hosts[$id]); |
|
1395 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1396 | + $buffer = $Common->getData($value['host']); |
|
1397 | + $all_data = json_decode($buffer,true); |
|
1398 | + if ($buffer != '') { |
|
1399 | 1399 | $Source->deleteLocationBySource('blitzortung'); |
1400 | 1400 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1401 | 1401 | $buffer = explode('\n',$buffer); |
1402 | 1402 | foreach ($buffer as $buffer_line) { |
1403 | - $line = json_decode($buffer_line,true); |
|
1404 | - if (isset($line['time'])) { |
|
1403 | + $line = json_decode($buffer_line,true); |
|
1404 | + if (isset($line['time'])) { |
|
1405 | 1405 | $data = array(); |
1406 | 1406 | $data['altitude'] = $line['alt']; // altitude |
1407 | 1407 | $data['latitude'] = $line['lat']; // lat |
@@ -1413,94 +1413,94 @@ discard block |
||
1413 | 1413 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1414 | 1414 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1415 | 1415 | unset($data); |
1416 | - } |
|
1416 | + } |
|
1417 | 1417 | } |
1418 | 1418 | if ($globalDebug) echo 'No more data...'."\n"; |
1419 | 1419 | unset($buffer); |
1420 | - } |
|
1421 | - $last_exec[$id]['last'] = time(); |
|
1420 | + } |
|
1421 | + $last_exec[$id]['last'] = time(); |
|
1422 | 1422 | //} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') { |
1423 | 1423 | } 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') { |
1424 | - //$last_exec[$id]['last'] = time(); |
|
1425 | - //$read = array( $sockets[$id] ); |
|
1426 | - $read = $sockets; |
|
1427 | - $write = NULL; |
|
1428 | - $e = NULL; |
|
1429 | - $n = socket_select($read, $write, $e, $timeout); |
|
1430 | - if ($e != NULL) var_dump($e); |
|
1431 | - if ($n > 0) { |
|
1424 | + //$last_exec[$id]['last'] = time(); |
|
1425 | + //$read = array( $sockets[$id] ); |
|
1426 | + $read = $sockets; |
|
1427 | + $write = NULL; |
|
1428 | + $e = NULL; |
|
1429 | + $n = socket_select($read, $write, $e, $timeout); |
|
1430 | + if ($e != NULL) var_dump($e); |
|
1431 | + if ($n > 0) { |
|
1432 | 1432 | $reset = 0; |
1433 | 1433 | foreach ($read as $nb => $r) { |
1434 | - //$value = $formats[$nb]; |
|
1435 | - $format = $globalSources[$nb]['format']; |
|
1436 | - if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1434 | + //$value = $formats[$nb]; |
|
1435 | + $format = $globalSources[$nb]['format']; |
|
1436 | + if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1437 | 1437 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1438 | - } elseif ($format === 'vrstcp') { |
|
1438 | + } elseif ($format === 'vrstcp') { |
|
1439 | 1439 | $buffer = @socket_read($r, 6000); |
1440 | - } else { |
|
1440 | + } else { |
|
1441 | 1441 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1442 | - } |
|
1443 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1444 | - //echo $buffer."\n"; |
|
1445 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1446 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1447 | - $error = false; |
|
1448 | - //$SI::del(); |
|
1449 | - if ($buffer !== FALSE) { |
|
1442 | + } |
|
1443 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1444 | + //echo $buffer."\n"; |
|
1445 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1446 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1447 | + $error = false; |
|
1448 | + //$SI::del(); |
|
1449 | + if ($buffer !== FALSE) { |
|
1450 | 1450 | if ($format === 'vrstcp') { |
1451 | - $buffer = explode('},{',$buffer); |
|
1451 | + $buffer = explode('},{',$buffer); |
|
1452 | 1452 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
1453 | - } |
|
1454 | - // SBS format is CSV format |
|
1455 | - if ($buffer !== FALSE && $buffer !== '') { |
|
1453 | + } |
|
1454 | + // SBS format is CSV format |
|
1455 | + if ($buffer !== FALSE && $buffer !== '') { |
|
1456 | 1456 | $tt[$format] = 0; |
1457 | 1457 | if ($format === 'acarssbs3') { |
1458 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1459 | - $ACARS->add(trim($buffer)); |
|
1460 | - $ACARS->deleteLiveAcarsData(); |
|
1458 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1459 | + $ACARS->add(trim($buffer)); |
|
1460 | + $ACARS->deleteLiveAcarsData(); |
|
1461 | 1461 | } elseif ($format === 'raw') { |
1462 | - // AVR format |
|
1463 | - $data = $SBS->parse($buffer); |
|
1464 | - if (is_array($data)) { |
|
1462 | + // AVR format |
|
1463 | + $data = $SBS->parse($buffer); |
|
1464 | + if (is_array($data)) { |
|
1465 | 1465 | $data['datetime'] = date('Y-m-d H:i:s'); |
1466 | 1466 | $data['format_source'] = 'raw'; |
1467 | 1467 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1468 | 1468 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1469 | 1469 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1470 | 1470 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1471 | - } |
|
1471 | + } |
|
1472 | 1472 | } elseif ($format === 'ais') { |
1473 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1474 | - $data = array(); |
|
1475 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1476 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1477 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1478 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1479 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1480 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1481 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1482 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1483 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1484 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1485 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1486 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1487 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1488 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1489 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1490 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1473 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1474 | + $data = array(); |
|
1475 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1476 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1477 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1478 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1479 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1480 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1481 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1482 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1483 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1484 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1485 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1486 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1487 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1488 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1489 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1490 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1491 | 1491 | |
1492 | - if (isset($ais_data['timestamp'])) { |
|
1492 | + if (isset($ais_data['timestamp'])) { |
|
1493 | 1493 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1494 | - } else { |
|
1494 | + } else { |
|
1495 | 1495 | $data['datetime'] = date('Y-m-d H:i:s'); |
1496 | - } |
|
1497 | - $data['format_source'] = 'aisnmea'; |
|
1498 | - $data['id_source'] = $id_source; |
|
1499 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1500 | - unset($data); |
|
1501 | - } elseif ($format === 'flightgearsp') { |
|
1502 | - //echo $buffer."\n"; |
|
1503 | - if (strlen($buffer) > 5) { |
|
1496 | + } |
|
1497 | + $data['format_source'] = 'aisnmea'; |
|
1498 | + $data['id_source'] = $id_source; |
|
1499 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1500 | + unset($data); |
|
1501 | + } elseif ($format === 'flightgearsp') { |
|
1502 | + //echo $buffer."\n"; |
|
1503 | + if (strlen($buffer) > 5) { |
|
1504 | 1504 | $line = explode(',',$buffer); |
1505 | 1505 | $data = array(); |
1506 | 1506 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1517,38 +1517,38 @@ discard block |
||
1517 | 1517 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1518 | 1518 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1519 | 1519 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1520 | - } |
|
1521 | - } elseif ($format === 'acars') { |
|
1522 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1523 | - $ACARS->add(trim($buffer)); |
|
1524 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1525 | - $ACARS->deleteLiveAcarsData(); |
|
1520 | + } |
|
1521 | + } elseif ($format === 'acars') { |
|
1522 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1523 | + $ACARS->add(trim($buffer)); |
|
1524 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1525 | + $ACARS->deleteLiveAcarsData(); |
|
1526 | 1526 | } elseif ($format === 'flightgearmp') { |
1527 | - if (substr($buffer,0,1) != '#') { |
|
1527 | + if (substr($buffer,0,1) != '#') { |
|
1528 | 1528 | $data = array(); |
1529 | 1529 | //echo $buffer."\n"; |
1530 | 1530 | $line = explode(' ',$buffer); |
1531 | 1531 | if (count($line) === 11) { |
1532 | - $userserver = explode('@',$line[0]); |
|
1533 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1534 | - $data['ident'] = $userserver[0]; |
|
1535 | - $data['registration'] = $userserver[0]; |
|
1536 | - $data['latitude'] = $line[4]; |
|
1537 | - $data['longitude'] = $line[5]; |
|
1538 | - $data['altitude'] = $line[6]; |
|
1539 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1540 | - $aircraft_type = $line[10]; |
|
1541 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1542 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1543 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1544 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1532 | + $userserver = explode('@',$line[0]); |
|
1533 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1534 | + $data['ident'] = $userserver[0]; |
|
1535 | + $data['registration'] = $userserver[0]; |
|
1536 | + $data['latitude'] = $line[4]; |
|
1537 | + $data['longitude'] = $line[5]; |
|
1538 | + $data['altitude'] = $line[6]; |
|
1539 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1540 | + $aircraft_type = $line[10]; |
|
1541 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1542 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1543 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1544 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1545 | + } |
|
1545 | 1546 | } |
1546 | - } |
|
1547 | 1547 | } elseif ($format === 'beast') { |
1548 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1549 | - die; |
|
1548 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1549 | + die; |
|
1550 | 1550 | } elseif ($format === 'vrstcp') { |
1551 | - foreach($buffer as $all_data) { |
|
1551 | + foreach($buffer as $all_data) { |
|
1552 | 1552 | $line = json_decode('{'.$all_data.'}',true); |
1553 | 1553 | $data = array(); |
1554 | 1554 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1568,153 +1568,153 @@ discard block |
||
1568 | 1568 | */ |
1569 | 1569 | $data['datetime'] = date('Y-m-d H:i:s'); |
1570 | 1570 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1571 | - $data['format_source'] = 'vrstcp'; |
|
1571 | + $data['format_source'] = 'vrstcp'; |
|
1572 | 1572 | $data['id_source'] = $id_source; |
1573 | 1573 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1574 | 1574 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1575 | 1575 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1576 | 1576 | unset($data); |
1577 | - } |
|
1577 | + } |
|
1578 | 1578 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
1579 | - $line = explode("\t", $buffer); |
|
1580 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1579 | + $line = explode("\t", $buffer); |
|
1580 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1581 | 1581 | $key = $line[$k]; |
1582 | - $lined[$key] = $line[$k+1]; |
|
1583 | - } |
|
1584 | - if (count($lined) > 3) { |
|
1585 | - $data['hex'] = $lined['hexid']; |
|
1586 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1587 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1588 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1589 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1590 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1591 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1592 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1593 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1594 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1595 | - $data['id_source'] = $id_source; |
|
1596 | - $data['format_source'] = 'tsv'; |
|
1597 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1598 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1582 | + $lined[$key] = $line[$k+1]; |
|
1583 | + } |
|
1584 | + if (count($lined) > 3) { |
|
1585 | + $data['hex'] = $lined['hexid']; |
|
1586 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1587 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1588 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1589 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1590 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1591 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1592 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1593 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1594 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1595 | + $data['id_source'] = $id_source; |
|
1596 | + $data['format_source'] = 'tsv'; |
|
1597 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1598 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1599 | 1599 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1600 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1601 | - unset($lined); |
|
1602 | - unset($data); |
|
1603 | - } else $error = true; |
|
1600 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1601 | + unset($lined); |
|
1602 | + unset($data); |
|
1603 | + } else $error = true; |
|
1604 | 1604 | } elseif ($format === 'aprs' && $use_aprs) { |
1605 | - if ($aprs_connect === 0) { |
|
1605 | + if ($aprs_connect === 0) { |
|
1606 | 1606 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1607 | 1607 | $aprs_connect = 1; |
1608 | - } |
|
1608 | + } |
|
1609 | 1609 | |
1610 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1610 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1611 | 1611 | $aprs_last_tx = time(); |
1612 | 1612 | $data_aprs = "# Keep alive"; |
1613 | 1613 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1614 | - } |
|
1614 | + } |
|
1615 | 1615 | |
1616 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1617 | - //echo 'APRS data : '.$buffer."\n"; |
|
1618 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1619 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1620 | - //echo $buffer."\n"; |
|
1621 | - date_default_timezone_set('UTC'); |
|
1622 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1616 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1617 | + //echo 'APRS data : '.$buffer."\n"; |
|
1618 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1619 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1620 | + //echo $buffer."\n"; |
|
1621 | + date_default_timezone_set('UTC'); |
|
1622 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1623 | 1623 | $line = $APRS->parse($buffer); |
1624 | 1624 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1625 | 1625 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1626 | - $aprs_last_tx = time(); |
|
1627 | - $data = array(); |
|
1628 | - //print_r($line); |
|
1629 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1630 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1631 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1632 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1633 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1634 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1635 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1636 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1637 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1638 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1639 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1640 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1641 | - $data['latitude'] = $line['latitude']; |
|
1642 | - $data['longitude'] = $line['longitude']; |
|
1643 | - //$data['verticalrate'] = $line[16]; |
|
1644 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1645 | - //else $data['speed'] = 0; |
|
1646 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1647 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1648 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1649 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1626 | + $aprs_last_tx = time(); |
|
1627 | + $data = array(); |
|
1628 | + //print_r($line); |
|
1629 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1630 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1631 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1632 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1633 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1634 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1635 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1636 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1637 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1638 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1639 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1640 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1641 | + $data['latitude'] = $line['latitude']; |
|
1642 | + $data['longitude'] = $line['longitude']; |
|
1643 | + //$data['verticalrate'] = $line[16]; |
|
1644 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1645 | + //else $data['speed'] = 0; |
|
1646 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1647 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1648 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1649 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1650 | 1650 | |
1651 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1652 | - //else echo 'No heading...'."\n"; |
|
1653 | - //else $data['heading'] = 0; |
|
1654 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1655 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1656 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1657 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1658 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1659 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1660 | - $data['id_source'] = $id_source; |
|
1661 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1662 | - else $data['format_source'] = 'aprs'; |
|
1663 | - $data['source_name'] = $line['source']; |
|
1664 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1665 | - else $data['source_type'] = 'flarm'; |
|
1666 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1667 | - $currentdate = date('Y-m-d H:i:s'); |
|
1668 | - $aprsdate = strtotime($data['datetime']); |
|
1669 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1670 | - // Accept data if time <= system time + 20s |
|
1671 | - //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'])))) { |
|
1672 | - if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1651 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1652 | + //else echo 'No heading...'."\n"; |
|
1653 | + //else $data['heading'] = 0; |
|
1654 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1655 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1656 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1657 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1658 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1659 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1660 | + $data['id_source'] = $id_source; |
|
1661 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1662 | + else $data['format_source'] = 'aprs'; |
|
1663 | + $data['source_name'] = $line['source']; |
|
1664 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1665 | + else $data['source_type'] = 'flarm'; |
|
1666 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1667 | + $currentdate = date('Y-m-d H:i:s'); |
|
1668 | + $aprsdate = strtotime($data['datetime']); |
|
1669 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1670 | + // Accept data if time <= system time + 20s |
|
1671 | + //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'])))) { |
|
1672 | + if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1673 | 1673 | $send = $SI->add($data); |
1674 | - } elseif ($data['source_type'] === 'ais') { |
|
1674 | + } elseif ($data['source_type'] === 'ais') { |
|
1675 | 1675 | $data['type'] = ''; |
1676 | 1676 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1677 | - } elseif (isset($line['stealth'])) { |
|
1677 | + } elseif (isset($line['stealth'])) { |
|
1678 | 1678 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1679 | 1679 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1680 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1681 | - //$line['symbol'] === 'Balloon' || |
|
1682 | - $line['symbol'] === 'Glider' || |
|
1683 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1684 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1685 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1686 | - $send = $SI->add($data); |
|
1687 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1688 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1689 | - $line['symbol'] === 'Ship (Power Boat)')) { |
|
1690 | - $send = $MI->add($data); |
|
1691 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1692 | - $line['symbol'] === 'Car' || |
|
1693 | - $line['symbol'] === 'Ambulance' || |
|
1694 | - $line['symbol'] === 'Van' || |
|
1695 | - $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1696 | - $line['symbol'] === 'Motorcycle' || |
|
1697 | - $line['symbol'] === 'Tractor' || |
|
1698 | - $line['symbol'] === 'Police' || |
|
1699 | - $line['symbol'] === 'Bike' || |
|
1700 | - $line['symbol'] === 'Jogger' || |
|
1701 | - $line['symbol'] === 'Horse' || |
|
1702 | - $line['symbol'] === 'Bus' || |
|
1703 | - $line['symbol'] === 'Jeep' || |
|
1704 | - $line['symbol'] === 'Recreational Vehicle' || |
|
1705 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1706 | - $line['symbol'] === 'Ship (Power Boat)' || |
|
1707 | - $line['symbol'] === 'Firetruck' || |
|
1708 | - $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1709 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1710 | - $line['symbol'] === 'SUV' || |
|
1711 | - $line['symbol'] === 'Snowmobile' || |
|
1712 | - $line['symbol'] === 'Mobile Satellite Station')) { |
|
1713 | - //} 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') { |
|
1680 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1681 | + //$line['symbol'] === 'Balloon' || |
|
1682 | + $line['symbol'] === 'Glider' || |
|
1683 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1684 | + if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1685 | + if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1686 | + $send = $SI->add($data); |
|
1687 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1688 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1689 | + $line['symbol'] === 'Ship (Power Boat)')) { |
|
1690 | + $send = $MI->add($data); |
|
1691 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1692 | + $line['symbol'] === 'Car' || |
|
1693 | + $line['symbol'] === 'Ambulance' || |
|
1694 | + $line['symbol'] === 'Van' || |
|
1695 | + $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1696 | + $line['symbol'] === 'Motorcycle' || |
|
1697 | + $line['symbol'] === 'Tractor' || |
|
1698 | + $line['symbol'] === 'Police' || |
|
1699 | + $line['symbol'] === 'Bike' || |
|
1700 | + $line['symbol'] === 'Jogger' || |
|
1701 | + $line['symbol'] === 'Horse' || |
|
1702 | + $line['symbol'] === 'Bus' || |
|
1703 | + $line['symbol'] === 'Jeep' || |
|
1704 | + $line['symbol'] === 'Recreational Vehicle' || |
|
1705 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1706 | + $line['symbol'] === 'Ship (Power Boat)' || |
|
1707 | + $line['symbol'] === 'Firetruck' || |
|
1708 | + $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1709 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1710 | + $line['symbol'] === 'SUV' || |
|
1711 | + $line['symbol'] === 'Snowmobile' || |
|
1712 | + $line['symbol'] === 'Mobile Satellite Station')) { |
|
1713 | + //} 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') { |
|
1714 | 1714 | // } 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') { |
1715 | 1715 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1716 | 1716 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1717 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1717 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1718 | 1718 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1719 | 1719 | $Source->deleteOldLocationByType('gs'); |
1720 | 1720 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1722,7 +1722,7 @@ discard block |
||
1722 | 1722 | } else { |
1723 | 1723 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1724 | 1724 | } |
1725 | - } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1725 | + } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1726 | 1726 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1727 | 1727 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1728 | 1728 | $Source->deleteOldLocationByType('wx'); |
@@ -1732,7 +1732,7 @@ discard block |
||
1732 | 1732 | } else { |
1733 | 1733 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1734 | 1734 | } |
1735 | - } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1735 | + } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1736 | 1736 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1737 | 1737 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1738 | 1738 | $Source->deleteOldLocationByType('lightning'); |
@@ -1741,11 +1741,11 @@ discard block |
||
1741 | 1741 | } else { |
1742 | 1742 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1743 | 1743 | } |
1744 | - } elseif ($globalDebug) { |
|
1745 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1746 | - print_r($line); |
|
1747 | - } |
|
1748 | - unset($data); |
|
1744 | + } elseif ($globalDebug) { |
|
1745 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1746 | + print_r($line); |
|
1747 | + } |
|
1748 | + unset($data); |
|
1749 | 1749 | } |
1750 | 1750 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1751 | 1751 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1764,12 +1764,12 @@ discard block |
||
1764 | 1764 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1765 | 1765 | $globalSources[$nb]['last_weather_clean'] = time(); |
1766 | 1766 | } |
1767 | - } |
|
1767 | + } |
|
1768 | 1768 | } else { |
1769 | - $line = explode(',', $buffer); |
|
1770 | - if (count($line) > 20) { |
|
1771 | - $data['hex'] = $line[4]; |
|
1772 | - /* |
|
1769 | + $line = explode(',', $buffer); |
|
1770 | + if (count($line) > 20) { |
|
1771 | + $data['hex'] = $line[4]; |
|
1772 | + /* |
|
1773 | 1773 | $data['datetime'] = $line[6].' '.$line[7]; |
1774 | 1774 | date_default_timezone_set($globalTimezone); |
1775 | 1775 | $datetime = new DateTime($data['datetime']); |
@@ -1777,30 +1777,30 @@ discard block |
||
1777 | 1777 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1778 | 1778 | date_default_timezone_set('UTC'); |
1779 | 1779 | */ |
1780 | - // Force datetime to current UTC datetime |
|
1781 | - date_default_timezone_set('UTC'); |
|
1782 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1783 | - $data['ident'] = trim($line[10]); |
|
1784 | - $data['latitude'] = $line[14]; |
|
1785 | - $data['longitude'] = $line[15]; |
|
1786 | - $data['verticalrate'] = $line[16]; |
|
1787 | - $data['emergency'] = $line[20]; |
|
1788 | - $data['speed'] = $line[12]; |
|
1789 | - $data['squawk'] = $line[17]; |
|
1790 | - $data['altitude'] = $line[11]; |
|
1791 | - $data['heading'] = $line[13]; |
|
1792 | - $data['ground'] = $line[21]; |
|
1793 | - $data['emergency'] = $line[19]; |
|
1794 | - $data['format_source'] = 'sbs'; |
|
1780 | + // Force datetime to current UTC datetime |
|
1781 | + date_default_timezone_set('UTC'); |
|
1782 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1783 | + $data['ident'] = trim($line[10]); |
|
1784 | + $data['latitude'] = $line[14]; |
|
1785 | + $data['longitude'] = $line[15]; |
|
1786 | + $data['verticalrate'] = $line[16]; |
|
1787 | + $data['emergency'] = $line[20]; |
|
1788 | + $data['speed'] = $line[12]; |
|
1789 | + $data['squawk'] = $line[17]; |
|
1790 | + $data['altitude'] = $line[11]; |
|
1791 | + $data['heading'] = $line[13]; |
|
1792 | + $data['ground'] = $line[21]; |
|
1793 | + $data['emergency'] = $line[19]; |
|
1794 | + $data['format_source'] = 'sbs'; |
|
1795 | 1795 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1796 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1796 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1797 | 1797 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1798 | - $data['id_source'] = $id_source; |
|
1799 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1800 | - else $error = true; |
|
1801 | - unset($data); |
|
1802 | - } else $error = true; |
|
1803 | - if ($error) { |
|
1798 | + $data['id_source'] = $id_source; |
|
1799 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1800 | + else $error = true; |
|
1801 | + unset($data); |
|
1802 | + } else $error = true; |
|
1803 | + if ($error) { |
|
1804 | 1804 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
1805 | 1805 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1806 | 1806 | } else { |
@@ -1816,13 +1816,13 @@ discard block |
||
1816 | 1816 | connect_all($sourceer); |
1817 | 1817 | $sourceer = array(); |
1818 | 1818 | } |
1819 | - } |
|
1819 | + } |
|
1820 | 1820 | } |
1821 | 1821 | // Sleep for xxx microseconds |
1822 | 1822 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1823 | - } else { |
|
1823 | + } else { |
|
1824 | 1824 | if ($format === 'flightgearmp') { |
1825 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1825 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1826 | 1826 | //@socket_close($r); |
1827 | 1827 | sleep($globalMinFetch); |
1828 | 1828 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1831,9 +1831,9 @@ discard block |
||
1831 | 1831 | break; |
1832 | 1832 | |
1833 | 1833 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1834 | - if (isset($tt[$format])) $tt[$format]++; |
|
1835 | - else $tt[$format] = 0; |
|
1836 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1834 | + if (isset($tt[$format])) $tt[$format]++; |
|
1835 | + else $tt[$format] = 0; |
|
1836 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1837 | 1837 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1838 | 1838 | //@socket_close($r); |
1839 | 1839 | sleep(2); |
@@ -1844,24 +1844,24 @@ discard block |
||
1844 | 1844 | //connect_all($globalSources); |
1845 | 1845 | $tt[$format]=0; |
1846 | 1846 | break; |
1847 | - } |
|
1848 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1847 | + } |
|
1848 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1849 | + } |
|
1849 | 1850 | } |
1850 | - } |
|
1851 | 1851 | } |
1852 | - } else { |
|
1852 | + } else { |
|
1853 | 1853 | $error = socket_strerror(socket_last_error()); |
1854 | 1854 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1855 | 1855 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1856 | 1856 | if (isset($globalDebug)) echo "Restarting...\n"; |
1857 | 1857 | // Restart the script if possible |
1858 | 1858 | if (is_array($sockets)) { |
1859 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1859 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1860 | 1860 | |
1861 | - foreach ($sockets as $sock) { |
|
1861 | + foreach ($sockets as $sock) { |
|
1862 | 1862 | @socket_shutdown($sock,2); |
1863 | 1863 | @socket_close($sock); |
1864 | - } |
|
1864 | + } |
|
1865 | 1865 | |
1866 | 1866 | } |
1867 | 1867 | if ($globalDebug) echo "Waiting..."; |
@@ -1876,15 +1876,15 @@ discard block |
||
1876 | 1876 | if ($globalDebug) echo "Restart all connections..."; |
1877 | 1877 | connect_all($globalSources); |
1878 | 1878 | } |
1879 | - } |
|
1879 | + } |
|
1880 | 1880 | } |
1881 | 1881 | if ($globalDaemon === false) { |
1882 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1883 | - if (isset($SI)) $SI->checkAll(); |
|
1884 | - if (isset($TI)) $TI->checkAll(); |
|
1885 | - if (isset($MI)) $MI->checkAll(); |
|
1882 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1883 | + if (isset($SI)) $SI->checkAll(); |
|
1884 | + if (isset($TI)) $TI->checkAll(); |
|
1885 | + if (isset($MI)) $MI->checkAll(); |
|
1886 | + } |
|
1886 | 1887 | } |
1887 | - } |
|
1888 | 1888 | } |
1889 | 1889 | |
1890 | 1890 | ?> |