@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | require_once('header.php'); |
24 | 24 | |
25 | 25 | //calculuation for the pagination |
26 | -if(!isset($_GET['limit'])) |
|
26 | +if (!isset($_GET['limit'])) |
|
27 | 27 | { |
28 | 28 | $limit_start = 0; |
29 | 29 | $limit_end = 25; |
30 | 30 | $absolute_difference = 25; |
31 | -} else { |
|
31 | +} else { |
|
32 | 32 | $limit_explode = explode(",", $_GET['limit']); |
33 | 33 | $limit_start = $limit_explode[0]; |
34 | 34 | $limit_end = $limit_explode[1]; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>'; |
52 | 52 | else print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>'; |
53 | 53 | |
54 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
54 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
55 | 55 | $sql_begin = microtime(true); |
56 | 56 | if ($type == 'marine') { |
57 | 57 | $spotter_array = $Marine->getLatestMarineData($limit_start.",".$absolute_difference, $sort); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } else { |
61 | 61 | $spotter_array = $Spotter->getLatestSpotterData($limit_start.",".$absolute_difference, $sort); |
62 | 62 | } |
63 | -$sql_time = microtime(true)-$sql_begin; |
|
63 | +$sql_time = microtime(true) - $sql_begin; |
|
64 | 64 | $page_begin = microtime(true); |
65 | 65 | if (!empty($spotter_array)) |
66 | 66 | { |
@@ -77,6 +77,6 @@ discard block |
||
77 | 77 | print '</div>'; |
78 | 78 | print '</div>'; |
79 | 79 | } |
80 | -$page_time = microtime(true)-$page_begin; |
|
80 | +$page_time = microtime(true) - $page_begin; |
|
81 | 81 | require_once('footer.php'); |
82 | 82 | ?> |
83 | 83 | \ No newline at end of file |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $limit_start = 0; |
29 | 29 | $limit_end = 25; |
30 | 30 | $absolute_difference = 25; |
31 | -} else { |
|
31 | +} else { |
|
32 | 32 | $limit_explode = explode(",", $_GET['limit']); |
33 | 33 | $limit_start = $limit_explode[0]; |
34 | 34 | $limit_end = $limit_explode[1]; |
@@ -47,9 +47,13 @@ discard block |
||
47 | 47 | print '<h1>'._("Latest Activity").'</h1>'; |
48 | 48 | print '</div>'; |
49 | 49 | print '<div class="table column">'; |
50 | -if ($type == 'marine') print '<p>'._("The table below shows the detailed information of all recent vessels.").'</p>'; |
|
51 | -elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>'; |
|
52 | -else print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>'; |
|
50 | +if ($type == 'marine') { |
|
51 | + print '<p>'._("The table below shows the detailed information of all recent vessels.").'</p>'; |
|
52 | +} elseif ($type == 'tracker') { |
|
53 | + print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>'; |
|
54 | +} else { |
|
55 | + print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>'; |
|
56 | +} |
|
53 | 57 | |
54 | 58 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
55 | 59 | $sql_begin = microtime(true); |
@@ -14,7 +14,7 @@ |
||
14 | 14 | /** |
15 | 15 | * Get SQL query part for filter used |
16 | 16 | * @param Array $filter the filter |
17 | - * @return Array the SQL part |
|
17 | + * @return string the SQL part |
|
18 | 18 | */ |
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -9,10 +9,10 @@ discard block |
||
9 | 9 | } |
10 | 10 | |
11 | 11 | /** |
12 | - * Get SQL query part for filter used |
|
13 | - * @param Array $filter the filter |
|
14 | - * @return Array the SQL part |
|
15 | - */ |
|
12 | + * Get SQL query part for filter used |
|
13 | + * @param Array $filter the filter |
|
14 | + * @return Array the SQL part |
|
15 | + */ |
|
16 | 16 | public function getFilter($filter = array(),$where = false,$and = false) { |
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
18 | 18 | $filters = array(); |
@@ -108,44 +108,44 @@ discard block |
||
108 | 108 | } |
109 | 109 | |
110 | 110 | |
111 | - /** |
|
112 | - * Gets all the spotter information based on a particular callsign |
|
113 | - * |
|
114 | - * @return Array the spotter information |
|
115 | - * |
|
116 | - */ |
|
117 | - public function getLastArchiveTrackerDataByIdent($ident) |
|
118 | - { |
|
111 | + /** |
|
112 | + * Gets all the spotter information based on a particular callsign |
|
113 | + * |
|
114 | + * @return Array the spotter information |
|
115 | + * |
|
116 | + */ |
|
117 | + public function getLastArchiveTrackerDataByIdent($ident) |
|
118 | + { |
|
119 | 119 | $Tracker = new Tracker($this->db); |
120 | - date_default_timezone_set('UTC'); |
|
120 | + date_default_timezone_set('UTC'); |
|
121 | 121 | |
122 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
123 | - //$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"; |
|
124 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
122 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
123 | + //$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"; |
|
124 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
125 | 125 | |
126 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
126 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
127 | 127 | |
128 | - return $spotter_array; |
|
129 | - } |
|
128 | + return $spotter_array; |
|
129 | + } |
|
130 | 130 | |
131 | 131 | |
132 | - /** |
|
133 | - * Gets last the spotter information based on a particular id |
|
134 | - * |
|
135 | - * @return Array the spotter information |
|
136 | - * |
|
137 | - */ |
|
138 | - public function getLastArchiveTrackerDataById($id) |
|
139 | - { |
|
140 | - $Tracker = new Tracker($this->db); |
|
141 | - date_default_timezone_set('UTC'); |
|
142 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
143 | - //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
|
144 | - //$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"; |
|
145 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
132 | + /** |
|
133 | + * Gets last the spotter information based on a particular id |
|
134 | + * |
|
135 | + * @return Array the spotter information |
|
136 | + * |
|
137 | + */ |
|
138 | + public function getLastArchiveTrackerDataById($id) |
|
139 | + { |
|
140 | + $Tracker = new Tracker($this->db); |
|
141 | + date_default_timezone_set('UTC'); |
|
142 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
143 | + //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
|
144 | + //$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"; |
|
145 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
146 | 146 | |
147 | 147 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
148 | - /* |
|
148 | + /* |
|
149 | 149 | try { |
150 | 150 | $Connection = new Connection(); |
151 | 151 | $sth = Connection->$db->prepare($query); |
@@ -155,232 +155,232 @@ discard block |
||
155 | 155 | } |
156 | 156 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
157 | 157 | */ |
158 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
159 | - |
|
160 | - return $spotter_array; |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Gets all the spotter information based on a particular id |
|
165 | - * |
|
166 | - * @return Array the spotter information |
|
167 | - * |
|
168 | - */ |
|
169 | - public function getAllArchiveTrackerDataById($id) |
|
158 | + $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
159 | + |
|
160 | + return $spotter_array; |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Gets all the spotter information based on a particular id |
|
165 | + * |
|
166 | + * @return Array the spotter information |
|
167 | + * |
|
168 | + */ |
|
169 | + public function getAllArchiveTrackerDataById($id) |
|
170 | 170 | { |
171 | - date_default_timezone_set('UTC'); |
|
172 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
173 | - $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
171 | + date_default_timezone_set('UTC'); |
|
172 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
173 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
174 | 174 | |
175 | 175 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
176 | 176 | |
177 | - try { |
|
178 | - $sth = $this->db->prepare($query); |
|
179 | - $sth->execute(array(':id' => $id)); |
|
180 | - } catch(PDOException $e) { |
|
181 | - echo $e->getMessage(); |
|
182 | - die; |
|
183 | - } |
|
184 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
185 | - |
|
186 | - return $spotter_array; |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * Gets coordinate & time spotter information based on a particular id |
|
191 | - * |
|
192 | - * @return Array the spotter information |
|
193 | - * |
|
194 | - */ |
|
195 | - public function getCoordArchiveTrackerDataById($id) |
|
196 | - { |
|
197 | - date_default_timezone_set('UTC'); |
|
198 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
199 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
177 | + try { |
|
178 | + $sth = $this->db->prepare($query); |
|
179 | + $sth->execute(array(':id' => $id)); |
|
180 | + } catch(PDOException $e) { |
|
181 | + echo $e->getMessage(); |
|
182 | + die; |
|
183 | + } |
|
184 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
185 | + |
|
186 | + return $spotter_array; |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Gets coordinate & time spotter information based on a particular id |
|
191 | + * |
|
192 | + * @return Array the spotter information |
|
193 | + * |
|
194 | + */ |
|
195 | + public function getCoordArchiveTrackerDataById($id) |
|
196 | + { |
|
197 | + date_default_timezone_set('UTC'); |
|
198 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
199 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
200 | 200 | |
201 | 201 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
202 | 202 | |
203 | - try { |
|
204 | - $sth = $this->db->prepare($query); |
|
205 | - $sth->execute(array(':id' => $id)); |
|
206 | - } catch(PDOException $e) { |
|
207 | - echo $e->getMessage(); |
|
208 | - die; |
|
209 | - } |
|
210 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
203 | + try { |
|
204 | + $sth = $this->db->prepare($query); |
|
205 | + $sth->execute(array(':id' => $id)); |
|
206 | + } catch(PDOException $e) { |
|
207 | + echo $e->getMessage(); |
|
208 | + die; |
|
209 | + } |
|
210 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
211 | 211 | |
212 | - return $spotter_array; |
|
213 | - } |
|
212 | + return $spotter_array; |
|
213 | + } |
|
214 | 214 | |
215 | 215 | |
216 | - /** |
|
217 | - * Gets altitude information based on a particular callsign |
|
218 | - * |
|
219 | - * @return Array the spotter information |
|
220 | - * |
|
221 | - */ |
|
222 | - public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
223 | - { |
|
216 | + /** |
|
217 | + * Gets altitude information based on a particular callsign |
|
218 | + * |
|
219 | + * @return Array the spotter information |
|
220 | + * |
|
221 | + */ |
|
222 | + public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
223 | + { |
|
224 | 224 | |
225 | - date_default_timezone_set('UTC'); |
|
225 | + date_default_timezone_set('UTC'); |
|
226 | 226 | |
227 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
228 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
227 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
228 | + $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"; |
|
229 | 229 | |
230 | - try { |
|
231 | - $sth = $this->db->prepare($query); |
|
232 | - $sth->execute(array(':ident' => $ident)); |
|
233 | - } catch(PDOException $e) { |
|
234 | - echo $e->getMessage(); |
|
235 | - die; |
|
236 | - } |
|
237 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
230 | + try { |
|
231 | + $sth = $this->db->prepare($query); |
|
232 | + $sth->execute(array(':ident' => $ident)); |
|
233 | + } catch(PDOException $e) { |
|
234 | + echo $e->getMessage(); |
|
235 | + die; |
|
236 | + } |
|
237 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
238 | 238 | |
239 | - return $spotter_array; |
|
240 | - } |
|
239 | + return $spotter_array; |
|
240 | + } |
|
241 | 241 | |
242 | - /** |
|
243 | - * Gets altitude information based on a particular id |
|
244 | - * |
|
245 | - * @return Array the spotter information |
|
246 | - * |
|
247 | - */ |
|
248 | - public function getAltitudeArchiveTrackerDataById($id) |
|
249 | - { |
|
242 | + /** |
|
243 | + * Gets altitude information based on a particular id |
|
244 | + * |
|
245 | + * @return Array the spotter information |
|
246 | + * |
|
247 | + */ |
|
248 | + public function getAltitudeArchiveTrackerDataById($id) |
|
249 | + { |
|
250 | 250 | |
251 | - date_default_timezone_set('UTC'); |
|
251 | + date_default_timezone_set('UTC'); |
|
252 | 252 | |
253 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
254 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
253 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
254 | + $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"; |
|
255 | 255 | |
256 | - try { |
|
257 | - $sth = $this->db->prepare($query); |
|
258 | - $sth->execute(array(':id' => $id)); |
|
259 | - } catch(PDOException $e) { |
|
260 | - echo $e->getMessage(); |
|
261 | - die; |
|
262 | - } |
|
263 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
256 | + try { |
|
257 | + $sth = $this->db->prepare($query); |
|
258 | + $sth->execute(array(':id' => $id)); |
|
259 | + } catch(PDOException $e) { |
|
260 | + echo $e->getMessage(); |
|
261 | + die; |
|
262 | + } |
|
263 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
264 | 264 | |
265 | - return $spotter_array; |
|
266 | - } |
|
265 | + return $spotter_array; |
|
266 | + } |
|
267 | 267 | |
268 | - /** |
|
269 | - * Gets altitude & speed information based on a particular id |
|
270 | - * |
|
271 | - * @return Array the spotter information |
|
272 | - * |
|
273 | - */ |
|
274 | - public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
275 | - { |
|
268 | + /** |
|
269 | + * Gets altitude & speed information based on a particular id |
|
270 | + * |
|
271 | + * @return Array the spotter information |
|
272 | + * |
|
273 | + */ |
|
274 | + public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
275 | + { |
|
276 | 276 | |
277 | - date_default_timezone_set('UTC'); |
|
277 | + date_default_timezone_set('UTC'); |
|
278 | 278 | |
279 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
280 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
279 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
280 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
281 | 281 | |
282 | - try { |
|
283 | - $sth = $this->db->prepare($query); |
|
284 | - $sth->execute(array(':id' => $id)); |
|
285 | - } catch(PDOException $e) { |
|
286 | - echo $e->getMessage(); |
|
287 | - die; |
|
288 | - } |
|
289 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
282 | + try { |
|
283 | + $sth = $this->db->prepare($query); |
|
284 | + $sth->execute(array(':id' => $id)); |
|
285 | + } catch(PDOException $e) { |
|
286 | + echo $e->getMessage(); |
|
287 | + die; |
|
288 | + } |
|
289 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
290 | 290 | |
291 | - return $spotter_array; |
|
292 | - } |
|
291 | + return $spotter_array; |
|
292 | + } |
|
293 | 293 | |
294 | 294 | |
295 | - /** |
|
296 | - * Gets altitude information based on a particular callsign |
|
297 | - * |
|
298 | - * @return Array the spotter information |
|
299 | - * |
|
300 | - */ |
|
301 | - public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
302 | - { |
|
295 | + /** |
|
296 | + * Gets altitude information based on a particular callsign |
|
297 | + * |
|
298 | + * @return Array the spotter information |
|
299 | + * |
|
300 | + */ |
|
301 | + public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
302 | + { |
|
303 | 303 | |
304 | - date_default_timezone_set('UTC'); |
|
304 | + date_default_timezone_set('UTC'); |
|
305 | 305 | |
306 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
307 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
306 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
307 | + $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"; |
|
308 | 308 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
309 | 309 | |
310 | - try { |
|
311 | - $sth = $this->db->prepare($query); |
|
312 | - $sth->execute(array(':ident' => $ident)); |
|
313 | - } catch(PDOException $e) { |
|
314 | - echo $e->getMessage(); |
|
315 | - die; |
|
316 | - } |
|
317 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
310 | + try { |
|
311 | + $sth = $this->db->prepare($query); |
|
312 | + $sth->execute(array(':ident' => $ident)); |
|
313 | + } catch(PDOException $e) { |
|
314 | + echo $e->getMessage(); |
|
315 | + die; |
|
316 | + } |
|
317 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
318 | 318 | |
319 | - return $spotter_array; |
|
320 | - } |
|
319 | + return $spotter_array; |
|
320 | + } |
|
321 | 321 | |
322 | 322 | |
323 | 323 | |
324 | - /** |
|
325 | - * Gets all the archive spotter information |
|
326 | - * |
|
327 | - * @return Array the spotter information |
|
328 | - * |
|
329 | - */ |
|
330 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
331 | - { |
|
332 | - $Tracker = new Tracker($this->db); |
|
333 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
334 | - $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"; |
|
324 | + /** |
|
325 | + * Gets all the archive spotter information |
|
326 | + * |
|
327 | + * @return Array the spotter information |
|
328 | + * |
|
329 | + */ |
|
330 | + public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
331 | + { |
|
332 | + $Tracker = new Tracker($this->db); |
|
333 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
334 | + $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"; |
|
335 | 335 | |
336 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
336 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
337 | 337 | |
338 | - return $spotter_array; |
|
339 | - } |
|
338 | + return $spotter_array; |
|
339 | + } |
|
340 | 340 | |
341 | - public function deleteTrackerArchiveTrackData() |
|
342 | - { |
|
341 | + public function deleteTrackerArchiveTrackData() |
|
342 | + { |
|
343 | 343 | global $globalArchiveKeepTrackMonths; |
344 | - date_default_timezone_set('UTC'); |
|
344 | + date_default_timezone_set('UTC'); |
|
345 | 345 | $query = 'DELETE FROM tracker_archive WHERE tracker_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
346 | - try { |
|
347 | - $sth = $this->db->prepare($query); |
|
348 | - $sth->execute(); |
|
349 | - } catch(PDOException $e) { |
|
350 | - echo $e->getMessage(); |
|
351 | - die; |
|
352 | - } |
|
346 | + try { |
|
347 | + $sth = $this->db->prepare($query); |
|
348 | + $sth->execute(); |
|
349 | + } catch(PDOException $e) { |
|
350 | + echo $e->getMessage(); |
|
351 | + die; |
|
352 | + } |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
356 | - * Gets Minimal Live Tracker data |
|
357 | - * |
|
358 | - * @return Array the spotter information |
|
359 | - * |
|
360 | - */ |
|
361 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
362 | - { |
|
363 | - global $globalDBdriver, $globalLiveInterval; |
|
364 | - date_default_timezone_set('UTC'); |
|
365 | - |
|
366 | - $filter_query = ''; |
|
367 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
368 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
369 | - } |
|
370 | - // Use spotter_output also ? |
|
371 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
372 | - $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 "; |
|
373 | - } |
|
374 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
375 | - $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 "; |
|
376 | - } |
|
377 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
378 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
379 | - } |
|
356 | + * Gets Minimal Live Tracker data |
|
357 | + * |
|
358 | + * @return Array the spotter information |
|
359 | + * |
|
360 | + */ |
|
361 | + public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
362 | + { |
|
363 | + global $globalDBdriver, $globalLiveInterval; |
|
364 | + date_default_timezone_set('UTC'); |
|
365 | + |
|
366 | + $filter_query = ''; |
|
367 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
368 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
369 | + } |
|
370 | + // Use spotter_output also ? |
|
371 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
372 | + $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 "; |
|
373 | + } |
|
374 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
375 | + $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 "; |
|
376 | + } |
|
377 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
378 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
379 | + } |
|
380 | 380 | |
381 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
382 | - if ($globalDBdriver == 'mysql') { |
|
383 | - /* |
|
381 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
382 | + if ($globalDBdriver == 'mysql') { |
|
383 | + /* |
|
384 | 384 | $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 |
385 | 385 | FROM tracker_archive |
386 | 386 | 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'; |
@@ -399,56 +399,56 @@ discard block |
||
399 | 399 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
400 | 400 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
401 | 401 | '.$filter_query.' ORDER BY famtrackid'; |
402 | - } else { |
|
403 | - //$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'; |
|
404 | - $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 |
|
402 | + } else { |
|
403 | + //$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'; |
|
404 | + $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 |
|
405 | 405 | FROM tracker_archive |
406 | 406 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
407 | 407 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
408 | 408 | '.$filter_query.' ORDER BY famtrackid'; |
409 | - } |
|
410 | - //echo $query; |
|
411 | - try { |
|
412 | - $sth = $this->db->prepare($query); |
|
413 | - $sth->execute(); |
|
414 | - } catch(PDOException $e) { |
|
415 | - echo $e->getMessage(); |
|
416 | - die; |
|
417 | - } |
|
418 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
409 | + } |
|
410 | + //echo $query; |
|
411 | + try { |
|
412 | + $sth = $this->db->prepare($query); |
|
413 | + $sth->execute(); |
|
414 | + } catch(PDOException $e) { |
|
415 | + echo $e->getMessage(); |
|
416 | + die; |
|
417 | + } |
|
418 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
419 | 419 | |
420 | - return $spotter_array; |
|
421 | - } |
|
420 | + return $spotter_array; |
|
421 | + } |
|
422 | 422 | |
423 | 423 | /** |
424 | - * Gets Minimal Live Tracker data |
|
425 | - * |
|
426 | - * @return Array the spotter information |
|
427 | - * |
|
428 | - */ |
|
429 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
430 | - { |
|
431 | - global $globalDBdriver, $globalLiveInterval; |
|
432 | - date_default_timezone_set('UTC'); |
|
433 | - |
|
434 | - $filter_query = ''; |
|
435 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
436 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
437 | - } |
|
438 | - // Should use spotter_output also ? |
|
439 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
440 | - $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 "; |
|
441 | - } |
|
442 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
443 | - $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 "; |
|
444 | - } |
|
445 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
446 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
447 | - } |
|
424 | + * Gets Minimal Live Tracker data |
|
425 | + * |
|
426 | + * @return Array the spotter information |
|
427 | + * |
|
428 | + */ |
|
429 | + public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
430 | + { |
|
431 | + global $globalDBdriver, $globalLiveInterval; |
|
432 | + date_default_timezone_set('UTC'); |
|
433 | + |
|
434 | + $filter_query = ''; |
|
435 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
436 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
437 | + } |
|
438 | + // Should use spotter_output also ? |
|
439 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
440 | + $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 "; |
|
441 | + } |
|
442 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
443 | + $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 "; |
|
444 | + } |
|
445 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
446 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
447 | + } |
|
448 | 448 | |
449 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
450 | - if ($globalDBdriver == 'mysql') { |
|
451 | - /* |
|
449 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
450 | + if ($globalDBdriver == 'mysql') { |
|
451 | + /* |
|
452 | 452 | $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 |
453 | 453 | FROM tracker_archive |
454 | 454 | 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'; |
@@ -459,95 +459,95 @@ discard block |
||
459 | 459 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
460 | 460 | '.$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'; |
461 | 461 | |
462 | - } else { |
|
463 | - //$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'; |
|
464 | - /* |
|
462 | + } else { |
|
463 | + //$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'; |
|
464 | + /* |
|
465 | 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 |
466 | 466 | FROM tracker_archive_output |
467 | 467 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
468 | 468 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
469 | 469 | '.$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'; |
470 | 470 | */ |
471 | - $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 |
|
471 | + $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
472 | 472 | FROM tracker_archive_output |
473 | 473 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
474 | 474 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
475 | 475 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
476 | 476 | // .' 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'; |
477 | 477 | |
478 | - } |
|
479 | - //echo $query; |
|
480 | - try { |
|
481 | - $sth = $this->db->prepare($query); |
|
482 | - $sth->execute(); |
|
483 | - } catch(PDOException $e) { |
|
484 | - echo $e->getMessage(); |
|
485 | - die; |
|
486 | - } |
|
487 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
478 | + } |
|
479 | + //echo $query; |
|
480 | + try { |
|
481 | + $sth = $this->db->prepare($query); |
|
482 | + $sth->execute(); |
|
483 | + } catch(PDOException $e) { |
|
484 | + echo $e->getMessage(); |
|
485 | + die; |
|
486 | + } |
|
487 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
488 | 488 | |
489 | - return $spotter_array; |
|
490 | - } |
|
489 | + return $spotter_array; |
|
490 | + } |
|
491 | 491 | |
492 | 492 | /** |
493 | - * Gets count Live Tracker data |
|
494 | - * |
|
495 | - * @return Array the spotter information |
|
496 | - * |
|
497 | - */ |
|
498 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
499 | - { |
|
500 | - global $globalDBdriver, $globalLiveInterval; |
|
501 | - date_default_timezone_set('UTC'); |
|
502 | - |
|
503 | - $filter_query = ''; |
|
504 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
505 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
506 | - } |
|
507 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
508 | - $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 "; |
|
509 | - } |
|
510 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
511 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
512 | - } |
|
513 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
514 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
515 | - } |
|
493 | + * Gets count Live Tracker data |
|
494 | + * |
|
495 | + * @return Array the spotter information |
|
496 | + * |
|
497 | + */ |
|
498 | + public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
499 | + { |
|
500 | + global $globalDBdriver, $globalLiveInterval; |
|
501 | + date_default_timezone_set('UTC'); |
|
516 | 502 | |
517 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
518 | - if ($globalDBdriver == 'mysql') { |
|
503 | + $filter_query = ''; |
|
504 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
505 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
506 | + } |
|
507 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
508 | + $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 "; |
|
509 | + } |
|
510 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
511 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
512 | + } |
|
513 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
514 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
515 | + } |
|
516 | + |
|
517 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
518 | + if ($globalDBdriver == 'mysql') { |
|
519 | 519 | $query = 'SELECT COUNT(DISTINCT famtrackid) as nb |
520 | 520 | FROM tracker_archive l |
521 | 521 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
522 | - } else { |
|
522 | + } else { |
|
523 | 523 | $query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
524 | - } |
|
525 | - //echo $query; |
|
526 | - try { |
|
527 | - $sth = $this->db->prepare($query); |
|
528 | - $sth->execute(); |
|
529 | - } catch(PDOException $e) { |
|
530 | - echo $e->getMessage(); |
|
531 | - die; |
|
532 | - } |
|
524 | + } |
|
525 | + //echo $query; |
|
526 | + try { |
|
527 | + $sth = $this->db->prepare($query); |
|
528 | + $sth->execute(); |
|
529 | + } catch(PDOException $e) { |
|
530 | + echo $e->getMessage(); |
|
531 | + die; |
|
532 | + } |
|
533 | 533 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
534 | 534 | $sth->closeCursor(); |
535 | - return $result['nb']; |
|
535 | + return $result['nb']; |
|
536 | 536 | |
537 | - } |
|
537 | + } |
|
538 | 538 | |
539 | 539 | |
540 | 540 | |
541 | 541 | // tracker_archive_output |
542 | 542 | |
543 | - /** |
|
544 | - * Gets all the spotter information |
|
545 | - * |
|
546 | - * @return Array the spotter information |
|
547 | - * |
|
548 | - */ |
|
549 | - 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()) |
|
550 | - { |
|
543 | + /** |
|
544 | + * Gets all the spotter information |
|
545 | + * |
|
546 | + * @return Array the spotter information |
|
547 | + * |
|
548 | + */ |
|
549 | + 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()) |
|
550 | + { |
|
551 | 551 | global $globalTimezone, $globalDBdriver; |
552 | 552 | require_once(dirname(__FILE__).'/class.Translation.php'); |
553 | 553 | $Translation = new Translation(); |
@@ -561,159 +561,159 @@ discard block |
||
561 | 561 | $filter_query = $this->getFilter($filters); |
562 | 562 | if ($q != "") |
563 | 563 | { |
564 | - if (!is_string($q)) |
|
565 | - { |
|
564 | + if (!is_string($q)) |
|
565 | + { |
|
566 | 566 | return false; |
567 | - } else { |
|
567 | + } else { |
|
568 | 568 | |
569 | 569 | $q_array = explode(" ", $q); |
570 | 570 | |
571 | 571 | foreach ($q_array as $q_item){ |
572 | - $additional_query .= " AND ("; |
|
573 | - $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
574 | - $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
575 | - $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
576 | - $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
577 | - $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
578 | - $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
579 | - $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
580 | - $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
581 | - $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
582 | - $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
583 | - $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
584 | - $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
585 | - $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
586 | - $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
587 | - $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
588 | - $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
589 | - $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
590 | - $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
591 | - $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
592 | - $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
593 | - $translate = $Translation->ident2icao($q_item); |
|
594 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
595 | - $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
596 | - $additional_query .= ")"; |
|
572 | + $additional_query .= " AND ("; |
|
573 | + $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
574 | + $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
575 | + $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
576 | + $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
577 | + $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
578 | + $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
579 | + $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
580 | + $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
581 | + $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
582 | + $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
583 | + $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
584 | + $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
585 | + $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
586 | + $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
587 | + $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
588 | + $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
589 | + $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
590 | + $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
591 | + $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
592 | + $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
593 | + $translate = $Translation->ident2icao($q_item); |
|
594 | + if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
595 | + $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
596 | + $additional_query .= ")"; |
|
597 | + } |
|
597 | 598 | } |
598 | - } |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | if ($registration != "") |
602 | 602 | { |
603 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
604 | - if (!is_string($registration)) |
|
605 | - { |
|
603 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
604 | + if (!is_string($registration)) |
|
605 | + { |
|
606 | 606 | return false; |
607 | - } else { |
|
607 | + } else { |
|
608 | 608 | $additional_query .= " AND (tracker_archive_output.registration = '".$registration."')"; |
609 | - } |
|
609 | + } |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | if ($aircraft_icao != "") |
613 | 613 | { |
614 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
615 | - if (!is_string($aircraft_icao)) |
|
616 | - { |
|
614 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
615 | + if (!is_string($aircraft_icao)) |
|
616 | + { |
|
617 | 617 | return false; |
618 | - } else { |
|
618 | + } else { |
|
619 | 619 | $additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
620 | - } |
|
620 | + } |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | if ($aircraft_manufacturer != "") |
624 | 624 | { |
625 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
626 | - if (!is_string($aircraft_manufacturer)) |
|
627 | - { |
|
625 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
626 | + if (!is_string($aircraft_manufacturer)) |
|
627 | + { |
|
628 | 628 | return false; |
629 | - } else { |
|
629 | + } else { |
|
630 | 630 | $additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
631 | - } |
|
631 | + } |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | if ($highlights == "true") |
635 | 635 | { |
636 | - if (!is_string($highlights)) |
|
637 | - { |
|
636 | + if (!is_string($highlights)) |
|
637 | + { |
|
638 | 638 | return false; |
639 | - } else { |
|
639 | + } else { |
|
640 | 640 | $additional_query .= " AND (tracker_archive_output.highlight <> '')"; |
641 | - } |
|
641 | + } |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | if ($airline_icao != "") |
645 | 645 | { |
646 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
647 | - if (!is_string($airline_icao)) |
|
648 | - { |
|
646 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
647 | + if (!is_string($airline_icao)) |
|
648 | + { |
|
649 | 649 | return false; |
650 | - } else { |
|
650 | + } else { |
|
651 | 651 | $additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')"; |
652 | - } |
|
652 | + } |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | if ($airline_country != "") |
656 | 656 | { |
657 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
658 | - if (!is_string($airline_country)) |
|
659 | - { |
|
657 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
658 | + if (!is_string($airline_country)) |
|
659 | + { |
|
660 | 660 | return false; |
661 | - } else { |
|
661 | + } else { |
|
662 | 662 | $additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')"; |
663 | - } |
|
663 | + } |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | if ($airline_type != "") |
667 | 667 | { |
668 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
669 | - if (!is_string($airline_type)) |
|
670 | - { |
|
668 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
669 | + if (!is_string($airline_type)) |
|
670 | + { |
|
671 | 671 | return false; |
672 | - } else { |
|
672 | + } else { |
|
673 | 673 | if ($airline_type == "passenger") |
674 | 674 | { |
675 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
675 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
676 | 676 | } |
677 | 677 | if ($airline_type == "cargo") |
678 | 678 | { |
679 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
679 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
680 | 680 | } |
681 | 681 | if ($airline_type == "military") |
682 | 682 | { |
683 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
683 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
684 | + } |
|
684 | 685 | } |
685 | - } |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | if ($airport != "") |
689 | 689 | { |
690 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
691 | - if (!is_string($airport)) |
|
692 | - { |
|
690 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
691 | + if (!is_string($airport)) |
|
692 | + { |
|
693 | 693 | return false; |
694 | - } else { |
|
694 | + } else { |
|
695 | 695 | $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))"; |
696 | - } |
|
696 | + } |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | if ($airport_country != "") |
700 | 700 | { |
701 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
702 | - if (!is_string($airport_country)) |
|
703 | - { |
|
701 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
702 | + if (!is_string($airport_country)) |
|
703 | + { |
|
704 | 704 | return false; |
705 | - } else { |
|
705 | + } else { |
|
706 | 706 | $additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))"; |
707 | - } |
|
707 | + } |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | if ($callsign != "") |
711 | 711 | { |
712 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
713 | - if (!is_string($callsign)) |
|
714 | - { |
|
712 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
713 | + if (!is_string($callsign)) |
|
714 | + { |
|
715 | 715 | return false; |
716 | - } else { |
|
716 | + } else { |
|
717 | 717 | $translate = $Translation->ident2icao($callsign); |
718 | 718 | if ($translate != $callsign) { |
719 | 719 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
@@ -721,99 +721,99 @@ discard block |
||
721 | 721 | } else { |
722 | 722 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
723 | 723 | } |
724 | - } |
|
724 | + } |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | if ($owner != "") |
728 | 728 | { |
729 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
730 | - if (!is_string($owner)) |
|
731 | - { |
|
729 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
730 | + if (!is_string($owner)) |
|
731 | + { |
|
732 | 732 | return false; |
733 | - } else { |
|
733 | + } else { |
|
734 | 734 | $additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')"; |
735 | - } |
|
735 | + } |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | if ($pilot_name != "") |
739 | 739 | { |
740 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
741 | - if (!is_string($pilot_name)) |
|
742 | - { |
|
740 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
741 | + if (!is_string($pilot_name)) |
|
742 | + { |
|
743 | 743 | return false; |
744 | - } else { |
|
744 | + } else { |
|
745 | 745 | $additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')"; |
746 | - } |
|
746 | + } |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | if ($pilot_id != "") |
750 | 750 | { |
751 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
752 | - if (!is_string($pilot_id)) |
|
753 | - { |
|
751 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
752 | + if (!is_string($pilot_id)) |
|
753 | + { |
|
754 | 754 | return false; |
755 | - } else { |
|
755 | + } else { |
|
756 | 756 | $additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')"; |
757 | - } |
|
757 | + } |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | if ($departure_airport_route != "") |
761 | 761 | { |
762 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
763 | - if (!is_string($departure_airport_route)) |
|
764 | - { |
|
762 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
763 | + if (!is_string($departure_airport_route)) |
|
764 | + { |
|
765 | 765 | return false; |
766 | - } else { |
|
766 | + } else { |
|
767 | 767 | $additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
768 | - } |
|
768 | + } |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | if ($arrival_airport_route != "") |
772 | 772 | { |
773 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
774 | - if (!is_string($arrival_airport_route)) |
|
775 | - { |
|
773 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
774 | + if (!is_string($arrival_airport_route)) |
|
775 | + { |
|
776 | 776 | return false; |
777 | - } else { |
|
777 | + } else { |
|
778 | 778 | $additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
779 | - } |
|
779 | + } |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | if ($altitude != "") |
783 | 783 | { |
784 | - $altitude_array = explode(",", $altitude); |
|
784 | + $altitude_array = explode(",", $altitude); |
|
785 | 785 | |
786 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
787 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
786 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
787 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | 788 | |
789 | 789 | |
790 | - if ($altitude_array[1] != "") |
|
791 | - { |
|
790 | + if ($altitude_array[1] != "") |
|
791 | + { |
|
792 | 792 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
793 | 793 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
794 | 794 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
795 | - } else { |
|
795 | + } else { |
|
796 | 796 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
797 | 797 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
798 | - } |
|
798 | + } |
|
799 | 799 | } |
800 | 800 | |
801 | 801 | if ($date_posted != "") |
802 | 802 | { |
803 | - $date_array = explode(",", $date_posted); |
|
803 | + $date_array = explode(",", $date_posted); |
|
804 | 804 | |
805 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
806 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
805 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
806 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
807 | 807 | |
808 | - if ($globalTimezone != '') { |
|
808 | + if ($globalTimezone != '') { |
|
809 | 809 | date_default_timezone_set($globalTimezone); |
810 | 810 | $datetime = new DateTime(); |
811 | 811 | $offset = $datetime->format('P'); |
812 | - } else $offset = '+00:00'; |
|
812 | + } else $offset = '+00:00'; |
|
813 | 813 | |
814 | 814 | |
815 | - if ($date_array[1] != "") |
|
816 | - { |
|
815 | + if ($date_array[1] != "") |
|
816 | + { |
|
817 | 817 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
818 | 818 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
819 | 819 | if ($globalDBdriver == 'mysql') { |
@@ -821,28 +821,28 @@ discard block |
||
821 | 821 | } else { |
822 | 822 | $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) "; |
823 | 823 | } |
824 | - } else { |
|
824 | + } else { |
|
825 | 825 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
826 | - if ($globalDBdriver == 'mysql') { |
|
826 | + if ($globalDBdriver == 'mysql') { |
|
827 | 827 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
828 | 828 | } else { |
829 | 829 | $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
830 | 830 | } |
831 | - } |
|
831 | + } |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | if ($limit != "") |
835 | 835 | { |
836 | - $limit_array = explode(",", $limit); |
|
836 | + $limit_array = explode(",", $limit); |
|
837 | 837 | |
838 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
839 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
838 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
839 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
840 | 840 | |
841 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
842 | - { |
|
841 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
842 | + { |
|
843 | 843 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
844 | 844 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
845 | - } |
|
845 | + } |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | |
@@ -873,33 +873,33 @@ discard block |
||
873 | 873 | $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
874 | 874 | |
875 | 875 | return $spotter_array; |
876 | - } |
|
876 | + } |
|
877 | 877 | |
878 | - public function deleteTrackerArchiveData() |
|
879 | - { |
|
878 | + public function deleteTrackerArchiveData() |
|
879 | + { |
|
880 | 880 | global $globalArchiveKeepMonths, $globalDBdriver; |
881 | - date_default_timezone_set('UTC'); |
|
882 | - if ($globalDBdriver == 'mysql') { |
|
881 | + date_default_timezone_set('UTC'); |
|
882 | + if ($globalDBdriver == 'mysql') { |
|
883 | 883 | $query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
884 | 884 | } else { |
885 | 885 | $query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
886 | 886 | } |
887 | - try { |
|
888 | - $sth = $this->db->prepare($query); |
|
889 | - $sth->execute(); |
|
890 | - } catch(PDOException $e) { |
|
891 | - return "error"; |
|
892 | - } |
|
887 | + try { |
|
888 | + $sth = $this->db->prepare($query); |
|
889 | + $sth->execute(); |
|
890 | + } catch(PDOException $e) { |
|
891 | + return "error"; |
|
892 | + } |
|
893 | 893 | } |
894 | 894 | |
895 | - /** |
|
896 | - * Gets all the spotter information based on the callsign |
|
897 | - * |
|
898 | - * @return Array the spotter information |
|
899 | - * |
|
900 | - */ |
|
901 | - public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
902 | - { |
|
895 | + /** |
|
896 | + * Gets all the spotter information based on the callsign |
|
897 | + * |
|
898 | + * @return Array the spotter information |
|
899 | + * |
|
900 | + */ |
|
901 | + public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
902 | + { |
|
903 | 903 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
904 | 904 | |
905 | 905 | date_default_timezone_set('UTC'); |
@@ -911,35 +911,35 @@ discard block |
||
911 | 911 | |
912 | 912 | if ($ident != "") |
913 | 913 | { |
914 | - if (!is_string($ident)) |
|
915 | - { |
|
914 | + if (!is_string($ident)) |
|
915 | + { |
|
916 | 916 | return false; |
917 | - } else { |
|
917 | + } else { |
|
918 | 918 | $additional_query = " AND (tracker_archive_output.ident = :ident)"; |
919 | 919 | $query_values = array(':ident' => $ident); |
920 | - } |
|
920 | + } |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | if ($limit != "") |
924 | 924 | { |
925 | - $limit_array = explode(",", $limit); |
|
925 | + $limit_array = explode(",", $limit); |
|
926 | 926 | |
927 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
928 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
927 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
928 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
929 | 929 | |
930 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
931 | - { |
|
930 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
931 | + { |
|
932 | 932 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
933 | 933 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
934 | - } |
|
934 | + } |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | if ($sort != "") |
938 | 938 | { |
939 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
940 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
939 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
940 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
941 | 941 | } else { |
942 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
942 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
943 | 943 | } |
944 | 944 | |
945 | 945 | $query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -947,17 +947,17 @@ discard block |
||
947 | 947 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
948 | 948 | |
949 | 949 | return $spotter_array; |
950 | - } |
|
950 | + } |
|
951 | 951 | |
952 | 952 | |
953 | - /** |
|
954 | - * Gets all the spotter information based on the owner |
|
955 | - * |
|
956 | - * @return Array the spotter information |
|
957 | - * |
|
958 | - */ |
|
959 | - public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
960 | - { |
|
953 | + /** |
|
954 | + * Gets all the spotter information based on the owner |
|
955 | + * |
|
956 | + * @return Array the spotter information |
|
957 | + * |
|
958 | + */ |
|
959 | + public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
960 | + { |
|
961 | 961 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
962 | 962 | |
963 | 963 | date_default_timezone_set('UTC'); |
@@ -970,35 +970,35 @@ discard block |
||
970 | 970 | |
971 | 971 | if ($owner != "") |
972 | 972 | { |
973 | - if (!is_string($owner)) |
|
974 | - { |
|
973 | + if (!is_string($owner)) |
|
974 | + { |
|
975 | 975 | return false; |
976 | - } else { |
|
976 | + } else { |
|
977 | 977 | $additional_query = " AND (tracker_archive_output.owner_name = :owner)"; |
978 | 978 | $query_values = array(':owner' => $owner); |
979 | - } |
|
979 | + } |
|
980 | 980 | } |
981 | 981 | |
982 | 982 | if ($limit != "") |
983 | 983 | { |
984 | - $limit_array = explode(",", $limit); |
|
984 | + $limit_array = explode(",", $limit); |
|
985 | 985 | |
986 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
987 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
986 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
987 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
988 | 988 | |
989 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
990 | - { |
|
989 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
990 | + { |
|
991 | 991 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
992 | 992 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
993 | - } |
|
993 | + } |
|
994 | 994 | } |
995 | 995 | |
996 | 996 | if ($sort != "") |
997 | 997 | { |
998 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
999 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
998 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
999 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1000 | 1000 | } else { |
1001 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1001 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | $query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1006,16 +1006,16 @@ discard block |
||
1006 | 1006 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
1007 | 1007 | |
1008 | 1008 | return $spotter_array; |
1009 | - } |
|
1010 | - |
|
1011 | - /** |
|
1012 | - * Gets all the spotter information based on the pilot |
|
1013 | - * |
|
1014 | - * @return Array the spotter information |
|
1015 | - * |
|
1016 | - */ |
|
1017 | - public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1018 | - { |
|
1009 | + } |
|
1010 | + |
|
1011 | + /** |
|
1012 | + * Gets all the spotter information based on the pilot |
|
1013 | + * |
|
1014 | + * @return Array the spotter information |
|
1015 | + * |
|
1016 | + */ |
|
1017 | + public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1018 | + { |
|
1019 | 1019 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
1020 | 1020 | |
1021 | 1021 | date_default_timezone_set('UTC'); |
@@ -1034,24 +1034,24 @@ discard block |
||
1034 | 1034 | |
1035 | 1035 | if ($limit != "") |
1036 | 1036 | { |
1037 | - $limit_array = explode(",", $limit); |
|
1037 | + $limit_array = explode(",", $limit); |
|
1038 | 1038 | |
1039 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1040 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1039 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1040 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | 1041 | |
1042 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1043 | - { |
|
1042 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1043 | + { |
|
1044 | 1044 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1045 | 1045 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1046 | - } |
|
1046 | + } |
|
1047 | 1047 | } |
1048 | 1048 | |
1049 | 1049 | if ($sort != "") |
1050 | 1050 | { |
1051 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
1052 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1051 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
1052 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1053 | 1053 | } else { |
1054 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1054 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | $query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1059,16 +1059,16 @@ discard block |
||
1059 | 1059 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
1060 | 1060 | |
1061 | 1061 | return $spotter_array; |
1062 | - } |
|
1063 | - |
|
1064 | - /** |
|
1065 | - * Gets all number of flight over countries |
|
1066 | - * |
|
1067 | - * @return Array the airline country list |
|
1068 | - * |
|
1069 | - */ |
|
1070 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1071 | - { |
|
1062 | + } |
|
1063 | + |
|
1064 | + /** |
|
1065 | + * Gets all number of flight over countries |
|
1066 | + * |
|
1067 | + * @return Array the airline country list |
|
1068 | + * |
|
1069 | + */ |
|
1070 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1071 | + { |
|
1072 | 1072 | global $globalDBdriver; |
1073 | 1073 | /* |
1074 | 1074 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1078,14 +1078,14 @@ discard block |
||
1078 | 1078 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1079 | 1079 | FROM countries c, tracker_archive s |
1080 | 1080 | WHERE c.iso2 = s.over_country "; |
1081 | - if ($olderthanmonths > 0) { |
|
1082 | - if ($globalDBdriver == 'mysql') { |
|
1081 | + if ($olderthanmonths > 0) { |
|
1082 | + if ($globalDBdriver == 'mysql') { |
|
1083 | 1083 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1084 | 1084 | } else { |
1085 | 1085 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1086 | 1086 | } |
1087 | 1087 | } |
1088 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1088 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1089 | 1089 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1090 | 1090 | if ($limit) $query .= " LIMIT 0,10"; |
1091 | 1091 | |
@@ -1098,23 +1098,23 @@ discard block |
||
1098 | 1098 | |
1099 | 1099 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1100 | 1100 | { |
1101 | - $temp_array['flight_count'] = $row['nb']; |
|
1102 | - $temp_array['flight_country'] = $row['name']; |
|
1103 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1104 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1105 | - $flight_array[] = $temp_array; |
|
1101 | + $temp_array['flight_count'] = $row['nb']; |
|
1102 | + $temp_array['flight_country'] = $row['name']; |
|
1103 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1104 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1105 | + $flight_array[] = $temp_array; |
|
1106 | 1106 | } |
1107 | 1107 | return $flight_array; |
1108 | - } |
|
1109 | - |
|
1110 | - /** |
|
1111 | - * Gets all number of flight over countries |
|
1112 | - * |
|
1113 | - * @return Array the airline country list |
|
1114 | - * |
|
1115 | - */ |
|
1116 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1117 | - { |
|
1108 | + } |
|
1109 | + |
|
1110 | + /** |
|
1111 | + * Gets all number of flight over countries |
|
1112 | + * |
|
1113 | + * @return Array the airline country list |
|
1114 | + * |
|
1115 | + */ |
|
1116 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1117 | + { |
|
1118 | 1118 | global $globalDBdriver; |
1119 | 1119 | /* |
1120 | 1120 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1124,14 +1124,14 @@ discard block |
||
1124 | 1124 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1125 | 1125 | FROM countries c, tracker_archive s, spotter_output o |
1126 | 1126 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.famtrackid = s.famtrackid "; |
1127 | - if ($olderthanmonths > 0) { |
|
1128 | - if ($globalDBdriver == 'mysql') { |
|
1127 | + if ($olderthanmonths > 0) { |
|
1128 | + if ($globalDBdriver == 'mysql') { |
|
1129 | 1129 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1130 | 1130 | } else { |
1131 | 1131 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1132 | 1132 | } |
1133 | 1133 | } |
1134 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1134 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1135 | 1135 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1136 | 1136 | if ($limit) $query .= " LIMIT 0,10"; |
1137 | 1137 | |
@@ -1144,24 +1144,24 @@ discard block |
||
1144 | 1144 | |
1145 | 1145 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1146 | 1146 | { |
1147 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1148 | - $temp_array['flight_count'] = $row['nb']; |
|
1149 | - $temp_array['flight_country'] = $row['name']; |
|
1150 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1151 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1152 | - $flight_array[] = $temp_array; |
|
1147 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1148 | + $temp_array['flight_count'] = $row['nb']; |
|
1149 | + $temp_array['flight_country'] = $row['name']; |
|
1150 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1151 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1152 | + $flight_array[] = $temp_array; |
|
1153 | 1153 | } |
1154 | 1154 | return $flight_array; |
1155 | - } |
|
1156 | - |
|
1157 | - /** |
|
1158 | - * Gets last spotter information based on a particular callsign |
|
1159 | - * |
|
1160 | - * @return Array the spotter information |
|
1161 | - * |
|
1162 | - */ |
|
1163 | - public function getDateArchiveTrackerDataById($id,$date) |
|
1164 | - { |
|
1155 | + } |
|
1156 | + |
|
1157 | + /** |
|
1158 | + * Gets last spotter information based on a particular callsign |
|
1159 | + * |
|
1160 | + * @return Array the spotter information |
|
1161 | + * |
|
1162 | + */ |
|
1163 | + public function getDateArchiveTrackerDataById($id,$date) |
|
1164 | + { |
|
1165 | 1165 | $Tracker = new Tracker($this->db); |
1166 | 1166 | date_default_timezone_set('UTC'); |
1167 | 1167 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1169,16 +1169,16 @@ discard block |
||
1169 | 1169 | $date = date('c',$date); |
1170 | 1170 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1171 | 1171 | return $spotter_array; |
1172 | - } |
|
1173 | - |
|
1174 | - /** |
|
1175 | - * Gets all the spotter information based on a particular callsign |
|
1176 | - * |
|
1177 | - * @return Array the spotter information |
|
1178 | - * |
|
1179 | - */ |
|
1180 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
1181 | - { |
|
1172 | + } |
|
1173 | + |
|
1174 | + /** |
|
1175 | + * Gets all the spotter information based on a particular callsign |
|
1176 | + * |
|
1177 | + * @return Array the spotter information |
|
1178 | + * |
|
1179 | + */ |
|
1180 | + public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
1181 | + { |
|
1182 | 1182 | $Tracker = new Tracker($this->db); |
1183 | 1183 | date_default_timezone_set('UTC'); |
1184 | 1184 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1186,16 +1186,16 @@ discard block |
||
1186 | 1186 | $date = date('c',$date); |
1187 | 1187 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1188 | 1188 | return $spotter_array; |
1189 | - } |
|
1190 | - |
|
1191 | - /** |
|
1192 | - * Gets all the spotter information based on the airport |
|
1193 | - * |
|
1194 | - * @return Array the spotter information |
|
1195 | - * |
|
1196 | - */ |
|
1197 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1198 | - { |
|
1189 | + } |
|
1190 | + |
|
1191 | + /** |
|
1192 | + * Gets all the spotter information based on the airport |
|
1193 | + * |
|
1194 | + * @return Array the spotter information |
|
1195 | + * |
|
1196 | + */ |
|
1197 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1198 | + { |
|
1199 | 1199 | global $global_query; |
1200 | 1200 | $Tracker = new Tracker(); |
1201 | 1201 | date_default_timezone_set('UTC'); |
@@ -1206,35 +1206,35 @@ discard block |
||
1206 | 1206 | |
1207 | 1207 | if ($airport != "") |
1208 | 1208 | { |
1209 | - if (!is_string($airport)) |
|
1210 | - { |
|
1209 | + if (!is_string($airport)) |
|
1210 | + { |
|
1211 | 1211 | return false; |
1212 | - } else { |
|
1212 | + } else { |
|
1213 | 1213 | $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))"; |
1214 | 1214 | $query_values = array(':airport' => $airport); |
1215 | - } |
|
1215 | + } |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | if ($limit != "") |
1219 | 1219 | { |
1220 | - $limit_array = explode(",", $limit); |
|
1220 | + $limit_array = explode(",", $limit); |
|
1221 | 1221 | |
1222 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1223 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1222 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1223 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1224 | 1224 | |
1225 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1226 | - { |
|
1225 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1226 | + { |
|
1227 | 1227 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1228 | 1228 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1229 | - } |
|
1229 | + } |
|
1230 | 1230 | } |
1231 | 1231 | |
1232 | 1232 | if ($sort != "") |
1233 | 1233 | { |
1234 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
1235 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1234 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
1235 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1236 | 1236 | } else { |
1237 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1237 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | $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; |
@@ -1242,6 +1242,6 @@ discard block |
||
1242 | 1242 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
1243 | 1243 | |
1244 | 1244 | return $spotter_array; |
1245 | - } |
|
1245 | + } |
|
1246 | 1246 | } |
1247 | 1247 | ?> |
1248 | 1248 | \ No newline at end of file |
@@ -26,7 +26,9 @@ discard block |
||
26 | 26 | if (isset($filter[0]['source'])) { |
27 | 27 | $filters = array_merge($filters,$filter); |
28 | 28 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
29 | + if (is_array($globalFilter)) { |
|
30 | + $filter = array_merge($filter,$globalFilter); |
|
31 | + } |
|
30 | 32 | $filter_query_join = ''; |
31 | 33 | $filter_query_where = ''; |
32 | 34 | foreach($filters as $flt) { |
@@ -72,8 +74,11 @@ discard block |
||
72 | 74 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
73 | 75 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
74 | 76 | } |
75 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
76 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
77 | + if ($filter_query_where == '' && $where) { |
|
78 | + $filter_query_where = ' WHERE'; |
|
79 | + } elseif ($filter_query_where != '' && $and) { |
|
80 | + $filter_query_where .= ' AND'; |
|
81 | + } |
|
77 | 82 | if ($filter_query_where != '') { |
78 | 83 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
79 | 84 | } |
@@ -591,7 +596,9 @@ discard block |
||
591 | 596 | $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
592 | 597 | $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
593 | 598 | $translate = $Translation->ident2icao($q_item); |
594 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
599 | + if ($translate != $q_item) { |
|
600 | + $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
601 | + } |
|
595 | 602 | $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
596 | 603 | $additional_query .= ")"; |
597 | 604 | } |
@@ -809,7 +816,9 @@ discard block |
||
809 | 816 | date_default_timezone_set($globalTimezone); |
810 | 817 | $datetime = new DateTime(); |
811 | 818 | $offset = $datetime->format('P'); |
812 | - } else $offset = '+00:00'; |
|
819 | + } else { |
|
820 | + $offset = '+00:00'; |
|
821 | + } |
|
813 | 822 | |
814 | 823 | |
815 | 824 | if ($date_array[1] != "") |
@@ -1085,9 +1094,13 @@ discard block |
||
1085 | 1094 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1086 | 1095 | } |
1087 | 1096 | } |
1088 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1097 | + if ($sincedate != '') { |
|
1098 | + $query .= "AND date > '".$sincedate."' "; |
|
1099 | + } |
|
1089 | 1100 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1090 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1101 | + if ($limit) { |
|
1102 | + $query .= " LIMIT 0,10"; |
|
1103 | + } |
|
1091 | 1104 | |
1092 | 1105 | |
1093 | 1106 | $sth = $this->db->prepare($query); |
@@ -1131,9 +1144,13 @@ discard block |
||
1131 | 1144 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1132 | 1145 | } |
1133 | 1146 | } |
1134 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1147 | + if ($sincedate != '') { |
|
1148 | + $query .= "AND s.date > '".$sincedate."' "; |
|
1149 | + } |
|
1135 | 1150 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1136 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1151 | + if ($limit) { |
|
1152 | + $query .= " LIMIT 0,10"; |
|
1153 | + } |
|
1137 | 1154 | |
1138 | 1155 | |
1139 | 1156 | $sth = $this->db->prepare($query); |
@@ -13,33 +13,33 @@ discard block |
||
13 | 13 | * @param Array $filter the filter |
14 | 14 | * @return Array the SQL part |
15 | 15 | */ |
16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
16 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
18 | 18 | $filters = array(); |
19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
20 | 20 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
21 | 21 | $filters = $globalStatsFilters[$globalFilterName]; |
22 | 22 | } else { |
23 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
23 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | if (isset($filter[0]['source'])) { |
27 | - $filters = array_merge($filters,$filter); |
|
27 | + $filters = array_merge($filters, $filter); |
|
28 | 28 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
29 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | - foreach($filters as $flt) { |
|
32 | + foreach ($filters as $flt) { |
|
33 | 33 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
34 | 34 | if (isset($flt['source'])) { |
35 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
35 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
36 | 36 | } else { |
37 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
37 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | } |
41 | 41 | if (isset($filter['source']) && !empty($filter['source'])) { |
42 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
42 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
43 | 43 | } |
44 | 44 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
45 | 45 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -67,22 +67,22 @@ discard block |
||
67 | 67 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_archive_output.date) = '".$filter['day']."'"; |
68 | 68 | } |
69 | 69 | } |
70 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid"; |
|
70 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid"; |
|
71 | 71 | } |
72 | 72 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
73 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
73 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
74 | 74 | } |
75 | 75 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
76 | 76 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
77 | 77 | if ($filter_query_where != '') { |
78 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
78 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
79 | 79 | } |
80 | 80 | $filter_query = $filter_query_join.$filter_query_where; |
81 | 81 | return $filter_query; |
82 | 82 | } |
83 | 83 | |
84 | 84 | // tracker_archive |
85 | - public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { |
|
85 | + public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
86 | 86 | /* |
87 | 87 | require_once(dirname(__FILE__).'/class.Tracker.php'); |
88 | 88 | if ($over_country == '') { |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | */ |
95 | 95 | $country = $over_country; |
96 | 96 | // Route is not added in tracker_archive |
97 | - $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
97 | + $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
98 | 98 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
99 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type); |
|
99 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type); |
|
100 | 100 | try { |
101 | 101 | $sth = $this->db->prepare($query); |
102 | 102 | $sth->execute($query_values); |
103 | 103 | $sth->closeCursor(); |
104 | - } catch(PDOException $e) { |
|
104 | + } catch (PDOException $e) { |
|
105 | 105 | return "error : ".$e->getMessage(); |
106 | 106 | } |
107 | 107 | return "success"; |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | |
122 | 122 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
123 | 123 | //$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"; |
124 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
124 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
125 | 125 | |
126 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
126 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident)); |
|
127 | 127 | |
128 | 128 | return $spotter_array; |
129 | 129 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
143 | 143 | //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
144 | 144 | //$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"; |
145 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
145 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
146 | 146 | |
147 | 147 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
148 | 148 | /* |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
157 | 157 | */ |
158 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
158 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id)); |
|
159 | 159 | |
160 | 160 | return $spotter_array; |
161 | 161 | } |
@@ -170,14 +170,14 @@ discard block |
||
170 | 170 | { |
171 | 171 | date_default_timezone_set('UTC'); |
172 | 172 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
173 | - $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
173 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
174 | 174 | |
175 | 175 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
176 | 176 | |
177 | 177 | try { |
178 | 178 | $sth = $this->db->prepare($query); |
179 | 179 | $sth->execute(array(':id' => $id)); |
180 | - } catch(PDOException $e) { |
|
180 | + } catch (PDOException $e) { |
|
181 | 181 | echo $e->getMessage(); |
182 | 182 | die; |
183 | 183 | } |
@@ -196,14 +196,14 @@ discard block |
||
196 | 196 | { |
197 | 197 | date_default_timezone_set('UTC'); |
198 | 198 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
199 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
199 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
200 | 200 | |
201 | 201 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
202 | 202 | |
203 | 203 | try { |
204 | 204 | $sth = $this->db->prepare($query); |
205 | 205 | $sth->execute(array(':id' => $id)); |
206 | - } catch(PDOException $e) { |
|
206 | + } catch (PDOException $e) { |
|
207 | 207 | echo $e->getMessage(); |
208 | 208 | die; |
209 | 209 | } |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | date_default_timezone_set('UTC'); |
226 | 226 | |
227 | 227 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
228 | - $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 | + $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"; |
|
229 | 229 | |
230 | 230 | try { |
231 | 231 | $sth = $this->db->prepare($query); |
232 | 232 | $sth->execute(array(':ident' => $ident)); |
233 | - } catch(PDOException $e) { |
|
233 | + } catch (PDOException $e) { |
|
234 | 234 | echo $e->getMessage(); |
235 | 235 | die; |
236 | 236 | } |
@@ -251,12 +251,12 @@ discard block |
||
251 | 251 | date_default_timezone_set('UTC'); |
252 | 252 | |
253 | 253 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
254 | - $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 | + $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"; |
|
255 | 255 | |
256 | 256 | try { |
257 | 257 | $sth = $this->db->prepare($query); |
258 | 258 | $sth->execute(array(':id' => $id)); |
259 | - } catch(PDOException $e) { |
|
259 | + } catch (PDOException $e) { |
|
260 | 260 | echo $e->getMessage(); |
261 | 261 | die; |
262 | 262 | } |
@@ -277,12 +277,12 @@ discard block |
||
277 | 277 | date_default_timezone_set('UTC'); |
278 | 278 | |
279 | 279 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
280 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
280 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
281 | 281 | |
282 | 282 | try { |
283 | 283 | $sth = $this->db->prepare($query); |
284 | 284 | $sth->execute(array(':id' => $id)); |
285 | - } catch(PDOException $e) { |
|
285 | + } catch (PDOException $e) { |
|
286 | 286 | echo $e->getMessage(); |
287 | 287 | die; |
288 | 288 | } |
@@ -304,13 +304,13 @@ discard block |
||
304 | 304 | date_default_timezone_set('UTC'); |
305 | 305 | |
306 | 306 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
307 | - $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 | + $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"; |
|
308 | 308 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
309 | 309 | |
310 | 310 | try { |
311 | 311 | $sth = $this->db->prepare($query); |
312 | 312 | $sth->execute(array(':ident' => $ident)); |
313 | - } catch(PDOException $e) { |
|
313 | + } catch (PDOException $e) { |
|
314 | 314 | echo $e->getMessage(); |
315 | 315 | die; |
316 | 316 | } |
@@ -327,13 +327,13 @@ discard block |
||
327 | 327 | * @return Array the spotter information |
328 | 328 | * |
329 | 329 | */ |
330 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
330 | + public function getTrackerArchiveData($ident, $famtrackid, $date) |
|
331 | 331 | { |
332 | 332 | $Tracker = new Tracker($this->db); |
333 | 333 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
334 | - $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 | + $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"; |
|
335 | 335 | |
336 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
336 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':famtrackid' => $famtrackid, ':date' => $date.'%')); |
|
337 | 337 | |
338 | 338 | return $spotter_array; |
339 | 339 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | try { |
347 | 347 | $sth = $this->db->prepare($query); |
348 | 348 | $sth->execute(); |
349 | - } catch(PDOException $e) { |
|
349 | + } catch (PDOException $e) { |
|
350 | 350 | echo $e->getMessage(); |
351 | 351 | die; |
352 | 352 | } |
@@ -358,24 +358,24 @@ discard block |
||
358 | 358 | * @return Array the spotter information |
359 | 359 | * |
360 | 360 | */ |
361 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
361 | + public function getMinLiveTrackerData($begindate, $enddate, $filter = array()) |
|
362 | 362 | { |
363 | 363 | global $globalDBdriver, $globalLiveInterval; |
364 | 364 | date_default_timezone_set('UTC'); |
365 | 365 | |
366 | 366 | $filter_query = ''; |
367 | 367 | if (isset($filter['source']) && !empty($filter['source'])) { |
368 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
368 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
369 | 369 | } |
370 | 370 | // Use spotter_output also ? |
371 | 371 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
372 | - $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 "; |
|
372 | + $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 "; |
|
373 | 373 | } |
374 | 374 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
375 | 375 | $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 "; |
376 | 376 | } |
377 | 377 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
378 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
378 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -394,14 +394,14 @@ discard block |
||
394 | 394 | GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid |
395 | 395 | AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
396 | 396 | */ |
397 | - $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 |
|
397 | + $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 |
|
398 | 398 | FROM tracker_archive |
399 | 399 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
400 | 400 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
401 | 401 | '.$filter_query.' ORDER BY famtrackid'; |
402 | 402 | } else { |
403 | 403 | //$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'; |
404 | - $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 | + $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 |
|
405 | 405 | FROM tracker_archive |
406 | 406 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
407 | 407 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | try { |
412 | 412 | $sth = $this->db->prepare($query); |
413 | 413 | $sth->execute(); |
414 | - } catch(PDOException $e) { |
|
414 | + } catch (PDOException $e) { |
|
415 | 415 | echo $e->getMessage(); |
416 | 416 | die; |
417 | 417 | } |
@@ -426,24 +426,24 @@ discard block |
||
426 | 426 | * @return Array the spotter information |
427 | 427 | * |
428 | 428 | */ |
429 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
429 | + public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array()) |
|
430 | 430 | { |
431 | 431 | global $globalDBdriver, $globalLiveInterval; |
432 | 432 | date_default_timezone_set('UTC'); |
433 | 433 | |
434 | 434 | $filter_query = ''; |
435 | 435 | if (isset($filter['source']) && !empty($filter['source'])) { |
436 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
436 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
437 | 437 | } |
438 | 438 | // Should use spotter_output also ? |
439 | 439 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
440 | - $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 "; |
|
440 | + $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 "; |
|
441 | 441 | } |
442 | 442 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
443 | 443 | $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 "; |
444 | 444 | } |
445 | 445 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
446 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
446 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | FROM tracker_archive |
454 | 454 | 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'; |
455 | 455 | */ |
456 | - $query = 'SELECT a.aircraft_shadow, 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 |
|
456 | + $query = 'SELECT a.aircraft_shadow, 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 |
|
457 | 457 | FROM tracker_archive_output |
458 | 458 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao |
459 | 459 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
469 | 469 | '.$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'; |
470 | 470 | */ |
471 | - $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 |
|
471 | + $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
472 | 472 | FROM tracker_archive_output |
473 | 473 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
474 | 474 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | try { |
481 | 481 | $sth = $this->db->prepare($query); |
482 | 482 | $sth->execute(); |
483 | - } catch(PDOException $e) { |
|
483 | + } catch (PDOException $e) { |
|
484 | 484 | echo $e->getMessage(); |
485 | 485 | die; |
486 | 486 | } |
@@ -495,23 +495,23 @@ discard block |
||
495 | 495 | * @return Array the spotter information |
496 | 496 | * |
497 | 497 | */ |
498 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
498 | + public function getLiveTrackerCount($begindate, $enddate, $filter = array()) |
|
499 | 499 | { |
500 | 500 | global $globalDBdriver, $globalLiveInterval; |
501 | 501 | date_default_timezone_set('UTC'); |
502 | 502 | |
503 | 503 | $filter_query = ''; |
504 | 504 | if (isset($filter['source']) && !empty($filter['source'])) { |
505 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
505 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
506 | 506 | } |
507 | 507 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
508 | - $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 "; |
|
508 | + $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 "; |
|
509 | 509 | } |
510 | 510 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
511 | 511 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
512 | 512 | } |
513 | 513 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
514 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
514 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | try { |
527 | 527 | $sth = $this->db->prepare($query); |
528 | 528 | $sth->execute(); |
529 | - } catch(PDOException $e) { |
|
529 | + } catch (PDOException $e) { |
|
530 | 530 | echo $e->getMessage(); |
531 | 531 | die; |
532 | 532 | } |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * @return Array the spotter information |
547 | 547 | * |
548 | 548 | */ |
549 | - 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()) |
|
549 | + 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()) |
|
550 | 550 | { |
551 | 551 | global $globalTimezone, $globalDBdriver; |
552 | 552 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | |
569 | 569 | $q_array = explode(" ", $q); |
570 | 570 | |
571 | - foreach ($q_array as $q_item){ |
|
571 | + foreach ($q_array as $q_item) { |
|
572 | 572 | $additional_query .= " AND ("; |
573 | 573 | $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
574 | 574 | $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | |
601 | 601 | if ($registration != "") |
602 | 602 | { |
603 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
603 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
604 | 604 | if (!is_string($registration)) |
605 | 605 | { |
606 | 606 | return false; |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | |
612 | 612 | if ($aircraft_icao != "") |
613 | 613 | { |
614 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
614 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
615 | 615 | if (!is_string($aircraft_icao)) |
616 | 616 | { |
617 | 617 | return false; |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | |
623 | 623 | if ($aircraft_manufacturer != "") |
624 | 624 | { |
625 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
625 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
626 | 626 | if (!is_string($aircraft_manufacturer)) |
627 | 627 | { |
628 | 628 | return false; |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | |
644 | 644 | if ($airline_icao != "") |
645 | 645 | { |
646 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
646 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
647 | 647 | if (!is_string($airline_icao)) |
648 | 648 | { |
649 | 649 | return false; |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | |
655 | 655 | if ($airline_country != "") |
656 | 656 | { |
657 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
657 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
658 | 658 | if (!is_string($airline_country)) |
659 | 659 | { |
660 | 660 | return false; |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | |
666 | 666 | if ($airline_type != "") |
667 | 667 | { |
668 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
668 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
669 | 669 | if (!is_string($airline_type)) |
670 | 670 | { |
671 | 671 | return false; |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | |
688 | 688 | if ($airport != "") |
689 | 689 | { |
690 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
690 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
691 | 691 | if (!is_string($airport)) |
692 | 692 | { |
693 | 693 | return false; |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | |
699 | 699 | if ($airport_country != "") |
700 | 700 | { |
701 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
701 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
702 | 702 | if (!is_string($airport_country)) |
703 | 703 | { |
704 | 704 | return false; |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | |
710 | 710 | if ($callsign != "") |
711 | 711 | { |
712 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
712 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
713 | 713 | if (!is_string($callsign)) |
714 | 714 | { |
715 | 715 | return false; |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | $translate = $Translation->ident2icao($callsign); |
718 | 718 | if ($translate != $callsign) { |
719 | 719 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
720 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
720 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
721 | 721 | } else { |
722 | 722 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
723 | 723 | } |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | |
727 | 727 | if ($owner != "") |
728 | 728 | { |
729 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
729 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
730 | 730 | if (!is_string($owner)) |
731 | 731 | { |
732 | 732 | return false; |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | |
738 | 738 | if ($pilot_name != "") |
739 | 739 | { |
740 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
740 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
741 | 741 | if (!is_string($pilot_name)) |
742 | 742 | { |
743 | 743 | return false; |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | |
749 | 749 | if ($pilot_id != "") |
750 | 750 | { |
751 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
751 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
752 | 752 | if (!is_string($pilot_id)) |
753 | 753 | { |
754 | 754 | return false; |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | |
760 | 760 | if ($departure_airport_route != "") |
761 | 761 | { |
762 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
762 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
763 | 763 | if (!is_string($departure_airport_route)) |
764 | 764 | { |
765 | 765 | return false; |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | |
771 | 771 | if ($arrival_airport_route != "") |
772 | 772 | { |
773 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
773 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
774 | 774 | if (!is_string($arrival_airport_route)) |
775 | 775 | { |
776 | 776 | return false; |
@@ -783,8 +783,8 @@ discard block |
||
783 | 783 | { |
784 | 784 | $altitude_array = explode(",", $altitude); |
785 | 785 | |
786 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
787 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
786 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
787 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
788 | 788 | |
789 | 789 | |
790 | 790 | if ($altitude_array[1] != "") |
@@ -802,8 +802,8 @@ discard block |
||
802 | 802 | { |
803 | 803 | $date_array = explode(",", $date_posted); |
804 | 804 | |
805 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
806 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
805 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
806 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
807 | 807 | |
808 | 808 | if ($globalTimezone != '') { |
809 | 809 | date_default_timezone_set($globalTimezone); |
@@ -835,8 +835,8 @@ discard block |
||
835 | 835 | { |
836 | 836 | $limit_array = explode(",", $limit); |
837 | 837 | |
838 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
839 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
838 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
839 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
840 | 840 | |
841 | 841 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
842 | 842 | { |
@@ -847,8 +847,8 @@ discard block |
||
847 | 847 | |
848 | 848 | |
849 | 849 | if ($origLat != "" && $origLon != "" && $dist != "") { |
850 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
851 | - $query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
850 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
851 | + $query = "SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
852 | 852 | FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
853 | 853 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
854 | 854 | } else { |
@@ -865,12 +865,12 @@ discard block |
||
865 | 865 | $additional_query .= " AND (tracker_archive_output.waypoints <> '')"; |
866 | 866 | } |
867 | 867 | |
868 | - $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
868 | + $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
869 | 869 | WHERE tracker_archive_output.ident <> '' |
870 | 870 | ".$additional_query." |
871 | 871 | ".$filter_query.$orderby_query; |
872 | 872 | } |
873 | - $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
|
873 | + $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
874 | 874 | |
875 | 875 | return $spotter_array; |
876 | 876 | } |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | try { |
888 | 888 | $sth = $this->db->prepare($query); |
889 | 889 | $sth->execute(); |
890 | - } catch(PDOException $e) { |
|
890 | + } catch (PDOException $e) { |
|
891 | 891 | return "error"; |
892 | 892 | } |
893 | 893 | } |
@@ -924,8 +924,8 @@ discard block |
||
924 | 924 | { |
925 | 925 | $limit_array = explode(",", $limit); |
926 | 926 | |
927 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
928 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
927 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
928 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
929 | 929 | |
930 | 930 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
931 | 931 | { |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | $query_values = array(); |
967 | 967 | $limit_query = ''; |
968 | 968 | $additional_query = ''; |
969 | - $filter_query = $this->getFilter($filter,true,true); |
|
969 | + $filter_query = $this->getFilter($filter, true, true); |
|
970 | 970 | |
971 | 971 | if ($owner != "") |
972 | 972 | { |
@@ -983,8 +983,8 @@ discard block |
||
983 | 983 | { |
984 | 984 | $limit_array = explode(",", $limit); |
985 | 985 | |
986 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
987 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
986 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
987 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
988 | 988 | |
989 | 989 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
990 | 990 | { |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | $query_values = array(); |
1025 | 1025 | $limit_query = ''; |
1026 | 1026 | $additional_query = ''; |
1027 | - $filter_query = $this->getFilter($filter,true,true); |
|
1027 | + $filter_query = $this->getFilter($filter, true, true); |
|
1028 | 1028 | |
1029 | 1029 | if ($pilot != "") |
1030 | 1030 | { |
@@ -1036,8 +1036,8 @@ discard block |
||
1036 | 1036 | { |
1037 | 1037 | $limit_array = explode(",", $limit); |
1038 | 1038 | |
1039 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1040 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1039 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1040 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1041 | 1041 | |
1042 | 1042 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1043 | 1043 | { |
@@ -1067,7 +1067,7 @@ discard block |
||
1067 | 1067 | * @return Array the airline country list |
1068 | 1068 | * |
1069 | 1069 | */ |
1070 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1070 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1071 | 1071 | { |
1072 | 1072 | global $globalDBdriver; |
1073 | 1073 | /* |
@@ -1096,7 +1096,7 @@ discard block |
||
1096 | 1096 | $flight_array = array(); |
1097 | 1097 | $temp_array = array(); |
1098 | 1098 | |
1099 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1099 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1100 | 1100 | { |
1101 | 1101 | $temp_array['flight_count'] = $row['nb']; |
1102 | 1102 | $temp_array['flight_country'] = $row['name']; |
@@ -1113,7 +1113,7 @@ discard block |
||
1113 | 1113 | * @return Array the airline country list |
1114 | 1114 | * |
1115 | 1115 | */ |
1116 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1116 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1117 | 1117 | { |
1118 | 1118 | global $globalDBdriver; |
1119 | 1119 | /* |
@@ -1142,7 +1142,7 @@ discard block |
||
1142 | 1142 | $flight_array = array(); |
1143 | 1143 | $temp_array = array(); |
1144 | 1144 | |
1145 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1145 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1146 | 1146 | { |
1147 | 1147 | $temp_array['airline_icao'] = $row['airline_icao']; |
1148 | 1148 | $temp_array['flight_count'] = $row['nb']; |
@@ -1160,14 +1160,14 @@ discard block |
||
1160 | 1160 | * @return Array the spotter information |
1161 | 1161 | * |
1162 | 1162 | */ |
1163 | - public function getDateArchiveTrackerDataById($id,$date) |
|
1163 | + public function getDateArchiveTrackerDataById($id, $date) |
|
1164 | 1164 | { |
1165 | 1165 | $Tracker = new Tracker($this->db); |
1166 | 1166 | date_default_timezone_set('UTC'); |
1167 | 1167 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1168 | - $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 AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
1169 | - $date = date('c',$date); |
|
1170 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1168 | + $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 AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
1169 | + $date = date('c', $date); |
|
1170 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1171 | 1171 | return $spotter_array; |
1172 | 1172 | } |
1173 | 1173 | |
@@ -1177,14 +1177,14 @@ discard block |
||
1177 | 1177 | * @return Array the spotter information |
1178 | 1178 | * |
1179 | 1179 | */ |
1180 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
1180 | + public function getDateArchiveTrackerDataByIdent($ident, $date) |
|
1181 | 1181 | { |
1182 | 1182 | $Tracker = new Tracker($this->db); |
1183 | 1183 | date_default_timezone_set('UTC'); |
1184 | 1184 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1185 | - $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 AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
1186 | - $date = date('c',$date); |
|
1187 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1185 | + $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 AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
1186 | + $date = date('c', $date); |
|
1187 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1188 | 1188 | return $spotter_array; |
1189 | 1189 | } |
1190 | 1190 | |
@@ -1194,7 +1194,7 @@ discard block |
||
1194 | 1194 | * @return Array the spotter information |
1195 | 1195 | * |
1196 | 1196 | */ |
1197 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1197 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1198 | 1198 | { |
1199 | 1199 | global $global_query; |
1200 | 1200 | $Tracker = new Tracker(); |
@@ -1202,7 +1202,7 @@ discard block |
||
1202 | 1202 | $query_values = array(); |
1203 | 1203 | $limit_query = ''; |
1204 | 1204 | $additional_query = ''; |
1205 | - $filter_query = $this->getFilter($filters,true,true); |
|
1205 | + $filter_query = $this->getFilter($filters, true, true); |
|
1206 | 1206 | |
1207 | 1207 | if ($airport != "") |
1208 | 1208 | { |
@@ -1219,8 +1219,8 @@ discard block |
||
1219 | 1219 | { |
1220 | 1220 | $limit_array = explode(",", $limit); |
1221 | 1221 | |
1222 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1223 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1222 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1223 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1224 | 1224 | |
1225 | 1225 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1226 | 1226 | { |
@@ -8,31 +8,31 @@ discard block |
||
8 | 8 | if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType']; |
9 | 9 | else $MapType = $globalMapProvider; |
10 | 10 | if (isset($_GET['3d'])) { |
11 | - setcookie('MapFormat','3d'); |
|
11 | + setcookie('MapFormat', '3d'); |
|
12 | 12 | } else if (isset($_GET['2d'])) { |
13 | - setcookie('MapFormat','2d'); |
|
13 | + setcookie('MapFormat', '2d'); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | if (isset($_POST['archive'])) { |
17 | - setcookie('archive','true'); |
|
18 | - setcookie('archive_begin',strtotime($_POST['start_date'])); |
|
19 | - setcookie('archive_end',strtotime($_POST['end_date'])); |
|
20 | - setcookie('archive_speed',$_POST['archivespeed']); |
|
17 | + setcookie('archive', 'true'); |
|
18 | + setcookie('archive_begin', strtotime($_POST['start_date'])); |
|
19 | + setcookie('archive_end', strtotime($_POST['end_date'])); |
|
20 | + setcookie('archive_speed', $_POST['archivespeed']); |
|
21 | 21 | } |
22 | 22 | if (isset($_POST['noarchive'])) { |
23 | - setcookie('archive','false',-1); |
|
24 | - setcookie('archive_begin','',-1); |
|
25 | - setcookie('archive_end','',-1); |
|
26 | - setcookie('archive_speed','',-1); |
|
23 | + setcookie('archive', 'false', -1); |
|
24 | + setcookie('archive_begin', '', -1); |
|
25 | + setcookie('archive_end', '', -1); |
|
26 | + setcookie('archive_speed', '', -1); |
|
27 | 27 | } |
28 | 28 | // When button "Remove all filters" is clicked |
29 | 29 | if (isset($_POST['removefilters'])) { |
30 | - $allfilters = array_filter(array_keys($_COOKIE),function($key) { |
|
31 | - return strpos($key,'filter_') === 0; |
|
30 | + $allfilters = array_filter(array_keys($_COOKIE), function($key) { |
|
31 | + return strpos($key, 'filter_') === 0; |
|
32 | 32 | }); |
33 | 33 | foreach ($allfilters as $filt) { |
34 | 34 | unset($_COOKIE[$filt]); |
35 | - setcookie($filt,null,-1); |
|
35 | + setcookie($filt, null, -1); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | ?> |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script> |
241 | 241 | <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script> |
242 | 242 | <script src="<?php print $globalURL; ?>/js/map.common.js"></script> |
243 | -<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script> |
|
243 | +<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script> |
|
244 | 244 | <?php |
245 | 245 | if (!isset($type) || $type == 'aircraft') { |
246 | 246 | ?> |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script> |
311 | 311 | <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script> |
312 | 312 | <script src="<?php print $globalURL; ?>/js/map.common.js"></script> |
313 | -<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script> |
|
313 | +<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script> |
|
314 | 314 | <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script> |
315 | 315 | <?php |
316 | 316 | if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) { |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | ?> |
590 | 590 | <div class="search"> |
591 | 591 | <form action="<?php print $globalURL; ?>/search" method="get"> |
592 | - <input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != ""){ print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button> |
|
592 | + <input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != "") { print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button> |
|
593 | 593 | </form> |
594 | 594 | </div> |
595 | 595 | <div class="social"> |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | print '</div>'; |
608 | 608 | } |
609 | 609 | |
610 | -if (strtolower($current_page) =='ident-detailed' || strtolower($current_page) == 'flightid-overview') { |
|
610 | +if (strtolower($current_page) == 'ident-detailed' || strtolower($current_page) == 'flightid-overview') { |
|
611 | 611 | ?> |
612 | 612 | <div class="top-header clear" role="main"> |
613 | 613 | <?php |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | </div> |
621 | 621 | <?php |
622 | 622 | } |
623 | -if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false)) |
|
623 | +if ((strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) || (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false)) |
|
624 | 624 | { |
625 | 625 | ?> |
626 | 626 | <div class="top-header clear" role="main"> |
@@ -633,15 +633,15 @@ discard block |
||
633 | 633 | var zoom = 13; |
634 | 634 | //create the map |
635 | 635 | <?php |
636 | - if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
636 | + if (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
637 | 637 | ?> |
638 | 638 | map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom); |
639 | 639 | <?php |
640 | - } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
640 | + } elseif (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) { |
|
641 | 641 | ?> |
642 | 642 | map = L.map('map', { zoomControl:true }); |
643 | 643 | <?php |
644 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
644 | + } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
645 | 645 | ?> |
646 | 646 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]); |
647 | 647 | var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map); |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map); |
650 | 650 | var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map); |
651 | 651 | <?php |
652 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
652 | + } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
653 | 653 | ?> |
654 | 654 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]); |
655 | 655 | <?php |
@@ -5,8 +5,11 @@ discard block |
||
5 | 5 | $file_path = pathinfo($_SERVER['SCRIPT_NAME']); |
6 | 6 | $current_page = $file_path['filename']; |
7 | 7 | date_default_timezone_set($globalTimezone); |
8 | -if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType']; |
|
9 | -else $MapType = $globalMapProvider; |
|
8 | +if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') { |
|
9 | + $MapType = $_COOKIE['MapType']; |
|
10 | +} else { |
|
11 | + $MapType = $globalMapProvider; |
|
12 | +} |
|
10 | 13 | if (isset($_GET['3d'])) { |
11 | 14 | setcookie('MapFormat','3d'); |
12 | 15 | } else if (isset($_GET['2d'])) { |
@@ -240,7 +243,13 @@ discard block |
||
240 | 243 | <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script> |
241 | 244 | <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script> |
242 | 245 | <script src="<?php print $globalURL; ?>/js/map.common.js"></script> |
243 | -<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script> |
|
246 | +<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) { |
|
247 | + print '&latitude='.$latitude; |
|
248 | +} |
|
249 | +?><?php if(isset($longitude)) { |
|
250 | + print '&longitude='.$longitude; |
|
251 | +} |
|
252 | +?>&<?php print time(); ?>"></script> |
|
244 | 253 | <?php |
245 | 254 | if (!isset($type) || $type == 'aircraft') { |
246 | 255 | ?> |
@@ -310,7 +319,13 @@ discard block |
||
310 | 319 | <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script> |
311 | 320 | <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script> |
312 | 321 | <script src="<?php print $globalURL; ?>/js/map.common.js"></script> |
313 | -<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script> |
|
322 | +<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) { |
|
323 | + print '&latitude='.$latitude; |
|
324 | +} |
|
325 | +?><?php if(isset($longitude)) { |
|
326 | + print '&longitude='.$longitude; |
|
327 | +} |
|
328 | +?>&<?php print time(); ?>"></script> |
|
314 | 329 | <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script> |
315 | 330 | <?php |
316 | 331 | if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) { |
@@ -384,7 +399,12 @@ discard block |
||
384 | 399 | <span class="icon-bar"></span> |
385 | 400 | </button> |
386 | 401 | <a href="<?php print $globalURL; ?>/search" class="navbar-toggle navbar-toggle-search"><i class="fa fa-search"></i></a> |
387 | - <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a> |
|
402 | + <a class="navbar-brand" href="<?php if ($globalURL == '') { |
|
403 | + print '/'; |
|
404 | +} else { |
|
405 | + print $globalURL; |
|
406 | +} |
|
407 | +?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a> |
|
388 | 408 | </div> |
389 | 409 | <div class="collapse navbar-collapse"> |
390 | 410 | |
@@ -410,7 +430,10 @@ discard block |
||
410 | 430 | <?php |
411 | 431 | } |
412 | 432 | ?> |
413 | - <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a> |
|
433 | + <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) { |
|
434 | + echo 'right-'; |
|
435 | +} |
|
436 | +?>caret"></b></a> |
|
414 | 437 | <ul class="dropdown-menu"> |
415 | 438 | <li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircrafts Types"); ?></a></li> |
416 | 439 | <li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li> |
@@ -467,8 +490,14 @@ discard block |
||
467 | 490 | </li> |
468 | 491 | <li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li> |
469 | 492 | <li><a href="<?php print $globalURL; ?>/statistics"><?php echo _("Statistics"); ?></a></li> |
470 | - <li class="dropdown<?php if ($sub) echo '-submenu'; ?>"> |
|
471 | - <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a> |
|
493 | + <li class="dropdown<?php if ($sub) { |
|
494 | + echo '-submenu'; |
|
495 | +} |
|
496 | +?>"> |
|
497 | + <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) { |
|
498 | + echo 'right-'; |
|
499 | +} |
|
500 | +?>caret"></b></a> |
|
472 | 501 | <ul class="dropdown-menu"> |
473 | 502 | <li><a href="<?php print $globalURL; ?>/tools/acars"><?php echo _("ACARS translator"); ?></a></li> |
474 | 503 | <li><a href="<?php print $globalURL; ?>/tools/metar"><?php echo _("METAR translator"); ?></a></li> |
@@ -497,7 +526,10 @@ discard block |
||
497 | 526 | <?php |
498 | 527 | } |
499 | 528 | ?> |
500 | - <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a> |
|
529 | + <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) { |
|
530 | + echo 'right-'; |
|
531 | +} |
|
532 | +?>caret"></b></a> |
|
501 | 533 | <ul class="dropdown-menu"> |
502 | 534 | <li><a href="<?php print $globalURL; ?>/marine/currently"><?php echo _("Current Activity"); ?></a></li> |
503 | 535 | <li><a href="<?php print $globalURL; ?>/marine/latest"><?php echo _("Latest Activity"); ?></a></li> |
@@ -528,7 +560,10 @@ discard block |
||
528 | 560 | <?php |
529 | 561 | } |
530 | 562 | ?> |
531 | - <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a> |
|
563 | + <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) { |
|
564 | + echo 'right-'; |
|
565 | +} |
|
566 | +?>caret"></b></a> |
|
532 | 567 | <ul class="dropdown-menu"> |
533 | 568 | <li><a href="<?php print $globalURL; ?>/tracker/currently"><?php echo _("Current Activity"); ?></a></li> |
534 | 569 | <li><a href="<?php print $globalURL; ?>/tracker/latest"><?php echo _("Latest Activity"); ?></a></li> |
@@ -577,7 +612,9 @@ discard block |
||
577 | 612 | $alllang = $Language->getLanguages(); |
578 | 613 | foreach ($alllang as $key => $lang) { |
579 | 614 | print '<option value="'.$key.'"'; |
580 | - if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
615 | + if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) { |
|
616 | + print ' selected '; |
|
617 | + } |
|
581 | 618 | print '>'.$lang[0].'</option>'; |
582 | 619 | } |
583 | 620 | ?> |
@@ -730,4 +767,7 @@ discard block |
||
730 | 767 | |
731 | 768 | ?> |
732 | 769 | |
733 | -<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear"> |
|
770 | +<section class="container main-content <?php if (strtolower($current_page) == 'index') { |
|
771 | + print 'index '; |
|
772 | +} |
|
773 | +?>clear"> |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | // When button "Remove all filters" is clicked |
29 | 29 | if (isset($_POST['removefilters'])) { |
30 | 30 | $allfilters = array_filter(array_keys($_COOKIE),function($key) { |
31 | - return strpos($key,'filter_') === 0; |
|
31 | + return strpos($key,'filter_') === 0; |
|
32 | 32 | }); |
33 | 33 | foreach ($allfilters as $filt) { |
34 | 34 | unset($_COOKIE[$filt]); |
@@ -167,17 +167,17 @@ discard block |
||
167 | 167 | } |
168 | 168 | ?> |
169 | 169 | <?php |
170 | - if (isset($_POST['archive'])) { |
|
170 | + if (isset($_POST['archive'])) { |
|
171 | 171 | ?> |
172 | 172 | <script src="<?php print $globalURL; ?>/js/map.common.js"></script> |
173 | 173 | <?php |
174 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
174 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
175 | 175 | ?> |
176 | 176 | |
177 | 177 | <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>&archive&begindate=<?php print strtotime($_POST['start_date']); ?>&enddate=<?php print strtotime($_POST['end_date']); ?>&archivespeed=<?php print $_POST['archivespeed']; ?>"></script> |
178 | 178 | <?php |
179 | - } |
|
180 | - } else { |
|
179 | + } |
|
180 | + } else { |
|
181 | 181 | ?> |
182 | 182 | <?php |
183 | 183 | /* if (isset($globalBeta) && $globalBeta) { |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | ?> |
191 | 191 | <?php |
192 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
192 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
193 | 193 | ?> |
194 | 194 | <?php |
195 | 195 | // if (isset($globalBeta) && $globalBeta) { |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | <script src="<?php print $globalURL; ?>/js/map-marine.2d.js.php?<?php print time(); ?>"></script> |
217 | 217 | <?php |
218 | 218 | } |
219 | - } |
|
219 | + } |
|
220 | 220 | ?> |
221 | 221 | <?php |
222 | 222 | // } |
223 | 223 | ?> |
224 | 224 | <?php |
225 | - } |
|
225 | + } |
|
226 | 226 | } |
227 | 227 | ?> |
228 | 228 | <?php |
@@ -391,24 +391,24 @@ discard block |
||
391 | 391 | <ul class="nav navbar-nav"> |
392 | 392 | |
393 | 393 | <?php |
394 | - $sub = false; |
|
395 | - if (((!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))) || (isset($globalMarine) && $globalMarine === TRUE && isset($globalTracker) && $globalTracker === TRUE)) { |
|
394 | + $sub = false; |
|
395 | + if (((!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))) || (isset($globalMarine) && $globalMarine === TRUE && isset($globalTracker) && $globalTracker === TRUE)) { |
|
396 | 396 | $sub = true; |
397 | - } |
|
397 | + } |
|
398 | 398 | ?> |
399 | 399 | <?php |
400 | - if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
|
400 | + if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
|
401 | 401 | ?> |
402 | 402 | <li class="dropdown"> |
403 | 403 | <?php |
404 | - if ($sub) { |
|
404 | + if ($sub) { |
|
405 | 405 | ?> |
406 | 406 | <li class="dropdown"> |
407 | 407 | <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Aircrafts"); ?> <b class="caret"></b></a> |
408 | 408 | <ul class="dropdown-menu multi-level"> |
409 | 409 | <li class="dropdown-submenu"> |
410 | 410 | <?php |
411 | - } |
|
411 | + } |
|
412 | 412 | ?> |
413 | 413 | <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a> |
414 | 414 | <ul class="dropdown-menu"> |
@@ -416,15 +416,15 @@ discard block |
||
416 | 416 | <li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li> |
417 | 417 | <li><a href="<?php print $globalURL; ?>/airport"><?php echo _("Airports"); ?></a></li> |
418 | 418 | <?php |
419 | - if ((!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) { |
|
419 | + if ((!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) { |
|
420 | 420 | ?> |
421 | 421 | <li><a href="<?php print $globalURL; ?>/owner"><?php echo _("Owners"); ?></a></li> |
422 | 422 | <?php |
423 | - } else { |
|
423 | + } else { |
|
424 | 424 | ?> |
425 | 425 | <li><a href="<?php print $globalURL; ?>/pilot"><?php echo _("Pilots"); ?></a></li> |
426 | 426 | <?php |
427 | - } |
|
427 | + } |
|
428 | 428 | ?> |
429 | 429 | <li><hr /></li> |
430 | 430 | <li><a href="<?php print $globalURL; ?>/currently"><?php echo _("Current Activity"); ?></a></li> |
@@ -432,34 +432,34 @@ discard block |
||
432 | 432 | <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li> |
433 | 433 | <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li> |
434 | 434 | <?php |
435 | - if ($globalACARS) { |
|
436 | - if (isset($globalDemo) && $globalDemo) { |
|
437 | - ?> |
|
435 | + if ($globalACARS) { |
|
436 | + if (isset($globalDemo) && $globalDemo) { |
|
437 | + ?> |
|
438 | 438 | <li><hr /></li> |
439 | 439 | <li><i><?php echo _('ACARS data not available publicly'); ?></i></li> |
440 | 440 | <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li> |
441 | 441 | <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li> |
442 | 442 | <?php |
443 | - } else { |
|
444 | - ?> |
|
443 | + } else { |
|
444 | + ?> |
|
445 | 445 | <li><hr /></li> |
446 | 446 | <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li> |
447 | 447 | <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li> |
448 | 448 | <?php |
449 | - } |
|
450 | - } |
|
451 | - ?> |
|
449 | + } |
|
450 | + } |
|
451 | + ?> |
|
452 | 452 | <?php |
453 | - if (isset($globalAccidents) && $globalAccidents) { |
|
454 | - ?> |
|
453 | + if (isset($globalAccidents) && $globalAccidents) { |
|
454 | + ?> |
|
455 | 455 | <li><hr /></li> |
456 | 456 | <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident"); ?></a></li> |
457 | 457 | <li><a href="<?php print $globalURL; ?>/accident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Accident"); ?></a></li> |
458 | 458 | <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident"); ?></a></li> |
459 | 459 | <li><a href="<?php print $globalURL; ?>/incident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Incident"); ?></a></li> |
460 | 460 | <?php |
461 | - } |
|
462 | - ?> |
|
461 | + } |
|
462 | + ?> |
|
463 | 463 | <li><hr /></li> |
464 | 464 | <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li> |
465 | 465 | <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li> |
@@ -482,14 +482,14 @@ discard block |
||
482 | 482 | </ul> |
483 | 483 | <?php |
484 | 484 | } |
485 | - } |
|
485 | + } |
|
486 | 486 | ?> |
487 | 487 | <?php |
488 | - if (isset($globalMarine) && $globalMarine) { |
|
488 | + if (isset($globalMarine) && $globalMarine) { |
|
489 | 489 | ?> |
490 | 490 | <li class="dropdown"> |
491 | 491 | <?php |
492 | - if ($sub) { |
|
492 | + if ($sub) { |
|
493 | 493 | ?> |
494 | 494 | <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Vessels"); ?> <b class="caret"></b></a> |
495 | 495 | <ul class="dropdown-menu multi-level"> |
@@ -513,14 +513,14 @@ discard block |
||
513 | 513 | } |
514 | 514 | ?> |
515 | 515 | <?php |
516 | - } |
|
516 | + } |
|
517 | 517 | ?> |
518 | 518 | <?php |
519 | - if (isset($globalTracker) && $globalTracker) { |
|
519 | + if (isset($globalTracker) && $globalTracker) { |
|
520 | 520 | ?> |
521 | 521 | <li class="dropdown"> |
522 | 522 | <?php |
523 | - if ($sub) { |
|
523 | + if ($sub) { |
|
524 | 524 | ?> |
525 | 525 | <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Trackers"); ?> <b class="caret"></b></a> |
526 | 526 | <ul class="dropdown-menu multi-level"> |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | } |
545 | 545 | ?> |
546 | 546 | <?php |
547 | - } |
|
547 | + } |
|
548 | 548 | ?> |
549 | 549 | |
550 | 550 | <li class="dropdown"> |
@@ -553,12 +553,12 @@ discard block |
||
553 | 553 | <li><a href="<?php print $globalURL; ?>/about"><?php echo _("About The Project"); ?></a></li> |
554 | 554 | <li><a href="<?php print $globalURL; ?>/about/export"><?php echo _("Exporting Data"); ?></a></li> |
555 | 555 | <?php |
556 | - if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
|
556 | + if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
|
557 | 557 | ?> |
558 | 558 | <li><hr /></li> |
559 | 559 | <li><a href="<?php print $globalURL; ?>/about/tv"><?php echo _("Spotter TV"); ?></a></li> |
560 | 560 | <?php |
561 | - } |
|
561 | + } |
|
562 | 562 | ?> |
563 | 563 | <?php if (isset($globalContribute) && $globalContribute) { ?> |
564 | 564 | <li><hr /></li> |
@@ -579,14 +579,14 @@ discard block |
||
579 | 579 | <form> |
580 | 580 | <select class="selectpicker" data-width="120px" onchange="language(this);"> |
581 | 581 | <?php |
582 | - $Language = new Language(); |
|
583 | - $alllang = $Language->getLanguages(); |
|
584 | - foreach ($alllang as $key => $lang) { |
|
585 | - print '<option value="'.$key.'"'; |
|
586 | - if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
587 | - print '>'.$lang[0].'</option>'; |
|
588 | - } |
|
589 | - ?> |
|
582 | + $Language = new Language(); |
|
583 | + $alllang = $Language->getLanguages(); |
|
584 | + foreach ($alllang as $key => $lang) { |
|
585 | + print '<option value="'.$key.'"'; |
|
586 | + if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
587 | + print '>'.$lang[0].'</option>'; |
|
588 | + } |
|
589 | + ?> |
|
590 | 590 | </select> |
591 | 591 | </form> |
592 | 592 | </div> |
@@ -617,18 +617,18 @@ discard block |
||
617 | 617 | ?> |
618 | 618 | <div class="top-header clear" role="main"> |
619 | 619 | <?php |
620 | - if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) { |
|
620 | + if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) { |
|
621 | 621 | ?> |
622 | 622 | <div id="archive-map"></div> |
623 | 623 | <?php |
624 | - } |
|
624 | + } |
|
625 | 625 | ?> |
626 | 626 | </div> |
627 | 627 | <?php |
628 | 628 | } |
629 | 629 | if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false)) |
630 | 630 | { |
631 | - ?> |
|
631 | + ?> |
|
632 | 632 | <div class="top-header clear" role="main"> |
633 | 633 | <div id="map"></div> |
634 | 634 | <link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" /> |
@@ -639,15 +639,15 @@ discard block |
||
639 | 639 | var zoom = 13; |
640 | 640 | //create the map |
641 | 641 | <?php |
642 | - if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
642 | + if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
643 | 643 | ?> |
644 | 644 | map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom); |
645 | 645 | <?php |
646 | - } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
646 | + } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
647 | 647 | ?> |
648 | 648 | map = L.map('map', { zoomControl:true }); |
649 | 649 | <?php |
650 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
650 | + } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
651 | 651 | ?> |
652 | 652 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]); |
653 | 653 | var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map); |
@@ -655,22 +655,22 @@ discard block |
||
655 | 655 | var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map); |
656 | 656 | var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map); |
657 | 657 | <?php |
658 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
658 | + } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
659 | 659 | ?> |
660 | 660 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]); |
661 | 661 | <?php |
662 | - } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) { |
|
662 | + } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) { |
|
663 | 663 | ?> |
664 | 664 | map = L.map('map', { zoomControl:true }); |
665 | 665 | <?php |
666 | - } |
|
666 | + } |
|
667 | 667 | ?> |
668 | 668 | //initialize the layer group for the aircrft markers |
669 | 669 | var layer_data = L.layerGroup(); |
670 | 670 | |
671 | 671 | //a few title layers |
672 | 672 | <?php |
673 | - if ($globalMapProvider == 'Mapbox') { |
|
673 | + if ($globalMapProvider == 'Mapbox') { |
|
674 | 674 | ?> |
675 | 675 | L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', { |
676 | 676 | maxZoom: 18, |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | token : '<?php print $globalMapboxToken; ?>' |
682 | 682 | }).addTo(map); |
683 | 683 | <?php |
684 | - } elseif ($globalMapProvider == 'OpenStreetMap') { |
|
684 | + } elseif ($globalMapProvider == 'OpenStreetMap') { |
|
685 | 685 | ?> |
686 | 686 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
687 | 687 | maxZoom: 18, |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | '<a href="http://www.openstreetmap.org/copyright">Open Database Licence</a>' |
690 | 690 | }).addTo(map); |
691 | 691 | <?php |
692 | - } elseif ($globalMapProvider == 'MapQuest-OSM') { |
|
692 | + } elseif ($globalMapProvider == 'MapQuest-OSM') { |
|
693 | 693 | ?> |
694 | 694 | L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', { |
695 | 695 | maxZoom: 18, |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | 'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>' |
699 | 699 | }).addTo(map); |
700 | 700 | <?php |
701 | - } elseif ($globalMapProvider == 'MapQuest-Aerial') { |
|
701 | + } elseif ($globalMapProvider == 'MapQuest-Aerial') { |
|
702 | 702 | ?> |
703 | 703 | L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', { |
704 | 704 | maxZoom: 18, |
@@ -707,27 +707,27 @@ discard block |
||
707 | 707 | 'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"' |
708 | 708 | }).addTo(map); |
709 | 709 | <?php |
710 | - } elseif ($globalMapProvider == 'Google-Roadmap') { |
|
710 | + } elseif ($globalMapProvider == 'Google-Roadmap') { |
|
711 | 711 | ?> |
712 | 712 | var googleLayer = new L.Google('ROADMAP'); |
713 | 713 | map.addLayer(googleLayer); |
714 | 714 | <?php |
715 | - } elseif ($globalMapProvider == 'Google-Satellite') { |
|
715 | + } elseif ($globalMapProvider == 'Google-Satellite') { |
|
716 | 716 | ?> |
717 | 717 | var googleLayer = new L.Google('SATELLITE'); |
718 | 718 | map.addLayer(googleLayer); |
719 | 719 | <?php |
720 | - } elseif ($globalMapProvider == 'Google-Hybrid') { |
|
720 | + } elseif ($globalMapProvider == 'Google-Hybrid') { |
|
721 | 721 | ?> |
722 | 722 | var googleLayer = new L.Google('HYBRID'); |
723 | 723 | map.addLayer(googleLayer); |
724 | 724 | <?php |
725 | - } elseif ($globalMapProvider == 'Google-Terrain') { |
|
725 | + } elseif ($globalMapProvider == 'Google-Terrain') { |
|
726 | 726 | ?> |
727 | 727 | var googleLayer = new L.Google('Terrain'); |
728 | 728 | map.addLayer(googleLayer); |
729 | 729 | <?php |
730 | - } |
|
730 | + } |
|
731 | 731 | ?> |
732 | 732 | </script> |
733 | 733 | </div> |
@@ -9,16 +9,16 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
10 | 10 | |
11 | 11 | class TrackerImport { |
12 | - private $all_tracked = array(); |
|
13 | - private $last_delete_hourly = 0; |
|
14 | - private $last_delete = 0; |
|
15 | - private $stats = array(); |
|
16 | - private $tmd = 0; |
|
17 | - private $source_location = array(); |
|
18 | - public $db = null; |
|
19 | - public $nb = 0; |
|
12 | + private $all_tracked = array(); |
|
13 | + private $last_delete_hourly = 0; |
|
14 | + private $last_delete = 0; |
|
15 | + private $stats = array(); |
|
16 | + private $tmd = 0; |
|
17 | + private $source_location = array(); |
|
18 | + public $db = null; |
|
19 | + public $nb = 0; |
|
20 | 20 | |
21 | - public function __construct($dbc = null) { |
|
21 | + public function __construct($dbc = null) { |
|
22 | 22 | global $globalBeta; |
23 | 23 | $Connection = new Connection($dbc); |
24 | 24 | $this->db = $Connection->db(); |
@@ -40,50 +40,50 @@ discard block |
||
40 | 40 | } |
41 | 41 | } |
42 | 42 | */ |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | - public function checkAll() { |
|
45 | + public function checkAll() { |
|
46 | 46 | global $globalDebug; |
47 | 47 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
48 | 48 | foreach ($this->all_tracked as $key => $flight) { |
49 | - if (isset($this->all_tracked[$key]['id'])) { |
|
49 | + if (isset($this->all_tracked[$key]['id'])) { |
|
50 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
51 | - $Tracker = new Tracker($this->db); |
|
52 | - $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
53 | - } |
|
51 | + $Tracker = new Tracker($this->db); |
|
52 | + $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
53 | + } |
|
54 | + } |
|
54 | 55 | } |
55 | - } |
|
56 | 56 | |
57 | - public function del() { |
|
57 | + public function del() { |
|
58 | 58 | global $globalDebug; |
59 | 59 | // Delete old infos |
60 | 60 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
61 | 61 | foreach ($this->all_tracked as $key => $flight) { |
62 | - if (isset($flight['lastupdate'])) { |
|
63 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
64 | - if (isset($this->all_tracked[$key]['id'])) { |
|
65 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
62 | + if (isset($flight['lastupdate'])) { |
|
63 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
64 | + if (isset($this->all_tracked[$key]['id'])) { |
|
65 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
66 | 66 | /* |
67 | 67 | $TrackerLive = new TrackerLive(); |
68 | 68 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
69 | 69 | $TrackerLive->db = null; |
70 | 70 | */ |
71 | - //$real_arrival = $this->arrival($key); |
|
72 | - $Tracker = new Tracker($this->db); |
|
73 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
71 | + //$real_arrival = $this->arrival($key); |
|
72 | + $Tracker = new Tracker($this->db); |
|
73 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
74 | 74 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
75 | 75 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
76 | 76 | } |
77 | 77 | // Put in archive |
78 | 78 | // $Tracker->db = null; |
79 | - } |
|
80 | - unset($this->all_tracked[$key]); |
|
81 | - } |
|
82 | - } |
|
83 | - } |
|
84 | - } |
|
79 | + } |
|
80 | + unset($this->all_tracked[$key]); |
|
81 | + } |
|
82 | + } |
|
83 | + } |
|
84 | + } |
|
85 | 85 | |
86 | - public function add($line) { |
|
86 | + public function add($line) { |
|
87 | 87 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
88 | 88 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
89 | 89 | date_default_timezone_set('UTC'); |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | |
93 | 93 | // SBS format is CSV format |
94 | 94 | if(is_array($line) && isset($line['ident'])) { |
95 | - //print_r($line); |
|
96 | - if (isset($line['ident'])) { |
|
95 | + //print_r($line); |
|
96 | + if (isset($line['ident'])) { |
|
97 | 97 | |
98 | 98 | /* |
99 | 99 | // Increment message number |
@@ -109,29 +109,29 @@ discard block |
||
109 | 109 | */ |
110 | 110 | |
111 | 111 | $Common = new Common(); |
112 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
113 | - else $id = trim($line['id']); |
|
112 | + if (!isset($line['id'])) $id = trim($line['ident']); |
|
113 | + else $id = trim($line['id']); |
|
114 | 114 | |
115 | 115 | if (!isset($this->all_tracked[$id])) { |
116 | - $this->all_tracked[$id] = array(); |
|
117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
119 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
120 | - if (!isset($line['id'])) { |
|
116 | + $this->all_tracked[$id] = array(); |
|
117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
119 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
120 | + if (!isset($line['id'])) { |
|
121 | 121 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
122 | 122 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
123 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
124 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
123 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
124 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
128 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
128 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
129 | 129 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
130 | - } else { |
|
130 | + } else { |
|
131 | 131 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
132 | 132 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
133 | 133 | return ''; |
134 | - } |
|
134 | + } |
|
135 | 135 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
136 | 136 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
137 | 137 | return ''; |
@@ -148,38 +148,38 @@ discard block |
||
148 | 148 | |
149 | 149 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
150 | 150 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
151 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
152 | - if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
151 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
152 | + if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
153 | 153 | $timeelapsed = microtime(true); |
154 | - $Tracker = new Tracker($this->db); |
|
155 | - $fromsource = NULL; |
|
156 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
154 | + $Tracker = new Tracker($this->db); |
|
155 | + $fromsource = NULL; |
|
156 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
157 | 157 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
158 | 158 | $Tracker->db = null; |
159 | 159 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
160 | - } |
|
161 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
160 | + } |
|
161 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | if (isset($line['speed']) && $line['speed'] != '') { |
165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
167 | 167 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
168 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
169 | - if ($distance > 1000 && $distance < 10000) { |
|
168 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
169 | + if ($distance > 1000 && $distance < 10000) { |
|
170 | 170 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
171 | 171 | $speed = $speed*3.6; |
172 | 172 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
173 | 173 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
174 | - } |
|
174 | + } |
|
175 | 175 | } |
176 | 176 | |
177 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
178 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
179 | - else unset($timediff); |
|
180 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
177 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
178 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
179 | + else unset($timediff); |
|
180 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
181 | 181 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
182 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
182 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
183 | 183 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
184 | 184 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
185 | 185 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -193,120 +193,120 @@ discard block |
||
193 | 193 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
194 | 194 | $this->tmd = 0; |
195 | 195 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
196 | - } |
|
196 | + } |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
200 | 200 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
201 | 201 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
202 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
203 | - $dataFound = true; |
|
204 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
202 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
203 | + $dataFound = true; |
|
204 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
205 | 205 | } |
206 | 206 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
207 | 207 | } |
208 | 208 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
209 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
209 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
210 | 210 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
211 | 211 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
212 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
213 | - $dataFound = true; |
|
214 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
212 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
213 | + $dataFound = true; |
|
214 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
215 | 215 | } |
216 | 216 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
217 | 217 | } |
218 | 218 | |
219 | - } else if ($globalDebug && $timediff > 20) { |
|
219 | + } else if ($globalDebug && $timediff > 20) { |
|
220 | 220 | $this->tmd = $this->tmd + 1; |
221 | 221 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
222 | 222 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
223 | 223 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
224 | 224 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
225 | - } |
|
225 | + } |
|
226 | 226 | } |
227 | 227 | if (isset($line['last_update']) && $line['last_update'] != '') { |
228 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
229 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
228 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
229 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
230 | 230 | } |
231 | 231 | if (isset($line['format_source']) && $line['format_source'] != '') { |
232 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
232 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
233 | 233 | } |
234 | 234 | if (isset($line['source_name']) && $line['source_name'] != '') { |
235 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
235 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
236 | 236 | } |
237 | 237 | if (isset($line['comment']) && $line['comment'] != '') { |
238 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
239 | - //$dataFound = true; |
|
238 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
239 | + //$dataFound = true; |
|
240 | 240 | } |
241 | 241 | if (isset($line['type']) && $line['type'] != '') { |
242 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
243 | - //$dataFound = true; |
|
242 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
243 | + //$dataFound = true; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | if (isset($line['altitude']) && $line['altitude'] != '') { |
247 | - //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
247 | + //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
248 | 248 | if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
249 | 249 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
250 | 250 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
251 | 251 | //$dataFound = true; |
252 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
252 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
256 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
256 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | if (isset($line['heading']) && $line['heading'] != '') { |
260 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
261 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
263 | - //$dataFound = true; |
|
260 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
261 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
263 | + //$dataFound = true; |
|
264 | 264 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
265 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
266 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
267 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
268 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
265 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
266 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
267 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
268 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
269 | 269 | } |
270 | 270 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
271 | 271 | |
272 | 272 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
273 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
274 | - if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
275 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
276 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
273 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
274 | + if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
275 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
276 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
277 | 277 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
278 | 278 | $timeelapsed = microtime(true); |
279 | 279 | $TrackerLive = new TrackerLive($this->db); |
280 | 280 | if (isset($line['id'])) { |
281 | - $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
282 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
281 | + $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
282 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
283 | 283 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
284 | - $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
285 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
284 | + $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
285 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
286 | 286 | } else $recent_ident = ''; |
287 | 287 | $TrackerLive->db=null; |
288 | 288 | |
289 | 289 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
290 | 290 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
291 | - } else { |
|
291 | + } else { |
|
292 | 292 | $recent_ident = ''; |
293 | 293 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
294 | - } |
|
295 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
296 | - if($recent_ident == "") |
|
297 | - { |
|
294 | + } |
|
295 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
296 | + if($recent_ident == "") |
|
297 | + { |
|
298 | 298 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
299 | 299 | //adds the spotter data for the archive |
300 | - $highlight = ''; |
|
301 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
302 | - $timeelapsed = microtime(true); |
|
303 | - $Tracker = new Tracker($this->db); |
|
304 | - $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
305 | - $Tracker->db = null; |
|
306 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
307 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
300 | + $highlight = ''; |
|
301 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
302 | + $timeelapsed = microtime(true); |
|
303 | + $Tracker = new Tracker($this->db); |
|
304 | + $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
305 | + $Tracker->db = null; |
|
306 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
307 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
308 | 308 | |
309 | - /* |
|
309 | + /* |
|
310 | 310 | // Add source stat in DB |
311 | 311 | $Stats = new Stats($this->db); |
312 | 312 | if (!empty($this->stats)) { |
@@ -333,20 +333,20 @@ discard block |
||
333 | 333 | } |
334 | 334 | $Stats->db = null; |
335 | 335 | */ |
336 | - $this->del(); |
|
336 | + $this->del(); |
|
337 | 337 | //$ignoreImport = false; |
338 | 338 | $this->all_tracked[$id]['addedTracker'] = 1; |
339 | 339 | //print_r($this->all_tracked[$id]); |
340 | 340 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
341 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
342 | - //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
343 | - $TrackerLive = new TrackerLive($this->db); |
|
344 | - $TrackerLive->deleteLiveTrackerData(); |
|
345 | - $TrackerLive->db=null; |
|
346 | - if ($globalDebug) echo " Done\n"; |
|
347 | - $this->last_delete = time(); |
|
341 | + if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
342 | + //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
343 | + $TrackerLive = new TrackerLive($this->db); |
|
344 | + $TrackerLive->deleteLiveTrackerData(); |
|
345 | + $TrackerLive->db=null; |
|
346 | + if ($globalDebug) echo " Done\n"; |
|
347 | + $this->last_delete = time(); |
|
348 | 348 | } |
349 | - } else { |
|
349 | + } else { |
|
350 | 350 | $this->all_tracked[$id]['id'] = $recent_ident; |
351 | 351 | $this->all_tracked[$id]['addedTracker'] = 1; |
352 | 352 | if (isset($globalDaemon) && !$globalDaemon) { |
@@ -355,16 +355,16 @@ discard block |
||
355 | 355 | $Tracker->db = null; |
356 | 356 | } |
357 | 357 | |
358 | - } |
|
358 | + } |
|
359 | + } |
|
359 | 360 | } |
360 | - } |
|
361 | - //adds the spotter LIVE data |
|
362 | - if ($globalDebug) { |
|
361 | + //adds the spotter LIVE data |
|
362 | + if ($globalDebug) { |
|
363 | 363 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
364 | - } |
|
365 | - $ignoreImport = false; |
|
364 | + } |
|
365 | + $ignoreImport = false; |
|
366 | 366 | |
367 | - if (!$ignoreImport) { |
|
367 | + if (!$ignoreImport) { |
|
368 | 368 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
369 | 369 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
370 | 370 | $timeelapsed = microtime(true); |
@@ -436,22 +436,22 @@ discard block |
||
436 | 436 | |
437 | 437 | |
438 | 438 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
440 | - $TrackerLive = new TrackerLive($this->db); |
|
441 | - $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
442 | - $TrackerLive->db = null; |
|
443 | - //TrackerLive->deleteLiveTrackerData(); |
|
444 | - if ($globalDebug) echo " Done\n"; |
|
445 | - $this->last_delete_hourly = time(); |
|
439 | + if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
440 | + $TrackerLive = new TrackerLive($this->db); |
|
441 | + $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
442 | + $TrackerLive->db = null; |
|
443 | + //TrackerLive->deleteLiveTrackerData(); |
|
444 | + if ($globalDebug) echo " Done\n"; |
|
445 | + $this->last_delete_hourly = time(); |
|
446 | 446 | } |
447 | 447 | |
448 | - } |
|
449 | - //$ignoreImport = false; |
|
448 | + } |
|
449 | + //$ignoreImport = false; |
|
450 | 450 | } |
451 | 451 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
452 | 452 | if ($send) return $this->all_tracked[$id]; |
453 | - } |
|
453 | + } |
|
454 | + } |
|
454 | 455 | } |
455 | - } |
|
456 | 456 | } |
457 | 457 | ?> |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | if (isset($this->all_tracked[$key]['id'])) { |
50 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
51 | 51 | $Tracker = new Tracker($this->db); |
52 | - $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
52 | + $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
61 | 61 | foreach ($this->all_tracked as $key => $flight) { |
62 | 62 | if (isset($flight['lastupdate'])) { |
63 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
63 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
64 | 64 | if (isset($this->all_tracked[$key]['id'])) { |
65 | 65 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
66 | 66 | /* |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | //$real_arrival = $this->arrival($key); |
72 | 72 | $Tracker = new Tracker($this->db); |
73 | 73 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
74 | - $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
|
74 | + $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']); |
|
75 | 75 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
76 | 76 | } |
77 | 77 | // Put in archive |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $send = false; |
92 | 92 | |
93 | 93 | // SBS format is CSV format |
94 | - if(is_array($line) && isset($line['ident'])) { |
|
94 | + if (is_array($line) && isset($line['ident'])) { |
|
95 | 95 | //print_r($line); |
96 | 96 | if (isset($line['ident'])) { |
97 | 97 | |
@@ -114,33 +114,33 @@ discard block |
||
114 | 114 | |
115 | 115 | if (!isset($this->all_tracked[$id])) { |
116 | 116 | $this->all_tracked[$id] = array(); |
117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
119 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0)); |
|
118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '')); |
|
119 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
120 | 120 | if (!isset($line['id'])) { |
121 | 121 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
122 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
123 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
122 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
123 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
124 | 124 | if ($globalAllTracked !== FALSE) $dataFound = true; |
125 | 125 | } |
126 | 126 | |
127 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
127 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
128 | 128 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
129 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
129 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
130 | 130 | } else { |
131 | 131 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
132 | 132 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
133 | 133 | return ''; |
134 | 134 | } |
135 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
135 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
136 | 136 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
137 | 137 | return ''; |
138 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
138 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
139 | 139 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
140 | 140 | return ''; |
141 | 141 | } elseif (!isset($line['datetime'])) { |
142 | 142 | date_default_timezone_set('UTC'); |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
144 | 144 | } else { |
145 | 145 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
146 | 146 | return ''; |
@@ -148,38 +148,38 @@ discard block |
||
148 | 148 | |
149 | 149 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
150 | 150 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
151 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
151 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
152 | 152 | if ($this->all_tracked[$id]['addedTracker'] == 1) { |
153 | 153 | $timeelapsed = microtime(true); |
154 | 154 | $Tracker = new Tracker($this->db); |
155 | 155 | $fromsource = NULL; |
156 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
156 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
157 | 157 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
158 | 158 | $Tracker->db = null; |
159 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
159 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
160 | 160 | } |
161 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
161 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | if (isset($line['speed']) && $line['speed'] != '') { |
165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
167 | 167 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
168 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
168 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
169 | 169 | if ($distance > 1000 && $distance < 10000) { |
170 | 170 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
171 | 171 | $speed = $speed*3.6; |
172 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
172 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
173 | 173 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | 177 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
178 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
178 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
179 | 179 | else unset($timediff); |
180 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
180 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) { |
|
181 | 181 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
182 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
182 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
183 | 183 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
184 | 184 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
185 | 185 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
188 | 188 | $timeelapsed = microtime(true); |
189 | 189 | $Tracker = new Tracker($this->db); |
190 | - $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
190 | + $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
191 | 191 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
192 | 192 | $Tracker->db = null; |
193 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
193 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
194 | 194 | $this->tmd = 0; |
195 | 195 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
196 | 196 | } |
@@ -198,73 +198,73 @@ discard block |
||
198 | 198 | |
199 | 199 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
200 | 200 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
201 | - if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
201 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
202 | 202 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
203 | 203 | $dataFound = true; |
204 | 204 | $this->all_tracked[$id]['time_last_coord'] = time(); |
205 | 205 | } |
206 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
206 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
207 | 207 | } |
208 | 208 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
209 | 209 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
210 | 210 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
211 | - if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
211 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
212 | 212 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
213 | 213 | $dataFound = true; |
214 | 214 | $this->all_tracked[$id]['time_last_coord'] = time(); |
215 | 215 | } |
216 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
216 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | } else if ($globalDebug && $timediff > 20) { |
220 | 220 | $this->tmd = $this->tmd + 1; |
221 | 221 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
222 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
223 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
222 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
223 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
224 | 224 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
225 | 225 | } |
226 | 226 | } |
227 | 227 | if (isset($line['last_update']) && $line['last_update'] != '') { |
228 | 228 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
229 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
229 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
230 | 230 | } |
231 | 231 | if (isset($line['format_source']) && $line['format_source'] != '') { |
232 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
232 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
233 | 233 | } |
234 | 234 | if (isset($line['source_name']) && $line['source_name'] != '') { |
235 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
235 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
236 | 236 | } |
237 | 237 | if (isset($line['comment']) && $line['comment'] != '') { |
238 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
238 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment'])); |
|
239 | 239 | //$dataFound = true; |
240 | 240 | } |
241 | 241 | if (isset($line['type']) && $line['type'] != '') { |
242 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
242 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
243 | 243 | //$dataFound = true; |
244 | 244 | } |
245 | 245 | |
246 | 246 | if (isset($line['altitude']) && $line['altitude'] != '') { |
247 | 247 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
248 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
249 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
|
250 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
|
248 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
249 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => round($line['altitude']/100))); |
|
250 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude'])); |
|
251 | 251 | //$dataFound = true; |
252 | 252 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
253 | 253 | } |
254 | 254 | |
255 | 255 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
256 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
256 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | if (isset($line['heading']) && $line['heading'] != '') { |
260 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
261 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
260 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
261 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
263 | 263 | //$dataFound = true; |
264 | 264 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
265 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
266 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
267 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
265 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
266 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
267 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
268 | 268 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
269 | 269 | } |
270 | 270 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -272,39 +272,39 @@ discard block |
||
272 | 272 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
273 | 273 | $this->all_tracked[$id]['lastupdate'] = time(); |
274 | 274 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
275 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
275 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
276 | 276 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
277 | 277 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
278 | 278 | $timeelapsed = microtime(true); |
279 | 279 | $TrackerLive = new TrackerLive($this->db); |
280 | 280 | if (isset($line['id'])) { |
281 | 281 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
282 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
282 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
283 | 283 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
284 | 284 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
285 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
285 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
286 | 286 | } else $recent_ident = ''; |
287 | - $TrackerLive->db=null; |
|
287 | + $TrackerLive->db = null; |
|
288 | 288 | |
289 | 289 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
290 | 290 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
291 | 291 | } else { |
292 | 292 | $recent_ident = ''; |
293 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
293 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
294 | 294 | } |
295 | 295 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
296 | - if($recent_ident == "") |
|
296 | + if ($recent_ident == "") |
|
297 | 297 | { |
298 | 298 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
299 | 299 | //adds the spotter data for the archive |
300 | 300 | $highlight = ''; |
301 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
301 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
302 | 302 | $timeelapsed = microtime(true); |
303 | 303 | $Tracker = new Tracker($this->db); |
304 | - $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
304 | + $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
305 | 305 | $Tracker->db = null; |
306 | 306 | if ($globalDebug && isset($result)) echo $result."\n"; |
307 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
307 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
308 | 308 | |
309 | 309 | /* |
310 | 310 | // Add source stat in DB |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
343 | 343 | $TrackerLive = new TrackerLive($this->db); |
344 | 344 | $TrackerLive->deleteLiveTrackerData(); |
345 | - $TrackerLive->db=null; |
|
345 | + $TrackerLive->db = null; |
|
346 | 346 | if ($globalDebug) echo " Done\n"; |
347 | 347 | $this->last_delete = time(); |
348 | 348 | } |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | $this->all_tracked[$id]['addedTracker'] = 1; |
352 | 352 | if (isset($globalDaemon) && !$globalDaemon) { |
353 | 353 | $Tracker = new Tracker($this->db); |
354 | - $Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
354 | + $Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
355 | 355 | $Tracker->db = null; |
356 | 356 | } |
357 | 357 | |
@@ -365,14 +365,14 @@ discard block |
||
365 | 365 | $ignoreImport = false; |
366 | 366 | |
367 | 367 | if (!$ignoreImport) { |
368 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
368 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
369 | 369 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
370 | 370 | $timeelapsed = microtime(true); |
371 | 371 | $TrackerLive = new TrackerLive($this->db); |
372 | - $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
372 | + $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
373 | 373 | $TrackerLive->db = null; |
374 | 374 | $this->all_tracked[$id]['putinarchive'] = false; |
375 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
375 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
376 | 376 | |
377 | 377 | // Put statistics in $this->stats variable |
378 | 378 | /* |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | $this->all_tracked[$id]['lastupdate'] = time(); |
432 | 432 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
433 | 433 | if ($globalDebug) echo $result."\n"; |
434 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
434 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
435 | 435 | //$this->del(); |
436 | 436 | |
437 | 437 |
@@ -44,7 +44,9 @@ discard block |
||
44 | 44 | |
45 | 45 | public function checkAll() { |
46 | 46 | global $globalDebug; |
47 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
47 | + if ($globalDebug) { |
|
48 | + echo "Update last seen tracked data...\n"; |
|
49 | + } |
|
48 | 50 | foreach ($this->all_tracked as $key => $flight) { |
49 | 51 | if (isset($this->all_tracked[$key]['id'])) { |
50 | 52 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -57,12 +59,16 @@ discard block |
||
57 | 59 | public function del() { |
58 | 60 | global $globalDebug; |
59 | 61 | // Delete old infos |
60 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
62 | + if ($globalDebug) { |
|
63 | + echo 'Delete old values and update latest data...'."\n"; |
|
64 | + } |
|
61 | 65 | foreach ($this->all_tracked as $key => $flight) { |
62 | 66 | if (isset($flight['lastupdate'])) { |
63 | 67 | if ($flight['lastupdate'] < (time()-3000)) { |
64 | 68 | if (isset($this->all_tracked[$key]['id'])) { |
65 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
69 | + if ($globalDebug) { |
|
70 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
71 | + } |
|
66 | 72 | /* |
67 | 73 | $TrackerLive = new TrackerLive(); |
68 | 74 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
@@ -72,7 +78,9 @@ discard block |
||
72 | 78 | $Tracker = new Tracker($this->db); |
73 | 79 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
74 | 80 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
75 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
81 | + if ($globalDebug && $result != 'success') { |
|
82 | + echo '!!! ERROR : '.$result."\n"; |
|
83 | + } |
|
76 | 84 | } |
77 | 85 | // Put in archive |
78 | 86 | // $Tracker->db = null; |
@@ -85,7 +93,9 @@ discard block |
||
85 | 93 | |
86 | 94 | public function add($line) { |
87 | 95 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
88 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
96 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
97 | + $globalCoordMinChange = '0.02'; |
|
98 | + } |
|
89 | 99 | date_default_timezone_set('UTC'); |
90 | 100 | $dataFound = false; |
91 | 101 | $send = false; |
@@ -109,8 +119,11 @@ discard block |
||
109 | 119 | */ |
110 | 120 | |
111 | 121 | $Common = new Common(); |
112 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
113 | - else $id = trim($line['id']); |
|
122 | + if (!isset($line['id'])) { |
|
123 | + $id = trim($line['ident']); |
|
124 | + } else { |
|
125 | + $id = trim($line['id']); |
|
126 | + } |
|
114 | 127 | |
115 | 128 | if (!isset($this->all_tracked[$id])) { |
116 | 129 | $this->all_tracked[$id] = array(); |
@@ -118,31 +131,46 @@ discard block |
||
118 | 131 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
119 | 132 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
120 | 133 | if (!isset($line['id'])) { |
121 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
134 | + if (!isset($globalDaemon)) { |
|
135 | + $globalDaemon = TRUE; |
|
136 | + } |
|
122 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
123 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
124 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
138 | + } else { |
|
139 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
140 | + } |
|
141 | + if ($globalAllTracked !== FALSE) { |
|
142 | + $dataFound = true; |
|
143 | + } |
|
125 | 144 | } |
126 | 145 | |
127 | 146 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
128 | 147 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
129 | 148 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
130 | 149 | } else { |
131 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
132 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
150 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
151 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
152 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
153 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
154 | + } |
|
133 | 155 | return ''; |
134 | 156 | } |
135 | 157 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
136 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
|
158 | + if ($globalDebug) { |
|
159 | + echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
|
160 | + } |
|
137 | 161 | return ''; |
138 | 162 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
139 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
|
163 | + if ($globalDebug) { |
|
164 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
|
165 | + } |
|
140 | 166 | return ''; |
141 | 167 | } elseif (!isset($line['datetime'])) { |
142 | 168 | date_default_timezone_set('UTC'); |
143 | 169 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
144 | 170 | } else { |
145 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
|
171 | + if ($globalDebug) { |
|
172 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
|
173 | + } |
|
146 | 174 | return ''; |
147 | 175 | } |
148 | 176 | |
@@ -154,11 +182,17 @@ discard block |
||
154 | 182 | $Tracker = new Tracker($this->db); |
155 | 183 | $fromsource = NULL; |
156 | 184 | $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
157 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
185 | + if ($globalDebug && $result != 'success') { |
|
186 | + echo '!!! ERROR : '.$result."\n"; |
|
187 | + } |
|
158 | 188 | $Tracker->db = null; |
159 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
189 | + if ($globalDebugTimeElapsed) { |
|
190 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
191 | + } |
|
192 | + } |
|
193 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
194 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
160 | 195 | } |
161 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
162 | 196 | } |
163 | 197 | |
164 | 198 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -169,14 +203,21 @@ discard block |
||
169 | 203 | if ($distance > 1000 && $distance < 10000) { |
170 | 204 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
171 | 205 | $speed = $speed*3.6; |
172 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
173 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
206 | + if ($speed < 1000) { |
|
207 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
208 | + } |
|
209 | + if ($globalDebug) { |
|
210 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
211 | + } |
|
174 | 212 | } |
175 | 213 | } |
176 | 214 | |
177 | 215 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
178 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
179 | - else unset($timediff); |
|
216 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
217 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
218 | + } else { |
|
219 | + unset($timediff); |
|
220 | + } |
|
180 | 221 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
181 | 222 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
182 | 223 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -184,20 +225,30 @@ discard block |
||
184 | 225 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
185 | 226 | $this->all_tracked[$id]['putinarchive'] = true; |
186 | 227 | |
187 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
228 | + if ($globalDebug) { |
|
229 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
230 | + } |
|
188 | 231 | $timeelapsed = microtime(true); |
189 | 232 | $Tracker = new Tracker($this->db); |
190 | 233 | $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
191 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
234 | + if (!empty($all_country)) { |
|
235 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
236 | + } |
|
192 | 237 | $Tracker->db = null; |
193 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
238 | + if ($globalDebugTimeElapsed) { |
|
239 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
240 | + } |
|
194 | 241 | $this->tmd = 0; |
195 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
244 | + } |
|
196 | 245 | } |
197 | 246 | } |
198 | 247 | |
199 | 248 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
200 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
249 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
250 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
251 | + } |
|
201 | 252 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
202 | 253 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
203 | 254 | $dataFound = true; |
@@ -206,8 +257,12 @@ discard block |
||
206 | 257 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
207 | 258 | } |
208 | 259 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
209 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
210 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
260 | + if ($line['longitude'] > 180) { |
|
261 | + $line['longitude'] = $line['longitude'] - 360; |
|
262 | + } |
|
263 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
264 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
265 | + } |
|
211 | 266 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
212 | 267 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
213 | 268 | $dataFound = true; |
@@ -225,7 +280,9 @@ discard block |
||
225 | 280 | } |
226 | 281 | } |
227 | 282 | if (isset($line['last_update']) && $line['last_update'] != '') { |
228 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
283 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
284 | + $dataFound = true; |
|
285 | + } |
|
229 | 286 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
230 | 287 | } |
231 | 288 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -245,7 +302,9 @@ discard block |
||
245 | 302 | |
246 | 303 | if (isset($line['altitude']) && $line['altitude'] != '') { |
247 | 304 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
248 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
305 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) { |
|
306 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
307 | + } |
|
249 | 308 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
250 | 309 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
251 | 310 | //$dataFound = true; |
@@ -257,15 +316,21 @@ discard block |
||
257 | 316 | } |
258 | 317 | |
259 | 318 | if (isset($line['heading']) && $line['heading'] != '') { |
260 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
319 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
320 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
321 | + } |
|
261 | 322 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
262 | 323 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
263 | 324 | //$dataFound = true; |
264 | 325 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
265 | 326 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
266 | 327 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
267 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
268 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
328 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
329 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
330 | + } |
|
331 | + if ($globalDebug) { |
|
332 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
333 | + } |
|
269 | 334 | } |
270 | 335 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
271 | 336 | |
@@ -274,20 +339,31 @@ discard block |
||
274 | 339 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
275 | 340 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
276 | 341 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
277 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
342 | + if ($globalDebug) { |
|
343 | + echo "Check if aircraft is already in DB..."; |
|
344 | + } |
|
278 | 345 | $timeelapsed = microtime(true); |
279 | 346 | $TrackerLive = new TrackerLive($this->db); |
280 | 347 | if (isset($line['id'])) { |
281 | 348 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
282 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
349 | + if ($globalDebugTimeElapsed) { |
|
350 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
351 | + } |
|
283 | 352 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
284 | 353 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
285 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
286 | - } else $recent_ident = ''; |
|
354 | + if ($globalDebugTimeElapsed) { |
|
355 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
356 | + } |
|
357 | + } else { |
|
358 | + $recent_ident = ''; |
|
359 | + } |
|
287 | 360 | $TrackerLive->db=null; |
288 | 361 | |
289 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
290 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
362 | + if ($globalDebug && $recent_ident == '') { |
|
363 | + echo " Not in DB.\n"; |
|
364 | + } elseif ($globalDebug && $recent_ident != '') { |
|
365 | + echo " Already in DB.\n"; |
|
366 | + } |
|
291 | 367 | } else { |
292 | 368 | $recent_ident = ''; |
293 | 369 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -295,16 +371,24 @@ discard block |
||
295 | 371 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
296 | 372 | if($recent_ident == "") |
297 | 373 | { |
298 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
374 | + if ($globalDebug) { |
|
375 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
376 | + } |
|
299 | 377 | //adds the spotter data for the archive |
300 | 378 | $highlight = ''; |
301 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
379 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
380 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
381 | + } |
|
302 | 382 | $timeelapsed = microtime(true); |
303 | 383 | $Tracker = new Tracker($this->db); |
304 | 384 | $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
305 | 385 | $Tracker->db = null; |
306 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
307 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
386 | + if ($globalDebug && isset($result)) { |
|
387 | + echo $result."\n"; |
|
388 | + } |
|
389 | + if ($globalDebugTimeElapsed) { |
|
390 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
391 | + } |
|
308 | 392 | |
309 | 393 | /* |
310 | 394 | // Add source stat in DB |
@@ -338,12 +422,16 @@ discard block |
||
338 | 422 | $this->all_tracked[$id]['addedTracker'] = 1; |
339 | 423 | //print_r($this->all_tracked[$id]); |
340 | 424 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
341 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
425 | + if ($globalDebug) { |
|
426 | + echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
427 | + } |
|
342 | 428 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
343 | 429 | $TrackerLive = new TrackerLive($this->db); |
344 | 430 | $TrackerLive->deleteLiveTrackerData(); |
345 | 431 | $TrackerLive->db=null; |
346 | - if ($globalDebug) echo " Done\n"; |
|
432 | + if ($globalDebug) { |
|
433 | + echo " Done\n"; |
|
434 | + } |
|
347 | 435 | $this->last_delete = time(); |
348 | 436 | } |
349 | 437 | } else { |
@@ -366,13 +454,17 @@ discard block |
||
366 | 454 | |
367 | 455 | if (!$ignoreImport) { |
368 | 456 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
369 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
457 | + if ($globalDebug) { |
|
458 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
459 | + } |
|
370 | 460 | $timeelapsed = microtime(true); |
371 | 461 | $TrackerLive = new TrackerLive($this->db); |
372 | 462 | $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
373 | 463 | $TrackerLive->db = null; |
374 | 464 | $this->all_tracked[$id]['putinarchive'] = false; |
375 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
465 | + if ($globalDebugTimeElapsed) { |
|
466 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
467 | + } |
|
376 | 468 | |
377 | 469 | // Put statistics in $this->stats variable |
378 | 470 | /* |
@@ -429,19 +521,29 @@ discard block |
||
429 | 521 | */ |
430 | 522 | |
431 | 523 | $this->all_tracked[$id]['lastupdate'] = time(); |
432 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
433 | - if ($globalDebug) echo $result."\n"; |
|
434 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
524 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
525 | + $send = true; |
|
526 | + } |
|
527 | + if ($globalDebug) { |
|
528 | + echo $result."\n"; |
|
529 | + } |
|
530 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
531 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
532 | + } |
|
435 | 533 | //$this->del(); |
436 | 534 | |
437 | 535 | |
438 | 536 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
537 | + if ($globalDebug) { |
|
538 | + echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
539 | + } |
|
440 | 540 | $TrackerLive = new TrackerLive($this->db); |
441 | 541 | $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
442 | 542 | $TrackerLive->db = null; |
443 | 543 | //TrackerLive->deleteLiveTrackerData(); |
444 | - if ($globalDebug) echo " Done\n"; |
|
544 | + if ($globalDebug) { |
|
545 | + echo " Done\n"; |
|
546 | + } |
|
445 | 547 | $this->last_delete_hourly = time(); |
446 | 548 | } |
447 | 549 | |
@@ -449,7 +551,9 @@ discard block |
||
449 | 551 | //$ignoreImport = false; |
450 | 552 | } |
451 | 553 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
452 | - if ($send) return $this->all_tracked[$id]; |
|
554 | + if ($send) { |
|
555 | + return $this->all_tracked[$id]; |
|
556 | + } |
|
453 | 557 | } |
454 | 558 | } |
455 | 559 | } |