@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | * @param Array $filter the filter |
18 | 18 | * @return Array the SQL part |
19 | 19 | */ |
20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
26 | 26 | } else { |
27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | if (isset($filter[0]['source'])) { |
31 | - $filters = array_merge($filters,$filter); |
|
31 | + $filters = array_merge($filters, $filter); |
|
32 | 32 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
34 | 34 | $filter_query_join = ''; |
35 | 35 | $filter_query_where = ''; |
36 | - foreach($filters as $flt) { |
|
36 | + foreach ($filters as $flt) { |
|
37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
39 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
40 | 40 | } else { |
41 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
47 | 47 | } |
48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
73 | 73 | } |
74 | 74 | } |
75 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
75 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
76 | 76 | } |
77 | 77 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
78 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
78 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
79 | 79 | } |
80 | 80 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
81 | 81 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
82 | 82 | if ($filter_query_where != '') { |
83 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
83 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
84 | 84 | } |
85 | 85 | $filter_query = $filter_query_join.$filter_query_where; |
86 | 86 | return $filter_query; |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | if ($limit != '') |
104 | 104 | { |
105 | 105 | $limit_array = explode(',', $limit); |
106 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
107 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
106 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
107 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
108 | 108 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
109 | 109 | { |
110 | 110 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
120 | 120 | } |
121 | 121 | } |
122 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
122 | + if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
123 | 123 | |
124 | 124 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
125 | 125 | if ($globalDBdriver == 'mysql') { |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } else { |
129 | 129 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query; |
130 | 130 | } |
131 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
131 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
132 | 132 | |
133 | 133 | return $spotter_array; |
134 | 134 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | global $globalDBdriver, $globalLiveInterval; |
145 | 145 | date_default_timezone_set('UTC'); |
146 | 146 | |
147 | - $filter_query = $this->getFilter($filter,true,true); |
|
147 | + $filter_query = $this->getFilter($filter, true, true); |
|
148 | 148 | |
149 | 149 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
150 | 150 | if ($globalDBdriver == 'mysql') { |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | try { |
159 | 159 | $sth = $this->db->prepare($query); |
160 | 160 | $sth->execute(); |
161 | - } catch(PDOException $e) { |
|
161 | + } catch (PDOException $e) { |
|
162 | 162 | echo $e->getMessage(); |
163 | 163 | die; |
164 | 164 | } |
@@ -173,19 +173,19 @@ discard block |
||
173 | 173 | * @return Array the spotter information |
174 | 174 | * |
175 | 175 | */ |
176 | - public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false) |
|
176 | + public function getMinLastLiveMarineData($coord = array(), $filter = array(), $limit = false) |
|
177 | 177 | { |
178 | 178 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
179 | 179 | date_default_timezone_set('UTC'); |
180 | 180 | $usecoord = false; |
181 | 181 | if (is_array($coord) && !empty($coord)) { |
182 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
183 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
184 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
185 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
182 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
183 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
184 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
185 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
186 | 186 | $usecoord = true; |
187 | 187 | } |
188 | - $filter_query = $this->getFilter($filter,true,true); |
|
188 | + $filter_query = $this->getFilter($filter, true, true); |
|
189 | 189 | |
190 | 190 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
191 | 191 | if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | try { |
235 | 235 | $sth = $this->db->prepare($query); |
236 | 236 | $sth->execute(); |
237 | - } catch(PDOException $e) { |
|
237 | + } catch (PDOException $e) { |
|
238 | 238 | echo $e->getMessage(); |
239 | 239 | die; |
240 | 240 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | public function getLiveMarineCount($filter = array()) |
252 | 252 | { |
253 | 253 | global $globalDBdriver, $globalLiveInterval; |
254 | - $filter_query = $this->getFilter($filter,true,true); |
|
254 | + $filter_query = $this->getFilter($filter, true, true); |
|
255 | 255 | |
256 | 256 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
257 | 257 | if ($globalDBdriver == 'mysql') { |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | try { |
263 | 263 | $sth = $this->db->prepare($query); |
264 | 264 | $sth->execute(); |
265 | - } catch(PDOException $e) { |
|
265 | + } catch (PDOException $e) { |
|
266 | 266 | echo $e->getMessage(); |
267 | 267 | die; |
268 | 268 | } |
@@ -285,10 +285,10 @@ discard block |
||
285 | 285 | $filter_query = $this->getFilter($filter); |
286 | 286 | |
287 | 287 | if (is_array($coord)) { |
288 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
289 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
290 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
291 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
288 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
289 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
290 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
291 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
292 | 292 | } else return array(); |
293 | 293 | if ($globalDBdriver == 'mysql') { |
294 | 294 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
311 | 311 | $Marine = new Marine($this->db); |
312 | 312 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
313 | - $filter_query = $this->getFilter($filter,true,true); |
|
313 | + $filter_query = $this->getFilter($filter, true, true); |
|
314 | 314 | |
315 | 315 | if (is_array($coord)) { |
316 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
317 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
318 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
319 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
316 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
317 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
318 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
319 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
320 | 320 | } else return array(); |
321 | 321 | /* |
322 | 322 | if ($globalDBdriver == 'mysql') { |
@@ -331,13 +331,13 @@ discard block |
||
331 | 331 | */ |
332 | 332 | if ($globalDBdriver == 'mysql') { |
333 | 333 | if (isset($globalArchive) && $globalArchive === TRUE) { |
334 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
334 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
335 | 335 | FROM marine_live |
336 | 336 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= marine_live.date |
337 | 337 | AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
338 | 338 | AND marine_live.latitude <> 0 AND marine_live.longitude <> 0'; |
339 | 339 | } else { |
340 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
340 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
341 | 341 | FROM marine_live |
342 | 342 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate |
343 | 343 | FROM marine_live l |
@@ -349,14 +349,14 @@ discard block |
||
349 | 349 | } |
350 | 350 | } else { |
351 | 351 | if (isset($globalArchive) && $globalArchive === TRUE) { |
352 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
352 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
353 | 353 | FROM marine_live |
354 | 354 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date |
355 | 355 | AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
356 | 356 | AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
357 | 357 | AND marine_live.latitude <> '0' AND marine_live.longitude <> '0'"; |
358 | 358 | } else { |
359 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
359 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
360 | 360 | FROM marine_live |
361 | 361 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate |
362 | 362 | FROM marine_live l |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | if ($interval == '1m') |
414 | 414 | { |
415 | 415 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
416 | - } else if ($interval == '15m'){ |
|
416 | + } else if ($interval == '15m') { |
|
417 | 417 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
418 | 418 | } |
419 | 419 | } |
@@ -421,14 +421,14 @@ discard block |
||
421 | 421 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
422 | 422 | } |
423 | 423 | |
424 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
424 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
425 | 425 | WHERE marine_live.latitude <> '' |
426 | 426 | AND marine_live.longitude <> '' |
427 | 427 | ".$additional_query." |
428 | 428 | HAVING distance < :radius |
429 | 429 | ORDER BY distance"; |
430 | 430 | |
431 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
431 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
432 | 432 | |
433 | 433 | return $spotter_array; |
434 | 434 | } |
@@ -446,9 +446,9 @@ discard block |
||
446 | 446 | date_default_timezone_set('UTC'); |
447 | 447 | |
448 | 448 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
449 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
449 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
450 | 450 | |
451 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
451 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
452 | 452 | |
453 | 453 | return $spotter_array; |
454 | 454 | } |
@@ -459,16 +459,16 @@ discard block |
||
459 | 459 | * @return Array the spotter information |
460 | 460 | * |
461 | 461 | */ |
462 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
462 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
463 | 463 | { |
464 | 464 | $Marine = new Marine($this->db); |
465 | 465 | date_default_timezone_set('UTC'); |
466 | 466 | |
467 | 467 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
468 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
468 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
469 | 469 | |
470 | - $date = date('c',$date); |
|
471 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
470 | + $date = date('c', $date); |
|
471 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
472 | 472 | |
473 | 473 | return $spotter_array; |
474 | 474 | } |
@@ -485,9 +485,9 @@ discard block |
||
485 | 485 | date_default_timezone_set('UTC'); |
486 | 486 | |
487 | 487 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
488 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
488 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
489 | 489 | |
490 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
490 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
491 | 491 | |
492 | 492 | return $spotter_array; |
493 | 493 | } |
@@ -498,15 +498,15 @@ discard block |
||
498 | 498 | * @return Array the spotter information |
499 | 499 | * |
500 | 500 | */ |
501 | - public function getDateLiveMarineDataById($id,$date) |
|
501 | + public function getDateLiveMarineDataById($id, $date) |
|
502 | 502 | { |
503 | 503 | $Marine = new Marine($this->db); |
504 | 504 | date_default_timezone_set('UTC'); |
505 | 505 | |
506 | 506 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
507 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
508 | - $date = date('c',$date); |
|
509 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
507 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
508 | + $date = date('c', $date); |
|
509 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
510 | 510 | |
511 | 511 | return $spotter_array; |
512 | 512 | } |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | * @return Array the spotter information |
519 | 519 | * |
520 | 520 | */ |
521 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
521 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
522 | 522 | { |
523 | 523 | global $globalDBdriver, $globalLiveInterval; |
524 | 524 | date_default_timezone_set('UTC'); |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | try { |
538 | 538 | $sth = $this->db->prepare($query); |
539 | 539 | $sth->execute(array(':id' => $id)); |
540 | - } catch(PDOException $e) { |
|
540 | + } catch (PDOException $e) { |
|
541 | 541 | echo $e->getMessage(); |
542 | 542 | die; |
543 | 543 | } |
@@ -555,12 +555,12 @@ discard block |
||
555 | 555 | { |
556 | 556 | date_default_timezone_set('UTC'); |
557 | 557 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
558 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
558 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
559 | 559 | try { |
560 | 560 | |
561 | 561 | $sth = $this->db->prepare($query); |
562 | 562 | $sth->execute(array(':ident' => $ident)); |
563 | - } catch(PDOException $e) { |
|
563 | + } catch (PDOException $e) { |
|
564 | 564 | echo $e->getMessage(); |
565 | 565 | die; |
566 | 566 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | |
591 | 591 | $sth = $this->db->prepare($query); |
592 | 592 | $sth->execute(); |
593 | - } catch(PDOException $e) { |
|
593 | + } catch (PDOException $e) { |
|
594 | 594 | return "error"; |
595 | 595 | } |
596 | 596 | |
@@ -613,14 +613,14 @@ discard block |
||
613 | 613 | |
614 | 614 | $sth = $this->db->prepare($query); |
615 | 615 | $sth->execute(); |
616 | - } catch(PDOException $e) { |
|
616 | + } catch (PDOException $e) { |
|
617 | 617 | return "error"; |
618 | 618 | } |
619 | 619 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
620 | 620 | $i = 0; |
621 | - $j =0; |
|
621 | + $j = 0; |
|
622 | 622 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
623 | - foreach($all as $row) |
|
623 | + foreach ($all as $row) |
|
624 | 624 | { |
625 | 625 | $i++; |
626 | 626 | $j++; |
@@ -628,9 +628,9 @@ discard block |
||
628 | 628 | if ($globalDebug) echo "."; |
629 | 629 | try { |
630 | 630 | |
631 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
631 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
632 | 632 | $sth->execute(); |
633 | - } catch(PDOException $e) { |
|
633 | + } catch (PDOException $e) { |
|
634 | 634 | return "error"; |
635 | 635 | } |
636 | 636 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -641,9 +641,9 @@ discard block |
||
641 | 641 | if ($i > 0) { |
642 | 642 | try { |
643 | 643 | |
644 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
644 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
645 | 645 | $sth->execute(); |
646 | - } catch(PDOException $e) { |
|
646 | + } catch (PDOException $e) { |
|
647 | 647 | return "error"; |
648 | 648 | } |
649 | 649 | } |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | |
657 | 657 | $sth = $this->db->prepare($query); |
658 | 658 | $sth->execute(); |
659 | - } catch(PDOException $e) { |
|
659 | + } catch (PDOException $e) { |
|
660 | 660 | return "error"; |
661 | 661 | } |
662 | 662 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -704,13 +704,13 @@ discard block |
||
704 | 704 | public function deleteLiveMarineDataByIdent($ident) |
705 | 705 | { |
706 | 706 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
707 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
707 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
708 | 708 | |
709 | 709 | try { |
710 | 710 | |
711 | 711 | $sth = $this->db->prepare($query); |
712 | 712 | $sth->execute(array(':ident' => $ident)); |
713 | - } catch(PDOException $e) { |
|
713 | + } catch (PDOException $e) { |
|
714 | 714 | return "error"; |
715 | 715 | } |
716 | 716 | |
@@ -726,13 +726,13 @@ discard block |
||
726 | 726 | public function deleteLiveMarineDataById($id) |
727 | 727 | { |
728 | 728 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
729 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
729 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
730 | 730 | |
731 | 731 | try { |
732 | 732 | |
733 | 733 | $sth = $this->db->prepare($query); |
734 | 734 | $sth->execute(array(':id' => $id)); |
735 | - } catch(PDOException $e) { |
|
735 | + } catch (PDOException $e) { |
|
736 | 736 | return "error"; |
737 | 737 | } |
738 | 738 | |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | { |
751 | 751 | global $globalDBdriver, $globalTimezone; |
752 | 752 | if ($globalDBdriver == 'mysql') { |
753 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
753 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
754 | 754 | WHERE marine_live.ident = :ident |
755 | 755 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
756 | 756 | AND marine_live.date < UTC_TIMESTAMP()'; |
757 | 757 | $query_data = array(':ident' => $ident); |
758 | 758 | } else { |
759 | - $query = "SELECT marine_live.ident FROM marine_live |
|
759 | + $query = "SELECT marine_live.ident FROM marine_live |
|
760 | 760 | WHERE marine_live.ident = :ident |
761 | 761 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
762 | 762 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -765,8 +765,8 @@ discard block |
||
765 | 765 | |
766 | 766 | $sth = $this->db->prepare($query); |
767 | 767 | $sth->execute($query_data); |
768 | - $ident_result=''; |
|
769 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
768 | + $ident_result = ''; |
|
769 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
770 | 770 | { |
771 | 771 | $ident_result = $row['ident']; |
772 | 772 | } |
@@ -783,13 +783,13 @@ discard block |
||
783 | 783 | { |
784 | 784 | global $globalDBdriver, $globalTimezone; |
785 | 785 | if ($globalDBdriver == 'mysql') { |
786 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
786 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
787 | 787 | WHERE marine_live.ident = :ident |
788 | 788 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
789 | 789 | // AND marine_live.date < UTC_TIMESTAMP()"; |
790 | 790 | $query_data = array(':ident' => $ident); |
791 | 791 | } else { |
792 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
792 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
793 | 793 | WHERE marine_live.ident = :ident |
794 | 794 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
795 | 795 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -798,8 +798,8 @@ discard block |
||
798 | 798 | |
799 | 799 | $sth = $this->db->prepare($query); |
800 | 800 | $sth->execute($query_data); |
801 | - $ident_result=''; |
|
802 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
801 | + $ident_result = ''; |
|
802 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
803 | 803 | { |
804 | 804 | $ident_result = $row['fammarine_id']; |
805 | 805 | } |
@@ -816,13 +816,13 @@ discard block |
||
816 | 816 | { |
817 | 817 | global $globalDBdriver, $globalTimezone; |
818 | 818 | if ($globalDBdriver == 'mysql') { |
819 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
819 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
820 | 820 | WHERE marine_live.fammarine_id = :id |
821 | 821 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
822 | 822 | // AND marine_live.date < UTC_TIMESTAMP()"; |
823 | 823 | $query_data = array(':id' => $id); |
824 | 824 | } else { |
825 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
825 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
826 | 826 | WHERE marine_live.fammarine_id = :id |
827 | 827 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
828 | 828 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -831,8 +831,8 @@ discard block |
||
831 | 831 | |
832 | 832 | $sth = $this->db->prepare($query); |
833 | 833 | $sth->execute($query_data); |
834 | - $ident_result=''; |
|
835 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
834 | + $ident_result = ''; |
|
835 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
836 | 836 | { |
837 | 837 | $ident_result = $row['fammarine_id']; |
838 | 838 | } |
@@ -849,13 +849,13 @@ discard block |
||
849 | 849 | { |
850 | 850 | global $globalDBdriver, $globalTimezone; |
851 | 851 | if ($globalDBdriver == 'mysql') { |
852 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
852 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
853 | 853 | WHERE marine_live.mmsi = :mmsi |
854 | 854 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
855 | 855 | // AND marine_live.date < UTC_TIMESTAMP()"; |
856 | 856 | $query_data = array(':mmsi' => $mmsi); |
857 | 857 | } else { |
858 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
858 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
859 | 859 | WHERE marine_live.mmsi = :mmsi |
860 | 860 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
861 | 861 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -864,8 +864,8 @@ discard block |
||
864 | 864 | |
865 | 865 | $sth = $this->db->prepare($query); |
866 | 866 | $sth->execute($query_data); |
867 | - $ident_result=''; |
|
868 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
867 | + $ident_result = ''; |
|
868 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
869 | 869 | { |
870 | 870 | $ident_result = $row['fammarine_id']; |
871 | 871 | } |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | * @return String success or false |
884 | 884 | * |
885 | 885 | */ |
886 | - public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
886 | + public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
887 | 887 | { |
888 | 888 | global $globalURL, $globalArchive, $globalDebug; |
889 | 889 | $Common = new Common(); |
@@ -935,26 +935,26 @@ discard block |
||
935 | 935 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
936 | 936 | |
937 | 937 | |
938 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
939 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
940 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
941 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
942 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
943 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
944 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
945 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
946 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
947 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
948 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
949 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
950 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
951 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
952 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
953 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
938 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
939 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
940 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
941 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
942 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
943 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
944 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
945 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
946 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
947 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
948 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
949 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
950 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
951 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
952 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
953 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
954 | 954 | |
955 | 955 | |
956 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
956 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
957 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
958 | 958 | if ($arrival_date == '') $arrival_date = NULL; |
959 | 959 | $query = ''; |
960 | 960 | if ($globalArchive) { |
@@ -964,19 +964,19 @@ discard block |
||
964 | 964 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
965 | 965 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
966 | 966 | |
967 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
967 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
968 | 968 | try { |
969 | 969 | $sth = $this->db->prepare($query); |
970 | 970 | $sth->execute($query_values); |
971 | 971 | $sth->closeCursor(); |
972 | - } catch(PDOException $e) { |
|
972 | + } catch (PDOException $e) { |
|
973 | 973 | return "error : ".$e->getMessage(); |
974 | 974 | } |
975 | 975 | |
976 | 976 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
977 | 977 | if ($globalDebug) echo '(Add to Marine archive : '; |
978 | 978 | $MarineArchive = new MarineArchive($this->db); |
979 | - $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country); |
|
979 | + $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country); |
|
980 | 980 | if ($globalDebug) echo $result.')'; |
981 | 981 | } |
982 | 982 | return "success"; |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | |
985 | 985 | public function getOrderBy() |
986 | 986 | { |
987 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
987 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
988 | 988 | return $orderby; |
989 | 989 | } |
990 | 990 |
@@ -9,15 +9,15 @@ discard block |
||
9 | 9 | |
10 | 10 | $from_archive = false; |
11 | 11 | if (isset($_GET['ident'])) { |
12 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
12 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
13 | 13 | if (isset($_GET['currenttime'])) { |
14 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
14 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
15 | 15 | $currenttime = round($currenttime/1000); |
16 | - $spotter_array = $MarineLive->getDateLiveMarineDataByIdent($ident,$currenttime); |
|
16 | + $spotter_array = $MarineLive->getDateLiveMarineDataByIdent($ident, $currenttime); |
|
17 | 17 | |
18 | 18 | if (empty($spotter_array)) { |
19 | 19 | $from_archive = true; |
20 | - $spotter_array = $MarineArchive->getDateArchiveMarineDataByIdent($ident,$currenttime); |
|
20 | + $spotter_array = $MarineArchive->getDateArchiveMarineDataByIdent($ident, $currenttime); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | } else { |
@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | } |
32 | 32 | } |
33 | 33 | if (isset($_GET['fammarine_id'])) { |
34 | - $fammarine_id = filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING); |
|
34 | + $fammarine_id = filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING); |
|
35 | 35 | if (isset($_GET['currenttime'])) { |
36 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
36 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
37 | 37 | $currenttime = round($currenttime/1000); |
38 | - $spotter_array = $MarineLive->getDateLiveMarineDataById($fammarine_id,$currenttime); |
|
38 | + $spotter_array = $MarineLive->getDateLiveMarineDataById($fammarine_id, $currenttime); |
|
39 | 39 | |
40 | 40 | if (empty($spotter_array)) { |
41 | 41 | $from_archive = true; |
42 | 42 | // $spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id); |
43 | - $spotter_array = $MarineArchive->getDateArchiveMarineDataById($flightaware_id,$currenttime); |
|
43 | + $spotter_array = $MarineArchive->getDateArchiveMarineDataById($flightaware_id, $currenttime); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | } else { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "") |
63 | 63 | { |
64 | 64 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
65 | - $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
65 | + $image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
66 | 66 | } else $image = $spotter_item['image_thumbnail']; |
67 | 67 | |
68 | 68 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | public $db; |
11 | 11 | public $SI; |
12 | 12 | private $fromACARSscript = false; |
13 | - public function __construct($dbc = null,$fromACARSscript = false) { |
|
13 | + public function __construct($dbc = null, $fromACARSscript = false) { |
|
14 | 14 | $Connection = new Connection($dbc); |
15 | 15 | $this->db = $Connection->db(); |
16 | 16 | if ($this->db === null) die('Error: No DB connection. (ACARS)'); |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | * @return String the icao |
27 | 27 | */ |
28 | 28 | public function ident2icao($ident) { |
29 | - if (substr($ident,0,2) == 'AF') { |
|
30 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
31 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
29 | + if (substr($ident, 0, 2) == 'AF') { |
|
30 | + if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
31 | + else $icao = 'AFR'.ltrim(substr($ident, 2), '0'); |
|
32 | 32 | } else { |
33 | 33 | $Spotter = new Spotter($this->db); |
34 | - $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
|
34 | + $identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2)); |
|
35 | 35 | if (isset($identicao[0])) { |
36 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
36 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
37 | 37 | } else $icao = $ident; |
38 | 38 | } |
39 | 39 | return $icao; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | $sth = $this->db->prepare($query); |
59 | 59 | $sth->execute(); |
60 | - } catch(PDOException $e) { |
|
60 | + } catch (PDOException $e) { |
|
61 | 61 | return "error"; |
62 | 62 | } |
63 | 63 | return "success"; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | $sth = $this->db->prepare($query); |
83 | 83 | $sth->execute(); |
84 | - } catch(PDOException $e) { |
|
84 | + } catch (PDOException $e) { |
|
85 | 85 | return "error"; |
86 | 86 | } |
87 | 87 | return "success"; |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | $ident = ''; |
107 | 107 | $message = ''; |
108 | 108 | $result = array(); |
109 | - $n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
110 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
111 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
112 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
109 | + $n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
110 | + if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
111 | + if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
112 | + if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
113 | 113 | if ($n != 0) { |
114 | - $registration = str_replace('.','',$registration); |
|
115 | - $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
|
114 | + $registration = str_replace('.', '', $registration); |
|
115 | + $result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message); |
|
116 | 116 | if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
117 | 117 | } else $message = $data; |
118 | 118 | $decode = array(); |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | $temp = ''; |
133 | 133 | $n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp); |
134 | 134 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
135 | - $latitude = $la / 10000.0; |
|
136 | - $longitude = $ln / 10000.0; |
|
135 | + $latitude = $la/10000.0; |
|
136 | + $longitude = $ln/10000.0; |
|
137 | 137 | if ($lac == 'S') $latitude = '-'.$latitude; |
138 | 138 | if ($lnc == 'W') $longitude = '-'.$longitude; |
139 | 139 | // Temp not always available |
140 | 140 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
141 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
142 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
141 | + if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt); |
|
142 | + else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C'); |
|
143 | 143 | |
144 | 144 | //$icao = $Translation->checkTranslation($ident); |
145 | 145 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -151,19 +151,19 @@ discard block |
||
151 | 151 | $dhour = ''; |
152 | 152 | $darr = ''; |
153 | 153 | $ahour = ''; |
154 | - $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
|
154 | + $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour); |
|
155 | 155 | if ($n == 4 && strlen($darr) == 4) { |
156 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
157 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
158 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
156 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
157 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
158 | + if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n"; |
|
159 | 159 | //$icao = ACARS->ident2icao($ident); |
160 | 160 | //$icao = $Translation->checkTranslation($ident); |
161 | 161 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
162 | 162 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
163 | 163 | $found = true; |
164 | 164 | } |
165 | - elseif ($n == 2 || $n == 4) { |
|
166 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
165 | + elseif ($n == 2 || $n == 4) { |
|
166 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
167 | 167 | if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
168 | 168 | //$icao = ACARS->ident2icao($ident); |
169 | 169 | //$icao = $Translation->checkTranslation($ident); |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | $ahour = ''; |
222 | 222 | $aair = ''; |
223 | 223 | $apiste = ''; |
224 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
|
224 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste); |
|
225 | 225 | if ($n > 8) { |
226 | - if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
227 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
228 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
226 | + if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
227 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
228 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
229 | 229 | $icao = trim($aident); |
230 | 230 | |
231 | 231 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
251 | 251 | $las = $las.'.'.$lass; |
252 | 252 | $lns = $lns.'.'.$lns; |
253 | - $latitude = $las / 1000.0; |
|
254 | - $longitude = $lns / 1000.0; |
|
253 | + $latitude = $las/1000.0; |
|
254 | + $longitude = $lns/1000.0; |
|
255 | 255 | if ($lac == 'S') $latitude = '-'.$latitude; |
256 | 256 | if ($lnc == 'W') $longitude = '-'.$longitude; |
257 | 257 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
@@ -346,17 +346,17 @@ discard block |
||
346 | 346 | $alt = ''; |
347 | 347 | $fuel = ''; |
348 | 348 | $speed = ''; |
349 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
349 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
350 | 350 | if ($n == 9) { |
351 | 351 | //if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
352 | 352 | $icao = trim($aident); |
353 | 353 | $decode['icao'] = $icao; |
354 | - $latitude = $las / 100.0; |
|
355 | - $longitude = $lns / 100.0; |
|
354 | + $latitude = $las/100.0; |
|
355 | + $longitude = $lns/100.0; |
|
356 | 356 | if ($lac == 'S') $latitude = '-'.$latitude; |
357 | 357 | if ($lnc == 'W') $longitude = '-'.$longitude; |
358 | 358 | |
359 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
|
359 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed); |
|
360 | 360 | $found = true; |
361 | 361 | } |
362 | 362 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | if ($lac == 'S') $latitude = '-'.$latitude; |
376 | 376 | if ($lnc == 'W') $longitude = '-'.$longitude; |
377 | 377 | |
378 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
|
378 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
|
379 | 379 | $found = true; |
380 | 380 | } |
381 | 381 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | $dair = ''; |
409 | 409 | $darr = ''; |
410 | 410 | $aident = ''; |
411 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
411 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
412 | 412 | if ($n == 8) { |
413 | 413 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
414 | 414 | $icao = trim($aident); |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | */ |
441 | 441 | $dair = ''; |
442 | 442 | $darr = ''; |
443 | - $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
|
443 | + $n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr); |
|
444 | 444 | if ($n == 3) { |
445 | 445 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
446 | 446 | //$icao = $Translation->checkTranslation($ident); |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | */ |
456 | 456 | $dair = ''; |
457 | 457 | $darr = ''; |
458 | - $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
|
458 | + $n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr); |
|
459 | 459 | if ($n == 3) { |
460 | 460 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
461 | 461 | //$icao = $Translation->checkTranslation($ident); |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | } |
466 | 466 | } |
467 | 467 | if (!$found) { |
468 | - $n = sscanf($message,'MET01%4c',$airport); |
|
468 | + $n = sscanf($message, 'MET01%4c', $airport); |
|
469 | 469 | if ($n == 1) { |
470 | 470 | if ($globalDebug) echo 'airport name : '.$airport; |
471 | 471 | $decode = array('Airport/Waypoint name' => $airport); |
@@ -473,241 +473,241 @@ discard block |
||
473 | 473 | } |
474 | 474 | } |
475 | 475 | if ($label == 'H1') { |
476 | - if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
|
477 | - $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
|
476 | + if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) { |
|
477 | + $decode = array_merge(array('Message nature' => 'Equipment failure'), $decode); |
|
478 | 478 | } |
479 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
480 | - $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
|
479 | + elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) { |
|
480 | + $decode = array_merge(array('Message nature' => 'Take off performance data'), $decode); |
|
481 | 481 | } |
482 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
483 | - $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
|
482 | + elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) { |
|
483 | + $decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode); |
|
484 | 484 | } |
485 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
486 | - $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
|
485 | + elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) { |
|
486 | + $decode = array_merge(array('Message nature' => 'Weather observation'), $decode); |
|
487 | 487 | } |
488 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
489 | - $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
|
488 | + elseif (preg_match(':^#DFB/PIREP:', $message)) { |
|
489 | + $decode = array_merge(array('Message nature' => 'Pilot Report'), $decode); |
|
490 | 490 | } |
491 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
492 | - $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
|
491 | + elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) { |
|
492 | + $decode = array_merge(array('Message nature' => 'Engine Data'), $decode); |
|
493 | 493 | } |
494 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
495 | - $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
|
494 | + elseif (preg_match(':^#M1AAEP:', $message)) { |
|
495 | + $decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode); |
|
496 | 496 | } |
497 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
498 | - $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
|
497 | + elseif (preg_match(':^#M2APWD:', $message)) { |
|
498 | + $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode); |
|
499 | 499 | } |
500 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
501 | - $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
|
500 | + elseif (preg_match(':^#M1BREQPWI:', $message)) { |
|
501 | + $decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode); |
|
502 | 502 | } |
503 | - elseif (preg_match(':^#CF:',$message)) { |
|
504 | - $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
|
503 | + elseif (preg_match(':^#CF:', $message)) { |
|
504 | + $decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode); |
|
505 | 505 | } |
506 | - elseif (preg_match(':^#DF:',$message)) { |
|
507 | - $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
|
506 | + elseif (preg_match(':^#DF:', $message)) { |
|
507 | + $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode); |
|
508 | 508 | } |
509 | - elseif (preg_match(':^#EC:',$message)) { |
|
510 | - $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
|
509 | + elseif (preg_match(':^#EC:', $message)) { |
|
510 | + $decode = array_merge(array('Message nature' => 'Engine Display System'), $decode); |
|
511 | 511 | } |
512 | - elseif (preg_match(':^#EI:',$message)) { |
|
513 | - $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
|
512 | + elseif (preg_match(':^#EI:', $message)) { |
|
513 | + $decode = array_merge(array('Message nature' => 'Engine Report'), $decode); |
|
514 | 514 | } |
515 | - elseif (preg_match(':^#H1:',$message)) { |
|
516 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
|
515 | + elseif (preg_match(':^#H1:', $message)) { |
|
516 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode); |
|
517 | 517 | } |
518 | - elseif (preg_match(':^#H2:',$message)) { |
|
519 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
|
518 | + elseif (preg_match(':^#H2:', $message)) { |
|
519 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode); |
|
520 | 520 | } |
521 | - elseif (preg_match(':^#HD:',$message)) { |
|
522 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
|
521 | + elseif (preg_match(':^#HD:', $message)) { |
|
522 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode); |
|
523 | 523 | } |
524 | - elseif (preg_match(':^#M1:',$message)) { |
|
525 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
|
524 | + elseif (preg_match(':^#M1:', $message)) { |
|
525 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode); |
|
526 | 526 | } |
527 | - elseif (preg_match(':^#M2:',$message)) { |
|
528 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
|
527 | + elseif (preg_match(':^#M2:', $message)) { |
|
528 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode); |
|
529 | 529 | } |
530 | - elseif (preg_match(':^#M3:',$message)) { |
|
531 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
|
530 | + elseif (preg_match(':^#M3:', $message)) { |
|
531 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode); |
|
532 | 532 | } |
533 | - elseif (preg_match(':^#MD:',$message)) { |
|
534 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
|
533 | + elseif (preg_match(':^#MD:', $message)) { |
|
534 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode); |
|
535 | 535 | } |
536 | - elseif (preg_match(':^#PS:',$message)) { |
|
537 | - $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
|
536 | + elseif (preg_match(':^#PS:', $message)) { |
|
537 | + $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode); |
|
538 | 538 | } |
539 | - elseif (preg_match(':^#S1:',$message)) { |
|
540 | - $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
|
539 | + elseif (preg_match(':^#S1:', $message)) { |
|
540 | + $decode = array_merge(array('Message nature' => 'SDU - Left'), $decode); |
|
541 | 541 | } |
542 | - elseif (preg_match(':^#S2:',$message)) { |
|
543 | - $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
|
542 | + elseif (preg_match(':^#S2:', $message)) { |
|
543 | + $decode = array_merge(array('Message nature' => 'SDU - Right'), $decode); |
|
544 | 544 | } |
545 | - elseif (preg_match(':^#SD:',$message)) { |
|
546 | - $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
|
545 | + elseif (preg_match(':^#SD:', $message)) { |
|
546 | + $decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode); |
|
547 | 547 | } |
548 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
549 | - $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
|
548 | + elseif (preg_match(':^#T[0-8]:', $message)) { |
|
549 | + $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode); |
|
550 | 550 | } |
551 | - elseif (preg_match(':^#WO:',$message)) { |
|
552 | - $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
|
551 | + elseif (preg_match(':^#WO:', $message)) { |
|
552 | + $decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode); |
|
553 | 553 | } |
554 | - elseif (preg_match(':^#A1:',$message)) { |
|
555 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
|
554 | + elseif (preg_match(':^#A1:', $message)) { |
|
555 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode); |
|
556 | 556 | } |
557 | - elseif (preg_match(':^#A3:',$message)) { |
|
558 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
|
557 | + elseif (preg_match(':^#A3:', $message)) { |
|
558 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode); |
|
559 | 559 | } |
560 | - elseif (preg_match(':^#A4:',$message)) { |
|
561 | - $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
|
560 | + elseif (preg_match(':^#A4:', $message)) { |
|
561 | + $decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode); |
|
562 | 562 | } |
563 | - elseif (preg_match(':^#A6:',$message)) { |
|
564 | - $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
|
563 | + elseif (preg_match(':^#A6:', $message)) { |
|
564 | + $decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode); |
|
565 | 565 | } |
566 | - elseif (preg_match(':^#A8:',$message)) { |
|
567 | - $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
|
566 | + elseif (preg_match(':^#A8:', $message)) { |
|
567 | + $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode); |
|
568 | 568 | } |
569 | - elseif (preg_match(':^#A9:',$message)) { |
|
570 | - $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
|
569 | + elseif (preg_match(':^#A9:', $message)) { |
|
570 | + $decode = array_merge(array('Message nature' => 'ATIS report'), $decode); |
|
571 | 571 | } |
572 | - elseif (preg_match(':^#A0:',$message)) { |
|
573 | - $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
|
572 | + elseif (preg_match(':^#A0:', $message)) { |
|
573 | + $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode); |
|
574 | 574 | } |
575 | - elseif (preg_match(':^#AA:',$message)) { |
|
576 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
575 | + elseif (preg_match(':^#AA:', $message)) { |
|
576 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
577 | 577 | } |
578 | - elseif (preg_match(':^#AB:',$message)) { |
|
579 | - $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
|
578 | + elseif (preg_match(':^#AB:', $message)) { |
|
579 | + $decode = array_merge(array('Message nature' => 'TWIP Report'), $decode); |
|
580 | 580 | } |
581 | - elseif (preg_match(':^#AC:',$message)) { |
|
582 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
|
581 | + elseif (preg_match(':^#AC:', $message)) { |
|
582 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode); |
|
583 | 583 | } |
584 | - elseif (preg_match(':^#AD:',$message)) { |
|
585 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
|
584 | + elseif (preg_match(':^#AD:', $message)) { |
|
585 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode); |
|
586 | 586 | } |
587 | - elseif (preg_match(':^#AF:',$message)) { |
|
588 | - $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
|
587 | + elseif (preg_match(':^#AF:', $message)) { |
|
588 | + $decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode); |
|
589 | 589 | } |
590 | - elseif (preg_match(':^#B1:',$message)) { |
|
591 | - $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
|
590 | + elseif (preg_match(':^#B1:', $message)) { |
|
591 | + $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode); |
|
592 | 592 | } |
593 | - elseif (preg_match(':^#B2:',$message)) { |
|
594 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
|
593 | + elseif (preg_match(':^#B2:', $message)) { |
|
594 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode); |
|
595 | 595 | } |
596 | - elseif (preg_match(':^#B3:',$message)) { |
|
597 | - $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
|
596 | + elseif (preg_match(':^#B3:', $message)) { |
|
597 | + $decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode); |
|
598 | 598 | } |
599 | - elseif (preg_match(':^#B4:',$message)) { |
|
600 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
|
599 | + elseif (preg_match(':^#B4:', $message)) { |
|
600 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode); |
|
601 | 601 | } |
602 | - elseif (preg_match(':^#B6:',$message)) { |
|
603 | - $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
|
602 | + elseif (preg_match(':^#B6:', $message)) { |
|
603 | + $decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode); |
|
604 | 604 | } |
605 | - elseif (preg_match(':^#B8:',$message)) { |
|
606 | - $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
|
605 | + elseif (preg_match(':^#B8:', $message)) { |
|
606 | + $decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode); |
|
607 | 607 | } |
608 | - elseif (preg_match(':^#B9:',$message)) { |
|
609 | - $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
|
608 | + elseif (preg_match(':^#B9:', $message)) { |
|
609 | + $decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode); |
|
610 | 610 | } |
611 | - elseif (preg_match(':^#B0:',$message)) { |
|
612 | - $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
|
611 | + elseif (preg_match(':^#B0:', $message)) { |
|
612 | + $decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode); |
|
613 | 613 | } |
614 | - elseif (preg_match(':^#BA:',$message)) { |
|
615 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
614 | + elseif (preg_match(':^#BA:', $message)) { |
|
615 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
616 | 616 | } |
617 | - elseif (preg_match(':^#BB:',$message)) { |
|
618 | - $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
|
617 | + elseif (preg_match(':^#BB:', $message)) { |
|
618 | + $decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode); |
|
619 | 619 | } |
620 | - elseif (preg_match(':^#BC:',$message)) { |
|
621 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
|
620 | + elseif (preg_match(':^#BC:', $message)) { |
|
621 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode); |
|
622 | 622 | } |
623 | - elseif (preg_match(':^#BD:',$message)) { |
|
624 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
|
623 | + elseif (preg_match(':^#BD:', $message)) { |
|
624 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode); |
|
625 | 625 | } |
626 | - elseif (preg_match(':^#BE:',$message)) { |
|
627 | - $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
|
626 | + elseif (preg_match(':^#BE:', $message)) { |
|
627 | + $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode); |
|
628 | 628 | } |
629 | - elseif (preg_match(':^#BF:',$message)) { |
|
630 | - $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
|
629 | + elseif (preg_match(':^#BF:', $message)) { |
|
630 | + $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode); |
|
631 | 631 | } |
632 | - elseif (preg_match(':^#H3:',$message)) { |
|
633 | - $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
|
632 | + elseif (preg_match(':^#H3:', $message)) { |
|
633 | + $decode = array_merge(array('Message nature' => 'Icing Report'), $decode); |
|
634 | 634 | } |
635 | 635 | } |
636 | 636 | if ($label == '10') { |
637 | - if (preg_match(':^DTO01:',$message)) { |
|
638 | - $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
|
637 | + if (preg_match(':^DTO01:', $message)) { |
|
638 | + $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode); |
|
639 | 639 | } |
640 | - elseif (preg_match(':^AIS01:',$message)) { |
|
641 | - $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
|
640 | + elseif (preg_match(':^AIS01:', $message)) { |
|
641 | + $decode = array_merge(array('Message nature' => 'AIS Request'), $decode); |
|
642 | 642 | } |
643 | - elseif (preg_match(':^FTX01:',$message)) { |
|
644 | - $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
|
643 | + elseif (preg_match(':^FTX01:', $message)) { |
|
644 | + $decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode); |
|
645 | 645 | } |
646 | - elseif (preg_match(':^FPL01:',$message)) { |
|
647 | - $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
|
646 | + elseif (preg_match(':^FPL01:', $message)) { |
|
647 | + $decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode); |
|
648 | 648 | } |
649 | - elseif (preg_match(':^WAB01:',$message)) { |
|
650 | - $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
|
649 | + elseif (preg_match(':^WAB01:', $message)) { |
|
650 | + $decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode); |
|
651 | 651 | } |
652 | - elseif (preg_match(':^MET01:',$message)) { |
|
653 | - $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
|
652 | + elseif (preg_match(':^MET01:', $message)) { |
|
653 | + $decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode); |
|
654 | 654 | } |
655 | - elseif (preg_match(':^WAB02:',$message)) { |
|
656 | - $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
|
655 | + elseif (preg_match(':^WAB02:', $message)) { |
|
656 | + $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode); |
|
657 | 657 | } |
658 | 658 | } |
659 | 659 | if ($label == '15') { |
660 | - if (preg_match(':^FST01:',$message)) { |
|
661 | - $decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode); |
|
660 | + if (preg_match(':^FST01:', $message)) { |
|
661 | + $decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode); |
|
662 | 662 | } |
663 | 663 | } |
664 | 664 | if (!$found && $label == 'SA') { |
665 | - $n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at); |
|
665 | + $n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at); |
|
666 | 666 | if ($n == 4) { |
667 | 667 | $vsta = array('Version' => $version); |
668 | 668 | if ($state == 'E') { |
669 | - $vsta = array_merge($vsta,array('Link state' => 'Established')); |
|
669 | + $vsta = array_merge($vsta, array('Link state' => 'Established')); |
|
670 | 670 | } |
671 | 671 | elseif ($state == 'L') { |
672 | - $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
|
672 | + $vsta = array_merge($vsta, array('Link state' => 'Lost')); |
|
673 | 673 | } |
674 | 674 | else { |
675 | - $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
|
675 | + $vsta = array_merge($vsta, array('Link state' => 'Unknown')); |
|
676 | 676 | } |
677 | 677 | if ($type == 'V') { |
678 | - $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
|
678 | + $vsta = array_merge($vsta, array('Link type' => 'VHF ACARS')); |
|
679 | 679 | } |
680 | 680 | elseif ($type == 'S') { |
681 | - $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
|
681 | + $vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM')); |
|
682 | 682 | } |
683 | 683 | elseif ($type == 'H') { |
684 | - $vsta = array_merge($vsta,array('Link type' => 'HF')); |
|
684 | + $vsta = array_merge($vsta, array('Link type' => 'HF')); |
|
685 | 685 | } |
686 | 686 | elseif ($type == 'G') { |
687 | - $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
|
687 | + $vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM')); |
|
688 | 688 | } |
689 | 689 | elseif ($type == 'C') { |
690 | - $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
|
690 | + $vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM')); |
|
691 | 691 | } |
692 | 692 | elseif ($type == '2') { |
693 | - $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
|
693 | + $vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2')); |
|
694 | 694 | } |
695 | 695 | elseif ($type == 'X') { |
696 | - $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
|
696 | + $vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero')); |
|
697 | 697 | } |
698 | 698 | elseif ($type == 'I') { |
699 | - $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
|
699 | + $vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM')); |
|
700 | 700 | } |
701 | 701 | else { |
702 | - $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
|
702 | + $vsta = array_merge($vsta, array('Link type' => 'Unknown')); |
|
703 | 703 | } |
704 | - $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
|
705 | - $decode = array_merge($vsta,$decode); |
|
704 | + $vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2)))); |
|
705 | + $decode = array_merge($vsta, $decode); |
|
706 | 706 | } |
707 | 707 | } |
708 | 708 | |
709 | 709 | $title = $this->getTitlefromLabel($label); |
710 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
710 | + if ($title != '') $decode = array_merge(array('Message title' => $title), $decode); |
|
711 | 711 | /* |
712 | 712 | // Business jets always use GS0001 |
713 | 713 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -735,13 +735,13 @@ discard block |
||
735 | 735 | $Translation = new Translation($this->db); |
736 | 736 | $message = $this->parse($data); |
737 | 737 | if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') { |
738 | - $ident = (string)$message['ident']; |
|
738 | + $ident = (string) $message['ident']; |
|
739 | 739 | $label = $message['label']; |
740 | 740 | $block_id = $message['block_id']; |
741 | 741 | $msg_no = $message['msg_no']; |
742 | 742 | $msg = $message['message']; |
743 | 743 | $decode = $message['decode']; |
744 | - $registration = (string)$message['registration']; |
|
744 | + $registration = (string) $message['registration']; |
|
745 | 745 | if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
746 | 746 | else $latitude = ''; |
747 | 747 | if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
@@ -755,20 +755,20 @@ discard block |
||
755 | 755 | $Image->addSpotterImage($registration); |
756 | 756 | } |
757 | 757 | // Business jets always use GS0001 |
758 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
758 | + if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude); |
|
759 | 759 | if ($globalDebug && isset($info) && $info != '') echo $info; |
760 | 760 | if (count($decode) > 0) $decode_json = json_encode($decode); |
761 | 761 | else $decode_json = ''; |
762 | 762 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
763 | - $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
|
763 | + $Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS'); |
|
764 | 764 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
765 | - $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
|
765 | + $Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS'); |
|
766 | 766 | } |
767 | - $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
768 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
769 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
767 | + $result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
768 | + if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F'); |
|
769 | + if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
770 | 770 | if ($globalDebug && count($decode) > 0) { |
771 | - echo "Human readable data : ".implode(' - ',$decode)."\n"; |
|
771 | + echo "Human readable data : ".implode(' - ', $decode)."\n"; |
|
772 | 772 | } |
773 | 773 | } |
774 | 774 | } |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | * @param String $msg_no Number of the ACARS message |
784 | 784 | * @param String $message ACARS message |
785 | 785 | */ |
786 | - public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
786 | + public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
787 | 787 | global $globalDebug; |
788 | 788 | date_default_timezone_set('UTC'); |
789 | 789 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
@@ -791,21 +791,21 @@ discard block |
||
791 | 791 | $this->db = $Connection->db; |
792 | 792 | if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
793 | 793 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
794 | - $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
|
794 | + $query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message); |
|
795 | 795 | try { |
796 | 796 | $stht = $this->db->prepare($query_test); |
797 | 797 | $stht->execute($query_test_values); |
798 | - } catch(PDOException $e) { |
|
798 | + } catch (PDOException $e) { |
|
799 | 799 | return "error : ".$e->getMessage(); |
800 | 800 | } |
801 | 801 | if ($stht->fetchColumn() == 0) { |
802 | 802 | if ($globalDebug) echo "Add Live ACARS data..."; |
803 | 803 | $query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)"; |
804 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s")); |
|
804 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s")); |
|
805 | 805 | try { |
806 | 806 | $sth = $this->db->prepare($query); |
807 | 807 | $sth->execute($query_values); |
808 | - } catch(PDOException $e) { |
|
808 | + } catch (PDOException $e) { |
|
809 | 809 | return "error : ".$e->getMessage(); |
810 | 810 | } |
811 | 811 | } else { |
@@ -827,10 +827,10 @@ discard block |
||
827 | 827 | * @param String $msg_no Number of the ACARS message |
828 | 828 | * @param String $message ACARS message |
829 | 829 | */ |
830 | - public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
830 | + public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
831 | 831 | global $globalDebug; |
832 | 832 | date_default_timezone_set('UTC'); |
833 | - if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) { |
|
833 | + if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) { |
|
834 | 834 | /* |
835 | 835 | if ($globalDebug) echo "Test if not already in Archive ACARS table..."; |
836 | 836 | $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message"; |
@@ -845,11 +845,11 @@ discard block |
||
845 | 845 | */ |
846 | 846 | if ($globalDebug) echo "Add Live ACARS data..."; |
847 | 847 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
848 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
848 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
849 | 849 | try { |
850 | 850 | $sth = $this->db->prepare($query); |
851 | 851 | $sth->execute($query_values); |
852 | - } catch(PDOException $e) { |
|
852 | + } catch (PDOException $e) { |
|
853 | 853 | return "error : ".$e->getMessage(); |
854 | 854 | } |
855 | 855 | if ($globalDebug) echo "Done\n"; |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | try { |
871 | 871 | $sth = $this->db->prepare($query); |
872 | 872 | $sth->execute($query_values); |
873 | - } catch(PDOException $e) { |
|
873 | + } catch (PDOException $e) { |
|
874 | 874 | echo "error : ".$e->getMessage(); |
875 | 875 | return ''; |
876 | 876 | } |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | try { |
891 | 891 | $sth = $this->db->prepare($query); |
892 | 892 | $sth->execute($query_values); |
893 | - } catch(PDOException $e) { |
|
893 | + } catch (PDOException $e) { |
|
894 | 894 | echo "error : ".$e->getMessage(); |
895 | 895 | return array(); |
896 | 896 | } |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | try { |
912 | 912 | $sth = $this->db->prepare($query); |
913 | 913 | $sth->execute($query_values); |
914 | - } catch(PDOException $e) { |
|
914 | + } catch (PDOException $e) { |
|
915 | 915 | echo "error : ".$e->getMessage(); |
916 | 916 | return array(); |
917 | 917 | } |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | * |
926 | 926 | * @return Array Return ACARS data in array |
927 | 927 | */ |
928 | - public function getLatestAcarsData($limit = '',$label = '') { |
|
928 | + public function getLatestAcarsData($limit = '', $label = '') { |
|
929 | 929 | global $globalURL, $globalDBdriver; |
930 | 930 | $Image = new Image($this->db); |
931 | 931 | $Spotter = new Spotter($this->db); |
@@ -936,8 +936,8 @@ discard block |
||
936 | 936 | if ($limit != "") |
937 | 937 | { |
938 | 938 | $limit_array = explode(",", $limit); |
939 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
940 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
939 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
940 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
941 | 941 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
942 | 942 | { |
943 | 943 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -953,46 +953,46 @@ discard block |
||
953 | 953 | try { |
954 | 954 | $sth = $this->db->prepare($query); |
955 | 955 | $sth->execute($query_values); |
956 | - } catch(PDOException $e) { |
|
956 | + } catch (PDOException $e) { |
|
957 | 957 | return "error : ".$e->getMessage(); |
958 | 958 | } |
959 | 959 | $i = 0; |
960 | 960 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
961 | 961 | $data = array(); |
962 | 962 | if ($row['registration'] != '') { |
963 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
963 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
964 | 964 | $image_array = $Image->getSpotterImage($row['registration']); |
965 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
966 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
967 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
965 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
966 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
967 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
968 | 968 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
969 | 969 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
970 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
970 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
971 | 971 | if (isset($identicao[0])) { |
972 | - if (substr($row['ident'],0,2) == 'AF') { |
|
973 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
974 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
975 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
976 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
972 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
973 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
974 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
975 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
976 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
977 | 977 | } else $icao = $row['ident']; |
978 | - $icao = $Translation->checkTranslation($icao,false); |
|
979 | - $decode = json_decode($row['decode'],true); |
|
978 | + $icao = $Translation->checkTranslation($icao, false); |
|
979 | + $decode = json_decode($row['decode'], true); |
|
980 | 980 | $found = false; |
981 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
981 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
982 | 982 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
983 | 983 | if (isset($airport_info[0]['icao'])) { |
984 | 984 | $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
985 | 985 | $found = true; |
986 | 986 | } |
987 | 987 | } |
988 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
988 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
989 | 989 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
990 | 990 | if (isset($airport_info[0]['icao'])) { |
991 | 991 | $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
992 | 992 | $found = true; |
993 | 993 | } |
994 | 994 | } |
995 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
995 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
996 | 996 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
997 | 997 | if (isset($airport_info[0]['icao'])) { |
998 | 998 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | } |
1001 | 1001 | } |
1002 | 1002 | if ($found) $row['decode'] = json_encode($decode); |
1003 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1003 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1004 | 1004 | $result[] = $data; |
1005 | 1005 | $i++; |
1006 | 1006 | } |
@@ -1016,7 +1016,7 @@ discard block |
||
1016 | 1016 | * |
1017 | 1017 | * @return Array Return ACARS data in array |
1018 | 1018 | */ |
1019 | - public function getArchiveAcarsData($limit = '',$label = '') { |
|
1019 | + public function getArchiveAcarsData($limit = '', $label = '') { |
|
1020 | 1020 | global $globalURL, $globalDBdriver; |
1021 | 1021 | $Image = new Image($this->db); |
1022 | 1022 | $Spotter = new Spotter($this->db); |
@@ -1026,8 +1026,8 @@ discard block |
||
1026 | 1026 | if ($limit != "") |
1027 | 1027 | { |
1028 | 1028 | $limit_array = explode(",", $limit); |
1029 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1030 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1029 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1030 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1031 | 1031 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1032 | 1032 | { |
1033 | 1033 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1048,43 +1048,43 @@ discard block |
||
1048 | 1048 | try { |
1049 | 1049 | $sth = $this->db->prepare($query); |
1050 | 1050 | $sth->execute($query_values); |
1051 | - } catch(PDOException $e) { |
|
1051 | + } catch (PDOException $e) { |
|
1052 | 1052 | return "error : ".$e->getMessage(); |
1053 | 1053 | } |
1054 | - $i=0; |
|
1054 | + $i = 0; |
|
1055 | 1055 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
1056 | 1056 | $data = array(); |
1057 | 1057 | if ($row['registration'] != '') { |
1058 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
1058 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
1059 | 1059 | $image_array = $Image->getSpotterImage($row['registration']); |
1060 | - if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
1061 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1062 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1060 | + if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
1061 | + else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1062 | + } else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1063 | 1063 | $icao = ''; |
1064 | 1064 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
1065 | 1065 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
1066 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
1066 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
1067 | 1067 | if (isset($identicao[0])) { |
1068 | - if (substr($row['ident'],0,2) == 'AF') { |
|
1069 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1070 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1071 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1072 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
1068 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
1069 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1070 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
1071 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
1072 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
1073 | 1073 | } else $icao = $row['ident']; |
1074 | 1074 | $icao = $Translation->checkTranslation($icao); |
1075 | - $decode = json_decode($row['decode'],true); |
|
1075 | + $decode = json_decode($row['decode'], true); |
|
1076 | 1076 | $found = false; |
1077 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
1077 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
1078 | 1078 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1079 | 1079 | if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1080 | 1080 | $found = true; |
1081 | 1081 | } |
1082 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
1082 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
1083 | 1083 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1084 | 1084 | if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1085 | 1085 | $found = true; |
1086 | 1086 | } |
1087 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
1087 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
1088 | 1088 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
1089 | 1089 | if (isset($airport_info[0]['icao'])) { |
1090 | 1090 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1092,7 +1092,7 @@ discard block |
||
1092 | 1092 | } |
1093 | 1093 | } |
1094 | 1094 | if ($found) $row['decode'] = json_encode($decode); |
1095 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1095 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1096 | 1096 | $result[] = $data; |
1097 | 1097 | $i++; |
1098 | 1098 | } |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | * @param String $icao |
1111 | 1111 | * @param String $ICAOTypeCode |
1112 | 1112 | */ |
1113 | - public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
|
1113 | + public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') { |
|
1114 | 1114 | global $globalDebug, $globalDBdriver; |
1115 | 1115 | $ident = trim($ident); |
1116 | 1116 | $Translation = new Translation($this->db); |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | if ($globalDebug) echo "Ident or registration null, exit\n"; |
1124 | 1124 | return ''; |
1125 | 1125 | } |
1126 | - $registration = str_replace('.','',$registration); |
|
1126 | + $registration = str_replace('.', '', $registration); |
|
1127 | 1127 | $ident = $Translation->ident2icao($ident); |
1128 | 1128 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1129 | 1129 | if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | try { |
1133 | 1133 | $sthsi = $this->db->prepare($querysi); |
1134 | 1134 | $sthsi->execute($querysi_values); |
1135 | - } catch(PDOException $e) { |
|
1135 | + } catch (PDOException $e) { |
|
1136 | 1136 | if ($globalDebug) echo $e->getMessage(); |
1137 | 1137 | return "error : ".$e->getMessage(); |
1138 | 1138 | } |
@@ -1142,8 +1142,8 @@ discard block |
||
1142 | 1142 | $Translation = new Translation($this->db); |
1143 | 1143 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1144 | 1144 | if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
1145 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1146 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1145 | + if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1146 | + elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1147 | 1147 | } else { |
1148 | 1148 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1149 | 1149 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | try { |
1152 | 1152 | $sth = $this->db->prepare($query); |
1153 | 1153 | $sth->execute($query_values); |
1154 | - } catch(PDOException $e) { |
|
1154 | + } catch (PDOException $e) { |
|
1155 | 1155 | if ($globalDebug) echo $e->getMessage(); |
1156 | 1156 | return "error : ".$e->getMessage(); |
1157 | 1157 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | $sth->closeCursor(); |
1160 | 1160 | if (isset($result['modes'])) $hex = $result['modes']; |
1161 | 1161 | else $hex = ''; |
1162 | - $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
|
1162 | + $SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS'); |
|
1163 | 1163 | if ($this->fromACARSscript) $this->SI->add($SI_data); |
1164 | 1164 | } |
1165 | 1165 | } |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | try { |
1170 | 1170 | $sth = $this->db->prepare($query); |
1171 | 1171 | $sth->execute($query_values); |
1172 | - } catch(PDOException $e) { |
|
1172 | + } catch (PDOException $e) { |
|
1173 | 1173 | if ($globalDebug) echo $e->getMessage(); |
1174 | 1174 | return "error : ".$e->getMessage(); |
1175 | 1175 | } |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
1180 | 1180 | else $ModeS = ''; |
1181 | 1181 | if ($ModeS == '') { |
1182 | - $id = explode('-',$result['flightaware_id']); |
|
1182 | + $id = explode('-', $result['flightaware_id']); |
|
1183 | 1183 | $ModeS = $id[0]; |
1184 | 1184 | } |
1185 | 1185 | if ($ModeS != '') { |
@@ -1189,20 +1189,20 @@ discard block |
||
1189 | 1189 | try { |
1190 | 1190 | $sthc = $this->db->prepare($queryc); |
1191 | 1191 | $sthc->execute($queryc_values); |
1192 | - } catch(PDOException $e) { |
|
1192 | + } catch (PDOException $e) { |
|
1193 | 1193 | if ($globalDebug) echo $e->getMessage(); |
1194 | 1194 | return "error : ".$e->getMessage(); |
1195 | 1195 | } |
1196 | 1196 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1197 | 1197 | $sthc->closeCursor(); |
1198 | - if (count($row) == 0) { |
|
1198 | + if (count($row) == 0) { |
|
1199 | 1199 | if ($globalDebug) echo " Add to ModeS table - "; |
1200 | 1200 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1201 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1201 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1202 | 1202 | try { |
1203 | 1203 | $sthi = $this->db->prepare($queryi); |
1204 | 1204 | $sthi->execute($queryi_values); |
1205 | - } catch(PDOException $e) { |
|
1205 | + } catch (PDOException $e) { |
|
1206 | 1206 | if ($globalDebug) echo $e->getMessage(); |
1207 | 1207 | return "error : ".$e->getMessage(); |
1208 | 1208 | } |
@@ -1210,15 +1210,15 @@ discard block |
||
1210 | 1210 | if ($globalDebug) echo " Update ModeS table - "; |
1211 | 1211 | if ($ICAOTypeCode != '') { |
1212 | 1212 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1213 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1213 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1214 | 1214 | } else { |
1215 | 1215 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1216 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration); |
|
1216 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration); |
|
1217 | 1217 | } |
1218 | 1218 | try { |
1219 | 1219 | $sthi = $this->db->prepare($queryi); |
1220 | 1220 | $sthi->execute($queryi_values); |
1221 | - } catch(PDOException $e) { |
|
1221 | + } catch (PDOException $e) { |
|
1222 | 1222 | if ($globalDebug) echo $e->getMessage(); |
1223 | 1223 | return "error : ".$e->getMessage(); |
1224 | 1224 | } |
@@ -1255,12 +1255,12 @@ discard block |
||
1255 | 1255 | elseif ($globalDBdriver == 'pgsql') { |
1256 | 1256 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1257 | 1257 | } |
1258 | - $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
|
1258 | + $queryi_values = array(':Registration' => $registration, ':ident' => $icao); |
|
1259 | 1259 | } |
1260 | 1260 | try { |
1261 | 1261 | $sthi = $this->db->prepare($queryi); |
1262 | 1262 | $sthi->execute($queryi_values); |
1263 | - } catch(PDOException $e) { |
|
1263 | + } catch (PDOException $e) { |
|
1264 | 1264 | if ($globalDebug) echo $e->getMessage(); |
1265 | 1265 | return "error : ".$e->getMessage(); |
1266 | 1266 | } |
@@ -29,31 +29,31 @@ discard block |
||
29 | 29 | |
30 | 30 | private function make_latf($temp) { // unsigned long |
31 | 31 | $flat = 0.0; // float |
32 | - $temp = $temp & 0x07FFFFFF; |
|
33 | - if ($temp & 0x04000000) { |
|
34 | - $temp = $temp ^ 0x07FFFFFF; |
|
32 | + $temp = $temp&0x07FFFFFF; |
|
33 | + if ($temp&0x04000000) { |
|
34 | + $temp = $temp^0x07FFFFFF; |
|
35 | 35 | $temp += 1; |
36 | - $flat = (float)($temp / (60.0 * 10000.0)); |
|
36 | + $flat = (float) ($temp/(60.0*10000.0)); |
|
37 | 37 | $flat *= -1.0; |
38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
38 | + } else $flat = (float) ($temp/(60.0*10000.0)); |
|
39 | 39 | return $flat; // float |
40 | 40 | } |
41 | 41 | |
42 | 42 | private function make_lonf($temp) { // unsigned long |
43 | 43 | $flon = 0.0; // float |
44 | - $temp = $temp & 0x0FFFFFFF; |
|
45 | - if ($temp & 0x08000000) { |
|
46 | - $temp = $temp ^ 0x0FFFFFFF; |
|
44 | + $temp = $temp&0x0FFFFFFF; |
|
45 | + if ($temp&0x08000000) { |
|
46 | + $temp = $temp^0x0FFFFFFF; |
|
47 | 47 | $temp += 1; |
48 | - $flon = (float)($temp / (60.0 * 10000.0)); |
|
48 | + $flon = (float) ($temp/(60.0*10000.0)); |
|
49 | 49 | $flon *= -1.0; |
50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
50 | + } else $flon = (float) ($temp/(60.0*10000.0)); |
|
51 | 51 | return $flon; |
52 | 52 | } |
53 | 53 | |
54 | 54 | private function ascii_2_dec($chr) { |
55 | - $dec=ord($chr);//get decimal ascii code |
|
56 | - $hex=dechex($dec);//convert decimal to hex |
|
55 | + $dec = ord($chr); //get decimal ascii code |
|
56 | + $hex = dechex($dec); //convert decimal to hex |
|
57 | 57 | return ($dec); |
58 | 58 | } |
59 | 59 | |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | //only process in the following range: 48-87, 96-119 |
73 | 73 | if ($ascii < 48) { } |
74 | 74 | else { |
75 | - if($ascii>119) { } |
|
75 | + if ($ascii > 119) { } |
|
76 | 76 | else { |
77 | - if ($ascii>87 && $ascii<96) ; |
|
77 | + if ($ascii > 87 && $ascii < 96); |
|
78 | 78 | else { |
79 | - $ascii=$ascii+40; |
|
80 | - if ($ascii>128){ |
|
81 | - $ascii=$ascii+32; |
|
79 | + $ascii = $ascii + 40; |
|
80 | + if ($ascii > 128) { |
|
81 | + $ascii = $ascii + 32; |
|
82 | 82 | } else { |
83 | - $ascii=$ascii+40; |
|
83 | + $ascii = $ascii + 40; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | private function dec_2_6bit($dec) { |
92 | - $bin=decbin($dec); |
|
92 | + $bin = decbin($dec); |
|
93 | 93 | return(substr($bin, -6)); |
94 | 94 | } |
95 | 95 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | ); |
108 | 108 | // " |
109 | 109 | $rv = ''; |
110 | - if ($_size % 6 == 0) { |
|
111 | - $len = $_size / 6; |
|
112 | - for ($i=0; $i<$len; $i++) { |
|
113 | - $offset = $i * 6; |
|
114 | - $rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ]; |
|
110 | + if ($_size%6 == 0) { |
|
111 | + $len = $_size/6; |
|
112 | + for ($i = 0; $i < $len; $i++) { |
|
113 | + $offset = $i*6; |
|
114 | + $rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))]; |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | return $rv; |
@@ -138,93 +138,93 @@ discard block |
||
138 | 138 | $ro->eta_hour = ''; |
139 | 139 | $ro->eta_minute = ''; |
140 | 140 | $ro->ts = time(); |
141 | - $ro->id = bindec(substr($_aisdata,0,6)); |
|
142 | - $ro->mmsi = bindec(substr($_aisdata,8,30)); |
|
141 | + $ro->id = bindec(substr($_aisdata, 0, 6)); |
|
142 | + $ro->mmsi = bindec(substr($_aisdata, 8, 30)); |
|
143 | 143 | if ($ro->id >= 1 && $ro->id <= 3) { |
144 | - $ro->cog = bindec(substr($_aisdata,116,12))/10; |
|
145 | - $ro->sog = bindec(substr($_aisdata,50,10))/10; |
|
146 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
147 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
144 | + $ro->cog = bindec(substr($_aisdata, 116, 12))/10; |
|
145 | + $ro->sog = bindec(substr($_aisdata, 50, 10))/10; |
|
146 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
147 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
148 | 148 | $ro->cls = 1; // class A |
149 | 149 | } else if ($ro->id == 4) { |
150 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,79,28))); |
|
151 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,107,27))); |
|
150 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 79, 28))); |
|
151 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 107, 27))); |
|
152 | 152 | $ro->cls = 1; // class A |
153 | 153 | } else if ($ro->id == 5) { |
154 | - $ro->imo = bindec(substr($_aisdata,40,30)); |
|
155 | - $ro->callsign = $this->binchar($_aisdata,70,42); |
|
156 | - $ro->name = $this->binchar($_aisdata,112,120); |
|
157 | - $ro->typeid = bindec(substr($_aisdata,232,8)); |
|
154 | + $ro->imo = bindec(substr($_aisdata, 40, 30)); |
|
155 | + $ro->callsign = $this->binchar($_aisdata, 70, 42); |
|
156 | + $ro->name = $this->binchar($_aisdata, 112, 120); |
|
157 | + $ro->typeid = bindec(substr($_aisdata, 232, 8)); |
|
158 | 158 | $ro->type = $this->getShipType($ro->typeid); |
159 | 159 | //$ro->to_bow = bindec(substr($_aisdata,240,9)); |
160 | 160 | //$ro->to_stern = bindec(substr($_aisdata,249,9)); |
161 | 161 | //$ro->to_port = bindec(substr($_aisdata,258,6)); |
162 | 162 | //$ro->to_starboard = bindec(substr($_aisdata,264,6)); |
163 | - $ro->eta_month = bindec(substr($_aisdata,274,4)); |
|
164 | - $ro->eta_day = bindec(substr($_aisdata,278,5)); |
|
165 | - $ro->eta_hour = bindec(substr($_aisdata,283,5)); |
|
166 | - $ro->eta_minute = bindec(substr($_aisdata,288,6)); |
|
163 | + $ro->eta_month = bindec(substr($_aisdata, 274, 4)); |
|
164 | + $ro->eta_day = bindec(substr($_aisdata, 278, 5)); |
|
165 | + $ro->eta_hour = bindec(substr($_aisdata, 283, 5)); |
|
166 | + $ro->eta_minute = bindec(substr($_aisdata, 288, 6)); |
|
167 | 167 | //$ro->draught = bindec(substr($_aisdata,294,8)); |
168 | - $ro->destination = $this->binchar($_aisdata,302,120); |
|
168 | + $ro->destination = $this->binchar($_aisdata, 302, 120); |
|
169 | 169 | $ro->cls = 1; // class A |
170 | 170 | } else if ($ro->id == 9) { |
171 | 171 | // Search and Rescue aircraft position report |
172 | 172 | } else if ($ro->id == 18) { |
173 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
174 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
175 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
|
176 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
|
177 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
173 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
174 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
175 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28))); |
|
176 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27))); |
|
177 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
178 | 178 | if ($ro->heading == 511) $ro->heading = ''; |
179 | 179 | $ro->cls = 2; // class B |
180 | 180 | } else if ($ro->id == 19) { |
181 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
182 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
183 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
184 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
185 | - $ro->name = $this->binchar($_aisdata,143,120); |
|
181 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
182 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
183 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
184 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
185 | + $ro->name = $this->binchar($_aisdata, 143, 120); |
|
186 | 186 | $ro->cls = 2; // class B |
187 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
187 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
188 | 188 | if ($ro->heading == 511) $ro->heading = ''; |
189 | - $ro->typeid = bindec(substr($_aisdata,263,8)); |
|
189 | + $ro->typeid = bindec(substr($_aisdata, 263, 8)); |
|
190 | 190 | $ro->type = $this->getShipType($ro->typeid); |
191 | 191 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
192 | 192 | //$ro->to_stern = bindec(substr($_aisdata,280,9)); |
193 | 193 | //$ro->to_port = bindec(substr($_aisdata,289,6)); |
194 | 194 | //$ro->to_starboard = bindec(substr($_aisdata,295,6)); |
195 | 195 | } else if ($ro->id == 21) { |
196 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,164,28))); |
|
197 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,192,27))); |
|
198 | - $ro->name = $this->binchar($_aisdata,43,120); |
|
196 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 164, 28))); |
|
197 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 192, 27))); |
|
198 | + $ro->name = $this->binchar($_aisdata, 43, 120); |
|
199 | 199 | //$ro->to_bow = bindec(substr($_aisdata,219,9)); |
200 | 200 | //$ro->to_stern = bindec(substr($_aisdata,228,9)); |
201 | 201 | //$ro->to_port = bindec(substr($_aisdata,237,6)); |
202 | 202 | //$ro->to_starboard = bindec(substr($_aisdata,243,6)); |
203 | 203 | $ro->cls = 2; // class B |
204 | 204 | } else if ($ro->id == 24) { |
205 | - $pn = bindec(substr($_aisdata,38,2)); |
|
205 | + $pn = bindec(substr($_aisdata, 38, 2)); |
|
206 | 206 | if ($pn == 0) { |
207 | - $ro->name = $this->binchar($_aisdata,40,120); |
|
207 | + $ro->name = $this->binchar($_aisdata, 40, 120); |
|
208 | 208 | } |
209 | - $ro->typeid = bindec(substr($_aisdata,40,8)); |
|
209 | + $ro->typeid = bindec(substr($_aisdata, 40, 8)); |
|
210 | 210 | $ro->type = $this->getShipType($ro->typeid); |
211 | - $ro->callsign = $this->binchar($_aisdata,90,42); |
|
211 | + $ro->callsign = $this->binchar($_aisdata, 90, 42); |
|
212 | 212 | //$ro->to_bow = bindec(substr($_aisdata,132,9)); |
213 | 213 | //$ro->to_stern = bindec(substr($_aisdata,141,9)); |
214 | 214 | //$ro->to_port = bindec(substr($_aisdata,150,6)); |
215 | 215 | //$ro->to_starboard = bindec(substr($_aisdata,156,6)); |
216 | 216 | $ro->cls = 2; // class B |
217 | 217 | } else if ($ro->id == 27) { |
218 | - $ro->cog = bindec(substr($_aisdata,85,9)); |
|
218 | + $ro->cog = bindec(substr($_aisdata, 85, 9)); |
|
219 | 219 | if ($ro->cog == 511) $ro->cog = 0.0; |
220 | - $ro->sog = bindec(substr($_aisdata,79,6)); |
|
220 | + $ro->sog = bindec(substr($_aisdata, 79, 6)); |
|
221 | 221 | if ($ro->sog == 63) $ro->sog = 0.0; |
222 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
|
223 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
|
222 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 44, 18))*10); |
|
223 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 62, 17))*10); |
|
224 | 224 | $ro->cls = 1; // class A |
225 | 225 | |
226 | 226 | } |
227 | - $ro->statusid = bindec(substr($_aisdata,38,4)); |
|
227 | + $ro->statusid = bindec(substr($_aisdata, 38, 4)); |
|
228 | 228 | $ro->status = $this->getStatus($ro->statusid); |
229 | 229 | //var_dump($ro); // dump results here for demo purpose |
230 | 230 | return $ro; |
@@ -355,14 +355,14 @@ discard block |
||
355 | 355 | global $port; // tcpip port... |
356 | 356 | |
357 | 357 | static $debug_counter = 0; |
358 | - $aisdata168='';//six bit array of ascii characters |
|
358 | + $aisdata168 = ''; //six bit array of ascii characters |
|
359 | 359 | $ais_nmea_array = str_split($_itu); // convert to an array |
360 | 360 | foreach ($ais_nmea_array as $value) { |
361 | 361 | $dec = $this->ascii_2_dec($value); |
362 | 362 | $bit8 = $this->asciidec_2_8bit($dec); |
363 | 363 | $bit6 = $this->dec_2_6bit($bit8); |
364 | 364 | //echo $value ."-" .$bit6 .""; |
365 | - $aisdata168 .=$bit6; |
|
365 | + $aisdata168 .= $bit6; |
|
366 | 366 | } |
367 | 367 | //echo $aisdata168 . "<br/>"; |
368 | 368 | //return $this->decode_ais($aisdata168, $aux); |
@@ -385,24 +385,24 @@ discard block |
||
385 | 385 | // calculate checksum after ! till * |
386 | 386 | // assume 1st ! is valid |
387 | 387 | // find * ensure that it is at correct position |
388 | - $end = strrpos ( $rawdata , '*' ); |
|
388 | + $end = strrpos($rawdata, '*'); |
|
389 | 389 | if ($end === FALSE) return -1; // check for NULLS!!! |
390 | - $cs = substr( $rawdata, $end + 1 ); |
|
391 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
392 | - $dcs = (int)hexdec( $cs ); |
|
393 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
394 | - if ( $chksum == $dcs ) { // NMEA checksum pass |
|
390 | + $cs = substr($rawdata, $end + 1); |
|
391 | + if (strlen($cs) != 2) return -1; // correct cs length |
|
392 | + $dcs = (int) hexdec($cs); |
|
393 | + for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum |
|
394 | + if ($chksum == $dcs) { // NMEA checksum pass |
|
395 | 395 | $pcs = explode(',', $rawdata); |
396 | 396 | // !AI??? identifier |
397 | 397 | if (!isset($pcs[1])) { |
398 | 398 | echo "ERROR,INVALID_DATA ".time()." $rawdata\n"; |
399 | 399 | return -1; |
400 | 400 | } |
401 | - $num_seq = (int)$pcs[1]; // number of sequences |
|
402 | - $seq = (int)$pcs[2]; // get sequence |
|
401 | + $num_seq = (int) $pcs[1]; // number of sequences |
|
402 | + $seq = (int) $pcs[2]; // get sequence |
|
403 | 403 | // get msg sequence id |
404 | 404 | if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
405 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
405 | + else $msg_sid = (int) $pcs[3]; // multipart message |
|
406 | 406 | $ais_ch = $pcs[4]; // get AIS channel |
407 | 407 | // message sequence checking |
408 | 408 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | } |
436 | 436 | } |
437 | 437 | $itu = $itu.$pcs[5]; // get itu message |
438 | - $filler += (int)$pcs[6][0]; // get filler |
|
438 | + $filler += (int) $pcs[6][0]; // get filler |
|
439 | 439 | if ($num_seq == 1 // valid single message |
440 | 440 | || $num_seq == $pseq // valid multi-part message |
441 | 441 | ) { |
@@ -455,13 +455,13 @@ discard block |
||
455 | 455 | $cbuf = $cbuf.$ibuf; |
456 | 456 | $last_pos = 0; |
457 | 457 | $result = new stdClass(); |
458 | - while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) { |
|
458 | + while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) { |
|
459 | 459 | //while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) { |
460 | 460 | //DEBUG echo $cbuf; |
461 | - if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
461 | + if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
462 | 462 | $tst = substr($cbuf, $start - 3, ($end - $start + 3)); |
463 | 463 | //DEBUG echo "[$start $end $tst]\n"; |
464 | - $result = $this->process_ais_raw( $tst, "" ); |
|
464 | + $result = $this->process_ais_raw($tst, ""); |
|
465 | 465 | $last_pos = $end + 1; |
466 | 466 | } else break; |
467 | 467 | } |
@@ -473,41 +473,41 @@ discard block |
||
473 | 473 | // incoming data from serial or IP comms |
474 | 474 | public function process_ais_line($cbuf) { |
475 | 475 | $result = new stdClass(); |
476 | - $start = strpos($cbuf,"VDM"); |
|
476 | + $start = strpos($cbuf, "VDM"); |
|
477 | 477 | $tst = substr($cbuf, $start - 3); |
478 | - $result = $this->process_ais_raw( $tst, "" ); |
|
478 | + $result = $this->process_ais_raw($tst, ""); |
|
479 | 479 | return $result; |
480 | 480 | } |
481 | 481 | |
482 | 482 | /* AIS Encoding |
483 | 483 | */ |
484 | - private function mk_ais_lat( $lat ) { |
|
484 | + private function mk_ais_lat($lat) { |
|
485 | 485 | //$lat = 1.2569; |
486 | - if ($lat<0.0) { |
|
486 | + if ($lat < 0.0) { |
|
487 | 487 | $lat = -$lat; |
488 | - $neg=true; |
|
489 | - } else $neg=false; |
|
488 | + $neg = true; |
|
489 | + } else $neg = false; |
|
490 | 490 | $latd = 0x00000000; |
491 | - $latd = intval ($lat * 600000.0); |
|
492 | - if ($neg==true) { |
|
491 | + $latd = intval($lat*600000.0); |
|
492 | + if ($neg == true) { |
|
493 | 493 | $latd = ~$latd; |
494 | - $latd+=1; |
|
494 | + $latd += 1; |
|
495 | 495 | $latd &= 0x07FFFFFF; |
496 | 496 | } |
497 | 497 | return $latd; |
498 | 498 | } |
499 | 499 | |
500 | - private function mk_ais_lon( $lon ) { |
|
500 | + private function mk_ais_lon($lon) { |
|
501 | 501 | //$lon = 103.851; |
502 | - if ($lon<0.0) { |
|
502 | + if ($lon < 0.0) { |
|
503 | 503 | $lon = -$lon; |
504 | - $neg=true; |
|
505 | - } else $neg=false; |
|
504 | + $neg = true; |
|
505 | + } else $neg = false; |
|
506 | 506 | $lond = 0x00000000; |
507 | - $lond = intval ($lon * 600000.0); |
|
508 | - if ($neg==true) { |
|
507 | + $lond = intval($lon*600000.0); |
|
508 | + if ($neg == true) { |
|
509 | 509 | $lond = ~$lond; |
510 | - $lond+=1; |
|
510 | + $lond += 1; |
|
511 | 511 | $lond &= 0x0FFFFFFF; |
512 | 512 | } |
513 | 513 | return $lond; |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | |
516 | 516 | private function char2bin($name, $max_len) { |
517 | 517 | $len = strlen($name); |
518 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
519 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
518 | + if ($len > $max_len) $name = substr($name, 0, $max_len); |
|
519 | + if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6); |
|
520 | 520 | else $pad = ''; |
521 | 521 | $rv = ''; |
522 | 522 | $ais_chars = array( |
@@ -533,26 +533,26 @@ discard block |
||
533 | 533 | if ($_a) foreach ($_a as $_1) { |
534 | 534 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
535 | 535 | else $dec = 0; |
536 | - $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
|
536 | + $bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT); |
|
537 | 537 | $rv .= $bin; |
538 | 538 | //echo "$_1 $dec ($bin)<br/>"; |
539 | 539 | } |
540 | 540 | return $rv.$pad; |
541 | 541 | } |
542 | 542 | |
543 | - private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') { |
|
543 | + private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') { |
|
544 | 544 | $len_bit = strlen($_enc); |
545 | - $rem6 = $len_bit % 6; |
|
545 | + $rem6 = $len_bit%6; |
|
546 | 546 | $pad6_len = 0; |
547 | 547 | if ($rem6) $pad6_len = 6 - $rem6; |
548 | 548 | //echo $pad6_len.'<br>'; |
549 | 549 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
550 | - $len_enc = strlen($_enc) / 6; |
|
550 | + $len_enc = strlen($_enc)/6; |
|
551 | 551 | //echo $_enc.' '.$len_enc.'<br/>'; |
552 | 552 | $itu = ''; |
553 | - for ($i=0; $i<$len_enc; $i++) { |
|
554 | - $offset = $i * 6; |
|
555 | - $dec = bindec(substr($_enc,$offset,6)); |
|
553 | + for ($i = 0; $i < $len_enc; $i++) { |
|
554 | + $offset = $i*6; |
|
555 | + $dec = bindec(substr($_enc, $offset, 6)); |
|
556 | 556 | if ($dec < 40) $dec += 48; |
557 | 557 | else $dec += 56; |
558 | 558 | //echo chr($dec)." $dec<br/>"; |
@@ -562,15 +562,15 @@ discard block |
||
562 | 562 | $chksum = 0; |
563 | 563 | $itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0"; |
564 | 564 | $len_itu = strlen($itu); |
565 | - for ($i=0; $i<$len_itu; $i++) { |
|
566 | - $chksum ^= ord( $itu[$i] ); |
|
565 | + for ($i = 0; $i < $len_itu; $i++) { |
|
566 | + $chksum ^= ord($itu[$i]); |
|
567 | 567 | } |
568 | - $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
|
569 | - $lsb = $chksum & 0x0F; |
|
570 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
568 | + $hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
|
569 | + $lsb = $chksum&0x0F; |
|
570 | + if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb]; |
|
571 | 571 | else $lsbc = '0'; |
572 | - $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
|
573 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
572 | + $msb = (($chksum&0xF0) >> 4)&0x0F; |
|
573 | + if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb]; |
|
574 | 574 | else $msbc = '0'; |
575 | 575 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
576 | 576 | return $itu; |
@@ -595,14 +595,14 @@ discard block |
||
595 | 595 | |
596 | 596 | public function mmsitype($mmsi) { |
597 | 597 | if (strlen($mmsi) == 9) { |
598 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
599 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
600 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
601 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
602 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
603 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
604 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
605 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
598 | + if (substr($mmsi, 0, 3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
599 | + elseif (substr($mmsi, 0, 3) == '972') return 'MOB (Man Overboard) device'; |
|
600 | + elseif (substr($mmsi, 0, 3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
601 | + elseif (substr($mmsi, 0, 3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
602 | + elseif (substr($mmsi, 0, 2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
603 | + elseif (substr($mmsi, 0, 2) == '99') return 'Aids to Navigation'; |
|
604 | + elseif (substr($mmsi, 0, 2) == '00') return 'Coastal stations'; |
|
605 | + elseif (substr($mmsi, 0, 1) == '0') return 'Group of ships'; |
|
606 | 606 | else return 'Ship'; |
607 | 607 | } |
608 | 608 | |
@@ -613,19 +613,19 @@ discard block |
||
613 | 613 | global $globalDebug; |
614 | 614 | $result = array(); |
615 | 615 | $data = new stdClass(); |
616 | - $start = strpos($buffer,"VDM"); |
|
616 | + $start = strpos($buffer, "VDM"); |
|
617 | 617 | $tst = substr($buffer, $start - 3); |
618 | - $data = $this->process_ais_raw( $tst, "" ); |
|
618 | + $data = $this->process_ais_raw($tst, ""); |
|
619 | 619 | if (!is_object($data)) { |
620 | 620 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
621 | 621 | return array(); |
622 | 622 | } |
623 | 623 | if ($data->lon != 0) $result['longitude'] = $data->lon; |
624 | 624 | if ($data->lat != 0) $result['latitude'] = $data->lat; |
625 | - $result['ident'] = trim(str_replace('@','',$data->name)); |
|
625 | + $result['ident'] = trim(str_replace('@', '', $data->name)); |
|
626 | 626 | $result['timestamp'] = $data->ts; |
627 | 627 | $result['mmsi'] = $data->mmsi; |
628 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
628 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'], 0, 3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
629 | 629 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
630 | 630 | if ($data->sog != -1.0) $result['speed'] = $data->sog; |
631 | 631 | if ($data->heading !== '') $result['heading'] = $data->heading; |
@@ -635,16 +635,16 @@ discard block |
||
635 | 635 | if ($data->type !== '') $result['type'] = $data->type; |
636 | 636 | if ($data->typeid !== '') $result['typeid'] = $data->typeid; |
637 | 637 | if ($data->imo !== '') $result['imo'] = $data->imo; |
638 | - if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
638 | + if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@', '', $data->callsign)); |
|
639 | 639 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
640 | - $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
|
640 | + $eta_ts = strtotime(date('Y').'-'.sprintf("%02d", $data->eta_month).'-'.sprintf("%02d", $data->eta_day).' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00'); |
|
641 | 641 | if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
642 | 642 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
643 | - $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
|
643 | + $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00'); |
|
644 | 644 | if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
645 | 645 | } |
646 | 646 | if ($data->destination != '') { |
647 | - $dest = trim(str_replace('@','',$data->destination)); |
|
647 | + $dest = trim(str_replace('@', '', $data->destination)); |
|
648 | 648 | if ($dest != '') $result['destination'] = $dest; |
649 | 649 | } |
650 | 650 | $result['all'] = (array) $data; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 60 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
61 | 61 | $Marine = new Marine($this->db); |
62 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
62 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | 73 | if (isset($flight['lastupdate'])) { |
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
74 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
75 | 75 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 76 | if (isset($this->all_tracked[$key]['id'])) { |
77 | 77 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | //$real_arrival = $this->arrival($key); |
84 | 84 | $Marine = new Marine($this->db); |
85 | 85 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | - $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
86 | + $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
88 | 88 | } |
89 | 89 | // Put in archive |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | public function add($line) { |
100 | - global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
|
100 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine; |
|
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
103 | 103 | $dataFound = false; |
104 | 104 | $send = false; |
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | - if(is_array($line) && isset($line['mmsi'])) { |
|
107 | + if (is_array($line) && isset($line['mmsi'])) { |
|
108 | 108 | //print_r($line); |
109 | 109 | if (isset($line['mmsi'])) { |
110 | 110 | |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | 131 | $this->all_tracked[$id] = array(); |
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
133 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'status_id' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => '')); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
135 | 135 | if (!isset($line['id'])) { |
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
137 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
137 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
139 | 139 | if ($globalAllTracked !== FALSE) $dataFound = true; |
140 | 140 | } |
141 | 141 | |
142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
144 | 144 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
145 | 145 | $Marine = new Marine($this->db); |
146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
@@ -154,64 +154,64 @@ discard block |
||
154 | 154 | } |
155 | 155 | } |
156 | 156 | if (isset($line['type_id'])) { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $line['type_id'])); |
|
159 | 159 | } |
160 | 160 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
161 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
162 | 162 | } |
163 | 163 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
165 | 165 | } |
166 | 166 | if (isset($line['imo']) && $line['imo'] != '') { |
167 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
167 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
168 | 168 | } |
169 | 169 | if (isset($line['callsign']) && $line['callsign'] != '') { |
170 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
170 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
171 | 171 | } |
172 | 172 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
173 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
173 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
174 | 174 | } |
175 | 175 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
176 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
176 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
180 | 180 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
181 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
181 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
182 | 182 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
183 | 183 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
184 | 184 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
185 | 185 | $timeelapsed = microtime(true); |
186 | 186 | $Marine = new Marine($this->db); |
187 | 187 | $fromsource = NULL; |
188 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
188 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
189 | 189 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
190 | 190 | $Marine->db = null; |
191 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
191 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
195 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
195 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
196 | 196 | } |
197 | 197 | |
198 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
|
198 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
199 | 199 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
200 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
200 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
201 | 201 | } else { |
202 | 202 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
203 | 203 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
204 | 204 | return ''; |
205 | 205 | } |
206 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
|
206 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) { |
|
207 | 207 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
208 | 208 | return ''; |
209 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
|
209 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) { |
|
210 | 210 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
211 | 211 | return ''; |
212 | 212 | } elseif (!isset($line['datetime'])) { |
213 | 213 | date_default_timezone_set('UTC'); |
214 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
214 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
215 | 215 | } else { |
216 | 216 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
217 | 217 | return ''; |
@@ -219,24 +219,24 @@ discard block |
||
219 | 219 | |
220 | 220 | |
221 | 221 | if (isset($line['speed'])) { |
222 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
223 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
222 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
223 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
224 | 224 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
225 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
225 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
226 | 226 | if ($distance > 1000 && $distance < 10000) { |
227 | 227 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
228 | 228 | $speed = $speed*3.6; |
229 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
229 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
230 | 230 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
234 | 234 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
235 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
235 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
236 | 236 | else unset($timediff); |
237 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
237 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) { |
|
238 | 238 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
239 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
239 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
240 | 240 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
241 | 241 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
242 | 242 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | $timeelapsed = microtime(true); |
246 | 246 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
247 | 247 | $Marine = new Marine($this->db); |
248 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
248 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
249 | 249 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
250 | 250 | $Marine->db = null; |
251 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
251 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
252 | 252 | } |
253 | 253 | $this->tmd = 0; |
254 | 254 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -257,52 +257,52 @@ discard block |
||
257 | 257 | |
258 | 258 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
259 | 259 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
260 | - 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') { |
|
260 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
261 | 261 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
262 | 262 | $dataFound = true; |
263 | 263 | $this->all_tracked[$id]['time_last_coord'] = time(); |
264 | 264 | } |
265 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
265 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
266 | 266 | } |
267 | 267 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
268 | 268 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
269 | 269 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
270 | - 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') { |
|
270 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
271 | 271 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
272 | 272 | $dataFound = true; |
273 | 273 | $this->all_tracked[$id]['time_last_coord'] = time(); |
274 | 274 | } |
275 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
275 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | } else if ($globalDebug && $timediff > 20) { |
279 | 279 | $this->tmd = $this->tmd + 1; |
280 | 280 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
281 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
282 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
281 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
282 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
283 | 283 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
284 | 284 | } |
285 | 285 | } |
286 | 286 | if (isset($line['last_update']) && $line['last_update'] != '') { |
287 | 287 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
288 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
288 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
289 | 289 | } |
290 | 290 | if (isset($line['format_source']) && $line['format_source'] != '') { |
291 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
291 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
292 | 292 | } |
293 | 293 | if (isset($line['source_name']) && $line['source_name'] != '') { |
294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
295 | 295 | } |
296 | 296 | if (isset($line['status']) && $line['status'] != '') { |
297 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
297 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
298 | 298 | } |
299 | 299 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
300 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
300 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id'])); |
|
301 | 301 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
302 | 302 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
303 | 303 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
304 | 304 | $Marine = new Marine($this->db); |
305 | - $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
|
305 | + $Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']); |
|
306 | 306 | unset($Marine); |
307 | 307 | } |
308 | 308 | } |
@@ -310,18 +310,18 @@ discard block |
||
310 | 310 | } |
311 | 311 | |
312 | 312 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
313 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
313 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | if (isset($line['heading']) && $line['heading'] != '') { |
317 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
318 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
319 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
317 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
318 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
319 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
320 | 320 | //$dataFound = true; |
321 | 321 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
322 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
323 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
324 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
322 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
323 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
324 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
325 | 325 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
326 | 326 | } |
327 | 327 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
332 | 332 | $this->all_tracked[$id]['lastupdate'] = time(); |
333 | 333 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
334 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
334 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
335 | 335 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
336 | 336 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
337 | 337 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
@@ -339,37 +339,37 @@ discard block |
||
339 | 339 | $MarineLive = new MarineLive($this->db); |
340 | 340 | if (isset($line['id'])) { |
341 | 341 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
342 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
342 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
343 | 343 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
344 | 344 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
345 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
345 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
346 | 346 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
347 | 347 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
348 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
348 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
349 | 349 | } else $recent_ident = ''; |
350 | - $MarineLive->db=null; |
|
350 | + $MarineLive->db = null; |
|
351 | 351 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
352 | 352 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
353 | 353 | } else $recent_ident = ''; |
354 | 354 | } else { |
355 | 355 | $recent_ident = ''; |
356 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
356 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
357 | 357 | } |
358 | 358 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
359 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
359 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
360 | 360 | { |
361 | 361 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
362 | 362 | //adds the spotter data for the archive |
363 | 363 | $highlight = ''; |
364 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
364 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
365 | 365 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
366 | 366 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
367 | 367 | $timeelapsed = microtime(true); |
368 | 368 | $Marine = new Marine($this->db); |
369 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
369 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
370 | 370 | $Marine->db = null; |
371 | 371 | if ($globalDebug && isset($result)) echo $result."\n"; |
372 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
372 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
@@ -377,15 +377,15 @@ discard block |
||
377 | 377 | $Stats = new Stats($this->db); |
378 | 378 | if (!empty($this->stats)) { |
379 | 379 | if ($globalDebug) echo 'Add source stats : '; |
380 | - foreach($this->stats as $date => $data) { |
|
381 | - foreach($data as $source => $sourced) { |
|
380 | + foreach ($this->stats as $date => $data) { |
|
381 | + foreach ($data as $source => $sourced) { |
|
382 | 382 | //print_r($sourced); |
383 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
384 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
383 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date); |
|
384 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date); |
|
385 | 385 | if (isset($sourced['msg'])) { |
386 | 386 | if (time() - $sourced['msg']['date'] > 10) { |
387 | 387 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
388 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
388 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date); |
|
389 | 389 | unset($this->stats[$date][$source]['msg']); |
390 | 390 | } |
391 | 391 | } |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
410 | 410 | $MarineLive = new MarineLive($this->db); |
411 | 411 | $MarineLive->deleteLiveMarineData(); |
412 | - $MarineLive->db=null; |
|
412 | + $MarineLive->db = null; |
|
413 | 413 | if ($globalDebug) echo " Done\n"; |
414 | 414 | } |
415 | 415 | $this->last_delete = time(); |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
421 | 421 | if (isset($globalDaemon) && !$globalDaemon) { |
422 | 422 | $Marine = new Marine($this->db); |
423 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
423 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
424 | 424 | $Marine->db = null; |
425 | 425 | } |
426 | 426 | } |
@@ -435,20 +435,20 @@ discard block |
||
435 | 435 | $ignoreImport = false; |
436 | 436 | |
437 | 437 | if (!$ignoreImport) { |
438 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
438 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
439 | 439 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
440 | 440 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
441 | 441 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
442 | 442 | $timeelapsed = microtime(true); |
443 | 443 | $MarineLive = new MarineLive($this->db); |
444 | - $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
444 | + $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
445 | 445 | $MarineLive->db = null; |
446 | 446 | if ($globalDebug) echo $result."\n"; |
447 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
447 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
451 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
451 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
452 | 452 | } |
453 | 453 | $this->all_tracked[$id]['putinarchive'] = false; |
454 | 454 | |
@@ -467,19 +467,19 @@ discard block |
||
467 | 467 | $latitude = $globalCenterLatitude; |
468 | 468 | $longitude = $globalCenterLongitude; |
469 | 469 | } |
470 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
470 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
471 | 471 | } else { |
472 | 472 | $latitude = $this->source_location[$source]['latitude']; |
473 | 473 | $longitude = $this->source_location[$source]['longitude']; |
474 | 474 | } |
475 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
475 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
476 | 476 | //$stats_heading = $stats_heading%22.5; |
477 | 477 | $stats_heading = round($stats_heading/22.5); |
478 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
478 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
479 | 479 | $current_date = date('Y-m-d'); |
480 | 480 | if ($stats_heading == 16) $stats_heading = 0; |
481 | 481 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
482 | - for ($i=0;$i<=15;$i++) { |
|
482 | + for ($i = 0; $i <= 15; $i++) { |
|
483 | 483 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
484 | 484 | } |
485 | 485 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -494,9 +494,9 @@ discard block |
||
494 | 494 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
495 | 495 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
496 | 496 | end($this->stats[$current_date][$source]['hist']); |
497 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
497 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
498 | 498 | } else $mini = 0; |
499 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
499 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
500 | 500 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
501 | 501 | } |
502 | 502 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | |
509 | 509 | $this->all_tracked[$id]['lastupdate'] = time(); |
510 | 510 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
511 | - } 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"; |
|
511 | + } 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"; |
|
512 | 512 | //$this->del(); |
513 | 513 | |
514 | 514 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
19 | 19 | |
20 | 20 | $spotter_array = $Spotter->getAllFlightsforSitemap(); |
21 | - foreach($spotter_array as $spotter_item) |
|
21 | + foreach ($spotter_array as $spotter_item) |
|
22 | 22 | { |
23 | 23 | $output .= '<url>'; |
24 | 24 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/flightid/'.$spotter_item['spotter_id'].'</loc>'; |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | $output .= '</urlset>'; |
30 | 30 | |
31 | 31 | |
32 | -} else if (isset($_GET['type']) && $_GET['type'] == "aircraft"){ |
|
32 | +} else if (isset($_GET['type']) && $_GET['type'] == "aircraft") { |
|
33 | 33 | |
34 | 34 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
35 | 35 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
36 | 36 | $aircraft_types = $Stats->getAllAircraftTypes(); |
37 | 37 | if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
38 | - foreach($aircraft_types as $aircraft_item) |
|
38 | + foreach ($aircraft_types as $aircraft_item) |
|
39 | 39 | { |
40 | 40 | $output .= '<url>'; |
41 | 41 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/aircraft/'.urlencode($aircraft_item['aircraft_icao']).'</loc>'; |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | $output .= '</urlset>'; |
47 | 47 | |
48 | 48 | |
49 | -} else if (isset($_GET['type']) && $_GET['type'] == "registration"){ |
|
49 | +} else if (isset($_GET['type']) && $_GET['type'] == "registration") { |
|
50 | 50 | |
51 | 51 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
52 | 52 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
53 | 53 | |
54 | 54 | $aircraft_registrations = $Spotter->getAllAircraftRegistrations(); |
55 | - foreach($aircraft_registrations as $aircraft_item) |
|
55 | + foreach ($aircraft_registrations as $aircraft_item) |
|
56 | 56 | { |
57 | 57 | $output .= '<url>'; |
58 | 58 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/registration/'.urlencode($aircraft_item['registration']).'</loc>'; |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | } |
63 | 63 | $output .= '</urlset>'; |
64 | 64 | |
65 | -} else if (isset($_GET['type']) && $_GET['type'] == "airline"){ |
|
65 | +} else if (isset($_GET['type']) && $_GET['type'] == "airline") { |
|
66 | 66 | |
67 | 67 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
68 | 68 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
69 | 69 | |
70 | 70 | $airline_names = $Stats->getAllAirlineNames(); |
71 | - foreach($airline_names as $airline_item) |
|
71 | + foreach ($airline_names as $airline_item) |
|
72 | 72 | { |
73 | 73 | $output .= '<url>'; |
74 | 74 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airline/'.urlencode($airline_item['airline_icao']).'</loc>'; |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | } |
79 | 79 | $output .= '</urlset>'; |
80 | 80 | |
81 | -} else if (isset($_GET['type']) && $_GET['type'] == "airport"){ |
|
81 | +} else if (isset($_GET['type']) && $_GET['type'] == "airport") { |
|
82 | 82 | |
83 | 83 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
84 | 84 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
85 | 85 | |
86 | 86 | $airport_names = $Stats->getAllAirportNames(); |
87 | 87 | if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
88 | - foreach($airport_names as $airport_item) |
|
88 | + foreach ($airport_names as $airport_item) |
|
89 | 89 | { |
90 | 90 | $output .= '<url>'; |
91 | 91 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airport/'.$airport_item['airport_icao'].'</loc>'; |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | } |
96 | 96 | $output .= '</urlset>'; |
97 | 97 | |
98 | -} else if (isset($_GET['type']) && $_GET['type'] == "manufacturer"){ |
|
98 | +} else if (isset($_GET['type']) && $_GET['type'] == "manufacturer") { |
|
99 | 99 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
100 | 100 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
101 | 101 | $manufacturer_names = $Stats->getAllManufacturers(); |
102 | 102 | if (empty($manufacturer_names)) $manufacturer_names = $Spotter->getAllManufacturers(); |
103 | - foreach($manufacturer_names as $manufacturer_item) |
|
103 | + foreach ($manufacturer_names as $manufacturer_item) |
|
104 | 104 | { |
105 | 105 | $output .= '<url>'; |
106 | 106 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/manufacturer/'.urlencode(strtolower(str_replace(" ", "-", $manufacturer_item['aircraft_manufacturer']))).'</loc>'; |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | $output .= '</url>'; |
110 | 110 | } |
111 | 111 | $output .= '</urlset>'; |
112 | -} else if (isset($_GET['type']) && $_GET['type'] == "country"){ |
|
112 | +} else if (isset($_GET['type']) && $_GET['type'] == "country") { |
|
113 | 113 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
114 | 114 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
115 | 115 | $country_names = $Spotter->getAllCountries(); |
116 | - foreach($country_names as $country_item) |
|
116 | + foreach ($country_names as $country_item) |
|
117 | 117 | { |
118 | 118 | $output .= '<url>'; |
119 | 119 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/country/'.urlencode(strtolower(str_replace(" ", "-", $country_item['country']))).'</loc>'; |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | $output .= '</url>'; |
123 | 123 | } |
124 | 124 | $output .= '</urlset>'; |
125 | -} else if (isset($_GET['type']) && $_GET['type'] == "ident"){ |
|
125 | +} else if (isset($_GET['type']) && $_GET['type'] == "ident") { |
|
126 | 126 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
127 | 127 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
128 | 128 | $ident_names = $Spotter->getAllIdents(); |
129 | - foreach($ident_names as $ident_item) |
|
129 | + foreach ($ident_names as $ident_item) |
|
130 | 130 | { |
131 | 131 | if (ctype_alnum($ident_item['ident'])) { |
132 | 132 | $output .= '<url>'; |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | } |
138 | 138 | } |
139 | 139 | $output .= '</urlset>'; |
140 | -} else if (isset($_GET['type']) && $_GET['type'] == "marine-ident"){ |
|
140 | +} else if (isset($_GET['type']) && $_GET['type'] == "marine-ident") { |
|
141 | 141 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
142 | 142 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
143 | 143 | $ident_names = $Marine->getAllIdents(); |
144 | - foreach($ident_names as $ident_item) |
|
144 | + foreach ($ident_names as $ident_item) |
|
145 | 145 | { |
146 | 146 | if (ctype_alnum($ident_item['ident'])) { |
147 | 147 | $output .= '<url>'; |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | } |
153 | 153 | } |
154 | 154 | $output .= '</urlset>'; |
155 | -} else if (isset($_GET['type']) && $_GET['type'] == "date"){ |
|
155 | +} else if (isset($_GET['type']) && $_GET['type'] == "date") { |
|
156 | 156 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
157 | 157 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
158 | 158 | $date_names = $Spotter->getAllDates(); |
159 | - foreach($date_names as $date_item) |
|
159 | + foreach ($date_names as $date_item) |
|
160 | 160 | { |
161 | 161 | $output .= '<url>'; |
162 | 162 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/date/'.date("Y-m-d", strtotime($date_item['date'])).'</loc>'; |
@@ -165,11 +165,11 @@ discard block |
||
165 | 165 | $output .= '</url>'; |
166 | 166 | } |
167 | 167 | $output .= '</urlset>'; |
168 | -} else if (isset($_GET['type']) && $_GET['type'] == "marine-date"){ |
|
168 | +} else if (isset($_GET['type']) && $_GET['type'] == "marine-date") { |
|
169 | 169 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
170 | 170 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
171 | 171 | $date_names = $Marine->getAllDates(); |
172 | - foreach($date_names as $date_item) |
|
172 | + foreach ($date_names as $date_item) |
|
173 | 173 | { |
174 | 174 | $output .= '<url>'; |
175 | 175 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/marine/date/'.date("Y-m-d", strtotime($date_item['date'])).'</loc>'; |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | $output .= '</url>'; |
179 | 179 | } |
180 | 180 | $output .= '</urlset>'; |
181 | -} else if (isset($_GET['type']) && $_GET['type'] == "tracker-date"){ |
|
181 | +} else if (isset($_GET['type']) && $_GET['type'] == "tracker-date") { |
|
182 | 182 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
183 | 183 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
184 | 184 | $date_names = $Tracker->getAllDates(); |
185 | - foreach($date_names as $date_item) |
|
185 | + foreach ($date_names as $date_item) |
|
186 | 186 | { |
187 | 187 | $output .= '<url>'; |
188 | 188 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/tracker/date/'.date("Y-m-d", strtotime($date_item['date'])).'</loc>'; |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | $output .= '</url>'; |
192 | 192 | } |
193 | 193 | $output .= '</urlset>'; |
194 | -} else if (isset($_GET['type']) && $_GET['type'] == "route"){ |
|
194 | +} else if (isset($_GET['type']) && $_GET['type'] == "route") { |
|
195 | 195 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
196 | 196 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
197 | 197 | $route_names = $Spotter->getAllRoutes(); |
198 | - foreach($route_names as $route_item) |
|
198 | + foreach ($route_names as $route_item) |
|
199 | 199 | { |
200 | 200 | $output .= '<url>'; |
201 | 201 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/route/'.$route_item['airport_departure_icao'].'/'.$route_item['airport_arrival_icao'].'</loc>'; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $output .= '</url>'; |
205 | 205 | } |
206 | 206 | $output .= '</urlset>'; |
207 | -} else if (isset($_GET['type']) && $_GET['type'] == "static"){ |
|
207 | +} else if (isset($_GET['type']) && $_GET['type'] == "static") { |
|
208 | 208 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
209 | 209 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
210 | 210 | /* STATIC PAGES */ |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $output .= '<changefreq>daily</changefreq>'; |
323 | 323 | $output .= '</url>'; |
324 | 324 | $output .= '</urlset>'; |
325 | -} else if (isset($_GET['type']) && $_GET['type'] == "marine-static"){ |
|
325 | +} else if (isset($_GET['type']) && $_GET['type'] == "marine-static") { |
|
326 | 326 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
327 | 327 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
328 | 328 | /* STATIC PAGES */ |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | $output .= '<changefreq>daily</changefreq>'; |
349 | 349 | $output .= '</url>'; |
350 | 350 | $output .= '</urlset>'; |
351 | -} else if (isset($_GET['type']) && $_GET['type'] == "tracker-static"){ |
|
351 | +} else if (isset($_GET['type']) && $_GET['type'] == "tracker-static") { |
|
352 | 352 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
353 | 353 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
354 | 354 | /* STATIC PAGES */ |
@@ -14,33 +14,33 @@ discard block |
||
14 | 14 | * @param Array $filter the filter |
15 | 15 | * @return Array the SQL part |
16 | 16 | */ |
17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
17 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
22 | 22 | $filters = $globalStatsFilters[$globalFilterName]; |
23 | 23 | } else { |
24 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
24 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | if (isset($filter[0]['source'])) { |
28 | - $filters = array_merge($filters,$filter); |
|
28 | + $filters = array_merge($filters, $filter); |
|
29 | 29 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
30 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
31 | 31 | $filter_query_join = ''; |
32 | 32 | $filter_query_where = ''; |
33 | - foreach($filters as $flt) { |
|
33 | + foreach ($filters as $flt) { |
|
34 | 34 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
35 | 35 | if (isset($flt['source'])) { |
36 | - $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 | + $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"; |
|
37 | 37 | } else { |
38 | - $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 | + $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"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | if (isset($filter['source']) && !empty($filter['source'])) { |
43 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
43 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
44 | 44 | } |
45 | 45 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
46 | 46 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -68,38 +68,38 @@ discard block |
||
68 | 68 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_archive_output.date) = '".$filter['day']."'"; |
69 | 69 | } |
70 | 70 | } |
71 | - $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 | + $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"; |
|
72 | 72 | } |
73 | 73 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
74 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
75 | 75 | } |
76 | 76 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
77 | 77 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
78 | 78 | if ($filter_query_where != '') { |
79 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
79 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
80 | 80 | } |
81 | 81 | $filter_query = $filter_query_join.$filter_query_where; |
82 | 82 | return $filter_query; |
83 | 83 | } |
84 | 84 | |
85 | 85 | // tracker_archive |
86 | - public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { |
|
86 | + public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
87 | 87 | require_once(dirname(__FILE__).'/class.Tracker.php'); |
88 | 88 | if ($over_country == '') { |
89 | 89 | $Tracker = new Tracker($this->db); |
90 | - $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
90 | + $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
91 | 91 | if (!empty($data_country)) $country = $data_country['iso2']; |
92 | 92 | else $country = ''; |
93 | 93 | } else $country = $over_country; |
94 | 94 | // Route is not added in tracker_archive |
95 | - $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
95 | + $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
96 | 96 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
97 | - $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' => $country,':comment' => $comment,':type' => $type); |
|
97 | + $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' => $country, ':comment' => $comment, ':type' => $type); |
|
98 | 98 | try { |
99 | 99 | $sth = $this->db->prepare($query); |
100 | 100 | $sth->execute($query_values); |
101 | 101 | $sth->closeCursor(); |
102 | - } catch(PDOException $e) { |
|
102 | + } catch (PDOException $e) { |
|
103 | 103 | return "error : ".$e->getMessage(); |
104 | 104 | } |
105 | 105 | return "success"; |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | |
120 | 120 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
121 | 121 | //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
122 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
122 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
123 | 123 | |
124 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
124 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident)); |
|
125 | 125 | |
126 | 126 | return $spotter_array; |
127 | 127 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
141 | 141 | //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
142 | 142 | //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
143 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
143 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
144 | 144 | |
145 | 145 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
146 | 146 | /* |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | } |
154 | 154 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
155 | 155 | */ |
156 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
156 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id)); |
|
157 | 157 | |
158 | 158 | return $spotter_array; |
159 | 159 | } |
@@ -168,14 +168,14 @@ discard block |
||
168 | 168 | { |
169 | 169 | date_default_timezone_set('UTC'); |
170 | 170 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
171 | - $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
171 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
172 | 172 | |
173 | 173 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
174 | 174 | |
175 | 175 | try { |
176 | 176 | $sth = $this->db->prepare($query); |
177 | 177 | $sth->execute(array(':id' => $id)); |
178 | - } catch(PDOException $e) { |
|
178 | + } catch (PDOException $e) { |
|
179 | 179 | echo $e->getMessage(); |
180 | 180 | die; |
181 | 181 | } |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | { |
195 | 195 | date_default_timezone_set('UTC'); |
196 | 196 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
197 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
197 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
198 | 198 | |
199 | 199 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
200 | 200 | |
201 | 201 | try { |
202 | 202 | $sth = $this->db->prepare($query); |
203 | 203 | $sth->execute(array(':id' => $id)); |
204 | - } catch(PDOException $e) { |
|
204 | + } catch (PDOException $e) { |
|
205 | 205 | echo $e->getMessage(); |
206 | 206 | die; |
207 | 207 | } |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | date_default_timezone_set('UTC'); |
224 | 224 | |
225 | 225 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
226 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
226 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
227 | 227 | |
228 | 228 | try { |
229 | 229 | $sth = $this->db->prepare($query); |
230 | 230 | $sth->execute(array(':ident' => $ident)); |
231 | - } catch(PDOException $e) { |
|
231 | + } catch (PDOException $e) { |
|
232 | 232 | echo $e->getMessage(); |
233 | 233 | die; |
234 | 234 | } |
@@ -249,12 +249,12 @@ discard block |
||
249 | 249 | date_default_timezone_set('UTC'); |
250 | 250 | |
251 | 251 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
252 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
252 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
253 | 253 | |
254 | 254 | try { |
255 | 255 | $sth = $this->db->prepare($query); |
256 | 256 | $sth->execute(array(':id' => $id)); |
257 | - } catch(PDOException $e) { |
|
257 | + } catch (PDOException $e) { |
|
258 | 258 | echo $e->getMessage(); |
259 | 259 | die; |
260 | 260 | } |
@@ -275,12 +275,12 @@ discard block |
||
275 | 275 | date_default_timezone_set('UTC'); |
276 | 276 | |
277 | 277 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
278 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
278 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
279 | 279 | |
280 | 280 | try { |
281 | 281 | $sth = $this->db->prepare($query); |
282 | 282 | $sth->execute(array(':id' => $id)); |
283 | - } catch(PDOException $e) { |
|
283 | + } catch (PDOException $e) { |
|
284 | 284 | echo $e->getMessage(); |
285 | 285 | die; |
286 | 286 | } |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | date_default_timezone_set('UTC'); |
303 | 303 | |
304 | 304 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
305 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
305 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
306 | 306 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
307 | 307 | |
308 | 308 | try { |
309 | 309 | $sth = $this->db->prepare($query); |
310 | 310 | $sth->execute(array(':ident' => $ident)); |
311 | - } catch(PDOException $e) { |
|
311 | + } catch (PDOException $e) { |
|
312 | 312 | echo $e->getMessage(); |
313 | 313 | die; |
314 | 314 | } |
@@ -325,13 +325,13 @@ discard block |
||
325 | 325 | * @return Array the spotter information |
326 | 326 | * |
327 | 327 | */ |
328 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
328 | + public function getTrackerArchiveData($ident, $famtrackid, $date) |
|
329 | 329 | { |
330 | 330 | $Tracker = new Tracker($this->db); |
331 | 331 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
332 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
332 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
333 | 333 | |
334 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
334 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':famtrackid' => $famtrackid, ':date' => $date.'%')); |
|
335 | 335 | |
336 | 336 | return $spotter_array; |
337 | 337 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | try { |
348 | 348 | $sth = $this->db->prepare($query); |
349 | 349 | $sth->execute(); |
350 | - } catch(PDOException $e) { |
|
350 | + } catch (PDOException $e) { |
|
351 | 351 | echo $e->getMessage(); |
352 | 352 | die; |
353 | 353 | } |
@@ -359,24 +359,24 @@ discard block |
||
359 | 359 | * @return Array the spotter information |
360 | 360 | * |
361 | 361 | */ |
362 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
362 | + public function getMinLiveTrackerData($begindate, $enddate, $filter = array()) |
|
363 | 363 | { |
364 | 364 | global $globalDBdriver, $globalLiveInterval; |
365 | 365 | date_default_timezone_set('UTC'); |
366 | 366 | |
367 | 367 | $filter_query = ''; |
368 | 368 | if (isset($filter['source']) && !empty($filter['source'])) { |
369 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
369 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
370 | 370 | } |
371 | 371 | // Use spotter_output also ? |
372 | 372 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
373 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
373 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
374 | 374 | } |
375 | 375 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
376 | 376 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
377 | 377 | } |
378 | 378 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
379 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
379 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -395,14 +395,14 @@ discard block |
||
395 | 395 | GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid |
396 | 396 | AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
397 | 397 | */ |
398 | - $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 | + $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 |
|
399 | 399 | FROM tracker_archive |
400 | 400 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
401 | 401 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
402 | 402 | '.$filter_query.' ORDER BY famtrackid'; |
403 | 403 | } else { |
404 | 404 | //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
405 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
405 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
406 | 406 | FROM tracker_archive |
407 | 407 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
408 | 408 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | try { |
413 | 413 | $sth = $this->db->prepare($query); |
414 | 414 | $sth->execute(); |
415 | - } catch(PDOException $e) { |
|
415 | + } catch (PDOException $e) { |
|
416 | 416 | echo $e->getMessage(); |
417 | 417 | die; |
418 | 418 | } |
@@ -427,24 +427,24 @@ discard block |
||
427 | 427 | * @return Array the spotter information |
428 | 428 | * |
429 | 429 | */ |
430 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
430 | + public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array()) |
|
431 | 431 | { |
432 | 432 | global $globalDBdriver, $globalLiveInterval; |
433 | 433 | date_default_timezone_set('UTC'); |
434 | 434 | |
435 | 435 | $filter_query = ''; |
436 | 436 | if (isset($filter['source']) && !empty($filter['source'])) { |
437 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
437 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
438 | 438 | } |
439 | 439 | // Should use spotter_output also ? |
440 | 440 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
441 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
441 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
442 | 442 | } |
443 | 443 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
444 | 444 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
445 | 445 | } |
446 | 446 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
447 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
447 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | FROM tracker_archive |
455 | 455 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
456 | 456 | */ |
457 | - $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 | + $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 |
|
458 | 458 | FROM tracker_archive_output |
459 | 459 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao |
460 | 460 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
470 | 470 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
471 | 471 | */ |
472 | - $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
472 | + $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
473 | 473 | FROM tracker_archive_output |
474 | 474 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
475 | 475 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | try { |
482 | 482 | $sth = $this->db->prepare($query); |
483 | 483 | $sth->execute(); |
484 | - } catch(PDOException $e) { |
|
484 | + } catch (PDOException $e) { |
|
485 | 485 | echo $e->getMessage(); |
486 | 486 | die; |
487 | 487 | } |
@@ -496,23 +496,23 @@ discard block |
||
496 | 496 | * @return Array the spotter information |
497 | 497 | * |
498 | 498 | */ |
499 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
499 | + public function getLiveTrackerCount($begindate, $enddate, $filter = array()) |
|
500 | 500 | { |
501 | 501 | global $globalDBdriver, $globalLiveInterval; |
502 | 502 | date_default_timezone_set('UTC'); |
503 | 503 | |
504 | 504 | $filter_query = ''; |
505 | 505 | if (isset($filter['source']) && !empty($filter['source'])) { |
506 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
506 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
507 | 507 | } |
508 | 508 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
509 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
509 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
510 | 510 | } |
511 | 511 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
512 | 512 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
513 | 513 | } |
514 | 514 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
515 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
515 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $this->db->prepare($query); |
529 | 529 | $sth->execute(); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | echo $e->getMessage(); |
532 | 532 | die; |
533 | 533 | } |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | * @return Array the spotter information |
548 | 548 | * |
549 | 549 | */ |
550 | - public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
550 | + public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
551 | 551 | { |
552 | 552 | global $globalTimezone, $globalDBdriver; |
553 | 553 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | |
570 | 570 | $q_array = explode(" ", $q); |
571 | 571 | |
572 | - foreach ($q_array as $q_item){ |
|
572 | + foreach ($q_array as $q_item) { |
|
573 | 573 | $additional_query .= " AND ("; |
574 | 574 | $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
575 | 575 | $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | |
602 | 602 | if ($registration != "") |
603 | 603 | { |
604 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
604 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
605 | 605 | if (!is_string($registration)) |
606 | 606 | { |
607 | 607 | return false; |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | |
613 | 613 | if ($aircraft_icao != "") |
614 | 614 | { |
615 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
615 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
616 | 616 | if (!is_string($aircraft_icao)) |
617 | 617 | { |
618 | 618 | return false; |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | |
624 | 624 | if ($aircraft_manufacturer != "") |
625 | 625 | { |
626 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
626 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
627 | 627 | if (!is_string($aircraft_manufacturer)) |
628 | 628 | { |
629 | 629 | return false; |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | |
645 | 645 | if ($airline_icao != "") |
646 | 646 | { |
647 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
647 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
648 | 648 | if (!is_string($airline_icao)) |
649 | 649 | { |
650 | 650 | return false; |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | |
656 | 656 | if ($airline_country != "") |
657 | 657 | { |
658 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
658 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
659 | 659 | if (!is_string($airline_country)) |
660 | 660 | { |
661 | 661 | return false; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | |
667 | 667 | if ($airline_type != "") |
668 | 668 | { |
669 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
669 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
670 | 670 | if (!is_string($airline_type)) |
671 | 671 | { |
672 | 672 | return false; |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | |
689 | 689 | if ($airport != "") |
690 | 690 | { |
691 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
691 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
692 | 692 | if (!is_string($airport)) |
693 | 693 | { |
694 | 694 | return false; |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | |
700 | 700 | if ($airport_country != "") |
701 | 701 | { |
702 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
702 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
703 | 703 | if (!is_string($airport_country)) |
704 | 704 | { |
705 | 705 | return false; |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | |
711 | 711 | if ($callsign != "") |
712 | 712 | { |
713 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
713 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
714 | 714 | if (!is_string($callsign)) |
715 | 715 | { |
716 | 716 | return false; |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | $translate = $Translation->ident2icao($callsign); |
719 | 719 | if ($translate != $callsign) { |
720 | 720 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
721 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
721 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
722 | 722 | } else { |
723 | 723 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
724 | 724 | } |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | |
728 | 728 | if ($owner != "") |
729 | 729 | { |
730 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
730 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
731 | 731 | if (!is_string($owner)) |
732 | 732 | { |
733 | 733 | return false; |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | |
739 | 739 | if ($pilot_name != "") |
740 | 740 | { |
741 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
741 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
742 | 742 | if (!is_string($pilot_name)) |
743 | 743 | { |
744 | 744 | return false; |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | |
750 | 750 | if ($pilot_id != "") |
751 | 751 | { |
752 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
752 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
753 | 753 | if (!is_string($pilot_id)) |
754 | 754 | { |
755 | 755 | return false; |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | |
761 | 761 | if ($departure_airport_route != "") |
762 | 762 | { |
763 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
763 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
764 | 764 | if (!is_string($departure_airport_route)) |
765 | 765 | { |
766 | 766 | return false; |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | |
772 | 772 | if ($arrival_airport_route != "") |
773 | 773 | { |
774 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
774 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
775 | 775 | if (!is_string($arrival_airport_route)) |
776 | 776 | { |
777 | 777 | return false; |
@@ -784,8 +784,8 @@ discard block |
||
784 | 784 | { |
785 | 785 | $altitude_array = explode(",", $altitude); |
786 | 786 | |
787 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
787 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
788 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
789 | 789 | |
790 | 790 | |
791 | 791 | if ($altitude_array[1] != "") |
@@ -803,8 +803,8 @@ discard block |
||
803 | 803 | { |
804 | 804 | $date_array = explode(",", $date_posted); |
805 | 805 | |
806 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
807 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
806 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
807 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
808 | 808 | |
809 | 809 | if ($globalTimezone != '') { |
810 | 810 | date_default_timezone_set($globalTimezone); |
@@ -836,8 +836,8 @@ discard block |
||
836 | 836 | { |
837 | 837 | $limit_array = explode(",", $limit); |
838 | 838 | |
839 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
840 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
839 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
840 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
841 | 841 | |
842 | 842 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
843 | 843 | { |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | |
849 | 849 | |
850 | 850 | if ($origLat != "" && $origLon != "" && $dist != "") { |
851 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
852 | - $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 |
|
851 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
852 | + $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 |
|
853 | 853 | 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)) |
854 | 854 | 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"; |
855 | 855 | } else { |
@@ -866,12 +866,12 @@ discard block |
||
866 | 866 | $additional_query .= " AND (tracker_archive_output.waypoints <> '')"; |
867 | 867 | } |
868 | 868 | |
869 | - $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
869 | + $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
870 | 870 | WHERE tracker_archive_output.ident <> '' |
871 | 871 | ".$additional_query." |
872 | 872 | ".$filter_query.$orderby_query; |
873 | 873 | } |
874 | - $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
|
874 | + $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
875 | 875 | |
876 | 876 | return $spotter_array; |
877 | 877 | } |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | try { |
889 | 889 | $sth = $this->db->prepare($query); |
890 | 890 | $sth->execute(); |
891 | - } catch(PDOException $e) { |
|
891 | + } catch (PDOException $e) { |
|
892 | 892 | return "error"; |
893 | 893 | } |
894 | 894 | } |
@@ -925,8 +925,8 @@ discard block |
||
925 | 925 | { |
926 | 926 | $limit_array = explode(",", $limit); |
927 | 927 | |
928 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
929 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
928 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
929 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
930 | 930 | |
931 | 931 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
932 | 932 | { |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | $query_values = array(); |
968 | 968 | $limit_query = ''; |
969 | 969 | $additional_query = ''; |
970 | - $filter_query = $this->getFilter($filter,true,true); |
|
970 | + $filter_query = $this->getFilter($filter, true, true); |
|
971 | 971 | |
972 | 972 | if ($owner != "") |
973 | 973 | { |
@@ -984,8 +984,8 @@ discard block |
||
984 | 984 | { |
985 | 985 | $limit_array = explode(",", $limit); |
986 | 986 | |
987 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
988 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
987 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
988 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
989 | 989 | |
990 | 990 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
991 | 991 | { |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | $query_values = array(); |
1026 | 1026 | $limit_query = ''; |
1027 | 1027 | $additional_query = ''; |
1028 | - $filter_query = $this->getFilter($filter,true,true); |
|
1028 | + $filter_query = $this->getFilter($filter, true, true); |
|
1029 | 1029 | |
1030 | 1030 | if ($pilot != "") |
1031 | 1031 | { |
@@ -1037,8 +1037,8 @@ discard block |
||
1037 | 1037 | { |
1038 | 1038 | $limit_array = explode(",", $limit); |
1039 | 1039 | |
1040 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1040 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1041 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1042 | 1042 | |
1043 | 1043 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1044 | 1044 | { |
@@ -1068,7 +1068,7 @@ discard block |
||
1068 | 1068 | * @return Array the airline country list |
1069 | 1069 | * |
1070 | 1070 | */ |
1071 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1071 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1072 | 1072 | { |
1073 | 1073 | global $globalDBdriver; |
1074 | 1074 | /* |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | $flight_array = array(); |
1098 | 1098 | $temp_array = array(); |
1099 | 1099 | |
1100 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1100 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1101 | 1101 | { |
1102 | 1102 | $temp_array['flight_count'] = $row['nb']; |
1103 | 1103 | $temp_array['flight_country'] = $row['name']; |
@@ -1114,7 +1114,7 @@ discard block |
||
1114 | 1114 | * @return Array the airline country list |
1115 | 1115 | * |
1116 | 1116 | */ |
1117 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1117 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1118 | 1118 | { |
1119 | 1119 | global $globalDBdriver; |
1120 | 1120 | /* |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | $flight_array = array(); |
1144 | 1144 | $temp_array = array(); |
1145 | 1145 | |
1146 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1146 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1147 | 1147 | { |
1148 | 1148 | $temp_array['airline_icao'] = $row['airline_icao']; |
1149 | 1149 | $temp_array['flight_count'] = $row['nb']; |
@@ -1161,14 +1161,14 @@ discard block |
||
1161 | 1161 | * @return Array the spotter information |
1162 | 1162 | * |
1163 | 1163 | */ |
1164 | - public function getDateArchiveTrackerDataById($id,$date) |
|
1164 | + public function getDateArchiveTrackerDataById($id, $date) |
|
1165 | 1165 | { |
1166 | 1166 | $Tracker = new Tracker($this->db); |
1167 | 1167 | date_default_timezone_set('UTC'); |
1168 | 1168 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1169 | - $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'; |
|
1170 | - $date = date('c',$date); |
|
1171 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1169 | + $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'; |
|
1170 | + $date = date('c', $date); |
|
1171 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1172 | 1172 | return $spotter_array; |
1173 | 1173 | } |
1174 | 1174 | |
@@ -1178,14 +1178,14 @@ discard block |
||
1178 | 1178 | * @return Array the spotter information |
1179 | 1179 | * |
1180 | 1180 | */ |
1181 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
1181 | + public function getDateArchiveTrackerDataByIdent($ident, $date) |
|
1182 | 1182 | { |
1183 | 1183 | $Tracker = new Tracker($this->db); |
1184 | 1184 | date_default_timezone_set('UTC'); |
1185 | 1185 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1186 | - $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'; |
|
1187 | - $date = date('c',$date); |
|
1188 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1186 | + $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'; |
|
1187 | + $date = date('c', $date); |
|
1188 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1189 | 1189 | return $spotter_array; |
1190 | 1190 | } |
1191 | 1191 | |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | * @return Array the spotter information |
1196 | 1196 | * |
1197 | 1197 | */ |
1198 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1198 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1199 | 1199 | { |
1200 | 1200 | global $global_query; |
1201 | 1201 | $Tracker = new Tracker($this->db); |
@@ -1203,7 +1203,7 @@ discard block |
||
1203 | 1203 | $query_values = array(); |
1204 | 1204 | $limit_query = ''; |
1205 | 1205 | $additional_query = ''; |
1206 | - $filter_query = $this->getFilter($filters,true,true); |
|
1206 | + $filter_query = $this->getFilter($filters, true, true); |
|
1207 | 1207 | |
1208 | 1208 | if ($airport != "") |
1209 | 1209 | { |
@@ -1220,8 +1220,8 @@ discard block |
||
1220 | 1220 | { |
1221 | 1221 | $limit_array = explode(",", $limit); |
1222 | 1222 | |
1223 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1224 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1223 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1224 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1225 | 1225 | |
1226 | 1226 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1227 | 1227 | { |
@@ -14,33 +14,33 @@ discard block |
||
14 | 14 | * @param Array $filter the filter |
15 | 15 | * @return Array the SQL part |
16 | 16 | */ |
17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
17 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
22 | 22 | $filters = $globalStatsFilters[$globalFilterName]; |
23 | 23 | } else { |
24 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
24 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | if (isset($filter[0]['source'])) { |
28 | - $filters = array_merge($filters,$filter); |
|
28 | + $filters = array_merge($filters, $filter); |
|
29 | 29 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
30 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
31 | 31 | $filter_query_join = ''; |
32 | 32 | $filter_query_where = ''; |
33 | - foreach($filters as $flt) { |
|
33 | + foreach ($filters as $flt) { |
|
34 | 34 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
35 | 35 | if (isset($flt['source'])) { |
36 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
36 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
37 | 37 | } else { |
38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | if (isset($filter['source']) && !empty($filter['source'])) { |
43 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
43 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
44 | 44 | } |
45 | 45 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
46 | 46 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -68,42 +68,42 @@ discard block |
||
68 | 68 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'"; |
69 | 69 | } |
70 | 70 | } |
71 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
71 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
72 | 72 | } |
73 | 73 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
74 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
75 | 75 | } |
76 | 76 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
77 | 77 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
78 | 78 | if ($filter_query_where != '') { |
79 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
79 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
80 | 80 | } |
81 | 81 | $filter_query = $filter_query_join.$filter_query_where; |
82 | 82 | return $filter_query; |
83 | 83 | } |
84 | 84 | |
85 | 85 | // marine_archive |
86 | - public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { |
|
86 | + public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
87 | 87 | require_once(dirname(__FILE__).'/class.Marine.php'); |
88 | 88 | if ($over_country == '') { |
89 | 89 | $Marine = new Marine($this->db); |
90 | - $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
90 | + $data_country = $Marine->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
91 | 91 | if (!empty($data_country)) $country = $data_country['iso2']; |
92 | 92 | else $country = ''; |
93 | 93 | } else $country = $over_country; |
94 | 94 | |
95 | 95 | //$country = $over_country; |
96 | 96 | // Route is not added in marine_archive |
97 | - $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
97 | + $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
98 | 98 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
99 | 99 | |
100 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
100 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
101 | 101 | |
102 | 102 | try { |
103 | 103 | $sth = $this->db->prepare($query); |
104 | 104 | $sth->execute($query_values); |
105 | 105 | $sth->closeCursor(); |
106 | - } catch(PDOException $e) { |
|
106 | + } catch (PDOException $e) { |
|
107 | 107 | return "error : ".$e->getMessage(); |
108 | 108 | } |
109 | 109 | return "success"; |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | |
124 | 124 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
125 | 125 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
126 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
126 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
127 | 127 | |
128 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
128 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident)); |
|
129 | 129 | |
130 | 130 | return $spotter_array; |
131 | 131 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
145 | 145 | //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
146 | 146 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
147 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
147 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
148 | 148 | |
149 | 149 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
150 | 150 | /* |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | } |
158 | 158 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
159 | 159 | */ |
160 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
160 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id)); |
|
161 | 161 | |
162 | 162 | return $spotter_array; |
163 | 163 | } |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | { |
173 | 173 | date_default_timezone_set('UTC'); |
174 | 174 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
175 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
175 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
176 | 176 | |
177 | 177 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
178 | 178 | |
179 | 179 | try { |
180 | 180 | $sth = $this->db->prepare($query); |
181 | 181 | $sth->execute(array(':id' => $id)); |
182 | - } catch(PDOException $e) { |
|
182 | + } catch (PDOException $e) { |
|
183 | 183 | echo $e->getMessage(); |
184 | 184 | die; |
185 | 185 | } |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | { |
199 | 199 | date_default_timezone_set('UTC'); |
200 | 200 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
201 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
201 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
202 | 202 | |
203 | 203 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
204 | 204 | |
205 | 205 | try { |
206 | 206 | $sth = $this->db->prepare($query); |
207 | 207 | $sth->execute(array(':id' => $id)); |
208 | - } catch(PDOException $e) { |
|
208 | + } catch (PDOException $e) { |
|
209 | 209 | echo $e->getMessage(); |
210 | 210 | die; |
211 | 211 | } |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | date_default_timezone_set('UTC'); |
228 | 228 | |
229 | 229 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
230 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
230 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
231 | 231 | |
232 | 232 | try { |
233 | 233 | $sth = $this->db->prepare($query); |
234 | 234 | $sth->execute(array(':ident' => $ident)); |
235 | - } catch(PDOException $e) { |
|
235 | + } catch (PDOException $e) { |
|
236 | 236 | echo $e->getMessage(); |
237 | 237 | die; |
238 | 238 | } |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | date_default_timezone_set('UTC'); |
254 | 254 | |
255 | 255 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
256 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
256 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
257 | 257 | |
258 | 258 | try { |
259 | 259 | $sth = $this->db->prepare($query); |
260 | 260 | $sth->execute(array(':id' => $id)); |
261 | - } catch(PDOException $e) { |
|
261 | + } catch (PDOException $e) { |
|
262 | 262 | echo $e->getMessage(); |
263 | 263 | die; |
264 | 264 | } |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | date_default_timezone_set('UTC'); |
280 | 280 | |
281 | 281 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
282 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
282 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
283 | 283 | |
284 | 284 | try { |
285 | 285 | $sth = $this->db->prepare($query); |
286 | 286 | $sth->execute(array(':id' => $id)); |
287 | - } catch(PDOException $e) { |
|
287 | + } catch (PDOException $e) { |
|
288 | 288 | echo $e->getMessage(); |
289 | 289 | die; |
290 | 290 | } |
@@ -306,13 +306,13 @@ discard block |
||
306 | 306 | date_default_timezone_set('UTC'); |
307 | 307 | |
308 | 308 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
309 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
309 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
310 | 310 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
311 | 311 | |
312 | 312 | try { |
313 | 313 | $sth = $this->db->prepare($query); |
314 | 314 | $sth->execute(array(':ident' => $ident)); |
315 | - } catch(PDOException $e) { |
|
315 | + } catch (PDOException $e) { |
|
316 | 316 | echo $e->getMessage(); |
317 | 317 | die; |
318 | 318 | } |
@@ -329,12 +329,12 @@ discard block |
||
329 | 329 | * @return Array the spotter information |
330 | 330 | * |
331 | 331 | */ |
332 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
332 | + public function getMarineArchiveData($ident, $fammarine_id, $date) |
|
333 | 333 | { |
334 | 334 | $Marine = new Marine($this->db); |
335 | 335 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
336 | 336 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
337 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
337 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); |
|
338 | 338 | return $spotter_array; |
339 | 339 | } |
340 | 340 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | try { |
354 | 354 | $sth = $this->db->prepare($query); |
355 | 355 | $sth->execute(); |
356 | - } catch(PDOException $e) { |
|
356 | + } catch (PDOException $e) { |
|
357 | 357 | echo $e->getMessage(); |
358 | 358 | die; |
359 | 359 | } |
@@ -365,24 +365,24 @@ discard block |
||
365 | 365 | * @return Array the spotter information |
366 | 366 | * |
367 | 367 | */ |
368 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
368 | + public function getMinLiveMarineData($begindate, $enddate, $filter = array()) |
|
369 | 369 | { |
370 | 370 | global $globalDBdriver, $globalLiveInterval; |
371 | 371 | date_default_timezone_set('UTC'); |
372 | 372 | |
373 | 373 | $filter_query = ''; |
374 | 374 | if (isset($filter['source']) && !empty($filter['source'])) { |
375 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
375 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
376 | 376 | } |
377 | 377 | // Use spotter_output also ? |
378 | 378 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
379 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
379 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
380 | 380 | } |
381 | 381 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
382 | 382 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
383 | 383 | } |
384 | 384 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
385 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
385 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -401,14 +401,14 @@ discard block |
||
401 | 401 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
402 | 402 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
403 | 403 | */ |
404 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
404 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
405 | 405 | FROM marine_archive |
406 | 406 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
407 | 407 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
408 | 408 | '.$filter_query.' ORDER BY fammarine_id'; |
409 | 409 | } else { |
410 | 410 | //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
411 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
411 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
412 | 412 | FROM marine_archive |
413 | 413 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
414 | 414 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | try { |
419 | 419 | $sth = $this->db->prepare($query); |
420 | 420 | $sth->execute(); |
421 | - } catch(PDOException $e) { |
|
421 | + } catch (PDOException $e) { |
|
422 | 422 | echo $e->getMessage(); |
423 | 423 | die; |
424 | 424 | } |
@@ -433,24 +433,24 @@ discard block |
||
433 | 433 | * @return Array the spotter information |
434 | 434 | * |
435 | 435 | */ |
436 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
436 | + public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array()) |
|
437 | 437 | { |
438 | 438 | global $globalDBdriver, $globalLiveInterval; |
439 | 439 | date_default_timezone_set('UTC'); |
440 | 440 | |
441 | 441 | $filter_query = ''; |
442 | 442 | if (isset($filter['source']) && !empty($filter['source'])) { |
443 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
443 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
444 | 444 | } |
445 | 445 | // Should use spotter_output also ? |
446 | 446 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
447 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
447 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
448 | 448 | } |
449 | 449 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
450 | 450 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
451 | 451 | } |
452 | 452 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
453 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
453 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | FROM marine_archive |
461 | 461 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
462 | 462 | */ |
463 | - $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
463 | + $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
464 | 464 | FROM marine_archive_output |
465 | 465 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
466 | 466 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
476 | 476 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
477 | 477 | */ |
478 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
478 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
479 | 479 | FROM marine_archive_output |
480 | 480 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
481 | 481 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | try { |
488 | 488 | $sth = $this->db->prepare($query); |
489 | 489 | $sth->execute(); |
490 | - } catch(PDOException $e) { |
|
490 | + } catch (PDOException $e) { |
|
491 | 491 | echo $e->getMessage(); |
492 | 492 | die; |
493 | 493 | } |
@@ -502,23 +502,23 @@ discard block |
||
502 | 502 | * @return Array the spotter information |
503 | 503 | * |
504 | 504 | */ |
505 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
505 | + public function getLiveMarineCount($begindate, $enddate, $filter = array()) |
|
506 | 506 | { |
507 | 507 | global $globalDBdriver, $globalLiveInterval; |
508 | 508 | date_default_timezone_set('UTC'); |
509 | 509 | |
510 | 510 | $filter_query = ''; |
511 | 511 | if (isset($filter['source']) && !empty($filter['source'])) { |
512 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
512 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
513 | 513 | } |
514 | 514 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
515 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
515 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
516 | 516 | } |
517 | 517 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
518 | 518 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
519 | 519 | } |
520 | 520 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
521 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
521 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | try { |
534 | 534 | $sth = $this->db->prepare($query); |
535 | 535 | $sth->execute(); |
536 | - } catch(PDOException $e) { |
|
536 | + } catch (PDOException $e) { |
|
537 | 537 | echo $e->getMessage(); |
538 | 538 | die; |
539 | 539 | } |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | * @return Array the spotter information |
554 | 554 | * |
555 | 555 | */ |
556 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
556 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
557 | 557 | { |
558 | 558 | global $globalTimezone, $globalDBdriver; |
559 | 559 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | |
576 | 576 | $q_array = explode(" ", $q); |
577 | 577 | |
578 | - foreach ($q_array as $q_item){ |
|
578 | + foreach ($q_array as $q_item) { |
|
579 | 579 | $additional_query .= " AND ("; |
580 | 580 | $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
581 | 581 | $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | |
608 | 608 | if ($registration != "") |
609 | 609 | { |
610 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
610 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
611 | 611 | if (!is_string($registration)) |
612 | 612 | { |
613 | 613 | return false; |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | |
619 | 619 | if ($aircraft_icao != "") |
620 | 620 | { |
621 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
621 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
622 | 622 | if (!is_string($aircraft_icao)) |
623 | 623 | { |
624 | 624 | return false; |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | |
630 | 630 | if ($aircraft_manufacturer != "") |
631 | 631 | { |
632 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
632 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
633 | 633 | if (!is_string($aircraft_manufacturer)) |
634 | 634 | { |
635 | 635 | return false; |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | |
651 | 651 | if ($airline_icao != "") |
652 | 652 | { |
653 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
653 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
654 | 654 | if (!is_string($airline_icao)) |
655 | 655 | { |
656 | 656 | return false; |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | |
662 | 662 | if ($airline_country != "") |
663 | 663 | { |
664 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
664 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
665 | 665 | if (!is_string($airline_country)) |
666 | 666 | { |
667 | 667 | return false; |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | |
673 | 673 | if ($airline_type != "") |
674 | 674 | { |
675 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
675 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
676 | 676 | if (!is_string($airline_type)) |
677 | 677 | { |
678 | 678 | return false; |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | |
695 | 695 | if ($airport != "") |
696 | 696 | { |
697 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
697 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
698 | 698 | if (!is_string($airport)) |
699 | 699 | { |
700 | 700 | return false; |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | |
706 | 706 | if ($airport_country != "") |
707 | 707 | { |
708 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
708 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
709 | 709 | if (!is_string($airport_country)) |
710 | 710 | { |
711 | 711 | return false; |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | |
717 | 717 | if ($callsign != "") |
718 | 718 | { |
719 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
719 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
720 | 720 | if (!is_string($callsign)) |
721 | 721 | { |
722 | 722 | return false; |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | $translate = $Translation->ident2icao($callsign); |
725 | 725 | if ($translate != $callsign) { |
726 | 726 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
727 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
727 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
728 | 728 | } else { |
729 | 729 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
730 | 730 | } |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | |
734 | 734 | if ($owner != "") |
735 | 735 | { |
736 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
736 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
737 | 737 | if (!is_string($owner)) |
738 | 738 | { |
739 | 739 | return false; |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | |
745 | 745 | if ($pilot_name != "") |
746 | 746 | { |
747 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
747 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
748 | 748 | if (!is_string($pilot_name)) |
749 | 749 | { |
750 | 750 | return false; |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | |
756 | 756 | if ($pilot_id != "") |
757 | 757 | { |
758 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
758 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
759 | 759 | if (!is_string($pilot_id)) |
760 | 760 | { |
761 | 761 | return false; |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | |
767 | 767 | if ($departure_airport_route != "") |
768 | 768 | { |
769 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
769 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
770 | 770 | if (!is_string($departure_airport_route)) |
771 | 771 | { |
772 | 772 | return false; |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | |
778 | 778 | if ($arrival_airport_route != "") |
779 | 779 | { |
780 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
780 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
781 | 781 | if (!is_string($arrival_airport_route)) |
782 | 782 | { |
783 | 783 | return false; |
@@ -790,8 +790,8 @@ discard block |
||
790 | 790 | { |
791 | 791 | $altitude_array = explode(",", $altitude); |
792 | 792 | |
793 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
794 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
793 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
794 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
795 | 795 | |
796 | 796 | |
797 | 797 | if ($altitude_array[1] != "") |
@@ -809,8 +809,8 @@ discard block |
||
809 | 809 | { |
810 | 810 | $date_array = explode(",", $date_posted); |
811 | 811 | |
812 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
813 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
812 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
813 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
814 | 814 | |
815 | 815 | if ($globalTimezone != '') { |
816 | 816 | date_default_timezone_set($globalTimezone); |
@@ -842,8 +842,8 @@ discard block |
||
842 | 842 | { |
843 | 843 | $limit_array = explode(",", $limit); |
844 | 844 | |
845 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
846 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
845 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
846 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
847 | 847 | |
848 | 848 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
849 | 849 | { |
@@ -854,8 +854,8 @@ discard block |
||
854 | 854 | |
855 | 855 | |
856 | 856 | if ($origLat != "" && $origLon != "" && $dist != "") { |
857 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
858 | - $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
857 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
858 | + $query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
859 | 859 | FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
860 | 860 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
861 | 861 | } else { |
@@ -872,12 +872,12 @@ discard block |
||
872 | 872 | $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
873 | 873 | } |
874 | 874 | |
875 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
875 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
876 | 876 | WHERE marine_archive_output.ident <> '' |
877 | 877 | ".$additional_query." |
878 | 878 | ".$filter_query.$orderby_query; |
879 | 879 | } |
880 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
880 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
881 | 881 | |
882 | 882 | return $spotter_array; |
883 | 883 | } |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | try { |
895 | 895 | $sth = $this->db->prepare($query); |
896 | 896 | $sth->execute(); |
897 | - } catch(PDOException $e) { |
|
897 | + } catch (PDOException $e) { |
|
898 | 898 | return "error"; |
899 | 899 | } |
900 | 900 | } |
@@ -931,8 +931,8 @@ discard block |
||
931 | 931 | { |
932 | 932 | $limit_array = explode(",", $limit); |
933 | 933 | |
934 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
935 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
934 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
935 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
936 | 936 | |
937 | 937 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
938 | 938 | { |
@@ -973,7 +973,7 @@ discard block |
||
973 | 973 | $query_values = array(); |
974 | 974 | $limit_query = ''; |
975 | 975 | $additional_query = ''; |
976 | - $filter_query = $this->getFilter($filter,true,true); |
|
976 | + $filter_query = $this->getFilter($filter, true, true); |
|
977 | 977 | |
978 | 978 | if ($owner != "") |
979 | 979 | { |
@@ -990,8 +990,8 @@ discard block |
||
990 | 990 | { |
991 | 991 | $limit_array = explode(",", $limit); |
992 | 992 | |
993 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
994 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
993 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
994 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
995 | 995 | |
996 | 996 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
997 | 997 | { |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | $query_values = array(); |
1032 | 1032 | $limit_query = ''; |
1033 | 1033 | $additional_query = ''; |
1034 | - $filter_query = $this->getFilter($filter,true,true); |
|
1034 | + $filter_query = $this->getFilter($filter, true, true); |
|
1035 | 1035 | |
1036 | 1036 | if ($pilot != "") |
1037 | 1037 | { |
@@ -1043,8 +1043,8 @@ discard block |
||
1043 | 1043 | { |
1044 | 1044 | $limit_array = explode(",", $limit); |
1045 | 1045 | |
1046 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1047 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1046 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1047 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1048 | 1048 | |
1049 | 1049 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1050 | 1050 | { |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | * @return Array the airline country list |
1075 | 1075 | * |
1076 | 1076 | */ |
1077 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1077 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1078 | 1078 | { |
1079 | 1079 | global $globalDBdriver; |
1080 | 1080 | /* |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | $flight_array = array(); |
1104 | 1104 | $temp_array = array(); |
1105 | 1105 | |
1106 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1106 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1107 | 1107 | { |
1108 | 1108 | $temp_array['flight_count'] = $row['nb']; |
1109 | 1109 | $temp_array['flight_country'] = $row['name']; |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | * @return Array the airline country list |
1121 | 1121 | * |
1122 | 1122 | */ |
1123 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1123 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1124 | 1124 | { |
1125 | 1125 | global $globalDBdriver; |
1126 | 1126 | /* |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | $flight_array = array(); |
1150 | 1150 | $temp_array = array(); |
1151 | 1151 | |
1152 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1152 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1153 | 1153 | { |
1154 | 1154 | $temp_array['airline_icao'] = $row['airline_icao']; |
1155 | 1155 | $temp_array['flight_count'] = $row['nb']; |
@@ -1167,14 +1167,14 @@ discard block |
||
1167 | 1167 | * @return Array the spotter information |
1168 | 1168 | * |
1169 | 1169 | */ |
1170 | - public function getDateArchiveMarineDataById($id,$date) |
|
1170 | + public function getDateArchiveMarineDataById($id, $date) |
|
1171 | 1171 | { |
1172 | 1172 | $Marine = new Marine($this->db); |
1173 | 1173 | date_default_timezone_set('UTC'); |
1174 | 1174 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1175 | 1175 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
1176 | - $date = date('c',$date); |
|
1177 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1176 | + $date = date('c', $date); |
|
1177 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1178 | 1178 | return $spotter_array; |
1179 | 1179 | } |
1180 | 1180 | |
@@ -1184,14 +1184,14 @@ discard block |
||
1184 | 1184 | * @return Array the spotter information |
1185 | 1185 | * |
1186 | 1186 | */ |
1187 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1187 | + public function getDateArchiveMarineDataByIdent($ident, $date) |
|
1188 | 1188 | { |
1189 | 1189 | $Marine = new Marine($this->db); |
1190 | 1190 | date_default_timezone_set('UTC'); |
1191 | 1191 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1192 | 1192 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
1193 | - $date = date('c',$date); |
|
1194 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1193 | + $date = date('c', $date); |
|
1194 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1195 | 1195 | return $spotter_array; |
1196 | 1196 | } |
1197 | 1197 | |
@@ -1201,7 +1201,7 @@ discard block |
||
1201 | 1201 | * @return Array the spotter information |
1202 | 1202 | * |
1203 | 1203 | */ |
1204 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1204 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1205 | 1205 | { |
1206 | 1206 | global $global_query; |
1207 | 1207 | $Marine = new Marine($this->db); |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | $query_values = array(); |
1210 | 1210 | $limit_query = ''; |
1211 | 1211 | $additional_query = ''; |
1212 | - $filter_query = $this->getFilter($filters,true,true); |
|
1212 | + $filter_query = $this->getFilter($filters, true, true); |
|
1213 | 1213 | |
1214 | 1214 | if ($airport != "") |
1215 | 1215 | { |
@@ -1226,8 +1226,8 @@ discard block |
||
1226 | 1226 | { |
1227 | 1227 | $limit_array = explode(",", $limit); |
1228 | 1228 | |
1229 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1230 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1229 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1230 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1231 | 1231 | |
1232 | 1232 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1233 | 1233 | { |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | } else { |
20 | 20 | $title = _("Statistics").' - '._("Most common Country a flight was over"); |
21 | 21 | } |
22 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
22 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
23 | 23 | if ($airline_icao == '' && isset($globalFilter)) { |
24 | 24 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
25 | 25 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | if ($type == 'aircraft') { |
51 | - $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name); |
|
51 | + $flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name); |
|
52 | 52 | } elseif ($type == 'marine') { |
53 | 53 | $flightover_array = $Marine->countAllMarineOverCountries(); |
54 | 54 | } elseif ($type == 'tracker') { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
63 | 63 | print 'var series = ['; |
64 | 64 | $flightover_data = ''; |
65 | -foreach($flightover_array as $flightover_item) |
|
65 | +foreach ($flightover_array as $flightover_item) |
|
66 | 66 | { |
67 | 67 | if ($type == 'aircraft') $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],'; |
68 | 68 | elseif ($type == 'marine') $flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],'; |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | print '</thead>'; |
114 | 114 | print '<tbody>'; |
115 | 115 | $i = 1; |
116 | - array_splice($flightover_array,10); |
|
117 | - foreach($flightover_array as $flightover_item) |
|
116 | + array_splice($flightover_array, 10); |
|
117 | + foreach ($flightover_array as $flightover_item) |
|
118 | 118 | { |
119 | 119 | print '<tr>'; |
120 | 120 | print '<td><strong>'.$i.'</strong></td>'; |