@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
3 | 3 | $global_query = "SELECT marine_output.* FROM marine_output"; |
4 | 4 | |
5 | -class Marine{ |
|
5 | +class Marine { |
|
6 | 6 | public $db; |
7 | 7 | |
8 | 8 | public function __construct($dbc = null) { |
@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
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 spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
39 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.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'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.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,7 +72,7 @@ discard block |
||
72 | 72 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
73 | 73 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
74 | 74 | if ($filter_query_where != '') { |
75 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
75 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
76 | 76 | } |
77 | 77 | $filter_query = $filter_query_join.$filter_query_where; |
78 | 78 | return $filter_query; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @return Array the spotter information |
88 | 88 | * |
89 | 89 | */ |
90 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
90 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
91 | 91 | { |
92 | 92 | date_default_timezone_set('UTC'); |
93 | 93 | if (!is_string($query)) |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | $sth = $this->db->prepare($query.$limitQuery); |
108 | 108 | $sth->execute($params); |
109 | 109 | } catch (PDOException $e) { |
110 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
110 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
111 | 111 | exit(); |
112 | 112 | } |
113 | 113 | |
114 | 114 | $num_rows = 0; |
115 | 115 | $spotter_array = array(); |
116 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
116 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
117 | 117 | { |
118 | 118 | $num_rows++; |
119 | 119 | $temp_array = array(); |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | } |
146 | 146 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
147 | 147 | |
148 | - if($temp_array['mmsi'] != "") |
|
148 | + if ($temp_array['mmsi'] != "") |
|
149 | 149 | { |
150 | 150 | $Image = new Image($this->db); |
151 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
151 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
152 | 152 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
153 | 153 | unset($Image); |
154 | 154 | if (count($image_array) > 0) { |
@@ -184,17 +184,17 @@ discard block |
||
184 | 184 | { |
185 | 185 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
186 | 186 | } else { |
187 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
187 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
188 | 188 | } |
189 | 189 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
190 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
191 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
190 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
191 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
192 | 192 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
193 | 193 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
194 | 194 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
195 | 195 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
196 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
197 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
196 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
197 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
198 | 198 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
199 | 199 | } |
200 | 200 | } |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | if ($limit != "") |
228 | 228 | { |
229 | 229 | $limit_array = explode(",", $limit); |
230 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
231 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
230 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
231 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
232 | 232 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
233 | 233 | { |
234 | 234 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | } else { |
243 | 243 | $orderby_query = " ORDER BY marine_output.date DESC"; |
244 | 244 | } |
245 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
246 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
245 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
246 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
247 | 247 | return $spotter_array; |
248 | 248 | } |
249 | 249 | |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | if ($id == '') return array(); |
262 | 262 | $additional_query = "marine_output.fammarine_id = :id"; |
263 | 263 | $query_values = array(':id' => $id); |
264 | - $query = $global_query." WHERE ".$additional_query." "; |
|
265 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
264 | + $query = $global_query." WHERE ".$additional_query." "; |
|
265 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
266 | 266 | return $spotter_array; |
267 | 267 | } |
268 | 268 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $query_values = array(); |
282 | 282 | $limit_query = ''; |
283 | 283 | $additional_query = ''; |
284 | - $filter_query = $this->getFilter($filter,true,true); |
|
284 | + $filter_query = $this->getFilter($filter, true, true); |
|
285 | 285 | if ($ident != "") |
286 | 286 | { |
287 | 287 | if (!is_string($ident)) |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | { |
298 | 298 | $limit_array = explode(",", $limit); |
299 | 299 | |
300 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
301 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
300 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
301 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
302 | 302 | |
303 | 303 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
304 | 304 | { |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | return $spotter_array; |
323 | 323 | } |
324 | 324 | |
325 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
325 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
326 | 326 | { |
327 | 327 | global $global_query, $globalTimezone, $globalDBdriver; |
328 | 328 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $limit_query = ''; |
331 | 331 | $additional_query = ''; |
332 | 332 | |
333 | - $filter_query = $this->getFilter($filter,true,true); |
|
333 | + $filter_query = $this->getFilter($filter, true, true); |
|
334 | 334 | |
335 | 335 | if ($date != "") |
336 | 336 | { |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | { |
357 | 357 | $limit_array = explode(",", $limit); |
358 | 358 | |
359 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
360 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
359 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
360 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
361 | 361 | |
362 | 362 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
363 | 363 | { |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | * @return Array list of source name |
389 | 389 | * |
390 | 390 | */ |
391 | - public function getAllSourceName($type = '',$filters = array()) |
|
391 | + public function getAllSourceName($type = '', $filters = array()) |
|
392 | 392 | { |
393 | - $filter_query = $this->getFilter($filters,true,true); |
|
393 | + $filter_query = $this->getFilter($filters, true, true); |
|
394 | 394 | $query_values = array(); |
395 | - $query = "SELECT DISTINCT marine_output.source_name |
|
395 | + $query = "SELECT DISTINCT marine_output.source_name |
|
396 | 396 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
397 | 397 | if ($type != '') { |
398 | 398 | $query_values = array(':type' => $type); |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | $source_array = array(); |
408 | 408 | $temp_array = array(); |
409 | 409 | |
410 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
410 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
411 | 411 | { |
412 | 412 | $temp_array['source_name'] = $row['source_name']; |
413 | 413 | $source_array[] = $temp_array; |
@@ -424,8 +424,8 @@ discard block |
||
424 | 424 | */ |
425 | 425 | public function getAllIdents($filters = array()) |
426 | 426 | { |
427 | - $filter_query = $this->getFilter($filters,true,true); |
|
428 | - $query = "SELECT DISTINCT marine_output.ident |
|
427 | + $filter_query = $this->getFilter($filters, true, true); |
|
428 | + $query = "SELECT DISTINCT marine_output.ident |
|
429 | 429 | FROM marine_output".$filter_query." marine_output.ident <> '' |
430 | 430 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
431 | 431 | |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | $ident_array = array(); |
436 | 436 | $temp_array = array(); |
437 | 437 | |
438 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
438 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
439 | 439 | { |
440 | 440 | $temp_array['ident'] = $row['ident']; |
441 | 441 | $ident_array[] = $temp_array; |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | */ |
453 | 453 | public function getIdentity($mmsi) |
454 | 454 | { |
455 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
455 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
456 | 456 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
457 | 457 | $sth = $this->db->prepare($query); |
458 | 458 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -477,12 +477,12 @@ discard block |
||
477 | 477 | } else $offset = '+00:00'; |
478 | 478 | |
479 | 479 | if ($globalDBdriver == 'mysql') { |
480 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
480 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
481 | 481 | FROM marine_output |
482 | 482 | WHERE marine_output.date <> '' |
483 | 483 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
484 | 484 | } else { |
485 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
485 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
486 | 486 | FROM marine_output |
487 | 487 | WHERE marine_output.date <> '' |
488 | 488 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | $date_array = array(); |
495 | 495 | $temp_array = array(); |
496 | 496 | |
497 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
497 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
498 | 498 | { |
499 | 499 | $temp_array['date'] = $row['date']; |
500 | 500 | |
@@ -513,11 +513,11 @@ discard block |
||
513 | 513 | * @return String success or false |
514 | 514 | * |
515 | 515 | */ |
516 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
516 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
517 | 517 | { |
518 | 518 | |
519 | 519 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
520 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
520 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
521 | 521 | |
522 | 522 | try { |
523 | 523 | $sth = $this->db->prepare($query); |
@@ -539,11 +539,11 @@ discard block |
||
539 | 539 | * @return String success or false |
540 | 540 | * |
541 | 541 | */ |
542 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
542 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
543 | 543 | { |
544 | 544 | |
545 | 545 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
546 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
546 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
547 | 547 | |
548 | 548 | try { |
549 | 549 | $sth = $this->db->prepare($query); |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
567 | 567 | { |
568 | 568 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
569 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
569 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
570 | 570 | |
571 | 571 | try { |
572 | 572 | $sth = $this->db->prepare($query); |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | * @param String $verticalrate vertival rate of flight |
605 | 605 | * @return String success or false |
606 | 606 | */ |
607 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
|
607 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '') |
|
608 | 608 | { |
609 | 609 | global $globalURL, $globalMarineImageFetch; |
610 | 610 | |
@@ -671,31 +671,31 @@ discard block |
||
671 | 671 | } |
672 | 672 | |
673 | 673 | |
674 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
674 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
675 | 675 | { |
676 | 676 | $date = date("Y-m-d H:i:s", time()); |
677 | 677 | } |
678 | 678 | |
679 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
680 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
681 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
682 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
683 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
684 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
685 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
686 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
687 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
688 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
689 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
690 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
691 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
692 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
679 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
680 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
681 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
682 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
683 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
684 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
685 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
686 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
687 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
688 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
689 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
690 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
691 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
692 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
693 | 693 | |
694 | 694 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
695 | 695 | $Image = new Image($this->db); |
696 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
696 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
697 | 697 | if (!isset($image_array[0]['mmsi'])) { |
698 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
698 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
699 | 699 | } |
700 | 700 | unset($Image); |
701 | 701 | } |
@@ -707,10 +707,10 @@ discard block |
||
707 | 707 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
708 | 708 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
709 | 709 | if ($arrival_date == '') $arrival_date = NULL; |
710 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
710 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
711 | 711 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
712 | 712 | |
713 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
713 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
714 | 714 | try { |
715 | 715 | |
716 | 716 | $sth = $this->db->prepare($query); |
@@ -735,13 +735,13 @@ discard block |
||
735 | 735 | { |
736 | 736 | global $globalDBdriver, $globalTimezone; |
737 | 737 | if ($globalDBdriver == 'mysql') { |
738 | - $query = "SELECT marine_output.ident FROM marine_output |
|
738 | + $query = "SELECT marine_output.ident FROM marine_output |
|
739 | 739 | WHERE marine_output.ident = :ident |
740 | 740 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
741 | 741 | AND marine_output.date < UTC_TIMESTAMP()"; |
742 | 742 | $query_data = array(':ident' => $ident); |
743 | 743 | } else { |
744 | - $query = "SELECT marine_output.ident FROM marine_output |
|
744 | + $query = "SELECT marine_output.ident FROM marine_output |
|
745 | 745 | WHERE marine_output.ident = :ident |
746 | 746 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
747 | 747 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -750,8 +750,8 @@ discard block |
||
750 | 750 | |
751 | 751 | $sth = $this->db->prepare($query); |
752 | 752 | $sth->execute($query_data); |
753 | - $ident_result=''; |
|
754 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
753 | + $ident_result = ''; |
|
754 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
755 | 755 | { |
756 | 756 | $ident_result = $row['ident']; |
757 | 757 | } |
@@ -777,8 +777,8 @@ discard block |
||
777 | 777 | return false; |
778 | 778 | } else { |
779 | 779 | $q_array = explode(" ", $q); |
780 | - foreach ($q_array as $q_item){ |
|
781 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
780 | + foreach ($q_array as $q_item) { |
|
781 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
782 | 782 | $additional_query .= " AND ("; |
783 | 783 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
784 | 784 | $additional_query .= ")"; |
@@ -786,11 +786,11 @@ discard block |
||
786 | 786 | } |
787 | 787 | } |
788 | 788 | if ($globalDBdriver == 'mysql') { |
789 | - $query = "SELECT marine_output.* FROM marine_output |
|
789 | + $query = "SELECT marine_output.* FROM marine_output |
|
790 | 790 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
791 | 791 | AND marine_output.date < UTC_TIMESTAMP()"; |
792 | 792 | } else { |
793 | - $query = "SELECT marine_output.* FROM marine_output |
|
793 | + $query = "SELECT marine_output.* FROM marine_output |
|
794 | 794 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
795 | 795 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
796 | 796 | } |
@@ -809,16 +809,16 @@ discard block |
||
809 | 809 | * |
810 | 810 | */ |
811 | 811 | |
812 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
812 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
813 | 813 | { |
814 | 814 | global $globalDBdriver, $globalArchive; |
815 | 815 | //$filter_query = $this->getFilter($filters,true,true); |
816 | - $Connection= new Connection($this->db); |
|
816 | + $Connection = new Connection($this->db); |
|
817 | 817 | if (!$Connection->tableExists('countries')) return array(); |
818 | 818 | require_once('class.SpotterLive.php'); |
819 | 819 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
820 | 820 | $MarineLive = new MarineLive($this->db); |
821 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
821 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
822 | 822 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
823 | 823 | if ($olderthanmonths > 0) { |
824 | 824 | if ($globalDBdriver == 'mysql') { |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | } else { |
839 | 839 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
840 | 840 | $MarineArchive = new MarineArchive($this->db); |
841 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
841 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
842 | 842 | $filter_query .= " over_country <> ''"; |
843 | 843 | if ($olderthanmonths > 0) { |
844 | 844 | if ($globalDBdriver == 'mysql') { |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | $flight_array = array(); |
867 | 867 | $temp_array = array(); |
868 | 868 | |
869 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
869 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
870 | 870 | { |
871 | 871 | $temp_array['marine_count'] = $row['nb']; |
872 | 872 | $temp_array['marine_country'] = $row['name']; |
@@ -885,11 +885,11 @@ discard block |
||
885 | 885 | * @return Array the callsign list |
886 | 886 | * |
887 | 887 | */ |
888 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
888 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
889 | 889 | { |
890 | 890 | global $globalDBdriver; |
891 | - $filter_query = $this->getFilter($filters,true,true); |
|
892 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
891 | + $filter_query = $this->getFilter($filters, true, true); |
|
892 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
893 | 893 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
894 | 894 | if ($olderthanmonths > 0) { |
895 | 895 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -903,28 +903,28 @@ discard block |
||
903 | 903 | if ($year != '') { |
904 | 904 | if ($globalDBdriver == 'mysql') { |
905 | 905 | $query .= " AND YEAR(marine_output.date) = :year"; |
906 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
906 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
907 | 907 | } else { |
908 | 908 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
909 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
909 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
910 | 910 | } |
911 | 911 | } |
912 | 912 | if ($month != '') { |
913 | 913 | if ($globalDBdriver == 'mysql') { |
914 | 914 | $query .= " AND MONTH(marine_output.date) = :month"; |
915 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
915 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
916 | 916 | } else { |
917 | 917 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
918 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
918 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
919 | 919 | } |
920 | 920 | } |
921 | 921 | if ($day != '') { |
922 | 922 | if ($globalDBdriver == 'mysql') { |
923 | 923 | $query .= " AND DAY(marine_output.date) = :day"; |
924 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
924 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
925 | 925 | } else { |
926 | 926 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
927 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
927 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
928 | 928 | } |
929 | 929 | } |
930 | 930 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | $callsign_array = array(); |
937 | 937 | $temp_array = array(); |
938 | 938 | |
939 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
939 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
940 | 940 | { |
941 | 941 | $temp_array['callsign_icao'] = $row['ident']; |
942 | 942 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | $date_array = array(); |
989 | 989 | $temp_array = array(); |
990 | 990 | |
991 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
991 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
992 | 992 | { |
993 | 993 | $temp_array['date_name'] = $row['date_name']; |
994 | 994 | $temp_array['date_count'] = $row['date_count']; |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | $datetime = new DateTime(); |
1015 | 1015 | $offset = $datetime->format('P'); |
1016 | 1016 | } else $offset = '+00:00'; |
1017 | - $filter_query = $this->getFilter($filters,true,true); |
|
1017 | + $filter_query = $this->getFilter($filters, true, true); |
|
1018 | 1018 | if ($globalDBdriver == 'mysql') { |
1019 | 1019 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1020 | 1020 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | $date_array = array(); |
1036 | 1036 | $temp_array = array(); |
1037 | 1037 | |
1038 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1038 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1039 | 1039 | { |
1040 | 1040 | $temp_array['date_name'] = $row['date_name']; |
1041 | 1041 | $temp_array['date_count'] = $row['date_count']; |
@@ -1060,7 +1060,7 @@ discard block |
||
1060 | 1060 | $datetime = new DateTime(); |
1061 | 1061 | $offset = $datetime->format('P'); |
1062 | 1062 | } else $offset = '+00:00'; |
1063 | - $filter_query = $this->getFilter($filters,true,true); |
|
1063 | + $filter_query = $this->getFilter($filters, true, true); |
|
1064 | 1064 | if ($globalDBdriver == 'mysql') { |
1065 | 1065 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1066 | 1066 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | $date_array = array(); |
1082 | 1082 | $temp_array = array(); |
1083 | 1083 | |
1084 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1084 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1085 | 1085 | { |
1086 | 1086 | $temp_array['date_name'] = $row['date_name']; |
1087 | 1087 | $temp_array['date_count'] = $row['date_count']; |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | $date_array = array(); |
1129 | 1129 | $temp_array = array(); |
1130 | 1130 | |
1131 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1131 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1132 | 1132 | { |
1133 | 1133 | $temp_array['month_name'] = $row['month_name']; |
1134 | 1134 | $temp_array['year_name'] = $row['year_name']; |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | $datetime = new DateTime(); |
1158 | 1158 | $offset = $datetime->format('P'); |
1159 | 1159 | } else $offset = '+00:00'; |
1160 | - $filter_query = $this->getFilter($filters,true,true); |
|
1160 | + $filter_query = $this->getFilter($filters, true, true); |
|
1161 | 1161 | if ($globalDBdriver == 'mysql') { |
1162 | 1162 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
1163 | 1163 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1178,7 +1178,7 @@ discard block |
||
1178 | 1178 | $date_array = array(); |
1179 | 1179 | $temp_array = array(); |
1180 | 1180 | |
1181 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1181 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1182 | 1182 | { |
1183 | 1183 | $temp_array['year_name'] = $row['year_name']; |
1184 | 1184 | $temp_array['month_name'] = $row['month_name']; |
@@ -1198,7 +1198,7 @@ discard block |
||
1198 | 1198 | * @return Array the hour list |
1199 | 1199 | * |
1200 | 1200 | */ |
1201 | - public function countAllHours($orderby,$filters = array()) |
|
1201 | + public function countAllHours($orderby, $filters = array()) |
|
1202 | 1202 | { |
1203 | 1203 | global $globalTimezone, $globalDBdriver; |
1204 | 1204 | if ($globalTimezone != '') { |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | $hour_array = array(); |
1247 | 1247 | $temp_array = array(); |
1248 | 1248 | |
1249 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1249 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1250 | 1250 | { |
1251 | 1251 | $temp_array['hour_name'] = $row['hour_name']; |
1252 | 1252 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1268,8 +1268,8 @@ discard block |
||
1268 | 1268 | public function countAllHoursByDate($date, $filters = array()) |
1269 | 1269 | { |
1270 | 1270 | global $globalTimezone, $globalDBdriver; |
1271 | - $filter_query = $this->getFilter($filters,true,true); |
|
1272 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1271 | + $filter_query = $this->getFilter($filters, true, true); |
|
1272 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1273 | 1273 | if ($globalTimezone != '') { |
1274 | 1274 | date_default_timezone_set($globalTimezone); |
1275 | 1275 | $datetime = new DateTime($date); |
@@ -1277,12 +1277,12 @@ discard block |
||
1277 | 1277 | } else $offset = '+00:00'; |
1278 | 1278 | |
1279 | 1279 | if ($globalDBdriver == 'mysql') { |
1280 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1280 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1281 | 1281 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
1282 | 1282 | GROUP BY hour_name |
1283 | 1283 | ORDER BY hour_name ASC"; |
1284 | 1284 | } else { |
1285 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1285 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1286 | 1286 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1287 | 1287 | GROUP BY hour_name |
1288 | 1288 | ORDER BY hour_name ASC"; |
@@ -1294,7 +1294,7 @@ discard block |
||
1294 | 1294 | $hour_array = array(); |
1295 | 1295 | $temp_array = array(); |
1296 | 1296 | |
1297 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1297 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1298 | 1298 | { |
1299 | 1299 | $temp_array['hour_name'] = $row['hour_name']; |
1300 | 1300 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1316,8 +1316,8 @@ discard block |
||
1316 | 1316 | public function countAllHoursByIdent($ident, $filters = array()) |
1317 | 1317 | { |
1318 | 1318 | global $globalTimezone, $globalDBdriver; |
1319 | - $filter_query = $this->getFilter($filters,true,true); |
|
1320 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1319 | + $filter_query = $this->getFilter($filters, true, true); |
|
1320 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1321 | 1321 | if ($globalTimezone != '') { |
1322 | 1322 | date_default_timezone_set($globalTimezone); |
1323 | 1323 | $datetime = new DateTime(); |
@@ -1325,12 +1325,12 @@ discard block |
||
1325 | 1325 | } else $offset = '+00:00'; |
1326 | 1326 | |
1327 | 1327 | if ($globalDBdriver == 'mysql') { |
1328 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1328 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1329 | 1329 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1330 | 1330 | GROUP BY hour_name |
1331 | 1331 | ORDER BY hour_name ASC"; |
1332 | 1332 | } else { |
1333 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1333 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1334 | 1334 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1335 | 1335 | GROUP BY hour_name |
1336 | 1336 | ORDER BY hour_name ASC"; |
@@ -1338,12 +1338,12 @@ discard block |
||
1338 | 1338 | |
1339 | 1339 | |
1340 | 1340 | $sth = $this->db->prepare($query); |
1341 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1341 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1342 | 1342 | |
1343 | 1343 | $hour_array = array(); |
1344 | 1344 | $temp_array = array(); |
1345 | 1345 | |
1346 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1346 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1347 | 1347 | { |
1348 | 1348 | $temp_array['hour_name'] = $row['hour_name']; |
1349 | 1349 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1362,33 +1362,33 @@ discard block |
||
1362 | 1362 | * @return Integer the number of vessels |
1363 | 1363 | * |
1364 | 1364 | */ |
1365 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
1365 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
1366 | 1366 | { |
1367 | 1367 | global $globalDBdriver; |
1368 | 1368 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
1369 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1369 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1370 | 1370 | $query_values = array(); |
1371 | 1371 | $query = ''; |
1372 | 1372 | if ($year != '') { |
1373 | 1373 | if ($globalDBdriver == 'mysql') { |
1374 | 1374 | $query .= " AND YEAR(marine_output.date) = :year"; |
1375 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1375 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1376 | 1376 | } else { |
1377 | 1377 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1378 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1378 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1379 | 1379 | } |
1380 | 1380 | } |
1381 | 1381 | if ($month != '') { |
1382 | 1382 | if ($globalDBdriver == 'mysql') { |
1383 | 1383 | $query .= " AND MONTH(marine_output.date) = :month"; |
1384 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1384 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1385 | 1385 | } else { |
1386 | 1386 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1387 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1387 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1388 | 1388 | } |
1389 | 1389 | } |
1390 | 1390 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1391 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1391 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1392 | 1392 | |
1393 | 1393 | $sth = $this->db->prepare($queryi); |
1394 | 1394 | $sth->execute($query_values); |
@@ -1401,32 +1401,32 @@ discard block |
||
1401 | 1401 | * @return Integer the number of vessels |
1402 | 1402 | * |
1403 | 1403 | */ |
1404 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
1404 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
1405 | 1405 | { |
1406 | 1406 | global $globalDBdriver; |
1407 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1407 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1408 | 1408 | $query_values = array(); |
1409 | 1409 | $query = ''; |
1410 | 1410 | if ($year != '') { |
1411 | 1411 | if ($globalDBdriver == 'mysql') { |
1412 | 1412 | $query .= " AND YEAR(marine_output.date) = :year"; |
1413 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1413 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1414 | 1414 | } else { |
1415 | 1415 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1416 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1416 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1417 | 1417 | } |
1418 | 1418 | } |
1419 | 1419 | if ($month != '') { |
1420 | 1420 | if ($globalDBdriver == 'mysql') { |
1421 | 1421 | $query .= " AND MONTH(marine_output.date) = :month"; |
1422 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1422 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1423 | 1423 | } else { |
1424 | 1424 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1425 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1425 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1426 | 1426 | } |
1427 | 1427 | } |
1428 | 1428 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1429 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1429 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1430 | 1430 | |
1431 | 1431 | $sth = $this->db->prepare($queryi); |
1432 | 1432 | $sth->execute($query_values); |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | public function countAllHoursFromToday($filters = array()) |
1444 | 1444 | { |
1445 | 1445 | global $globalTimezone, $globalDBdriver; |
1446 | - $filter_query = $this->getFilter($filters,true,true); |
|
1446 | + $filter_query = $this->getFilter($filters, true, true); |
|
1447 | 1447 | if ($globalTimezone != '') { |
1448 | 1448 | date_default_timezone_set($globalTimezone); |
1449 | 1449 | $datetime = new DateTime(); |
@@ -1451,12 +1451,12 @@ discard block |
||
1451 | 1451 | } else $offset = '+00:00'; |
1452 | 1452 | |
1453 | 1453 | if ($globalDBdriver == 'mysql') { |
1454 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1454 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1455 | 1455 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
1456 | 1456 | GROUP BY hour_name |
1457 | 1457 | ORDER BY hour_name ASC"; |
1458 | 1458 | } else { |
1459 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1459 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1460 | 1460 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1461 | 1461 | GROUP BY hour_name |
1462 | 1462 | ORDER BY hour_name ASC"; |
@@ -1468,7 +1468,7 @@ discard block |
||
1468 | 1468 | $hour_array = array(); |
1469 | 1469 | $temp_array = array(); |
1470 | 1470 | |
1471 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1471 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1472 | 1472 | { |
1473 | 1473 | $temp_array['hour_name'] = $row['hour_name']; |
1474 | 1474 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1487,9 +1487,9 @@ discard block |
||
1487 | 1487 | */ |
1488 | 1488 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1489 | 1489 | { |
1490 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
1490 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
1491 | 1491 | |
1492 | - $query = "SELECT marine_output.marine_id |
|
1492 | + $query = "SELECT marine_output.marine_id |
|
1493 | 1493 | FROM marine_output |
1494 | 1494 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
1495 | 1495 | |
@@ -1497,7 +1497,7 @@ discard block |
||
1497 | 1497 | $sth = $this->db->prepare($query); |
1498 | 1498 | $sth->execute(); |
1499 | 1499 | |
1500 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1500 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1501 | 1501 | { |
1502 | 1502 | return $row['marine_id']; |
1503 | 1503 | } |
@@ -1522,23 +1522,23 @@ discard block |
||
1522 | 1522 | } |
1523 | 1523 | |
1524 | 1524 | $current_date = date("Y-m-d H:i:s"); |
1525 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1525 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1526 | 1526 | |
1527 | 1527 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1528 | 1528 | |
1529 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1529 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1530 | 1530 | $years = $time_array['years']; |
1531 | 1531 | |
1532 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1532 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1533 | 1533 | $months = $time_array['months']; |
1534 | 1534 | |
1535 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1535 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1536 | 1536 | $days = $time_array['days']; |
1537 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1537 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1538 | 1538 | $hours = $time_array['hours']; |
1539 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1539 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1540 | 1540 | $minutes = $time_array['minutes']; |
1541 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1541 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1542 | 1542 | |
1543 | 1543 | return $time_array; |
1544 | 1544 | } |
@@ -1561,63 +1561,63 @@ discard block |
||
1561 | 1561 | $temp_array['direction_degree'] = $direction; |
1562 | 1562 | $temp_array['direction_shortname'] = "N"; |
1563 | 1563 | $temp_array['direction_fullname'] = "North"; |
1564 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1564 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1565 | 1565 | $temp_array['direction_degree'] = $direction; |
1566 | 1566 | $temp_array['direction_shortname'] = "NNE"; |
1567 | 1567 | $temp_array['direction_fullname'] = "North-Northeast"; |
1568 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1568 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1569 | 1569 | $temp_array['direction_degree'] = $direction; |
1570 | 1570 | $temp_array['direction_shortname'] = "NE"; |
1571 | 1571 | $temp_array['direction_fullname'] = "Northeast"; |
1572 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1572 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1573 | 1573 | $temp_array['direction_degree'] = $direction; |
1574 | 1574 | $temp_array['direction_shortname'] = "ENE"; |
1575 | 1575 | $temp_array['direction_fullname'] = "East-Northeast"; |
1576 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1576 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1577 | 1577 | $temp_array['direction_degree'] = $direction; |
1578 | 1578 | $temp_array['direction_shortname'] = "E"; |
1579 | 1579 | $temp_array['direction_fullname'] = "East"; |
1580 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1580 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1581 | 1581 | $temp_array['direction_degree'] = $direction; |
1582 | 1582 | $temp_array['direction_shortname'] = "ESE"; |
1583 | 1583 | $temp_array['direction_fullname'] = "East-Southeast"; |
1584 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1584 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1585 | 1585 | $temp_array['direction_degree'] = $direction; |
1586 | 1586 | $temp_array['direction_shortname'] = "SE"; |
1587 | 1587 | $temp_array['direction_fullname'] = "Southeast"; |
1588 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1588 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1589 | 1589 | $temp_array['direction_degree'] = $direction; |
1590 | 1590 | $temp_array['direction_shortname'] = "SSE"; |
1591 | 1591 | $temp_array['direction_fullname'] = "South-Southeast"; |
1592 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1592 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1593 | 1593 | $temp_array['direction_degree'] = $direction; |
1594 | 1594 | $temp_array['direction_shortname'] = "S"; |
1595 | 1595 | $temp_array['direction_fullname'] = "South"; |
1596 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1596 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1597 | 1597 | $temp_array['direction_degree'] = $direction; |
1598 | 1598 | $temp_array['direction_shortname'] = "SSW"; |
1599 | 1599 | $temp_array['direction_fullname'] = "South-Southwest"; |
1600 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1600 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1601 | 1601 | $temp_array['direction_degree'] = $direction; |
1602 | 1602 | $temp_array['direction_shortname'] = "SW"; |
1603 | 1603 | $temp_array['direction_fullname'] = "Southwest"; |
1604 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1604 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1605 | 1605 | $temp_array['direction_degree'] = $direction; |
1606 | 1606 | $temp_array['direction_shortname'] = "WSW"; |
1607 | 1607 | $temp_array['direction_fullname'] = "West-Southwest"; |
1608 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1608 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1609 | 1609 | $temp_array['direction_degree'] = $direction; |
1610 | 1610 | $temp_array['direction_shortname'] = "W"; |
1611 | 1611 | $temp_array['direction_fullname'] = "West"; |
1612 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1612 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1613 | 1613 | $temp_array['direction_degree'] = $direction; |
1614 | 1614 | $temp_array['direction_shortname'] = "WNW"; |
1615 | 1615 | $temp_array['direction_fullname'] = "West-Northwest"; |
1616 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1616 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1617 | 1617 | $temp_array['direction_degree'] = $direction; |
1618 | 1618 | $temp_array['direction_shortname'] = "NW"; |
1619 | 1619 | $temp_array['direction_fullname'] = "Northwest"; |
1620 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1620 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1621 | 1621 | $temp_array['direction_degree'] = $direction; |
1622 | 1622 | $temp_array['direction_shortname'] = "NNW"; |
1623 | 1623 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1634,11 +1634,11 @@ discard block |
||
1634 | 1634 | * @param Float $longitude longitute of the flight |
1635 | 1635 | * @return String the countrie |
1636 | 1636 | */ |
1637 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1637 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1638 | 1638 | { |
1639 | 1639 | global $globalDBdriver, $globalDebug; |
1640 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1641 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1640 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1641 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1642 | 1642 | |
1643 | 1643 | $Connection = new Connection($this->db); |
1644 | 1644 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1678,7 +1678,7 @@ discard block |
||
1678 | 1678 | public function getCountryFromISO2($iso2) |
1679 | 1679 | { |
1680 | 1680 | global $globalDBdriver, $globalDebug; |
1681 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1681 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1682 | 1682 | |
1683 | 1683 | $Connection = new Connection($this->db); |
1684 | 1684 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1726,7 +1726,7 @@ discard block |
||
1726 | 1726 | |
1727 | 1727 | $bitly_data = json_decode($bitly_data); |
1728 | 1728 | $bitly_url = ''; |
1729 | - if ($bitly_data->status_txt = "OK"){ |
|
1729 | + if ($bitly_data->status_txt = "OK") { |
|
1730 | 1730 | $bitly_url = $bitly_data->data->url; |
1731 | 1731 | } |
1732 | 1732 | |
@@ -1740,11 +1740,11 @@ discard block |
||
1740 | 1740 | * @return Array the vessel type list |
1741 | 1741 | * |
1742 | 1742 | */ |
1743 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
1743 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1744 | 1744 | { |
1745 | 1745 | global $globalDBdriver; |
1746 | - $filter_query = $this->getFilter($filters,true,true); |
|
1747 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
1746 | + $filter_query = $this->getFilter($filters, true, true); |
|
1747 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
1748 | 1748 | FROM marine_output ".$filter_query." marine_output.type <> ''"; |
1749 | 1749 | if ($olderthanmonths > 0) { |
1750 | 1750 | if ($globalDBdriver == 'mysql') { |
@@ -1764,28 +1764,28 @@ discard block |
||
1764 | 1764 | if ($year != '') { |
1765 | 1765 | if ($globalDBdriver == 'mysql') { |
1766 | 1766 | $query .= " AND YEAR(marine_output.date) = :year"; |
1767 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1767 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1768 | 1768 | } else { |
1769 | 1769 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1770 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1770 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1771 | 1771 | } |
1772 | 1772 | } |
1773 | 1773 | if ($month != '') { |
1774 | 1774 | if ($globalDBdriver == 'mysql') { |
1775 | 1775 | $query .= " AND MONTH(marine_output.date) = :month"; |
1776 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1776 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1777 | 1777 | } else { |
1778 | 1778 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1779 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1779 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1780 | 1780 | } |
1781 | 1781 | } |
1782 | 1782 | if ($day != '') { |
1783 | 1783 | if ($globalDBdriver == 'mysql') { |
1784 | 1784 | $query .= " AND DAY(marine_output.date) = :day"; |
1785 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1785 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1786 | 1786 | } else { |
1787 | 1787 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
1788 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1788 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1789 | 1789 | } |
1790 | 1790 | } |
1791 | 1791 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
@@ -1794,7 +1794,7 @@ discard block |
||
1794 | 1794 | $sth->execute($query_values); |
1795 | 1795 | $marine_array = array(); |
1796 | 1796 | $temp_array = array(); |
1797 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1797 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1798 | 1798 | { |
1799 | 1799 | $temp_array['marine_type'] = $row['marine_type']; |
1800 | 1800 | $temp_array['marine_type_count'] = $row['marine_type_count']; |
@@ -1805,7 +1805,7 @@ discard block |
||
1805 | 1805 | |
1806 | 1806 | public function getOrderBy() |
1807 | 1807 | { |
1808 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
1808 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
1809 | 1809 | |
1810 | 1810 | return $orderby; |
1811 | 1811 |
@@ -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' => $over_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' => $over_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,13 +329,13 @@ 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 | - $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"; |
|
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 | 337 | |
338 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
338 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); |
|
339 | 339 | |
340 | 340 | return $spotter_array; |
341 | 341 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | try { |
349 | 349 | $sth = $this->db->prepare($query); |
350 | 350 | $sth->execute(); |
351 | - } catch(PDOException $e) { |
|
351 | + } catch (PDOException $e) { |
|
352 | 352 | echo $e->getMessage(); |
353 | 353 | die; |
354 | 354 | } |
@@ -360,24 +360,24 @@ discard block |
||
360 | 360 | * @return Array the spotter information |
361 | 361 | * |
362 | 362 | */ |
363 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
363 | + public function getMinLiveMarineData($begindate, $enddate, $filter = array()) |
|
364 | 364 | { |
365 | 365 | global $globalDBdriver, $globalLiveInterval; |
366 | 366 | date_default_timezone_set('UTC'); |
367 | 367 | |
368 | 368 | $filter_query = ''; |
369 | 369 | if (isset($filter['source']) && !empty($filter['source'])) { |
370 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
370 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
371 | 371 | } |
372 | 372 | // Use spotter_output also ? |
373 | 373 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
374 | - $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 "; |
|
374 | + $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 "; |
|
375 | 375 | } |
376 | 376 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
377 | 377 | $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 "; |
378 | 378 | } |
379 | 379 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
380 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
380 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -396,14 +396,14 @@ discard block |
||
396 | 396 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
397 | 397 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
398 | 398 | */ |
399 | - $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 |
|
399 | + $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 |
|
400 | 400 | FROM marine_archive |
401 | 401 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
402 | 402 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
403 | 403 | '.$filter_query.' ORDER BY fammarine_id'; |
404 | 404 | } else { |
405 | 405 | //$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'; |
406 | - $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 |
|
406 | + $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 |
|
407 | 407 | FROM marine_archive |
408 | 408 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
409 | 409 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | try { |
414 | 414 | $sth = $this->db->prepare($query); |
415 | 415 | $sth->execute(); |
416 | - } catch(PDOException $e) { |
|
416 | + } catch (PDOException $e) { |
|
417 | 417 | echo $e->getMessage(); |
418 | 418 | die; |
419 | 419 | } |
@@ -428,24 +428,24 @@ discard block |
||
428 | 428 | * @return Array the spotter information |
429 | 429 | * |
430 | 430 | */ |
431 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
431 | + public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array()) |
|
432 | 432 | { |
433 | 433 | global $globalDBdriver, $globalLiveInterval; |
434 | 434 | date_default_timezone_set('UTC'); |
435 | 435 | |
436 | 436 | $filter_query = ''; |
437 | 437 | if (isset($filter['source']) && !empty($filter['source'])) { |
438 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
438 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
439 | 439 | } |
440 | 440 | // Should use spotter_output also ? |
441 | 441 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
442 | - $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 "; |
|
442 | + $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 "; |
|
443 | 443 | } |
444 | 444 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
445 | 445 | $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 "; |
446 | 446 | } |
447 | 447 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
448 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
448 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | FROM marine_archive |
456 | 456 | 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'; |
457 | 457 | */ |
458 | - $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 |
|
458 | + $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 |
|
459 | 459 | FROM marine_archive_output |
460 | 460 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
461 | 461 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
471 | 471 | '.$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'; |
472 | 472 | */ |
473 | - $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 |
|
473 | + $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 |
|
474 | 474 | FROM marine_archive_output |
475 | 475 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
476 | 476 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | try { |
483 | 483 | $sth = $this->db->prepare($query); |
484 | 484 | $sth->execute(); |
485 | - } catch(PDOException $e) { |
|
485 | + } catch (PDOException $e) { |
|
486 | 486 | echo $e->getMessage(); |
487 | 487 | die; |
488 | 488 | } |
@@ -497,23 +497,23 @@ discard block |
||
497 | 497 | * @return Array the spotter information |
498 | 498 | * |
499 | 499 | */ |
500 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
500 | + public function getLiveMarineCount($begindate, $enddate, $filter = array()) |
|
501 | 501 | { |
502 | 502 | global $globalDBdriver, $globalLiveInterval; |
503 | 503 | date_default_timezone_set('UTC'); |
504 | 504 | |
505 | 505 | $filter_query = ''; |
506 | 506 | if (isset($filter['source']) && !empty($filter['source'])) { |
507 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
507 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
508 | 508 | } |
509 | 509 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
510 | - $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 "; |
|
510 | + $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 "; |
|
511 | 511 | } |
512 | 512 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
513 | 513 | $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 "; |
514 | 514 | } |
515 | 515 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
516 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
516 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | try { |
529 | 529 | $sth = $this->db->prepare($query); |
530 | 530 | $sth->execute(); |
531 | - } catch(PDOException $e) { |
|
531 | + } catch (PDOException $e) { |
|
532 | 532 | echo $e->getMessage(); |
533 | 533 | die; |
534 | 534 | } |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | * @return Array the spotter information |
549 | 549 | * |
550 | 550 | */ |
551 | - 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()) |
|
551 | + 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()) |
|
552 | 552 | { |
553 | 553 | global $globalTimezone, $globalDBdriver; |
554 | 554 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | |
571 | 571 | $q_array = explode(" ", $q); |
572 | 572 | |
573 | - foreach ($q_array as $q_item){ |
|
573 | + foreach ($q_array as $q_item) { |
|
574 | 574 | $additional_query .= " AND ("; |
575 | 575 | $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
576 | 576 | $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | |
603 | 603 | if ($registration != "") |
604 | 604 | { |
605 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
605 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
606 | 606 | if (!is_string($registration)) |
607 | 607 | { |
608 | 608 | return false; |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | |
614 | 614 | if ($aircraft_icao != "") |
615 | 615 | { |
616 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
616 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
617 | 617 | if (!is_string($aircraft_icao)) |
618 | 618 | { |
619 | 619 | return false; |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | |
625 | 625 | if ($aircraft_manufacturer != "") |
626 | 626 | { |
627 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
627 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
628 | 628 | if (!is_string($aircraft_manufacturer)) |
629 | 629 | { |
630 | 630 | return false; |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | |
646 | 646 | if ($airline_icao != "") |
647 | 647 | { |
648 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
648 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
649 | 649 | if (!is_string($airline_icao)) |
650 | 650 | { |
651 | 651 | return false; |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | |
657 | 657 | if ($airline_country != "") |
658 | 658 | { |
659 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
659 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
660 | 660 | if (!is_string($airline_country)) |
661 | 661 | { |
662 | 662 | return false; |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | |
668 | 668 | if ($airline_type != "") |
669 | 669 | { |
670 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
670 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
671 | 671 | if (!is_string($airline_type)) |
672 | 672 | { |
673 | 673 | return false; |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | |
690 | 690 | if ($airport != "") |
691 | 691 | { |
692 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
692 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
693 | 693 | if (!is_string($airport)) |
694 | 694 | { |
695 | 695 | return false; |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | |
701 | 701 | if ($airport_country != "") |
702 | 702 | { |
703 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
703 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
704 | 704 | if (!is_string($airport_country)) |
705 | 705 | { |
706 | 706 | return false; |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | |
712 | 712 | if ($callsign != "") |
713 | 713 | { |
714 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
714 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
715 | 715 | if (!is_string($callsign)) |
716 | 716 | { |
717 | 717 | return false; |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | $translate = $Translation->ident2icao($callsign); |
720 | 720 | if ($translate != $callsign) { |
721 | 721 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
722 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
722 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
723 | 723 | } else { |
724 | 724 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
725 | 725 | } |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | |
729 | 729 | if ($owner != "") |
730 | 730 | { |
731 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
731 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
732 | 732 | if (!is_string($owner)) |
733 | 733 | { |
734 | 734 | return false; |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | |
740 | 740 | if ($pilot_name != "") |
741 | 741 | { |
742 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
742 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
743 | 743 | if (!is_string($pilot_name)) |
744 | 744 | { |
745 | 745 | return false; |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | |
751 | 751 | if ($pilot_id != "") |
752 | 752 | { |
753 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
753 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
754 | 754 | if (!is_string($pilot_id)) |
755 | 755 | { |
756 | 756 | return false; |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | |
762 | 762 | if ($departure_airport_route != "") |
763 | 763 | { |
764 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
764 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
765 | 765 | if (!is_string($departure_airport_route)) |
766 | 766 | { |
767 | 767 | return false; |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | |
773 | 773 | if ($arrival_airport_route != "") |
774 | 774 | { |
775 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
775 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
776 | 776 | if (!is_string($arrival_airport_route)) |
777 | 777 | { |
778 | 778 | return false; |
@@ -785,8 +785,8 @@ discard block |
||
785 | 785 | { |
786 | 786 | $altitude_array = explode(",", $altitude); |
787 | 787 | |
788 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
789 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
789 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
790 | 790 | |
791 | 791 | |
792 | 792 | if ($altitude_array[1] != "") |
@@ -804,8 +804,8 @@ discard block |
||
804 | 804 | { |
805 | 805 | $date_array = explode(",", $date_posted); |
806 | 806 | |
807 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
808 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
807 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
808 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
809 | 809 | |
810 | 810 | if ($globalTimezone != '') { |
811 | 811 | date_default_timezone_set($globalTimezone); |
@@ -837,8 +837,8 @@ discard block |
||
837 | 837 | { |
838 | 838 | $limit_array = explode(",", $limit); |
839 | 839 | |
840 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
841 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
840 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
841 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
842 | 842 | |
843 | 843 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
844 | 844 | { |
@@ -849,8 +849,8 @@ discard block |
||
849 | 849 | |
850 | 850 | |
851 | 851 | if ($origLat != "" && $origLon != "" && $dist != "") { |
852 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
853 | - $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 |
|
852 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
853 | + $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 |
|
854 | 854 | 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)) |
855 | 855 | 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"; |
856 | 856 | } else { |
@@ -867,12 +867,12 @@ discard block |
||
867 | 867 | $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
868 | 868 | } |
869 | 869 | |
870 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
870 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
871 | 871 | WHERE marine_archive_output.ident <> '' |
872 | 872 | ".$additional_query." |
873 | 873 | ".$filter_query.$orderby_query; |
874 | 874 | } |
875 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
875 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
876 | 876 | |
877 | 877 | return $spotter_array; |
878 | 878 | } |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | try { |
890 | 890 | $sth = $this->db->prepare($query); |
891 | 891 | $sth->execute(); |
892 | - } catch(PDOException $e) { |
|
892 | + } catch (PDOException $e) { |
|
893 | 893 | return "error"; |
894 | 894 | } |
895 | 895 | } |
@@ -926,8 +926,8 @@ discard block |
||
926 | 926 | { |
927 | 927 | $limit_array = explode(",", $limit); |
928 | 928 | |
929 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
930 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
929 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
930 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
931 | 931 | |
932 | 932 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
933 | 933 | { |
@@ -968,7 +968,7 @@ discard block |
||
968 | 968 | $query_values = array(); |
969 | 969 | $limit_query = ''; |
970 | 970 | $additional_query = ''; |
971 | - $filter_query = $this->getFilter($filter,true,true); |
|
971 | + $filter_query = $this->getFilter($filter, true, true); |
|
972 | 972 | |
973 | 973 | if ($owner != "") |
974 | 974 | { |
@@ -985,8 +985,8 @@ discard block |
||
985 | 985 | { |
986 | 986 | $limit_array = explode(",", $limit); |
987 | 987 | |
988 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
989 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
988 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
989 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
990 | 990 | |
991 | 991 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
992 | 992 | { |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | $query_values = array(); |
1027 | 1027 | $limit_query = ''; |
1028 | 1028 | $additional_query = ''; |
1029 | - $filter_query = $this->getFilter($filter,true,true); |
|
1029 | + $filter_query = $this->getFilter($filter, true, true); |
|
1030 | 1030 | |
1031 | 1031 | if ($pilot != "") |
1032 | 1032 | { |
@@ -1038,8 +1038,8 @@ discard block |
||
1038 | 1038 | { |
1039 | 1039 | $limit_array = explode(",", $limit); |
1040 | 1040 | |
1041 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1042 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1042 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1043 | 1043 | |
1044 | 1044 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1045 | 1045 | { |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | * @return Array the airline country list |
1070 | 1070 | * |
1071 | 1071 | */ |
1072 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1072 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1073 | 1073 | { |
1074 | 1074 | global $globalDBdriver; |
1075 | 1075 | /* |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | $flight_array = array(); |
1099 | 1099 | $temp_array = array(); |
1100 | 1100 | |
1101 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1101 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1102 | 1102 | { |
1103 | 1103 | $temp_array['flight_count'] = $row['nb']; |
1104 | 1104 | $temp_array['flight_country'] = $row['name']; |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | * @return Array the airline country list |
1116 | 1116 | * |
1117 | 1117 | */ |
1118 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1118 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1119 | 1119 | { |
1120 | 1120 | global $globalDBdriver; |
1121 | 1121 | /* |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | $flight_array = array(); |
1145 | 1145 | $temp_array = array(); |
1146 | 1146 | |
1147 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1147 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1148 | 1148 | { |
1149 | 1149 | $temp_array['airline_icao'] = $row['airline_icao']; |
1150 | 1150 | $temp_array['flight_count'] = $row['nb']; |
@@ -1162,14 +1162,14 @@ discard block |
||
1162 | 1162 | * @return Array the spotter information |
1163 | 1163 | * |
1164 | 1164 | */ |
1165 | - public function getDateArchiveMarineDataById($id,$date) |
|
1165 | + public function getDateArchiveMarineDataById($id, $date) |
|
1166 | 1166 | { |
1167 | 1167 | $Marine = new Marine($this->db); |
1168 | 1168 | date_default_timezone_set('UTC'); |
1169 | 1169 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1170 | 1170 | $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'; |
1171 | - $date = date('c',$date); |
|
1172 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1171 | + $date = date('c', $date); |
|
1172 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1173 | 1173 | return $spotter_array; |
1174 | 1174 | } |
1175 | 1175 | |
@@ -1179,14 +1179,14 @@ discard block |
||
1179 | 1179 | * @return Array the spotter information |
1180 | 1180 | * |
1181 | 1181 | */ |
1182 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1182 | + public function getDateArchiveMarineDataByIdent($ident, $date) |
|
1183 | 1183 | { |
1184 | 1184 | $Marine = new Marine($this->db); |
1185 | 1185 | date_default_timezone_set('UTC'); |
1186 | 1186 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1187 | 1187 | $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'; |
1188 | - $date = date('c',$date); |
|
1189 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1188 | + $date = date('c', $date); |
|
1189 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1190 | 1190 | return $spotter_array; |
1191 | 1191 | } |
1192 | 1192 | |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | * @return Array the spotter information |
1197 | 1197 | * |
1198 | 1198 | */ |
1199 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1199 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1200 | 1200 | { |
1201 | 1201 | global $global_query; |
1202 | 1202 | $Marine = new Marine($this->db); |
@@ -1204,7 +1204,7 @@ discard block |
||
1204 | 1204 | $query_values = array(); |
1205 | 1205 | $limit_query = ''; |
1206 | 1206 | $additional_query = ''; |
1207 | - $filter_query = $this->getFilter($filters,true,true); |
|
1207 | + $filter_query = $this->getFilter($filters, true, true); |
|
1208 | 1208 | |
1209 | 1209 | if ($airport != "") |
1210 | 1210 | { |
@@ -1221,8 +1221,8 @@ discard block |
||
1221 | 1221 | { |
1222 | 1222 | $limit_array = explode(",", $limit); |
1223 | 1223 | |
1224 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1225 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1224 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1225 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1226 | 1226 | |
1227 | 1227 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1228 | 1228 | { |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | try { |
983 | 983 | $sth = $this->db->prepare($query); |
984 | 984 | $sth->execute($query_values); |
985 | - } catch(PDOException $e) { |
|
985 | + } catch (PDOException $e) { |
|
986 | 986 | echo "error : ".$e->getMessage(); |
987 | 987 | } |
988 | 988 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1000,19 +1000,19 @@ discard block |
||
1000 | 1000 | try { |
1001 | 1001 | $sth = $this->db->prepare($query); |
1002 | 1002 | $sth->execute($query_values); |
1003 | - } catch(PDOException $e) { |
|
1003 | + } catch (PDOException $e) { |
|
1004 | 1004 | echo "error : ".$e->getMessage(); |
1005 | 1005 | } |
1006 | 1006 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1007 | 1007 | return $all; |
1008 | 1008 | } |
1009 | 1009 | public function getAllNOTAMtext() { |
1010 | - $query = 'SELECT full_notam FROM notam'; |
|
1010 | + $query = 'SELECT full_notam FROM notam'; |
|
1011 | 1011 | $query_values = array(); |
1012 | 1012 | try { |
1013 | 1013 | $sth = $this->db->prepare($query); |
1014 | 1014 | $sth->execute($query_values); |
1015 | - } catch(PDOException $e) { |
|
1015 | + } catch (PDOException $e) { |
|
1016 | 1016 | echo "error : ".$e->getMessage(); |
1017 | 1017 | } |
1018 | 1018 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1021,13 +1021,13 @@ discard block |
||
1021 | 1021 | public function createNOTAMtextFile($filename) { |
1022 | 1022 | $allnotam_result = $this->getAllNOTAMtext(); |
1023 | 1023 | $notamtext = ''; |
1024 | - foreach($allnotam_result as $notam) { |
|
1024 | + foreach ($allnotam_result as $notam) { |
|
1025 | 1025 | $notamtext .= '%%'."\n"; |
1026 | 1026 | $notamtext .= $notam['full_notam']; |
1027 | 1027 | $notamtext .= "\n".'%%'."\n"; |
1028 | 1028 | } |
1029 | 1029 | //$allnotam = implode('\n%%%%\n',$allnotam_result); |
1030 | - file_put_contents($filename,$notamtext); |
|
1030 | + file_put_contents($filename, $notamtext); |
|
1031 | 1031 | } |
1032 | 1032 | public function parseNOTAMtextFile($filename) { |
1033 | 1033 | $data = file_get_contents($filename); |
@@ -1048,7 +1048,7 @@ 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 | echo "error : ".$e->getMessage(); |
1053 | 1053 | } |
1054 | 1054 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1057,10 +1057,10 @@ discard block |
||
1057 | 1057 | public function getAllNOTAMbyCoord($coord) { |
1058 | 1058 | global $globalDBdriver; |
1059 | 1059 | if (is_array($coord)) { |
1060 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1061 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1062 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1063 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1060 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1061 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1062 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1063 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1064 | 1064 | if ($minlat > $maxlat) { |
1065 | 1065 | $tmplat = $minlat; |
1066 | 1066 | $minlat = $maxlat; |
@@ -1082,19 +1082,19 @@ discard block |
||
1082 | 1082 | try { |
1083 | 1083 | $sth = $this->db->prepare($query); |
1084 | 1084 | $sth->execute($query_values); |
1085 | - } catch(PDOException $e) { |
|
1085 | + } catch (PDOException $e) { |
|
1086 | 1086 | echo "error : ".$e->getMessage(); |
1087 | 1087 | } |
1088 | 1088 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1089 | 1089 | return $all; |
1090 | 1090 | } |
1091 | - public function getAllNOTAMbyCoordScope($coord,$scope) { |
|
1091 | + public function getAllNOTAMbyCoordScope($coord, $scope) { |
|
1092 | 1092 | global $globalDBdriver; |
1093 | 1093 | if (is_array($coord)) { |
1094 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1095 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1096 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1097 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1094 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1095 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1096 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1097 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1098 | 1098 | } else return array(); |
1099 | 1099 | if ($globalDBdriver == 'mysql') { |
1100 | 1100 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope'; |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | try { |
1107 | 1107 | $sth = $this->db->prepare($query); |
1108 | 1108 | $sth->execute($query_values); |
1109 | - } catch(PDOException $e) { |
|
1109 | + } catch (PDOException $e) { |
|
1110 | 1110 | echo "error : ".$e->getMessage(); |
1111 | 1111 | } |
1112 | 1112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | try { |
1119 | 1119 | $sth = $this->db->prepare($query); |
1120 | 1120 | $sth->execute($query_values); |
1121 | - } catch(PDOException $e) { |
|
1121 | + } catch (PDOException $e) { |
|
1122 | 1122 | return "error : ".$e->getMessage(); |
1123 | 1123 | } |
1124 | 1124 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1126,13 +1126,13 @@ discard block |
||
1126 | 1126 | else return array(); |
1127 | 1127 | } |
1128 | 1128 | |
1129 | - public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) { |
|
1129 | + public function addNOTAM($ref, $title, $type, $fir, $code, $rules, $scope, $lower_limit, $upper_limit, $center_latitude, $center_longitude, $radius, $date_begin, $date_end, $permanent, $text, $full_notam) { |
|
1130 | 1130 | $query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)"; |
1131 | - $query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam); |
|
1131 | + $query_values = array(':ref' => $ref, ':title' => $title, ':type' => $type, ':fir' => $fir, ':code' => $code, ':rules' => $rules, ':scope' => $scope, ':lower_limit' => $lower_limit, ':upper_limit' => $upper_limit, ':center_latitude' => $center_latitude, ':center_longitude' => $center_longitude, ':radius' => $radius, ':date_begin' => $date_begin, ':date_end' => $date_end, ':permanent' => $permanent, ':text' => $text, ':full_notam' => $full_notam); |
|
1132 | 1132 | try { |
1133 | 1133 | $sth = $this->db->prepare($query); |
1134 | 1134 | $sth->execute($query_values); |
1135 | - } catch(PDOException $e) { |
|
1135 | + } catch (PDOException $e) { |
|
1136 | 1136 | return "error : ".$e->getMessage(); |
1137 | 1137 | } |
1138 | 1138 | } |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | try { |
1144 | 1144 | $sth = $this->db->prepare($query); |
1145 | 1145 | $sth->execute($query_values); |
1146 | - } catch(PDOException $e) { |
|
1146 | + } catch (PDOException $e) { |
|
1147 | 1147 | return "error : ".$e->getMessage(); |
1148 | 1148 | } |
1149 | 1149 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | try { |
1159 | 1159 | $sth = $this->db->prepare($query); |
1160 | 1160 | $sth->execute($query_values); |
1161 | - } catch(PDOException $e) { |
|
1161 | + } catch (PDOException $e) { |
|
1162 | 1162 | return "error : ".$e->getMessage(); |
1163 | 1163 | } |
1164 | 1164 | } |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | try { |
1169 | 1169 | $sth = $this->db->prepare($query); |
1170 | 1170 | $sth->execute($query_values); |
1171 | - } catch(PDOException $e) { |
|
1171 | + } catch (PDOException $e) { |
|
1172 | 1172 | return "error : ".$e->getMessage(); |
1173 | 1173 | } |
1174 | 1174 | } |
@@ -1177,7 +1177,7 @@ discard block |
||
1177 | 1177 | try { |
1178 | 1178 | $sth = $this->db->prepare($query); |
1179 | 1179 | $sth->execute(); |
1180 | - } catch(PDOException $e) { |
|
1180 | + } catch (PDOException $e) { |
|
1181 | 1181 | return "error : ".$e->getMessage(); |
1182 | 1182 | } |
1183 | 1183 | } |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | try { |
1187 | 1187 | $sth = $this->db->prepare($query); |
1188 | 1188 | $sth->execute(); |
1189 | - } catch(PDOException $e) { |
|
1189 | + } catch (PDOException $e) { |
|
1190 | 1190 | return "error : ".$e->getMessage(); |
1191 | 1191 | } |
1192 | 1192 | } |
@@ -1194,14 +1194,14 @@ discard block |
||
1194 | 1194 | public function updateNOTAM() { |
1195 | 1195 | global $globalNOTAMAirports; |
1196 | 1196 | if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) { |
1197 | - foreach (array_chunk($globalNOTAMAirports,10) as $airport) { |
|
1198 | - $airport_icao = implode(',',$airport); |
|
1197 | + foreach (array_chunk($globalNOTAMAirports, 10) as $airport) { |
|
1198 | + $airport_icao = implode(',', $airport); |
|
1199 | 1199 | $alldata = $this->downloadNOTAM($airport_icao); |
1200 | 1200 | if (count($alldata) > 0) { |
1201 | 1201 | foreach ($alldata as $initial_data) { |
1202 | 1202 | $data = $this->parse($initial_data); |
1203 | 1203 | $notamref = $this->getNOTAMbyRef($data['ref']); |
1204 | - if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1204 | + if (count($notamref) == 0) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
1205 | 1205 | } |
1206 | 1206 | } |
1207 | 1207 | } |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | foreach ($alldata as $initial_data) { |
1215 | 1215 | $data = $this->parse($initial_data); |
1216 | 1216 | $notamref = $this->getNOTAMbyRef($data['ref']); |
1217 | - if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1217 | + if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
1218 | 1218 | } |
1219 | 1219 | } |
1220 | 1220 | } |
@@ -1223,12 +1223,12 @@ discard block |
||
1223 | 1223 | global $globalTransaction; |
1224 | 1224 | $Spotter = new Spotter($this->db); |
1225 | 1225 | $allairports = $Spotter->getAllAirportInfo(); |
1226 | - foreach (array_chunk($allairports,20) as $airport) { |
|
1226 | + foreach (array_chunk($allairports, 20) as $airport) { |
|
1227 | 1227 | $airports_icao = array(); |
1228 | - foreach($airport as $icao) { |
|
1228 | + foreach ($airport as $icao) { |
|
1229 | 1229 | if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; |
1230 | 1230 | } |
1231 | - $airport_icao = implode(',',$airports_icao); |
|
1231 | + $airport_icao = implode(',', $airports_icao); |
|
1232 | 1232 | $alldata = $this->downloadNOTAM($airport_icao); |
1233 | 1233 | if ($globalTransaction) $this->db->beginTransaction(); |
1234 | 1234 | if (count($alldata) > 0) { |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | if (count($notamref) == 0) { |
1242 | 1242 | if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); |
1243 | 1243 | if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); |
1244 | - elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1244 | + elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'], '', '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
1245 | 1245 | } |
1246 | 1246 | } |
1247 | 1247 | } |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | date_default_timezone_set("UTC"); |
1256 | 1256 | $Common = new Common(); |
1257 | 1257 | //$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
1258 | - $url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
|
1258 | + $url = str_replace('{icao}', $icao, 'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
|
1259 | 1259 | $data = $Common->getData($url); |
1260 | 1260 | preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); |
1261 | 1261 | //print_r($matches); |
@@ -1272,9 +1272,9 @@ discard block |
||
1272 | 1272 | $result['permanent'] = ''; |
1273 | 1273 | $result['date_begin'] = NULL; |
1274 | 1274 | $result['date_end'] = NULL; |
1275 | - $data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data); |
|
1275 | + $data = str_ireplace(array("\r", "\n", '\r', '\n'), ' ', $data); |
|
1276 | 1276 | //echo $data."\n"; |
1277 | - $data = preg_split('#\s(?=([A-Z]\)\s))#',$data); |
|
1277 | + $data = preg_split('#\s(?=([A-Z]\)\s))#', $data); |
|
1278 | 1278 | //print_r($data); |
1279 | 1279 | $q = false; |
1280 | 1280 | $a = false; |
@@ -1283,9 +1283,9 @@ discard block |
||
1283 | 1283 | $e = false; |
1284 | 1284 | foreach ($data as $line) { |
1285 | 1285 | $line = trim($line); |
1286 | - if (preg_match('#(^|\s)Q\) (.*)#',$line,$matches) && $q === false) { |
|
1287 | - $line = str_replace(' ','',$line); |
|
1288 | - if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#',$line,$matches)) { |
|
1286 | + if (preg_match('#(^|\s)Q\) (.*)#', $line, $matches) && $q === false) { |
|
1287 | + $line = str_replace(' ', '', $line); |
|
1288 | + if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#', $line, $matches)) { |
|
1289 | 1289 | //if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) { |
1290 | 1290 | //print_r($matches); |
1291 | 1291 | $result['fir'] = $matches[1]; |
@@ -1331,9 +1331,9 @@ discard block |
||
1331 | 1331 | elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; |
1332 | 1332 | $result['lower_limit'] = $matches[6]; |
1333 | 1333 | $result['upper_limit'] = $matches[7]; |
1334 | - $latitude = $Common->convertDec($matches[8],'latitude'); |
|
1334 | + $latitude = $Common->convertDec($matches[8], 'latitude'); |
|
1335 | 1335 | if ($matches[9] == 'S') $latitude = -$latitude; |
1336 | - $longitude = $Common->convertDec($matches[10],'longitude'); |
|
1336 | + $longitude = $Common->convertDec($matches[10], 'longitude'); |
|
1337 | 1337 | if ($matches[11] == 'W') $longitude = -$longitude; |
1338 | 1338 | $result['latitude'] = $latitude; |
1339 | 1339 | $result['longitude'] = $longitude; |
@@ -1345,24 +1345,24 @@ discard block |
||
1345 | 1345 | echo "Can't parse : ".$line."\n"; |
1346 | 1346 | } |
1347 | 1347 | } |
1348 | - elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) { |
|
1348 | + elseif (preg_match('#(^|\s)A\) (.*)#', $line, $matches) && $a === false) { |
|
1349 | 1349 | $result['icao'] = $matches[2]; |
1350 | 1350 | $a = true; |
1351 | 1351 | } |
1352 | - elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) { |
|
1352 | + elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#', $line, $matches) && $b === false) { |
|
1353 | 1353 | if ($matches[1] > 50) $year = '19'.$matches[2]; |
1354 | 1354 | else $year = '20'.$matches[2]; |
1355 | 1355 | $result['date_begin'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
1356 | 1356 | $b = true; |
1357 | 1357 | } |
1358 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) { |
|
1358 | + elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $line, $matches) && $c === false) { |
|
1359 | 1359 | if ($matches[2] > 50) $year = '19'.$matches[2]; |
1360 | 1360 | else $year = '20'.$matches[2]; |
1361 | 1361 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
1362 | 1362 | $result['permanent'] = 0; |
1363 | 1363 | $c = true; |
1364 | 1364 | } |
1365 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
1365 | + elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#', $line, $matches) && $c === false) { |
|
1366 | 1366 | if ($matches[2] > 50) $year = '19'.$matches[2]; |
1367 | 1367 | else $year = '20'.$matches[2]; |
1368 | 1368 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
@@ -1372,7 +1372,7 @@ discard block |
||
1372 | 1372 | else $result['permanent'] = 0; |
1373 | 1373 | $c = true; |
1374 | 1374 | } |
1375 | - elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
1375 | + elseif (preg_match('#(^|\s)C\) (EST|PERM)$#', $line, $matches) && $c === false) { |
|
1376 | 1376 | $result['date_end'] = '2030/12/20 12:00'; |
1377 | 1377 | if ($matches[2] == 'EST') $result['estimated'] = 1; |
1378 | 1378 | else $result['estimated'] = 0; |
@@ -1380,20 +1380,20 @@ discard block |
||
1380 | 1380 | else $result['permanent'] = 0; |
1381 | 1381 | $c = true; |
1382 | 1382 | } |
1383 | - elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) { |
|
1383 | + elseif (preg_match('#(^|\s)E\) (.*)#', $line, $matches) && $e === false) { |
|
1384 | 1384 | $rtext = array(); |
1385 | - $text = explode(' ',$matches[2]); |
|
1385 | + $text = explode(' ', $matches[2]); |
|
1386 | 1386 | foreach ($text as $word) { |
1387 | 1387 | if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); |
1388 | - elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
1388 | + elseif (ctype_digit(strval(substr($word, 3))) && isset($this->abbr[substr($word, 0, 3)])) $rtext[] = strtoupper($this->abbr[substr($word, 0, 3)]).' '.substr($word, 3); |
|
1389 | 1389 | else $rtext[] = $word; |
1390 | 1390 | } |
1391 | - $result['text'] = implode(' ',$rtext); |
|
1391 | + $result['text'] = implode(' ', $rtext); |
|
1392 | 1392 | $e = true; |
1393 | 1393 | //} elseif (preg_match('#F\) (.*)#',$line,$matches)) { |
1394 | 1394 | //} elseif (preg_match('#G\) (.*)#',$line,$matches)) { |
1395 | - } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { |
|
1396 | - $text = explode(' ',$line); |
|
1395 | + } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#', $line, $matches)) { |
|
1396 | + $text = explode(' ', $line); |
|
1397 | 1397 | $result['ref'] = $text[0]; |
1398 | 1398 | if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; |
1399 | 1399 | if ($matches[1] == 'NOTAMC') { |
@@ -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' => $over_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' => $over_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 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | try { |
345 | 345 | $sth = $this->db->prepare($query); |
346 | 346 | $sth->execute(); |
347 | - } catch(PDOException $e) { |
|
347 | + } catch (PDOException $e) { |
|
348 | 348 | echo $e->getMessage(); |
349 | 349 | die; |
350 | 350 | } |
@@ -356,24 +356,24 @@ discard block |
||
356 | 356 | * @return Array the spotter information |
357 | 357 | * |
358 | 358 | */ |
359 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
359 | + public function getMinLiveTrackerData($begindate, $enddate, $filter = array()) |
|
360 | 360 | { |
361 | 361 | global $globalDBdriver, $globalLiveInterval; |
362 | 362 | date_default_timezone_set('UTC'); |
363 | 363 | |
364 | 364 | $filter_query = ''; |
365 | 365 | if (isset($filter['source']) && !empty($filter['source'])) { |
366 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
366 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
367 | 367 | } |
368 | 368 | // Use spotter_output also ? |
369 | 369 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
370 | - $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 "; |
|
370 | + $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 "; |
|
371 | 371 | } |
372 | 372 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
373 | 373 | $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 "; |
374 | 374 | } |
375 | 375 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
376 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
376 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -392,14 +392,14 @@ discard block |
||
392 | 392 | GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid |
393 | 393 | AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
394 | 394 | */ |
395 | - $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 |
|
395 | + $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 |
|
396 | 396 | FROM tracker_archive |
397 | 397 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
398 | 398 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
399 | 399 | '.$filter_query.' ORDER BY famtrackid'; |
400 | 400 | } else { |
401 | 401 | //$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'; |
402 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
402 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
403 | 403 | FROM tracker_archive |
404 | 404 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
405 | 405 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | try { |
410 | 410 | $sth = $this->db->prepare($query); |
411 | 411 | $sth->execute(); |
412 | - } catch(PDOException $e) { |
|
412 | + } catch (PDOException $e) { |
|
413 | 413 | echo $e->getMessage(); |
414 | 414 | die; |
415 | 415 | } |
@@ -424,24 +424,24 @@ discard block |
||
424 | 424 | * @return Array the spotter information |
425 | 425 | * |
426 | 426 | */ |
427 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
427 | + public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array()) |
|
428 | 428 | { |
429 | 429 | global $globalDBdriver, $globalLiveInterval; |
430 | 430 | date_default_timezone_set('UTC'); |
431 | 431 | |
432 | 432 | $filter_query = ''; |
433 | 433 | if (isset($filter['source']) && !empty($filter['source'])) { |
434 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
434 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
435 | 435 | } |
436 | 436 | // Should use spotter_output also ? |
437 | 437 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
438 | - $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 "; |
|
438 | + $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 "; |
|
439 | 439 | } |
440 | 440 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
441 | 441 | $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 "; |
442 | 442 | } |
443 | 443 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
444 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
444 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | FROM tracker_archive |
452 | 452 | 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'; |
453 | 453 | */ |
454 | - $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 |
|
454 | + $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 |
|
455 | 455 | FROM tracker_archive_output |
456 | 456 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao |
457 | 457 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
467 | 467 | '.$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'; |
468 | 468 | */ |
469 | - $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 |
|
469 | + $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 |
|
470 | 470 | FROM tracker_archive_output |
471 | 471 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
472 | 472 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | try { |
479 | 479 | $sth = $this->db->prepare($query); |
480 | 480 | $sth->execute(); |
481 | - } catch(PDOException $e) { |
|
481 | + } catch (PDOException $e) { |
|
482 | 482 | echo $e->getMessage(); |
483 | 483 | die; |
484 | 484 | } |
@@ -493,23 +493,23 @@ discard block |
||
493 | 493 | * @return Array the spotter information |
494 | 494 | * |
495 | 495 | */ |
496 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
496 | + public function getLiveTrackerCount($begindate, $enddate, $filter = array()) |
|
497 | 497 | { |
498 | 498 | global $globalDBdriver, $globalLiveInterval; |
499 | 499 | date_default_timezone_set('UTC'); |
500 | 500 | |
501 | 501 | $filter_query = ''; |
502 | 502 | if (isset($filter['source']) && !empty($filter['source'])) { |
503 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
503 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
504 | 504 | } |
505 | 505 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
506 | - $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 "; |
|
506 | + $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 "; |
|
507 | 507 | } |
508 | 508 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
509 | 509 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
510 | 510 | } |
511 | 511 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
512 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
512 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | try { |
525 | 525 | $sth = $this->db->prepare($query); |
526 | 526 | $sth->execute(); |
527 | - } catch(PDOException $e) { |
|
527 | + } catch (PDOException $e) { |
|
528 | 528 | echo $e->getMessage(); |
529 | 529 | die; |
530 | 530 | } |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | * @return Array the spotter information |
545 | 545 | * |
546 | 546 | */ |
547 | - 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()) |
|
547 | + 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()) |
|
548 | 548 | { |
549 | 549 | global $globalTimezone, $globalDBdriver; |
550 | 550 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | |
567 | 567 | $q_array = explode(" ", $q); |
568 | 568 | |
569 | - foreach ($q_array as $q_item){ |
|
569 | + foreach ($q_array as $q_item) { |
|
570 | 570 | $additional_query .= " AND ("; |
571 | 571 | $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
572 | 572 | $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | |
599 | 599 | if ($registration != "") |
600 | 600 | { |
601 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
601 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
602 | 602 | if (!is_string($registration)) |
603 | 603 | { |
604 | 604 | return false; |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | |
610 | 610 | if ($aircraft_icao != "") |
611 | 611 | { |
612 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
612 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
613 | 613 | if (!is_string($aircraft_icao)) |
614 | 614 | { |
615 | 615 | return false; |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | |
621 | 621 | if ($aircraft_manufacturer != "") |
622 | 622 | { |
623 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
623 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
624 | 624 | if (!is_string($aircraft_manufacturer)) |
625 | 625 | { |
626 | 626 | return false; |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | |
642 | 642 | if ($airline_icao != "") |
643 | 643 | { |
644 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
644 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
645 | 645 | if (!is_string($airline_icao)) |
646 | 646 | { |
647 | 647 | return false; |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | |
653 | 653 | if ($airline_country != "") |
654 | 654 | { |
655 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
655 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
656 | 656 | if (!is_string($airline_country)) |
657 | 657 | { |
658 | 658 | return false; |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | |
664 | 664 | if ($airline_type != "") |
665 | 665 | { |
666 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
666 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
667 | 667 | if (!is_string($airline_type)) |
668 | 668 | { |
669 | 669 | return false; |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | |
686 | 686 | if ($airport != "") |
687 | 687 | { |
688 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
688 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
689 | 689 | if (!is_string($airport)) |
690 | 690 | { |
691 | 691 | return false; |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | |
697 | 697 | if ($airport_country != "") |
698 | 698 | { |
699 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
699 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
700 | 700 | if (!is_string($airport_country)) |
701 | 701 | { |
702 | 702 | return false; |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | |
708 | 708 | if ($callsign != "") |
709 | 709 | { |
710 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
710 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
711 | 711 | if (!is_string($callsign)) |
712 | 712 | { |
713 | 713 | return false; |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | $translate = $Translation->ident2icao($callsign); |
716 | 716 | if ($translate != $callsign) { |
717 | 717 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
718 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
718 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
719 | 719 | } else { |
720 | 720 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
721 | 721 | } |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | |
725 | 725 | if ($owner != "") |
726 | 726 | { |
727 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
727 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
728 | 728 | if (!is_string($owner)) |
729 | 729 | { |
730 | 730 | return false; |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | |
736 | 736 | if ($pilot_name != "") |
737 | 737 | { |
738 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
738 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
739 | 739 | if (!is_string($pilot_name)) |
740 | 740 | { |
741 | 741 | return false; |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | |
747 | 747 | if ($pilot_id != "") |
748 | 748 | { |
749 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
749 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
750 | 750 | if (!is_string($pilot_id)) |
751 | 751 | { |
752 | 752 | return false; |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | |
758 | 758 | if ($departure_airport_route != "") |
759 | 759 | { |
760 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
760 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
761 | 761 | if (!is_string($departure_airport_route)) |
762 | 762 | { |
763 | 763 | return false; |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | |
769 | 769 | if ($arrival_airport_route != "") |
770 | 770 | { |
771 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
771 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
772 | 772 | if (!is_string($arrival_airport_route)) |
773 | 773 | { |
774 | 774 | return false; |
@@ -781,8 +781,8 @@ discard block |
||
781 | 781 | { |
782 | 782 | $altitude_array = explode(",", $altitude); |
783 | 783 | |
784 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
785 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
784 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
785 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
786 | 786 | |
787 | 787 | |
788 | 788 | if ($altitude_array[1] != "") |
@@ -800,8 +800,8 @@ discard block |
||
800 | 800 | { |
801 | 801 | $date_array = explode(",", $date_posted); |
802 | 802 | |
803 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
804 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
803 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
804 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
805 | 805 | |
806 | 806 | if ($globalTimezone != '') { |
807 | 807 | date_default_timezone_set($globalTimezone); |
@@ -833,8 +833,8 @@ discard block |
||
833 | 833 | { |
834 | 834 | $limit_array = explode(",", $limit); |
835 | 835 | |
836 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
837 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
836 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
837 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
838 | 838 | |
839 | 839 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
840 | 840 | { |
@@ -845,8 +845,8 @@ discard block |
||
845 | 845 | |
846 | 846 | |
847 | 847 | if ($origLat != "" && $origLon != "" && $dist != "") { |
848 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
849 | - $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 |
|
848 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
849 | + $query = "SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
850 | 850 | 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)) |
851 | 851 | 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"; |
852 | 852 | } else { |
@@ -863,12 +863,12 @@ discard block |
||
863 | 863 | $additional_query .= " AND (tracker_archive_output.waypoints <> '')"; |
864 | 864 | } |
865 | 865 | |
866 | - $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
866 | + $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
867 | 867 | WHERE tracker_archive_output.ident <> '' |
868 | 868 | ".$additional_query." |
869 | 869 | ".$filter_query.$orderby_query; |
870 | 870 | } |
871 | - $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
|
871 | + $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
872 | 872 | |
873 | 873 | return $spotter_array; |
874 | 874 | } |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | try { |
886 | 886 | $sth = $this->db->prepare($query); |
887 | 887 | $sth->execute(); |
888 | - } catch(PDOException $e) { |
|
888 | + } catch (PDOException $e) { |
|
889 | 889 | return "error"; |
890 | 890 | } |
891 | 891 | } |
@@ -922,8 +922,8 @@ discard block |
||
922 | 922 | { |
923 | 923 | $limit_array = explode(",", $limit); |
924 | 924 | |
925 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
926 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
925 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
926 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
927 | 927 | |
928 | 928 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
929 | 929 | { |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | $query_values = array(); |
965 | 965 | $limit_query = ''; |
966 | 966 | $additional_query = ''; |
967 | - $filter_query = $this->getFilter($filter,true,true); |
|
967 | + $filter_query = $this->getFilter($filter, true, true); |
|
968 | 968 | |
969 | 969 | if ($owner != "") |
970 | 970 | { |
@@ -981,8 +981,8 @@ discard block |
||
981 | 981 | { |
982 | 982 | $limit_array = explode(",", $limit); |
983 | 983 | |
984 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
985 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
984 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
985 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
986 | 986 | |
987 | 987 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
988 | 988 | { |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | $query_values = array(); |
1023 | 1023 | $limit_query = ''; |
1024 | 1024 | $additional_query = ''; |
1025 | - $filter_query = $this->getFilter($filter,true,true); |
|
1025 | + $filter_query = $this->getFilter($filter, true, true); |
|
1026 | 1026 | |
1027 | 1027 | if ($pilot != "") |
1028 | 1028 | { |
@@ -1034,8 +1034,8 @@ discard block |
||
1034 | 1034 | { |
1035 | 1035 | $limit_array = explode(",", $limit); |
1036 | 1036 | |
1037 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1038 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1037 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1038 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1039 | 1039 | |
1040 | 1040 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1041 | 1041 | { |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | * @return Array the airline country list |
1066 | 1066 | * |
1067 | 1067 | */ |
1068 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1068 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1069 | 1069 | { |
1070 | 1070 | global $globalDBdriver; |
1071 | 1071 | /* |
@@ -1094,7 +1094,7 @@ discard block |
||
1094 | 1094 | $flight_array = array(); |
1095 | 1095 | $temp_array = array(); |
1096 | 1096 | |
1097 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1097 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1098 | 1098 | { |
1099 | 1099 | $temp_array['flight_count'] = $row['nb']; |
1100 | 1100 | $temp_array['flight_country'] = $row['name']; |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | * @return Array the airline country list |
1112 | 1112 | * |
1113 | 1113 | */ |
1114 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1114 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1115 | 1115 | { |
1116 | 1116 | global $globalDBdriver; |
1117 | 1117 | /* |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | $flight_array = array(); |
1141 | 1141 | $temp_array = array(); |
1142 | 1142 | |
1143 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1143 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1144 | 1144 | { |
1145 | 1145 | $temp_array['airline_icao'] = $row['airline_icao']; |
1146 | 1146 | $temp_array['flight_count'] = $row['nb']; |
@@ -1158,14 +1158,14 @@ discard block |
||
1158 | 1158 | * @return Array the spotter information |
1159 | 1159 | * |
1160 | 1160 | */ |
1161 | - public function getDateArchiveTrackerDataById($id,$date) |
|
1161 | + public function getDateArchiveTrackerDataById($id, $date) |
|
1162 | 1162 | { |
1163 | 1163 | $Tracker = new Tracker($this->db); |
1164 | 1164 | date_default_timezone_set('UTC'); |
1165 | 1165 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1166 | - $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'; |
|
1167 | - $date = date('c',$date); |
|
1168 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1166 | + $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'; |
|
1167 | + $date = date('c', $date); |
|
1168 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1169 | 1169 | return $spotter_array; |
1170 | 1170 | } |
1171 | 1171 | |
@@ -1175,14 +1175,14 @@ discard block |
||
1175 | 1175 | * @return Array the spotter information |
1176 | 1176 | * |
1177 | 1177 | */ |
1178 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
1178 | + public function getDateArchiveTrackerDataByIdent($ident, $date) |
|
1179 | 1179 | { |
1180 | 1180 | $Tracker = new Tracker($this->db); |
1181 | 1181 | date_default_timezone_set('UTC'); |
1182 | 1182 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1183 | - $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'; |
|
1184 | - $date = date('c',$date); |
|
1185 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1183 | + $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'; |
|
1184 | + $date = date('c', $date); |
|
1185 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1186 | 1186 | return $spotter_array; |
1187 | 1187 | } |
1188 | 1188 | |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | * @return Array the spotter information |
1193 | 1193 | * |
1194 | 1194 | */ |
1195 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1195 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1196 | 1196 | { |
1197 | 1197 | global $global_query; |
1198 | 1198 | $Tracker = new Tracker($this->db); |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | $query_values = array(); |
1201 | 1201 | $limit_query = ''; |
1202 | 1202 | $additional_query = ''; |
1203 | - $filter_query = $this->getFilter($filters,true,true); |
|
1203 | + $filter_query = $this->getFilter($filters, true, true); |
|
1204 | 1204 | |
1205 | 1205 | if ($airport != "") |
1206 | 1206 | { |
@@ -1217,8 +1217,8 @@ discard block |
||
1217 | 1217 | { |
1218 | 1218 | $limit_array = explode(",", $limit); |
1219 | 1219 | |
1220 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1221 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1220 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1221 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1222 | 1222 | |
1223 | 1223 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1224 | 1224 | { |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | require_once(dirname(__FILE__).'/class.Image.php'); |
5 | 5 | $global_query = "SELECT tracker_output.* FROM tracker_output"; |
6 | 6 | |
7 | -class Tracker{ |
|
7 | +class Tracker { |
|
8 | 8 | public $db; |
9 | 9 | |
10 | 10 | public function __construct($dbc = null) { |
@@ -19,33 +19,33 @@ discard block |
||
19 | 19 | * @return Array the SQL part |
20 | 20 | */ |
21 | 21 | |
22 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
22 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
23 | 23 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
24 | 24 | $filters = array(); |
25 | 25 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
26 | 26 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
27 | 27 | $filters = $globalStatsFilters[$globalFilterName]; |
28 | 28 | } else { |
29 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
29 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | if (isset($filter[0]['source'])) { |
33 | - $filters = array_merge($filters,$filter); |
|
33 | + $filters = array_merge($filters, $filter); |
|
34 | 34 | } |
35 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
36 | 36 | $filter_query_join = ''; |
37 | 37 | $filter_query_where = ''; |
38 | - foreach($filters as $flt) { |
|
38 | + foreach ($filters as $flt) { |
|
39 | 39 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
40 | 40 | if (isset($flt['source'])) { |
41 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
42 | 42 | } else { |
43 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
43 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | } |
47 | 47 | if (isset($filter['source']) && !empty($filter['source'])) { |
48 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
48 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
49 | 49 | } |
50 | 50 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
51 | 51 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
75 | 75 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
76 | 76 | if ($filter_query_where != '') { |
77 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
77 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
78 | 78 | } |
79 | 79 | $filter_query = $filter_query_join.$filter_query_where; |
80 | 80 | return $filter_query; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return Array the spotter information |
90 | 90 | * |
91 | 91 | */ |
92 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
92 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
93 | 93 | { |
94 | 94 | date_default_timezone_set('UTC'); |
95 | 95 | if (!is_string($query)) |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | $sth = $this->db->prepare($query.$limitQuery); |
110 | 110 | $sth->execute($params); |
111 | 111 | } catch (PDOException $e) { |
112 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
112 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
113 | 113 | exit(); |
114 | 114 | } |
115 | 115 | |
116 | 116 | $num_rows = 0; |
117 | 117 | $spotter_array = array(); |
118 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
118 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
119 | 119 | { |
120 | 120 | $num_rows++; |
121 | 121 | $temp_array = array(); |
@@ -171,17 +171,17 @@ discard block |
||
171 | 171 | { |
172 | 172 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
173 | 173 | } else { |
174 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
174 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
175 | 175 | } |
176 | 176 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
177 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
178 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
177 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
178 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
179 | 179 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
180 | 180 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
181 | 181 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
182 | 182 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
183 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
184 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
183 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
184 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
185 | 185 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
186 | 186 | } |
187 | 187 | } |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | { |
219 | 219 | $limit_array = explode(",", $limit); |
220 | 220 | |
221 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
222 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
221 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
222 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
223 | 223 | |
224 | 224 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
225 | 225 | { |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | $orderby_query = " ORDER BY tracker_output.date DESC"; |
237 | 237 | } |
238 | 238 | |
239 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
239 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
240 | 240 | |
241 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
241 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
242 | 242 | |
243 | 243 | return $spotter_array; |
244 | 244 | } |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | if ($id == '') return array(); |
258 | 258 | $additional_query = "tracker_output.famtrackid = :id"; |
259 | 259 | $query_values = array(':id' => $id); |
260 | - $query = $global_query." WHERE ".$additional_query." "; |
|
261 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
260 | + $query = $global_query." WHERE ".$additional_query." "; |
|
261 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
262 | 262 | return $spotter_array; |
263 | 263 | } |
264 | 264 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $query_values = array(); |
278 | 278 | $limit_query = ''; |
279 | 279 | $additional_query = ''; |
280 | - $filter_query = $this->getFilter($filter,true,true); |
|
280 | + $filter_query = $this->getFilter($filter, true, true); |
|
281 | 281 | if ($ident != "") |
282 | 282 | { |
283 | 283 | if (!is_string($ident)) |
@@ -293,8 +293,8 @@ discard block |
||
293 | 293 | { |
294 | 294 | $limit_array = explode(",", $limit); |
295 | 295 | |
296 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
297 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
296 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
297 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
298 | 298 | |
299 | 299 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
300 | 300 | { |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | return $spotter_array; |
319 | 319 | } |
320 | 320 | |
321 | - public function getTrackerDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
321 | + public function getTrackerDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
322 | 322 | { |
323 | 323 | global $global_query, $globalTimezone, $globalDBdriver; |
324 | 324 | |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | $limit_query = ''; |
327 | 327 | $additional_query = ''; |
328 | 328 | |
329 | - $filter_query = $this->getFilter($filter,true,true); |
|
329 | + $filter_query = $this->getFilter($filter, true, true); |
|
330 | 330 | |
331 | 331 | if ($date != "") |
332 | 332 | { |
@@ -352,8 +352,8 @@ discard block |
||
352 | 352 | { |
353 | 353 | $limit_array = explode(",", $limit); |
354 | 354 | |
355 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
356 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
355 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
356 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
357 | 357 | |
358 | 358 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
359 | 359 | { |
@@ -384,11 +384,11 @@ discard block |
||
384 | 384 | * @return Array list of source name |
385 | 385 | * |
386 | 386 | */ |
387 | - public function getAllSourceName($type = '',$filters = array()) |
|
387 | + public function getAllSourceName($type = '', $filters = array()) |
|
388 | 388 | { |
389 | - $filter_query = $this->getFilter($filters,true,true); |
|
389 | + $filter_query = $this->getFilter($filters, true, true); |
|
390 | 390 | $query_values = array(); |
391 | - $query = "SELECT DISTINCT tracker_output.source_name |
|
391 | + $query = "SELECT DISTINCT tracker_output.source_name |
|
392 | 392 | FROM tracker_output".$filter_query." tracker_output.source_name <> ''"; |
393 | 393 | if ($type != '') { |
394 | 394 | $query_values = array(':type' => $type); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | $source_array = array(); |
404 | 404 | $temp_array = array(); |
405 | 405 | |
406 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
406 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
407 | 407 | { |
408 | 408 | $temp_array['source_name'] = $row['source_name']; |
409 | 409 | $source_array[] = $temp_array; |
@@ -420,8 +420,8 @@ discard block |
||
420 | 420 | */ |
421 | 421 | public function getAllIdents($filters = array()) |
422 | 422 | { |
423 | - $filter_query = $this->getFilter($filters,true,true); |
|
424 | - $query = "SELECT DISTINCT tracker_output.ident |
|
423 | + $filter_query = $this->getFilter($filters, true, true); |
|
424 | + $query = "SELECT DISTINCT tracker_output.ident |
|
425 | 425 | FROM tracker_output".$filter_query." tracker_output.ident <> '' |
426 | 426 | ORDER BY tracker_output.date ASC LIMIT 700 OFFSET 0"; |
427 | 427 | |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | $ident_array = array(); |
432 | 432 | $temp_array = array(); |
433 | 433 | |
434 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
434 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
435 | 435 | { |
436 | 436 | $temp_array['ident'] = $row['ident']; |
437 | 437 | $ident_array[] = $temp_array; |
@@ -456,12 +456,12 @@ discard block |
||
456 | 456 | } else $offset = '+00:00'; |
457 | 457 | |
458 | 458 | if ($globalDBdriver == 'mysql') { |
459 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
|
459 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
|
460 | 460 | FROM tracker_output |
461 | 461 | WHERE tracker_output.date <> '' |
462 | 462 | ORDER BY tracker_output.date ASC LIMIT 0,200"; |
463 | 463 | } else { |
464 | - $query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
464 | + $query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
465 | 465 | FROM tracker_output |
466 | 466 | WHERE tracker_output.date <> '' |
467 | 467 | ORDER BY tracker_output.date ASC LIMIT 0,200"; |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | $date_array = array(); |
474 | 474 | $temp_array = array(); |
475 | 475 | |
476 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
476 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
477 | 477 | { |
478 | 478 | $temp_array['date'] = $row['date']; |
479 | 479 | |
@@ -492,11 +492,11 @@ discard block |
||
492 | 492 | * @return String success or false |
493 | 493 | * |
494 | 494 | */ |
495 | - public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL) |
|
495 | + public function updateIdentTrackerData($famtrackid = '', $ident = '', $fromsource = NULL) |
|
496 | 496 | { |
497 | 497 | |
498 | 498 | $query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid'; |
499 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
499 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident); |
|
500 | 500 | |
501 | 501 | try { |
502 | 502 | $sth = $this->db->prepare($query); |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '') |
521 | 521 | { |
522 | 522 | $query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid'; |
523 | - $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
523 | + $query_values = array(':famtrackid' => $famtrackid, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
524 | 524 | |
525 | 525 | try { |
526 | 526 | $sth = $this->db->prepare($query); |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * @param String $verticalrate vertival rate of flight |
561 | 561 | * @return String success or false |
562 | 562 | */ |
563 | - public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '') |
|
563 | + public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '', $format_source = '', $source_name = '') |
|
564 | 564 | { |
565 | 565 | global $globalURL; |
566 | 566 | |
@@ -628,21 +628,21 @@ discard block |
||
628 | 628 | } |
629 | 629 | |
630 | 630 | |
631 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
631 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
632 | 632 | { |
633 | 633 | $date = date("Y-m-d H:i:s", time()); |
634 | 634 | } |
635 | 635 | |
636 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
637 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
638 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
639 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
640 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
641 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
642 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
643 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
644 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
645 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
636 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
637 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
638 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
639 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
640 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
641 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
642 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
643 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
644 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
645 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
646 | 646 | |
647 | 647 | if ($latitude == '' && $longitude == '') { |
648 | 648 | $latitude = 0; |
@@ -650,10 +650,10 @@ discard block |
||
650 | 650 | } |
651 | 651 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
652 | 652 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
653 | - $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
653 | + $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
654 | 654 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
655 | 655 | |
656 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
656 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':comment' => $comment, ':type' => $type); |
|
657 | 657 | |
658 | 658 | try { |
659 | 659 | |
@@ -679,13 +679,13 @@ discard block |
||
679 | 679 | { |
680 | 680 | global $globalDBdriver, $globalTimezone; |
681 | 681 | if ($globalDBdriver == 'mysql') { |
682 | - $query = "SELECT tracker_output.ident FROM tracker_output |
|
682 | + $query = "SELECT tracker_output.ident FROM tracker_output |
|
683 | 683 | WHERE tracker_output.ident = :ident |
684 | 684 | AND tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
685 | 685 | AND tracker_output.date < UTC_TIMESTAMP()"; |
686 | 686 | $query_data = array(':ident' => $ident); |
687 | 687 | } else { |
688 | - $query = "SELECT tracker_output.ident FROM tracker_output |
|
688 | + $query = "SELECT tracker_output.ident FROM tracker_output |
|
689 | 689 | WHERE tracker_output.ident = :ident |
690 | 690 | AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
691 | 691 | AND tracker_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -694,8 +694,8 @@ discard block |
||
694 | 694 | |
695 | 695 | $sth = $this->db->prepare($query); |
696 | 696 | $sth->execute($query_data); |
697 | - $ident_result=''; |
|
698 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
697 | + $ident_result = ''; |
|
698 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
699 | 699 | { |
700 | 700 | $ident_result = $row['ident']; |
701 | 701 | } |
@@ -721,8 +721,8 @@ discard block |
||
721 | 721 | return false; |
722 | 722 | } else { |
723 | 723 | $q_array = explode(" ", $q); |
724 | - foreach ($q_array as $q_item){ |
|
725 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
724 | + foreach ($q_array as $q_item) { |
|
725 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
726 | 726 | $additional_query .= " AND ("; |
727 | 727 | $additional_query .= "(tracker_output.ident like '%".$q_item."%')"; |
728 | 728 | $additional_query .= ")"; |
@@ -730,11 +730,11 @@ discard block |
||
730 | 730 | } |
731 | 731 | } |
732 | 732 | if ($globalDBdriver == 'mysql') { |
733 | - $query = "SELECT tracker_output.* FROM tracker_output |
|
733 | + $query = "SELECT tracker_output.* FROM tracker_output |
|
734 | 734 | WHERE tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
735 | 735 | AND tracker_output.date < UTC_TIMESTAMP()"; |
736 | 736 | } else { |
737 | - $query = "SELECT tracker_output.* FROM tracker_output |
|
737 | + $query = "SELECT tracker_output.* FROM tracker_output |
|
738 | 738 | WHERE tracker_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
739 | 739 | AND tracker_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
740 | 740 | } |
@@ -753,16 +753,16 @@ discard block |
||
753 | 753 | * |
754 | 754 | */ |
755 | 755 | |
756 | - public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
756 | + public function countAllTrackerOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
757 | 757 | { |
758 | 758 | global $globalDBdriver, $globalArchive; |
759 | 759 | //$filter_query = $this->getFilter($filters,true,true); |
760 | - $Connection= new Connection($this->db); |
|
760 | + $Connection = new Connection($this->db); |
|
761 | 761 | if (!$Connection->tableExists('countries')) return array(); |
762 | 762 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
763 | 763 | require_once('class.TrackerLive.php'); |
764 | 764 | $TrackerLive = new TrackerLive($this->db); |
765 | - $filter_query = $TrackerLive->getFilter($filters,true,true); |
|
765 | + $filter_query = $TrackerLive->getFilter($filters, true, true); |
|
766 | 766 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
767 | 767 | if ($olderthanmonths > 0) { |
768 | 768 | if ($globalDBdriver == 'mysql') { |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | } else { |
783 | 783 | require_once('class.TrackerArchive.php'); |
784 | 784 | $TrackerArchive = new TrackerArchive($this->db); |
785 | - $filter_query = $TrackerArchive->getFilter($filters,true,true); |
|
785 | + $filter_query = $TrackerArchive->getFilter($filters, true, true); |
|
786 | 786 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
787 | 787 | if ($olderthanmonths > 0) { |
788 | 788 | if ($globalDBdriver == 'mysql') { |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | $flight_array = array(); |
811 | 811 | $temp_array = array(); |
812 | 812 | |
813 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
813 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
814 | 814 | { |
815 | 815 | $temp_array['flight_count'] = $row['nb']; |
816 | 816 | $temp_array['flight_country'] = $row['name']; |
@@ -827,11 +827,11 @@ discard block |
||
827 | 827 | * @return Array the callsign list |
828 | 828 | * |
829 | 829 | */ |
830 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
830 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
831 | 831 | { |
832 | 832 | global $globalDBdriver; |
833 | - $filter_query = $this->getFilter($filters,true,true); |
|
834 | - $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
833 | + $filter_query = $this->getFilter($filters, true, true); |
|
834 | + $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
835 | 835 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
836 | 836 | if ($olderthanmonths > 0) { |
837 | 837 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -845,28 +845,28 @@ discard block |
||
845 | 845 | if ($year != '') { |
846 | 846 | if ($globalDBdriver == 'mysql') { |
847 | 847 | $query .= " AND YEAR(tracker_output.date) = :year"; |
848 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
848 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
849 | 849 | } else { |
850 | 850 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
851 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
851 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
852 | 852 | } |
853 | 853 | } |
854 | 854 | if ($month != '') { |
855 | 855 | if ($globalDBdriver == 'mysql') { |
856 | 856 | $query .= " AND MONTH(tracker_output.date) = :month"; |
857 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
857 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
858 | 858 | } else { |
859 | 859 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
860 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
860 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
861 | 861 | } |
862 | 862 | } |
863 | 863 | if ($day != '') { |
864 | 864 | if ($globalDBdriver == 'mysql') { |
865 | 865 | $query .= " AND DAY(tracker_output.date) = :day"; |
866 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
866 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
867 | 867 | } else { |
868 | 868 | $query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day"; |
869 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
869 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
870 | 870 | } |
871 | 871 | } |
872 | 872 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | $callsign_array = array(); |
879 | 879 | $temp_array = array(); |
880 | 880 | |
881 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
881 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
882 | 882 | { |
883 | 883 | $temp_array['callsign_icao'] = $row['ident']; |
884 | 884 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | $date_array = array(); |
931 | 931 | $temp_array = array(); |
932 | 932 | |
933 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
933 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
934 | 934 | { |
935 | 935 | $temp_array['date_name'] = $row['date_name']; |
936 | 936 | $temp_array['date_count'] = $row['date_count']; |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | $datetime = new DateTime(); |
957 | 957 | $offset = $datetime->format('P'); |
958 | 958 | } else $offset = '+00:00'; |
959 | - $filter_query = $this->getFilter($filters,true,true); |
|
959 | + $filter_query = $this->getFilter($filters, true, true); |
|
960 | 960 | if ($globalDBdriver == 'mysql') { |
961 | 961 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
962 | 962 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | $date_array = array(); |
978 | 978 | $temp_array = array(); |
979 | 979 | |
980 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
980 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
981 | 981 | { |
982 | 982 | $temp_array['date_name'] = $row['date_name']; |
983 | 983 | $temp_array['date_count'] = $row['date_count']; |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | $datetime = new DateTime(); |
1003 | 1003 | $offset = $datetime->format('P'); |
1004 | 1004 | } else $offset = '+00:00'; |
1005 | - $filter_query = $this->getFilter($filters,true,true); |
|
1005 | + $filter_query = $this->getFilter($filters, true, true); |
|
1006 | 1006 | if ($globalDBdriver == 'mysql') { |
1007 | 1007 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1008 | 1008 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | $date_array = array(); |
1024 | 1024 | $temp_array = array(); |
1025 | 1025 | |
1026 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1026 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1027 | 1027 | { |
1028 | 1028 | $temp_array['date_name'] = $row['date_name']; |
1029 | 1029 | $temp_array['date_count'] = $row['date_count']; |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | $date_array = array(); |
1071 | 1071 | $temp_array = array(); |
1072 | 1072 | |
1073 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1073 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1074 | 1074 | { |
1075 | 1075 | $temp_array['month_name'] = $row['month_name']; |
1076 | 1076 | $temp_array['year_name'] = $row['year_name']; |
@@ -1099,7 +1099,7 @@ discard block |
||
1099 | 1099 | $datetime = new DateTime(); |
1100 | 1100 | $offset = $datetime->format('P'); |
1101 | 1101 | } else $offset = '+00:00'; |
1102 | - $filter_query = $this->getFilter($filters,true,true); |
|
1102 | + $filter_query = $this->getFilter($filters, true, true); |
|
1103 | 1103 | if ($globalDBdriver == 'mysql') { |
1104 | 1104 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
1105 | 1105 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | $date_array = array(); |
1121 | 1121 | $temp_array = array(); |
1122 | 1122 | |
1123 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1123 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1124 | 1124 | { |
1125 | 1125 | $temp_array['year_name'] = $row['year_name']; |
1126 | 1126 | $temp_array['month_name'] = $row['month_name']; |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | * @return Array the hour list |
1141 | 1141 | * |
1142 | 1142 | */ |
1143 | - public function countAllHours($orderby,$filters = array()) |
|
1143 | + public function countAllHours($orderby, $filters = array()) |
|
1144 | 1144 | { |
1145 | 1145 | global $globalTimezone, $globalDBdriver; |
1146 | 1146 | if ($globalTimezone != '') { |
@@ -1188,7 +1188,7 @@ discard block |
||
1188 | 1188 | $hour_array = array(); |
1189 | 1189 | $temp_array = array(); |
1190 | 1190 | |
1191 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1191 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1192 | 1192 | { |
1193 | 1193 | $temp_array['hour_name'] = $row['hour_name']; |
1194 | 1194 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1210,8 +1210,8 @@ discard block |
||
1210 | 1210 | public function countAllHoursByDate($date, $filters = array()) |
1211 | 1211 | { |
1212 | 1212 | global $globalTimezone, $globalDBdriver; |
1213 | - $filter_query = $this->getFilter($filters,true,true); |
|
1214 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1213 | + $filter_query = $this->getFilter($filters, true, true); |
|
1214 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1215 | 1215 | if ($globalTimezone != '') { |
1216 | 1216 | date_default_timezone_set($globalTimezone); |
1217 | 1217 | $datetime = new DateTime($date); |
@@ -1219,12 +1219,12 @@ discard block |
||
1219 | 1219 | } else $offset = '+00:00'; |
1220 | 1220 | |
1221 | 1221 | if ($globalDBdriver == 'mysql') { |
1222 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1222 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1223 | 1223 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date |
1224 | 1224 | GROUP BY hour_name |
1225 | 1225 | ORDER BY hour_name ASC"; |
1226 | 1226 | } else { |
1227 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1227 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1228 | 1228 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1229 | 1229 | GROUP BY hour_name |
1230 | 1230 | ORDER BY hour_name ASC"; |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | $hour_array = array(); |
1237 | 1237 | $temp_array = array(); |
1238 | 1238 | |
1239 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1239 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1240 | 1240 | { |
1241 | 1241 | $temp_array['hour_name'] = $row['hour_name']; |
1242 | 1242 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1258,8 +1258,8 @@ discard block |
||
1258 | 1258 | public function countAllHoursByIdent($ident, $filters = array()) |
1259 | 1259 | { |
1260 | 1260 | global $globalTimezone, $globalDBdriver; |
1261 | - $filter_query = $this->getFilter($filters,true,true); |
|
1262 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1261 | + $filter_query = $this->getFilter($filters, true, true); |
|
1262 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1263 | 1263 | if ($globalTimezone != '') { |
1264 | 1264 | date_default_timezone_set($globalTimezone); |
1265 | 1265 | $datetime = new DateTime(); |
@@ -1267,12 +1267,12 @@ discard block |
||
1267 | 1267 | } else $offset = '+00:00'; |
1268 | 1268 | |
1269 | 1269 | if ($globalDBdriver == 'mysql') { |
1270 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1270 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1271 | 1271 | FROM tracker_output".$filter_query." tracker_output.ident = :ident |
1272 | 1272 | GROUP BY hour_name |
1273 | 1273 | ORDER BY hour_name ASC"; |
1274 | 1274 | } else { |
1275 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1275 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1276 | 1276 | FROM tracker_output".$filter_query." tracker_output.ident = :ident |
1277 | 1277 | GROUP BY hour_name |
1278 | 1278 | ORDER BY hour_name ASC"; |
@@ -1280,12 +1280,12 @@ discard block |
||
1280 | 1280 | |
1281 | 1281 | |
1282 | 1282 | $sth = $this->db->prepare($query); |
1283 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1283 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1284 | 1284 | |
1285 | 1285 | $hour_array = array(); |
1286 | 1286 | $temp_array = array(); |
1287 | 1287 | |
1288 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1288 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1289 | 1289 | { |
1290 | 1290 | $temp_array['hour_name'] = $row['hour_name']; |
1291 | 1291 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1304,33 +1304,33 @@ discard block |
||
1304 | 1304 | * @return Integer the number of trackers |
1305 | 1305 | * |
1306 | 1306 | */ |
1307 | - public function countOverallTracker($filters = array(),$year = '',$month = '') |
|
1307 | + public function countOverallTracker($filters = array(), $year = '', $month = '') |
|
1308 | 1308 | { |
1309 | 1309 | global $globalDBdriver; |
1310 | 1310 | //$queryi = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output"; |
1311 | - $queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output"; |
|
1311 | + $queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output"; |
|
1312 | 1312 | $query_values = array(); |
1313 | 1313 | $query = ''; |
1314 | 1314 | if ($year != '') { |
1315 | 1315 | if ($globalDBdriver == 'mysql') { |
1316 | 1316 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1317 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1317 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1318 | 1318 | } else { |
1319 | 1319 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1320 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1320 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1321 | 1321 | } |
1322 | 1322 | } |
1323 | 1323 | if ($month != '') { |
1324 | 1324 | if ($globalDBdriver == 'mysql') { |
1325 | 1325 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1326 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1326 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1327 | 1327 | } else { |
1328 | 1328 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1329 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1329 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1330 | 1330 | } |
1331 | 1331 | } |
1332 | 1332 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1333 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1333 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1334 | 1334 | |
1335 | 1335 | $sth = $this->db->prepare($queryi); |
1336 | 1336 | $sth->execute($query_values); |
@@ -1343,32 +1343,32 @@ discard block |
||
1343 | 1343 | * @return Integer the number of flights |
1344 | 1344 | * |
1345 | 1345 | */ |
1346 | - public function countOverallTrackerTypes($filters = array(),$year = '',$month = '') |
|
1346 | + public function countOverallTrackerTypes($filters = array(), $year = '', $month = '') |
|
1347 | 1347 | { |
1348 | 1348 | global $globalDBdriver; |
1349 | - $queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output"; |
|
1349 | + $queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output"; |
|
1350 | 1350 | $query_values = array(); |
1351 | 1351 | $query = ''; |
1352 | 1352 | if ($year != '') { |
1353 | 1353 | if ($globalDBdriver == 'mysql') { |
1354 | 1354 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1355 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1355 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1356 | 1356 | } else { |
1357 | 1357 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1358 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1358 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1359 | 1359 | } |
1360 | 1360 | } |
1361 | 1361 | if ($month != '') { |
1362 | 1362 | if ($globalDBdriver == 'mysql') { |
1363 | 1363 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1364 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1364 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1365 | 1365 | } else { |
1366 | 1366 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1367 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1367 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1368 | 1368 | } |
1369 | 1369 | } |
1370 | 1370 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1371 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1371 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1372 | 1372 | |
1373 | 1373 | $sth = $this->db->prepare($queryi); |
1374 | 1374 | $sth->execute($query_values); |
@@ -1385,7 +1385,7 @@ discard block |
||
1385 | 1385 | public function countAllHoursFromToday($filters = array()) |
1386 | 1386 | { |
1387 | 1387 | global $globalTimezone, $globalDBdriver; |
1388 | - $filter_query = $this->getFilter($filters,true,true); |
|
1388 | + $filter_query = $this->getFilter($filters, true, true); |
|
1389 | 1389 | if ($globalTimezone != '') { |
1390 | 1390 | date_default_timezone_set($globalTimezone); |
1391 | 1391 | $datetime = new DateTime(); |
@@ -1393,12 +1393,12 @@ discard block |
||
1393 | 1393 | } else $offset = '+00:00'; |
1394 | 1394 | |
1395 | 1395 | if ($globalDBdriver == 'mysql') { |
1396 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1396 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1397 | 1397 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE() |
1398 | 1398 | GROUP BY hour_name |
1399 | 1399 | ORDER BY hour_name ASC"; |
1400 | 1400 | } else { |
1401 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1401 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1402 | 1402 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1403 | 1403 | GROUP BY hour_name |
1404 | 1404 | ORDER BY hour_name ASC"; |
@@ -1410,7 +1410,7 @@ discard block |
||
1410 | 1410 | $hour_array = array(); |
1411 | 1411 | $temp_array = array(); |
1412 | 1412 | |
1413 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1413 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1414 | 1414 | { |
1415 | 1415 | $temp_array['hour_name'] = $row['hour_name']; |
1416 | 1416 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1429,9 +1429,9 @@ discard block |
||
1429 | 1429 | */ |
1430 | 1430 | public function getTrackerIDBasedOnFamTrackID($famtrackid) |
1431 | 1431 | { |
1432 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
1432 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
1433 | 1433 | |
1434 | - $query = "SELECT tracker_output.tracker_id |
|
1434 | + $query = "SELECT tracker_output.tracker_id |
|
1435 | 1435 | FROM tracker_output |
1436 | 1436 | WHERE tracker_output.famtrackid = '".$famtrackid."'"; |
1437 | 1437 | |
@@ -1439,7 +1439,7 @@ discard block |
||
1439 | 1439 | $sth = $this->db->prepare($query); |
1440 | 1440 | $sth->execute(); |
1441 | 1441 | |
1442 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1442 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1443 | 1443 | { |
1444 | 1444 | return $row['tracker_id']; |
1445 | 1445 | } |
@@ -1464,23 +1464,23 @@ discard block |
||
1464 | 1464 | } |
1465 | 1465 | |
1466 | 1466 | $current_date = date("Y-m-d H:i:s"); |
1467 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1467 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1468 | 1468 | |
1469 | 1469 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1470 | 1470 | |
1471 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1471 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1472 | 1472 | $years = $time_array['years']; |
1473 | 1473 | |
1474 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1474 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1475 | 1475 | $months = $time_array['months']; |
1476 | 1476 | |
1477 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1477 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1478 | 1478 | $days = $time_array['days']; |
1479 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1479 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1480 | 1480 | $hours = $time_array['hours']; |
1481 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1481 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1482 | 1482 | $minutes = $time_array['minutes']; |
1483 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1483 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1484 | 1484 | |
1485 | 1485 | return $time_array; |
1486 | 1486 | } |
@@ -1503,63 +1503,63 @@ discard block |
||
1503 | 1503 | $temp_array['direction_degree'] = $direction; |
1504 | 1504 | $temp_array['direction_shortname'] = "N"; |
1505 | 1505 | $temp_array['direction_fullname'] = "North"; |
1506 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1506 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1507 | 1507 | $temp_array['direction_degree'] = $direction; |
1508 | 1508 | $temp_array['direction_shortname'] = "NNE"; |
1509 | 1509 | $temp_array['direction_fullname'] = "North-Northeast"; |
1510 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1510 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1511 | 1511 | $temp_array['direction_degree'] = $direction; |
1512 | 1512 | $temp_array['direction_shortname'] = "NE"; |
1513 | 1513 | $temp_array['direction_fullname'] = "Northeast"; |
1514 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1514 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1515 | 1515 | $temp_array['direction_degree'] = $direction; |
1516 | 1516 | $temp_array['direction_shortname'] = "ENE"; |
1517 | 1517 | $temp_array['direction_fullname'] = "East-Northeast"; |
1518 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1518 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1519 | 1519 | $temp_array['direction_degree'] = $direction; |
1520 | 1520 | $temp_array['direction_shortname'] = "E"; |
1521 | 1521 | $temp_array['direction_fullname'] = "East"; |
1522 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1522 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1523 | 1523 | $temp_array['direction_degree'] = $direction; |
1524 | 1524 | $temp_array['direction_shortname'] = "ESE"; |
1525 | 1525 | $temp_array['direction_fullname'] = "East-Southeast"; |
1526 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1526 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1527 | 1527 | $temp_array['direction_degree'] = $direction; |
1528 | 1528 | $temp_array['direction_shortname'] = "SE"; |
1529 | 1529 | $temp_array['direction_fullname'] = "Southeast"; |
1530 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1530 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1531 | 1531 | $temp_array['direction_degree'] = $direction; |
1532 | 1532 | $temp_array['direction_shortname'] = "SSE"; |
1533 | 1533 | $temp_array['direction_fullname'] = "South-Southeast"; |
1534 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1534 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1535 | 1535 | $temp_array['direction_degree'] = $direction; |
1536 | 1536 | $temp_array['direction_shortname'] = "S"; |
1537 | 1537 | $temp_array['direction_fullname'] = "South"; |
1538 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1538 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1539 | 1539 | $temp_array['direction_degree'] = $direction; |
1540 | 1540 | $temp_array['direction_shortname'] = "SSW"; |
1541 | 1541 | $temp_array['direction_fullname'] = "South-Southwest"; |
1542 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1542 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1543 | 1543 | $temp_array['direction_degree'] = $direction; |
1544 | 1544 | $temp_array['direction_shortname'] = "SW"; |
1545 | 1545 | $temp_array['direction_fullname'] = "Southwest"; |
1546 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1546 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1547 | 1547 | $temp_array['direction_degree'] = $direction; |
1548 | 1548 | $temp_array['direction_shortname'] = "WSW"; |
1549 | 1549 | $temp_array['direction_fullname'] = "West-Southwest"; |
1550 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1550 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1551 | 1551 | $temp_array['direction_degree'] = $direction; |
1552 | 1552 | $temp_array['direction_shortname'] = "W"; |
1553 | 1553 | $temp_array['direction_fullname'] = "West"; |
1554 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1554 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1555 | 1555 | $temp_array['direction_degree'] = $direction; |
1556 | 1556 | $temp_array['direction_shortname'] = "WNW"; |
1557 | 1557 | $temp_array['direction_fullname'] = "West-Northwest"; |
1558 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1558 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1559 | 1559 | $temp_array['direction_degree'] = $direction; |
1560 | 1560 | $temp_array['direction_shortname'] = "NW"; |
1561 | 1561 | $temp_array['direction_fullname'] = "Northwest"; |
1562 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1562 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1563 | 1563 | $temp_array['direction_degree'] = $direction; |
1564 | 1564 | $temp_array['direction_shortname'] = "NNW"; |
1565 | 1565 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1576,11 +1576,11 @@ discard block |
||
1576 | 1576 | * @param Float $longitude longitute of the flight |
1577 | 1577 | * @return String the countrie |
1578 | 1578 | */ |
1579 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1579 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1580 | 1580 | { |
1581 | 1581 | global $globalDBdriver, $globalDebug; |
1582 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1583 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1582 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1583 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1584 | 1584 | |
1585 | 1585 | $Connection = new Connection($this->db); |
1586 | 1586 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1620,7 +1620,7 @@ discard block |
||
1620 | 1620 | public function getCountryFromISO2($iso2) |
1621 | 1621 | { |
1622 | 1622 | global $globalDBdriver, $globalDebug; |
1623 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1623 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1624 | 1624 | |
1625 | 1625 | $Connection = new Connection($this->db); |
1626 | 1626 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1649,11 +1649,11 @@ discard block |
||
1649 | 1649 | * @return Array the vessel type list |
1650 | 1650 | * |
1651 | 1651 | */ |
1652 | - public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
1652 | + public function countAllTrackerTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1653 | 1653 | { |
1654 | 1654 | global $globalDBdriver; |
1655 | - $filter_query = $this->getFilter($filters,true,true); |
|
1656 | - $query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count |
|
1655 | + $filter_query = $this->getFilter($filters, true, true); |
|
1656 | + $query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count |
|
1657 | 1657 | FROM tracker_output ".$filter_query." tracker_output.type <> ''"; |
1658 | 1658 | if ($olderthanmonths > 0) { |
1659 | 1659 | if ($globalDBdriver == 'mysql') { |
@@ -1673,28 +1673,28 @@ discard block |
||
1673 | 1673 | if ($year != '') { |
1674 | 1674 | if ($globalDBdriver == 'mysql') { |
1675 | 1675 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1676 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1676 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1677 | 1677 | } else { |
1678 | 1678 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1679 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1679 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1680 | 1680 | } |
1681 | 1681 | } |
1682 | 1682 | if ($month != '') { |
1683 | 1683 | if ($globalDBdriver == 'mysql') { |
1684 | 1684 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1685 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1685 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1686 | 1686 | } else { |
1687 | 1687 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1688 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1688 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1689 | 1689 | } |
1690 | 1690 | } |
1691 | 1691 | if ($day != '') { |
1692 | 1692 | if ($globalDBdriver == 'mysql') { |
1693 | 1693 | $query .= " AND DAY(tracker_output.date) = :day"; |
1694 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1694 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1695 | 1695 | } else { |
1696 | 1696 | $query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day"; |
1697 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1697 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1698 | 1698 | } |
1699 | 1699 | } |
1700 | 1700 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
@@ -1703,7 +1703,7 @@ discard block |
||
1703 | 1703 | $sth->execute($query_values); |
1704 | 1704 | $tracker_array = array(); |
1705 | 1705 | $temp_array = array(); |
1706 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1706 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1707 | 1707 | { |
1708 | 1708 | $temp_array['tracker_type'] = $row['tracker_type']; |
1709 | 1709 | $temp_array['tracker_type_count'] = $row['tracker_type_count']; |
@@ -1738,7 +1738,7 @@ discard block |
||
1738 | 1738 | |
1739 | 1739 | $bitly_data = json_decode($bitly_data); |
1740 | 1740 | $bitly_url = ''; |
1741 | - if ($bitly_data->status_txt = "OK"){ |
|
1741 | + if ($bitly_data->status_txt = "OK") { |
|
1742 | 1742 | $bitly_url = $bitly_data->data->url; |
1743 | 1743 | } |
1744 | 1744 | |
@@ -1748,7 +1748,7 @@ discard block |
||
1748 | 1748 | |
1749 | 1749 | public function getOrderBy() |
1750 | 1750 | { |
1751 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
1751 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
1752 | 1752 | |
1753 | 1753 | return $orderby; |
1754 | 1754 |
@@ -55,23 +55,23 @@ discard block |
||
55 | 55 | $min = true; |
56 | 56 | $allhistory = false; |
57 | 57 | $filter['source'] = array(); |
58 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
59 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
60 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
61 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
62 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
63 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
64 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
65 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
66 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
67 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
58 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
59 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
60 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
61 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
62 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
63 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
64 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
65 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
66 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
67 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
68 | 68 | |
69 | 69 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
70 | 70 | $min = true; |
71 | 71 | } else $min = false; |
72 | 72 | |
73 | 73 | if (isset($_GET['ident'])) { |
74 | - $ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
|
74 | + $ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING)); |
|
75 | 75 | if ($tracker) { |
76 | 76 | $spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident); |
77 | 77 | } elseif ($marine) { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | $allhistory = true; |
87 | 87 | } elseif (isset($_GET['flightaware_id'])) { |
88 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
88 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
89 | 89 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
90 | 90 | if (empty($spotter_array)) { |
91 | 91 | $from_archive = true; |
@@ -93,44 +93,44 @@ discard block |
||
93 | 93 | } |
94 | 94 | $allhistory = true; |
95 | 95 | } elseif (isset($_GET['famtrack_id'])) { |
96 | - $famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING)); |
|
96 | + $famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING)); |
|
97 | 97 | $spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id); |
98 | 98 | $allhistory = true; |
99 | 99 | } elseif (isset($_GET['fammarine_id'])) { |
100 | - $fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING)); |
|
100 | + $fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING)); |
|
101 | 101 | $spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id); |
102 | 102 | $allhistory = true; |
103 | 103 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) { |
104 | 104 | //} elseif (isset($_GET['coord'])) { |
105 | 105 | $usecoord = true; |
106 | - $coord = explode(',',$_GET['coord']); |
|
106 | + $coord = explode(',', $_GET['coord']); |
|
107 | 107 | if ($tracker) { |
108 | - $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter); |
|
108 | + $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord, $filter); |
|
109 | 109 | } elseif ($marine) { |
110 | - $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord,$filter); |
|
110 | + $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord, $filter); |
|
111 | 111 | } else { |
112 | - $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter); |
|
112 | + $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter); |
|
113 | 113 | } |
114 | 114 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) { |
115 | 115 | $usecoord = true; |
116 | - $coord = explode(',',$_GET['coord']); |
|
116 | + $coord = explode(',', $_GET['coord']); |
|
117 | 117 | if ($tracker) { |
118 | - $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter); |
|
118 | + $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter); |
|
119 | 119 | } elseif ($marine) { |
120 | - $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter); |
|
120 | + $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter); |
|
121 | 121 | } else { |
122 | - $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter); |
|
122 | + $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter); |
|
123 | 123 | } |
124 | 124 | } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) { |
125 | 125 | $from_archive = true; |
126 | 126 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
127 | 127 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
128 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
129 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
130 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
131 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
132 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
133 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
128 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
129 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
130 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
131 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
132 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
133 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
134 | 134 | } elseif ($min) { |
135 | 135 | if ($tracker) { |
136 | 136 | $spotter_array = $TrackerLive->getMinLiveTrackerData($filter); |
@@ -142,17 +142,17 @@ discard block |
||
142 | 142 | # $min = true; |
143 | 143 | } else { |
144 | 144 | if ($tracker) { |
145 | - $spotter_array = $TrackerLive->getLiveTrackerData('','',$filter); |
|
145 | + $spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter); |
|
146 | 146 | } elseif ($marine) { |
147 | - $spotter_array = $marineLive->getLiveMarineData('','',$filter); |
|
147 | + $spotter_array = $marineLive->getLiveMarineData('', '', $filter); |
|
148 | 148 | } else { |
149 | - $spotter_array = $SpotterLive->getLiveSpotterData('','',$filter); |
|
149 | + $spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | if ($usecoord) { |
154 | 154 | if (isset($_GET['archive'])) { |
155 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
155 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
156 | 156 | } else { |
157 | 157 | if ($tracker) { |
158 | 158 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | if ($flightcnt == '') $flightcnt = 0; |
166 | 166 | } else $flightcnt = 0; |
167 | 167 | |
168 | -$sqltime = round(microtime(true)-$begintime,2); |
|
168 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
169 | 169 | |
170 | 170 | if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
171 | 171 | else $usenextlatlon = true; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | if (!empty($spotter_array) && is_array($spotter_array)) |
183 | 183 | { |
184 | 184 | $output .= '"features": ['; |
185 | - foreach($spotter_array as $spotter_item) |
|
185 | + foreach ($spotter_array as $spotter_item) |
|
186 | 186 | { |
187 | 187 | $j++; |
188 | 188 | date_default_timezone_set('UTC'); |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | */ |
239 | 239 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
240 | 240 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
241 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
242 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
241 | + if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
242 | + else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
243 | 243 | //" |
244 | 244 | } else { |
245 | 245 | if ($compress) $output .= '"c": "NA",'; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
249 | 249 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
250 | 250 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
251 | - $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
|
251 | + $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",'; |
|
252 | 252 | } elseif (isset($spotter_item['aircraft_type'])) { |
253 | 253 | $output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",'; |
254 | 254 | } elseif (!$min) { |
@@ -389,16 +389,16 @@ discard block |
||
389 | 389 | else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
390 | 390 | |
391 | 391 | if (isset($archivespeed)) { |
392 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
|
392 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed); |
|
393 | 393 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
394 | 394 | } elseif ($usenextlatlon) { |
395 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']); |
|
395 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']); |
|
396 | 396 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
397 | 397 | } |
398 | 398 | |
399 | 399 | if (!$min) $output .= '"image": "'.$image.'",'; |
400 | 400 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
401 | - $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
|
401 | + $output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",'; |
|
402 | 402 | } |
403 | 403 | if (isset($spotter_item['image_source_website'])) { |
404 | 404 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
421 | 421 | } |
422 | 422 | if (isset($spotter_item['acars'])) { |
423 | - $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
|
423 | + $output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",'; |
|
424 | 424 | } |
425 | 425 | // type when not aircraft ? |
426 | 426 | if (isset($spotter_item['type'])) { |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | |
499 | 499 | } |
500 | 500 | */ |
501 | - $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
|
501 | + $history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING); |
|
502 | 502 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
503 | 503 | |
504 | 504 | if ( |
@@ -506,11 +506,11 @@ discard block |
||
506 | 506 | || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
507 | 507 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
508 | 508 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
509 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
509 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
510 | 510 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
511 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
511 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id'])) |
|
512 | 512 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
513 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
513 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid'])) |
|
514 | 514 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
515 | 515 | ) { |
516 | 516 | if ($tracker) { |
@@ -547,9 +547,9 @@ discard block |
||
547 | 547 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
548 | 548 | } |
549 | 549 | $output_history .= '['; |
550 | - $output_history .= $spotter_history['longitude'].', '; |
|
551 | - $output_history .= $spotter_history['latitude'].', '; |
|
552 | - $output_history .= $spotter_history['altitude']*30.48; |
|
550 | + $output_history .= $spotter_history['longitude'].', '; |
|
551 | + $output_history .= $spotter_history['latitude'].', '; |
|
552 | + $output_history .= $spotter_history['altitude']*30.48; |
|
553 | 553 | $output_history .= '],'; |
554 | 554 | /* |
555 | 555 | if ($from_archive === false) { |
@@ -567,8 +567,8 @@ discard block |
||
567 | 567 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
568 | 568 | } else $d = true; |
569 | 569 | $output_history .= '['; |
570 | - $output_history .= $spotter_history['longitude'].', '; |
|
571 | - $output_history .= $spotter_history['latitude']; |
|
570 | + $output_history .= $spotter_history['longitude'].', '; |
|
571 | + $output_history .= $spotter_history['latitude']; |
|
572 | 572 | $output_history .= '],'; |
573 | 573 | /* |
574 | 574 | if ($from_archive === false) { |
@@ -584,9 +584,9 @@ discard block |
||
584 | 584 | |
585 | 585 | if ($from_archive === false) { |
586 | 586 | $output_historyd = '['; |
587 | - $output_historyd .= $spotter_item['longitude'].', '; |
|
588 | - $output_historyd .= $spotter_item['latitude']; |
|
589 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
587 | + $output_historyd .= $spotter_item['longitude'].', '; |
|
588 | + $output_historyd .= $spotter_item['latitude']; |
|
589 | + if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
590 | 590 | $output_historyd .= '],'; |
591 | 591 | //$output_history = $output_historyd.$output_history; |
592 | 592 | $output_history = $output_history.$output_historyd; |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | } |
601 | 601 | } |
602 | 602 | |
603 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
603 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
604 | 604 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
605 | 605 | && (isset($spotter_item['departure_airport']) |
606 | 606 | && $spotter_item['departure_airport'] != 'NA' |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | |
635 | 635 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
636 | 636 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
637 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
637 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
638 | 638 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
639 | 639 | && (isset($spotter_item['arrival_airport']) |
640 | 640 | && $spotter_item['arrival_airport'] != 'NA' |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | $output = substr($output, 0, -1); |
666 | 666 | $output .= ']'; |
667 | 667 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
668 | - $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
|
668 | + $output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",'; |
|
669 | 669 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
670 | 670 | $output .= '"fc": "'.$j.'"'; |
671 | 671 | } else { |
@@ -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 famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
39 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
40 | 40 | } else { |
41 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
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 tracker_output.date) = '".$filter['day']."'"; |
73 | 73 | } |
74 | 74 | } |
75 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
75 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
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]; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } else { |
128 | 128 | $query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query; |
129 | 129 | } |
130 | - $spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true); |
|
130 | + $spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true); |
|
131 | 131 | |
132 | 132 | return $spotter_array; |
133 | 133 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | global $globalDBdriver, $globalLiveInterval; |
144 | 144 | date_default_timezone_set('UTC'); |
145 | 145 | |
146 | - $filter_query = $this->getFilter($filter,true,true); |
|
146 | + $filter_query = $this->getFilter($filter, true, true); |
|
147 | 147 | |
148 | 148 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
149 | 149 | if ($globalDBdriver == 'mysql') { |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | try { |
162 | 162 | $sth = $this->db->prepare($query); |
163 | 163 | $sth->execute(); |
164 | - } catch(PDOException $e) { |
|
164 | + } catch (PDOException $e) { |
|
165 | 165 | echo $e->getMessage(); |
166 | 166 | die; |
167 | 167 | } |
@@ -176,25 +176,25 @@ discard block |
||
176 | 176 | * @return Array the spotter information |
177 | 177 | * |
178 | 178 | */ |
179 | - public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false) |
|
179 | + public function getMinLastLiveTrackerData($coord, $filter = array(), $limit = false) |
|
180 | 180 | { |
181 | 181 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit; |
182 | 182 | date_default_timezone_set('UTC'); |
183 | 183 | $usecoord = false; |
184 | 184 | if (is_array($coord) && !empty($coord)) { |
185 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
186 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
187 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
188 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
185 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
186 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
187 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
188 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
189 | 189 | $usecoord = true; |
190 | 190 | } |
191 | - $filter_query = $this->getFilter($filter,true,true); |
|
191 | + $filter_query = $this->getFilter($filter, true, true); |
|
192 | 192 | |
193 | 193 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
194 | 194 | if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300'; |
195 | 195 | if ($globalDBdriver == 'mysql') { |
196 | 196 | if (isset($globalArchive) && $globalArchive) { |
197 | - $query = "SELECT * FROM ( |
|
197 | + $query = "SELECT * FROM ( |
|
198 | 198 | SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source |
199 | 199 | FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid "; |
200 | 200 | if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | } else { |
218 | 218 | if (isset($globalArchive) && $globalArchive) { |
219 | - $query = "SELECT * FROM ( |
|
219 | + $query = "SELECT * FROM ( |
|
220 | 220 | SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source |
221 | 221 | FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid "; |
222 | 222 | if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | try { |
241 | 241 | $sth = $this->db->prepare($query); |
242 | 242 | $sth->execute(); |
243 | - } catch(PDOException $e) { |
|
243 | + } catch (PDOException $e) { |
|
244 | 244 | echo $e->getMessage(); |
245 | 245 | die; |
246 | 246 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | public function getLiveTrackerCount($filter = array()) |
258 | 258 | { |
259 | 259 | global $globalDBdriver, $globalLiveInterval; |
260 | - $filter_query = $this->getFilter($filter,true,true); |
|
260 | + $filter_query = $this->getFilter($filter, true, true); |
|
261 | 261 | |
262 | 262 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
263 | 263 | if ($globalDBdriver == 'mysql') { |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | try { |
269 | 269 | $sth = $this->db->prepare($query); |
270 | 270 | $sth->execute(); |
271 | - } catch(PDOException $e) { |
|
271 | + } catch (PDOException $e) { |
|
272 | 272 | echo $e->getMessage(); |
273 | 273 | die; |
274 | 274 | } |
@@ -291,10 +291,10 @@ discard block |
||
291 | 291 | $filter_query = $this->getFilter($filter); |
292 | 292 | |
293 | 293 | if (is_array($coord)) { |
294 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
295 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
296 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
297 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
294 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
295 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
296 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
297 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
298 | 298 | } else return array(); |
299 | 299 | if ($globalDBdriver == 'mysql') { |
300 | 300 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
@@ -319,17 +319,17 @@ discard block |
||
319 | 319 | $filter_query = $this->getFilter($filter); |
320 | 320 | |
321 | 321 | if (is_array($coord)) { |
322 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
323 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
324 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
325 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
322 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
323 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
324 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
325 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
326 | 326 | } else return array(); |
327 | 327 | if ($globalDBdriver == 'mysql') { |
328 | 328 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
329 | 329 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
330 | 330 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
331 | 331 | } else { |
332 | - $query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
332 | + $query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
333 | 333 | FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date l.latitude BETWEEN ".$minlat." AND ".$maxlat." AND l.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query." tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'"; |
334 | 334 | } |
335 | 335 | $spotter_array = $Spotter->getDataFromDB($query); |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | if ($interval == '1m') |
378 | 378 | { |
379 | 379 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
380 | - } else if ($interval == '15m'){ |
|
380 | + } else if ($interval == '15m') { |
|
381 | 381 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
382 | 382 | } |
383 | 383 | } |
@@ -385,14 +385,14 @@ discard block |
||
385 | 385 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
386 | 386 | } |
387 | 387 | |
388 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
388 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
389 | 389 | WHERE tracker_live.latitude <> '' |
390 | 390 | AND tracker_live.longitude <> '' |
391 | 391 | ".$additional_query." |
392 | 392 | HAVING distance < :radius |
393 | 393 | ORDER BY distance"; |
394 | 394 | |
395 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
395 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
396 | 396 | |
397 | 397 | return $spotter_array; |
398 | 398 | } |
@@ -410,9 +410,9 @@ discard block |
||
410 | 410 | date_default_timezone_set('UTC'); |
411 | 411 | |
412 | 412 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
413 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
413 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
414 | 414 | |
415 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
415 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
416 | 416 | |
417 | 417 | return $spotter_array; |
418 | 418 | } |
@@ -423,16 +423,16 @@ discard block |
||
423 | 423 | * @return Array the spotter information |
424 | 424 | * |
425 | 425 | */ |
426 | - public function getDateLiveTrackerDataByIdent($ident,$date) |
|
426 | + public function getDateLiveTrackerDataByIdent($ident, $date) |
|
427 | 427 | { |
428 | 428 | $Tracker = new Tracker($this->db); |
429 | 429 | date_default_timezone_set('UTC'); |
430 | 430 | |
431 | 431 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
432 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
432 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
433 | 433 | |
434 | - $date = date('c',$date); |
|
435 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
434 | + $date = date('c', $date); |
|
435 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
436 | 436 | |
437 | 437 | return $spotter_array; |
438 | 438 | } |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | date_default_timezone_set('UTC'); |
450 | 450 | |
451 | 451 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
452 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
452 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
453 | 453 | |
454 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
|
454 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true); |
|
455 | 455 | |
456 | 456 | return $spotter_array; |
457 | 457 | } |
@@ -462,15 +462,15 @@ discard block |
||
462 | 462 | * @return Array the spotter information |
463 | 463 | * |
464 | 464 | */ |
465 | - public function getDateLiveTrackerDataById($id,$date) |
|
465 | + public function getDateLiveTrackerDataById($id, $date) |
|
466 | 466 | { |
467 | 467 | $Tracker = new Tracker($this->db); |
468 | 468 | date_default_timezone_set('UTC'); |
469 | 469 | |
470 | 470 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
471 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
472 | - $date = date('c',$date); |
|
473 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
471 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
472 | + $date = date('c', $date); |
|
473 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
474 | 474 | |
475 | 475 | return $spotter_array; |
476 | 476 | } |
@@ -487,13 +487,13 @@ discard block |
||
487 | 487 | date_default_timezone_set('UTC'); |
488 | 488 | |
489 | 489 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
490 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
490 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
491 | 491 | |
492 | 492 | try { |
493 | 493 | |
494 | 494 | $sth = $this->db->prepare($query); |
495 | 495 | $sth->execute(array(':ident' => $ident)); |
496 | - } catch(PDOException $e) { |
|
496 | + } catch (PDOException $e) { |
|
497 | 497 | echo $e->getMessage(); |
498 | 498 | die; |
499 | 499 | } |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @return Array the spotter information |
509 | 509 | * |
510 | 510 | */ |
511 | - public function getAllLiveTrackerDataById($id,$liveinterval = false) |
|
511 | + public function getAllLiveTrackerDataById($id, $liveinterval = false) |
|
512 | 512 | { |
513 | 513 | global $globalDBdriver, $globalLiveInterval; |
514 | 514 | date_default_timezone_set('UTC'); |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $this->db->prepare($query); |
529 | 529 | $sth->execute(array(':id' => $id)); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | echo $e->getMessage(); |
532 | 532 | die; |
533 | 533 | } |
@@ -545,12 +545,12 @@ discard block |
||
545 | 545 | { |
546 | 546 | date_default_timezone_set('UTC'); |
547 | 547 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
548 | - $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
548 | + $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
549 | 549 | try { |
550 | 550 | |
551 | 551 | $sth = $this->db->prepare($query); |
552 | 552 | $sth->execute(array(':ident' => $ident)); |
553 | - } catch(PDOException $e) { |
|
553 | + } catch (PDOException $e) { |
|
554 | 554 | echo $e->getMessage(); |
555 | 555 | die; |
556 | 556 | } |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | |
581 | 581 | $sth = $this->db->prepare($query); |
582 | 582 | $sth->execute(); |
583 | - } catch(PDOException $e) { |
|
583 | + } catch (PDOException $e) { |
|
584 | 584 | return "error"; |
585 | 585 | } |
586 | 586 | |
@@ -603,14 +603,14 @@ discard block |
||
603 | 603 | |
604 | 604 | $sth = $this->db->prepare($query); |
605 | 605 | $sth->execute(); |
606 | - } catch(PDOException $e) { |
|
606 | + } catch (PDOException $e) { |
|
607 | 607 | return "error"; |
608 | 608 | } |
609 | 609 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
610 | 610 | $i = 0; |
611 | - $j =0; |
|
611 | + $j = 0; |
|
612 | 612 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
613 | - foreach($all as $row) |
|
613 | + foreach ($all as $row) |
|
614 | 614 | { |
615 | 615 | $i++; |
616 | 616 | $j++; |
@@ -618,9 +618,9 @@ discard block |
||
618 | 618 | if ($globalDebug) echo "."; |
619 | 619 | try { |
620 | 620 | |
621 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
621 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
622 | 622 | $sth->execute(); |
623 | - } catch(PDOException $e) { |
|
623 | + } catch (PDOException $e) { |
|
624 | 624 | return "error"; |
625 | 625 | } |
626 | 626 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
@@ -631,9 +631,9 @@ discard block |
||
631 | 631 | if ($i > 0) { |
632 | 632 | try { |
633 | 633 | |
634 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
634 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
635 | 635 | $sth->execute(); |
636 | - } catch(PDOException $e) { |
|
636 | + } catch (PDOException $e) { |
|
637 | 637 | return "error"; |
638 | 638 | } |
639 | 639 | } |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | |
647 | 647 | $sth = $this->db->prepare($query); |
648 | 648 | $sth->execute(); |
649 | - } catch(PDOException $e) { |
|
649 | + } catch (PDOException $e) { |
|
650 | 650 | return "error"; |
651 | 651 | } |
652 | 652 | /* $query_delete = "DELETE FROM tracker_live WHERE famtrackid IN ("; |
@@ -694,13 +694,13 @@ discard block |
||
694 | 694 | public function deleteLiveTrackerDataByIdent($ident) |
695 | 695 | { |
696 | 696 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
697 | - $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
697 | + $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
698 | 698 | |
699 | 699 | try { |
700 | 700 | |
701 | 701 | $sth = $this->db->prepare($query); |
702 | 702 | $sth->execute(array(':ident' => $ident)); |
703 | - } catch(PDOException $e) { |
|
703 | + } catch (PDOException $e) { |
|
704 | 704 | return "error"; |
705 | 705 | } |
706 | 706 | |
@@ -716,13 +716,13 @@ discard block |
||
716 | 716 | public function deleteLiveTrackerDataById($id) |
717 | 717 | { |
718 | 718 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
719 | - $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
719 | + $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
720 | 720 | |
721 | 721 | try { |
722 | 722 | |
723 | 723 | $sth = $this->db->prepare($query); |
724 | 724 | $sth->execute(array(':id' => $id)); |
725 | - } catch(PDOException $e) { |
|
725 | + } catch (PDOException $e) { |
|
726 | 726 | return "error"; |
727 | 727 | } |
728 | 728 | |
@@ -740,13 +740,13 @@ discard block |
||
740 | 740 | { |
741 | 741 | global $globalDBdriver, $globalTimezone; |
742 | 742 | if ($globalDBdriver == 'mysql') { |
743 | - $query = 'SELECT tracker_live.ident FROM tracker_live |
|
743 | + $query = 'SELECT tracker_live.ident FROM tracker_live |
|
744 | 744 | WHERE tracker_live.ident = :ident |
745 | 745 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
746 | 746 | AND tracker_live.date < UTC_TIMESTAMP()'; |
747 | 747 | $query_data = array(':ident' => $ident); |
748 | 748 | } else { |
749 | - $query = "SELECT tracker_live.ident FROM tracker_live |
|
749 | + $query = "SELECT tracker_live.ident FROM tracker_live |
|
750 | 750 | WHERE tracker_live.ident = :ident |
751 | 751 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
752 | 752 | AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -755,8 +755,8 @@ discard block |
||
755 | 755 | |
756 | 756 | $sth = $this->db->prepare($query); |
757 | 757 | $sth->execute($query_data); |
758 | - $ident_result=''; |
|
759 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
758 | + $ident_result = ''; |
|
759 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
760 | 760 | { |
761 | 761 | $ident_result = $row['ident']; |
762 | 762 | } |
@@ -773,13 +773,13 @@ discard block |
||
773 | 773 | { |
774 | 774 | global $globalDBdriver, $globalTimezone; |
775 | 775 | if ($globalDBdriver == 'mysql') { |
776 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
776 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
777 | 777 | WHERE tracker_live.ident = :ident |
778 | 778 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
779 | 779 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
780 | 780 | $query_data = array(':ident' => $ident); |
781 | 781 | } else { |
782 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
782 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
783 | 783 | WHERE tracker_live.ident = :ident |
784 | 784 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
785 | 785 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -788,8 +788,8 @@ discard block |
||
788 | 788 | |
789 | 789 | $sth = $this->db->prepare($query); |
790 | 790 | $sth->execute($query_data); |
791 | - $ident_result=''; |
|
792 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
791 | + $ident_result = ''; |
|
792 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
793 | 793 | { |
794 | 794 | $ident_result = $row['famtrackid']; |
795 | 795 | } |
@@ -806,13 +806,13 @@ discard block |
||
806 | 806 | { |
807 | 807 | global $globalDBdriver, $globalTimezone; |
808 | 808 | if ($globalDBdriver == 'mysql') { |
809 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
809 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
810 | 810 | WHERE tracker_live.famtrackid = :id |
811 | 811 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
812 | 812 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
813 | 813 | $query_data = array(':id' => $id); |
814 | 814 | } else { |
815 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
815 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
816 | 816 | WHERE tracker_live.famtrackid = :id |
817 | 817 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
818 | 818 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -821,8 +821,8 @@ discard block |
||
821 | 821 | |
822 | 822 | $sth = $this->db->prepare($query); |
823 | 823 | $sth->execute($query_data); |
824 | - $ident_result=''; |
|
825 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
824 | + $ident_result = ''; |
|
825 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
826 | 826 | { |
827 | 827 | $ident_result = $row['famtrackid']; |
828 | 828 | } |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | * @return String success or false |
841 | 841 | * |
842 | 842 | */ |
843 | - public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
843 | + public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
844 | 844 | { |
845 | 845 | global $globalURL, $globalArchive, $globalDebug; |
846 | 846 | $Common = new Common(); |
@@ -899,21 +899,21 @@ discard block |
||
899 | 899 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
900 | 900 | |
901 | 901 | |
902 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
903 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
904 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
905 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
906 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
907 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
908 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
909 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
910 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
911 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
912 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
913 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
914 | - |
|
915 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
916 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
902 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
903 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
904 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
905 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
906 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
907 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
908 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
909 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
910 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
911 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
912 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
913 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
914 | + |
|
915 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
916 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
917 | 917 | |
918 | 918 | $query = ''; |
919 | 919 | if ($globalArchive) { |
@@ -923,12 +923,12 @@ discard block |
||
923 | 923 | $query .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
924 | 924 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
925 | 925 | |
926 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type); |
|
926 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type); |
|
927 | 927 | try { |
928 | 928 | |
929 | 929 | $sth = $this->db->prepare($query); |
930 | 930 | $sth->execute($query_values); |
931 | - } catch(PDOException $e) { |
|
931 | + } catch (PDOException $e) { |
|
932 | 932 | return "error : ".$e->getMessage(); |
933 | 933 | } |
934 | 934 | /* |
@@ -938,7 +938,7 @@ discard block |
||
938 | 938 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
939 | 939 | if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
940 | 940 | $TrackerArchive = new TrackerArchive($this->db); |
941 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
941 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident, $latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type, $noarchive, $format_source, $source_name, $over_country); |
|
942 | 942 | if ($globalDebug) echo $result.')'; |
943 | 943 | } |
944 | 944 | |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | |
949 | 949 | public function getOrderBy() |
950 | 950 | { |
951 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
951 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
952 | 952 | return $orderby; |
953 | 953 | } |
954 | 954 |
@@ -17,62 +17,62 @@ 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['airlines']) && !empty($flt['airlines'])) { |
38 | 38 | if ($flt['airlines'][0] != '') { |
39 | 39 | if (isset($flt['source'])) { |
40 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
41 | 41 | } else { |
42 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
42 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
46 | 46 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
47 | 47 | if (isset($flt['source'])) { |
48 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
48 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
49 | 49 | } else { |
50 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
50 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
54 | 54 | if (isset($flt['source'])) { |
55 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
55 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
56 | 56 | } else { |
57 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
57 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
61 | 61 | if (isset($flt['source'])) { |
62 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
62 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
63 | 63 | } else { |
64 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
64 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
68 | 68 | if (isset($flt['source'])) { |
69 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
69 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
73 | 73 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
74 | 74 | if ($filter['airlines'][0] != '') { |
75 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
75 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
83 | 83 | } |
84 | 84 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
85 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
85 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
86 | 86 | } |
87 | 87 | if (isset($filter['source']) && !empty($filter['source'])) { |
88 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
88 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
89 | 89 | } |
90 | 90 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
91 | 91 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
115 | 115 | } |
116 | 116 | } |
117 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
117 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
118 | 118 | } |
119 | 119 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
120 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
120 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
121 | 121 | } |
122 | 122 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
123 | 123 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
124 | 124 | if ($filter_query_where != '') { |
125 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
125 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
126 | 126 | } |
127 | 127 | $filter_query = $filter_query_join.$filter_query_where; |
128 | 128 | return $filter_query; |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | if ($limit != '') |
146 | 146 | { |
147 | 147 | $limit_array = explode(',', $limit); |
148 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
149 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
148 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
149 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
150 | 150 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
151 | 151 | { |
152 | 152 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | } else { |
171 | 171 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
172 | 172 | } |
173 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
173 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
174 | 174 | |
175 | 175 | return $spotter_array; |
176 | 176 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | { |
186 | 186 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
187 | 187 | date_default_timezone_set('UTC'); |
188 | - $filter_query = $this->getFilter($filter,true,true); |
|
188 | + $filter_query = $this->getFilter($filter, true, true); |
|
189 | 189 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
190 | 190 | if ($globalDBdriver == 'mysql') { |
191 | 191 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | try { |
209 | 209 | $sth = $this->db->prepare($query); |
210 | 210 | $sth->execute(); |
211 | - } catch(PDOException $e) { |
|
211 | + } catch (PDOException $e) { |
|
212 | 212 | echo $e->getMessage(); |
213 | 213 | die; |
214 | 214 | } |
@@ -222,19 +222,19 @@ discard block |
||
222 | 222 | * @return Array the spotter information |
223 | 223 | * |
224 | 224 | */ |
225 | - public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false) |
|
225 | + public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = false) |
|
226 | 226 | { |
227 | 227 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
228 | 228 | date_default_timezone_set('UTC'); |
229 | 229 | $usecoord = false; |
230 | 230 | if (is_array($coord) && !empty($coord)) { |
231 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
232 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
233 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
234 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
231 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
232 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
233 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
234 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
235 | 235 | $usecoord = true; |
236 | 236 | } |
237 | - $filter_query = $this->getFilter($filter,true,true); |
|
237 | + $filter_query = $this->getFilter($filter, true, true); |
|
238 | 238 | |
239 | 239 | if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
240 | 240 | if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | try { |
296 | 296 | $sth = $this->db->prepare($query); |
297 | 297 | $sth->execute(); |
298 | - } catch(PDOException $e) { |
|
298 | + } catch (PDOException $e) { |
|
299 | 299 | echo $e->getMessage(); |
300 | 300 | die; |
301 | 301 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | public function getLiveSpotterCount($filter = array()) |
313 | 313 | { |
314 | 314 | global $globalDBdriver, $globalLiveInterval; |
315 | - $filter_query = $this->getFilter($filter,true,true); |
|
315 | + $filter_query = $this->getFilter($filter, true, true); |
|
316 | 316 | |
317 | 317 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
318 | 318 | if ($globalDBdriver == 'mysql') { |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | try { |
326 | 326 | $sth = $this->db->prepare($query); |
327 | 327 | $sth->execute(); |
328 | - } catch(PDOException $e) { |
|
328 | + } catch (PDOException $e) { |
|
329 | 329 | echo $e->getMessage(); |
330 | 330 | die; |
331 | 331 | } |
@@ -348,10 +348,10 @@ discard block |
||
348 | 348 | $filter_query = $this->getFilter($filter); |
349 | 349 | |
350 | 350 | if (is_array($coord)) { |
351 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
352 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
353 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
354 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
351 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
352 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
353 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
354 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
355 | 355 | } else return array(); |
356 | 356 | if ($globalDBdriver == 'mysql') { |
357 | 357 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -374,23 +374,23 @@ discard block |
||
374 | 374 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
375 | 375 | $Spotter = new Spotter($this->db); |
376 | 376 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
377 | - $filter_query = $this->getFilter($filter,true,true); |
|
377 | + $filter_query = $this->getFilter($filter, true, true); |
|
378 | 378 | |
379 | 379 | if (is_array($coord)) { |
380 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
381 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
382 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
383 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
380 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
381 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
382 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
383 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
384 | 384 | } else return array(); |
385 | 385 | if ($globalDBdriver == 'mysql') { |
386 | 386 | if (isset($globalArchive) && $globalArchive === TRUE) { |
387 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
387 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
388 | 388 | FROM spotter_live |
389 | 389 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
390 | 390 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
391 | 391 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0'; |
392 | 392 | } else { |
393 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
393 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
394 | 394 | FROM spotter_live |
395 | 395 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
396 | 396 | FROM spotter_live l |
@@ -402,14 +402,14 @@ discard block |
||
402 | 402 | } |
403 | 403 | } else { |
404 | 404 | if (isset($globalArchive) && $globalArchive === TRUE) { |
405 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
405 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
406 | 406 | FROM spotter_live |
407 | 407 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
408 | 408 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
409 | 409 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
410 | 410 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
411 | 411 | } else { |
412 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
412 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
413 | 413 | FROM spotter_live |
414 | 414 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
415 | 415 | FROM spotter_live l |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | try { |
425 | 425 | $sth = $this->db->prepare($query); |
426 | 426 | $sth->execute(); |
427 | - } catch(PDOException $e) { |
|
427 | + } catch (PDOException $e) { |
|
428 | 428 | echo $e->getMessage(); |
429 | 429 | die; |
430 | 430 | } |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | if ($interval == '1m') |
474 | 474 | { |
475 | 475 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
476 | - } else if ($interval == '15m'){ |
|
476 | + } else if ($interval == '15m') { |
|
477 | 477 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
478 | 478 | } |
479 | 479 | } |
@@ -481,14 +481,14 @@ discard block |
||
481 | 481 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
482 | 482 | } |
483 | 483 | |
484 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
484 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
485 | 485 | WHERE spotter_live.latitude <> '' |
486 | 486 | AND spotter_live.longitude <> '' |
487 | 487 | ".$additional_query." |
488 | 488 | HAVING distance < :radius |
489 | 489 | ORDER BY distance"; |
490 | 490 | |
491 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
491 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
492 | 492 | |
493 | 493 | return $spotter_array; |
494 | 494 | } |
@@ -506,9 +506,9 @@ discard block |
||
506 | 506 | date_default_timezone_set('UTC'); |
507 | 507 | |
508 | 508 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
509 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
509 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
510 | 510 | |
511 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
511 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
512 | 512 | |
513 | 513 | return $spotter_array; |
514 | 514 | } |
@@ -519,16 +519,16 @@ discard block |
||
519 | 519 | * @return Array the spotter information |
520 | 520 | * |
521 | 521 | */ |
522 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
522 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
523 | 523 | { |
524 | 524 | $Spotter = new Spotter($this->db); |
525 | 525 | date_default_timezone_set('UTC'); |
526 | 526 | |
527 | 527 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
528 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
528 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
529 | 529 | |
530 | - $date = date('c',$date); |
|
531 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
530 | + $date = date('c', $date); |
|
531 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
532 | 532 | |
533 | 533 | return $spotter_array; |
534 | 534 | } |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | $Spotter = new Spotter($this->db); |
545 | 545 | date_default_timezone_set('UTC'); |
546 | 546 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
547 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
548 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
547 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
548 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
549 | 549 | return $spotter_array; |
550 | 550 | } |
551 | 551 | |
@@ -555,15 +555,15 @@ discard block |
||
555 | 555 | * @return Array the spotter information |
556 | 556 | * |
557 | 557 | */ |
558 | - public function getDateLiveSpotterDataById($id,$date) |
|
558 | + public function getDateLiveSpotterDataById($id, $date) |
|
559 | 559 | { |
560 | 560 | $Spotter = new Spotter($this->db); |
561 | 561 | date_default_timezone_set('UTC'); |
562 | 562 | |
563 | 563 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
564 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
565 | - $date = date('c',$date); |
|
566 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
564 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
565 | + $date = date('c', $date); |
|
566 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
567 | 567 | return $spotter_array; |
568 | 568 | } |
569 | 569 | |
@@ -579,13 +579,13 @@ discard block |
||
579 | 579 | date_default_timezone_set('UTC'); |
580 | 580 | |
581 | 581 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
582 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
582 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
583 | 583 | |
584 | 584 | try { |
585 | 585 | |
586 | 586 | $sth = $this->db->prepare($query); |
587 | 587 | $sth->execute(array(':ident' => $ident)); |
588 | - } catch(PDOException $e) { |
|
588 | + } catch (PDOException $e) { |
|
589 | 589 | echo $e->getMessage(); |
590 | 590 | die; |
591 | 591 | } |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * @return Array the spotter information |
601 | 601 | * |
602 | 602 | */ |
603 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
603 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
604 | 604 | { |
605 | 605 | global $globalDBdriver, $globalLiveInterval; |
606 | 606 | date_default_timezone_set('UTC'); |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | try { |
620 | 620 | $sth = $this->db->prepare($query); |
621 | 621 | $sth->execute(array(':id' => $id)); |
622 | - } catch(PDOException $e) { |
|
622 | + } catch (PDOException $e) { |
|
623 | 623 | echo $e->getMessage(); |
624 | 624 | die; |
625 | 625 | } |
@@ -637,12 +637,12 @@ discard block |
||
637 | 637 | { |
638 | 638 | date_default_timezone_set('UTC'); |
639 | 639 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
640 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
640 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
641 | 641 | try { |
642 | 642 | |
643 | 643 | $sth = $this->db->prepare($query); |
644 | 644 | $sth->execute(array(':ident' => $ident)); |
645 | - } catch(PDOException $e) { |
|
645 | + } catch (PDOException $e) { |
|
646 | 646 | echo $e->getMessage(); |
647 | 647 | die; |
648 | 648 | } |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | |
673 | 673 | $sth = $this->db->prepare($query); |
674 | 674 | $sth->execute(); |
675 | - } catch(PDOException $e) { |
|
675 | + } catch (PDOException $e) { |
|
676 | 676 | return "error"; |
677 | 677 | } |
678 | 678 | |
@@ -695,14 +695,14 @@ discard block |
||
695 | 695 | |
696 | 696 | $sth = $this->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | - } catch(PDOException $e) { |
|
698 | + } catch (PDOException $e) { |
|
699 | 699 | return "error"; |
700 | 700 | } |
701 | 701 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
702 | 702 | $i = 0; |
703 | - $j =0; |
|
703 | + $j = 0; |
|
704 | 704 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
705 | - foreach($all as $row) |
|
705 | + foreach ($all as $row) |
|
706 | 706 | { |
707 | 707 | $i++; |
708 | 708 | $j++; |
@@ -710,9 +710,9 @@ discard block |
||
710 | 710 | if ($globalDebug) echo "."; |
711 | 711 | try { |
712 | 712 | |
713 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
713 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
714 | 714 | $sth->execute(); |
715 | - } catch(PDOException $e) { |
|
715 | + } catch (PDOException $e) { |
|
716 | 716 | return "error"; |
717 | 717 | } |
718 | 718 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -723,9 +723,9 @@ discard block |
||
723 | 723 | if ($i > 0) { |
724 | 724 | try { |
725 | 725 | |
726 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
726 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
727 | 727 | $sth->execute(); |
728 | - } catch(PDOException $e) { |
|
728 | + } catch (PDOException $e) { |
|
729 | 729 | return "error"; |
730 | 730 | } |
731 | 731 | } |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | |
739 | 739 | $sth = $this->db->prepare($query); |
740 | 740 | $sth->execute(); |
741 | - } catch(PDOException $e) { |
|
741 | + } catch (PDOException $e) { |
|
742 | 742 | return "error"; |
743 | 743 | } |
744 | 744 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -786,13 +786,13 @@ discard block |
||
786 | 786 | public function deleteLiveSpotterDataByIdent($ident) |
787 | 787 | { |
788 | 788 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
789 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
789 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
790 | 790 | |
791 | 791 | try { |
792 | 792 | |
793 | 793 | $sth = $this->db->prepare($query); |
794 | 794 | $sth->execute(array(':ident' => $ident)); |
795 | - } catch(PDOException $e) { |
|
795 | + } catch (PDOException $e) { |
|
796 | 796 | return "error"; |
797 | 797 | } |
798 | 798 | |
@@ -808,13 +808,13 @@ discard block |
||
808 | 808 | public function deleteLiveSpotterDataById($id) |
809 | 809 | { |
810 | 810 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
811 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
811 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
812 | 812 | |
813 | 813 | try { |
814 | 814 | |
815 | 815 | $sth = $this->db->prepare($query); |
816 | 816 | $sth->execute(array(':id' => $id)); |
817 | - } catch(PDOException $e) { |
|
817 | + } catch (PDOException $e) { |
|
818 | 818 | return "error"; |
819 | 819 | } |
820 | 820 | |
@@ -832,13 +832,13 @@ discard block |
||
832 | 832 | { |
833 | 833 | global $globalDBdriver, $globalTimezone; |
834 | 834 | if ($globalDBdriver == 'mysql') { |
835 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
835 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
836 | 836 | WHERE spotter_live.ident = :ident |
837 | 837 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
838 | 838 | AND spotter_live.date < UTC_TIMESTAMP()'; |
839 | 839 | $query_data = array(':ident' => $ident); |
840 | 840 | } else { |
841 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
841 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
842 | 842 | WHERE spotter_live.ident = :ident |
843 | 843 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
844 | 844 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -847,8 +847,8 @@ discard block |
||
847 | 847 | |
848 | 848 | $sth = $this->db->prepare($query); |
849 | 849 | $sth->execute($query_data); |
850 | - $ident_result=''; |
|
851 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
850 | + $ident_result = ''; |
|
851 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
852 | 852 | { |
853 | 853 | $ident_result = $row['ident']; |
854 | 854 | } |
@@ -865,13 +865,13 @@ discard block |
||
865 | 865 | { |
866 | 866 | global $globalDBdriver, $globalTimezone; |
867 | 867 | if ($globalDBdriver == 'mysql') { |
868 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
868 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
869 | 869 | WHERE spotter_live.ident = :ident |
870 | 870 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
871 | 871 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
872 | 872 | $query_data = array(':ident' => $ident); |
873 | 873 | } else { |
874 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
874 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
875 | 875 | WHERE spotter_live.ident = :ident |
876 | 876 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
877 | 877 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -880,8 +880,8 @@ discard block |
||
880 | 880 | |
881 | 881 | $sth = $this->db->prepare($query); |
882 | 882 | $sth->execute($query_data); |
883 | - $ident_result=''; |
|
884 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
883 | + $ident_result = ''; |
|
884 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
885 | 885 | { |
886 | 886 | $ident_result = $row['flightaware_id']; |
887 | 887 | } |
@@ -898,13 +898,13 @@ discard block |
||
898 | 898 | { |
899 | 899 | global $globalDBdriver, $globalTimezone; |
900 | 900 | if ($globalDBdriver == 'mysql') { |
901 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
901 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
902 | 902 | WHERE spotter_live.flightaware_id = :id |
903 | 903 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
904 | 904 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
905 | 905 | $query_data = array(':id' => $id); |
906 | 906 | } else { |
907 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
907 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
908 | 908 | WHERE spotter_live.flightaware_id = :id |
909 | 909 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
910 | 910 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -913,8 +913,8 @@ discard block |
||
913 | 913 | |
914 | 914 | $sth = $this->db->prepare($query); |
915 | 915 | $sth->execute($query_data); |
916 | - $ident_result=''; |
|
917 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
916 | + $ident_result = ''; |
|
917 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
918 | 918 | { |
919 | 919 | $ident_result = $row['flightaware_id']; |
920 | 920 | } |
@@ -931,13 +931,13 @@ discard block |
||
931 | 931 | { |
932 | 932 | global $globalDBdriver, $globalTimezone; |
933 | 933 | if ($globalDBdriver == 'mysql') { |
934 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
934 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
935 | 935 | WHERE spotter_live.ModeS = :modes |
936 | 936 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
937 | 937 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
938 | 938 | $query_data = array(':modes' => $modes); |
939 | 939 | } else { |
940 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
940 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
941 | 941 | WHERE spotter_live.ModeS = :modes |
942 | 942 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
943 | 943 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -946,8 +946,8 @@ discard block |
||
946 | 946 | |
947 | 947 | $sth = $this->db->prepare($query); |
948 | 948 | $sth->execute($query_data); |
949 | - $ident_result=''; |
|
950 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
949 | + $ident_result = ''; |
|
950 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
951 | 951 | { |
952 | 952 | //$ident_result = $row['spotter_live_id']; |
953 | 953 | $ident_result = $row['flightaware_id']; |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | * @return String success or false |
967 | 967 | * |
968 | 968 | */ |
969 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
969 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
970 | 970 | { |
971 | 971 | global $globalURL, $globalArchive, $globalDebug; |
972 | 972 | $Common = new Common(); |
@@ -1066,27 +1066,27 @@ discard block |
||
1066 | 1066 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
1067 | 1067 | |
1068 | 1068 | |
1069 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
1070 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1071 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
1072 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
1073 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
1074 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1075 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1076 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
1077 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1078 | - $altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1079 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
1080 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1081 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
1082 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
1083 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
1084 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
1085 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
1086 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
1087 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
1088 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
1089 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
1069 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
1070 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1071 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
1072 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
1073 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
1074 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1075 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1076 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
1077 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1078 | + $altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1079 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
1080 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1081 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
1082 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
1083 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
1084 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
1085 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
1086 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
1087 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
1088 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
1089 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
1090 | 1090 | |
1091 | 1091 | $airline_name = ''; |
1092 | 1092 | $airline_icao = ''; |
@@ -1108,10 +1108,10 @@ discard block |
||
1108 | 1108 | $arrival_airport_country = ''; |
1109 | 1109 | |
1110 | 1110 | |
1111 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1112 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1113 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1114 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1111 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
1112 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
1113 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
1114 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1115 | 1115 | |
1116 | 1116 | $query = ''; |
1117 | 1117 | if ($globalArchive) { |
@@ -1122,19 +1122,19 @@ discard block |
||
1122 | 1122 | $query .= 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country, real_altitude) |
1123 | 1123 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country, :real_altitude)'; |
1124 | 1124 | |
1125 | - $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country,':real_altitude' => $altitude_real); |
|
1125 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country, ':real_altitude' => $altitude_real); |
|
1126 | 1126 | try { |
1127 | 1127 | |
1128 | 1128 | $sth = $this->db->prepare($query); |
1129 | 1129 | $sth->execute($query_values); |
1130 | 1130 | $sth->closeCursor(); |
1131 | - } catch(PDOException $e) { |
|
1131 | + } catch (PDOException $e) { |
|
1132 | 1132 | return "error : ".$e->getMessage(); |
1133 | 1133 | } |
1134 | 1134 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1135 | 1135 | if ($globalDebug) echo '(Add to SBS archive : '; |
1136 | 1136 | $SpotterArchive = new SpotterArchive($this->db); |
1137 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1137 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
1138 | 1138 | if ($globalDebug) echo $result.')'; |
1139 | 1139 | } elseif ($globalDebug && $putinarchive !== true) { |
1140 | 1140 | echo '(Not adding to archive)'; |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | |
1148 | 1148 | public function getOrderBy() |
1149 | 1149 | { |
1150 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
1150 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
1151 | 1151 | return $orderby; |
1152 | 1152 | } |
1153 | 1153 |
@@ -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; |
@@ -313,17 +313,17 @@ discard block |
||
313 | 313 | $filter_query = $this->getFilter($filter); |
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 | if ($globalDBdriver == 'mysql') { |
322 | 322 | $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 |
323 | 323 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
324 | 324 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
325 | 325 | } else { |
326 | - $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 |
|
326 | + $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 |
|
327 | 327 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
328 | 328 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
329 | 329 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | if ($interval == '1m') |
373 | 373 | { |
374 | 374 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
375 | - } else if ($interval == '15m'){ |
|
375 | + } else if ($interval == '15m') { |
|
376 | 376 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
377 | 377 | } |
378 | 378 | } |
@@ -380,14 +380,14 @@ discard block |
||
380 | 380 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
381 | 381 | } |
382 | 382 | |
383 | - $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 |
|
383 | + $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 |
|
384 | 384 | WHERE marine_live.latitude <> '' |
385 | 385 | AND marine_live.longitude <> '' |
386 | 386 | ".$additional_query." |
387 | 387 | HAVING distance < :radius |
388 | 388 | ORDER BY distance"; |
389 | 389 | |
390 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
390 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
391 | 391 | |
392 | 392 | return $spotter_array; |
393 | 393 | } |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | date_default_timezone_set('UTC'); |
406 | 406 | |
407 | 407 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
408 | - $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'; |
|
408 | + $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'; |
|
409 | 409 | |
410 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
410 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
411 | 411 | |
412 | 412 | return $spotter_array; |
413 | 413 | } |
@@ -418,16 +418,16 @@ discard block |
||
418 | 418 | * @return Array the spotter information |
419 | 419 | * |
420 | 420 | */ |
421 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
421 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
422 | 422 | { |
423 | 423 | $Marine = new Marine($this->db); |
424 | 424 | date_default_timezone_set('UTC'); |
425 | 425 | |
426 | 426 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
427 | - $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'; |
|
427 | + $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'; |
|
428 | 428 | |
429 | - $date = date('c',$date); |
|
430 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
429 | + $date = date('c', $date); |
|
430 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
431 | 431 | |
432 | 432 | return $spotter_array; |
433 | 433 | } |
@@ -444,9 +444,9 @@ discard block |
||
444 | 444 | date_default_timezone_set('UTC'); |
445 | 445 | |
446 | 446 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
447 | - $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'; |
|
447 | + $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'; |
|
448 | 448 | |
449 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
449 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
450 | 450 | |
451 | 451 | return $spotter_array; |
452 | 452 | } |
@@ -457,15 +457,15 @@ discard block |
||
457 | 457 | * @return Array the spotter information |
458 | 458 | * |
459 | 459 | */ |
460 | - public function getDateLiveMarineDataById($id,$date) |
|
460 | + public function getDateLiveMarineDataById($id, $date) |
|
461 | 461 | { |
462 | 462 | $Marine = new Marine($this->db); |
463 | 463 | date_default_timezone_set('UTC'); |
464 | 464 | |
465 | 465 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
466 | - $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'; |
|
467 | - $date = date('c',$date); |
|
468 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
466 | + $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'; |
|
467 | + $date = date('c', $date); |
|
468 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
469 | 469 | |
470 | 470 | return $spotter_array; |
471 | 471 | } |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @return Array the spotter information |
478 | 478 | * |
479 | 479 | */ |
480 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
480 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
481 | 481 | { |
482 | 482 | global $globalDBdriver, $globalLiveInterval; |
483 | 483 | date_default_timezone_set('UTC'); |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | try { |
497 | 497 | $sth = $this->db->prepare($query); |
498 | 498 | $sth->execute(array(':id' => $id)); |
499 | - } catch(PDOException $e) { |
|
499 | + } catch (PDOException $e) { |
|
500 | 500 | echo $e->getMessage(); |
501 | 501 | die; |
502 | 502 | } |
@@ -514,12 +514,12 @@ discard block |
||
514 | 514 | { |
515 | 515 | date_default_timezone_set('UTC'); |
516 | 516 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
517 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
517 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
518 | 518 | try { |
519 | 519 | |
520 | 520 | $sth = $this->db->prepare($query); |
521 | 521 | $sth->execute(array(':ident' => $ident)); |
522 | - } catch(PDOException $e) { |
|
522 | + } catch (PDOException $e) { |
|
523 | 523 | echo $e->getMessage(); |
524 | 524 | die; |
525 | 525 | } |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | |
550 | 550 | $sth = $this->db->prepare($query); |
551 | 551 | $sth->execute(); |
552 | - } catch(PDOException $e) { |
|
552 | + } catch (PDOException $e) { |
|
553 | 553 | return "error"; |
554 | 554 | } |
555 | 555 | |
@@ -572,14 +572,14 @@ discard block |
||
572 | 572 | |
573 | 573 | $sth = $this->db->prepare($query); |
574 | 574 | $sth->execute(); |
575 | - } catch(PDOException $e) { |
|
575 | + } catch (PDOException $e) { |
|
576 | 576 | return "error"; |
577 | 577 | } |
578 | 578 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
579 | 579 | $i = 0; |
580 | - $j =0; |
|
580 | + $j = 0; |
|
581 | 581 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
582 | - foreach($all as $row) |
|
582 | + foreach ($all as $row) |
|
583 | 583 | { |
584 | 584 | $i++; |
585 | 585 | $j++; |
@@ -587,9 +587,9 @@ discard block |
||
587 | 587 | if ($globalDebug) echo "."; |
588 | 588 | try { |
589 | 589 | |
590 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
590 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
591 | 591 | $sth->execute(); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | return "error"; |
594 | 594 | } |
595 | 595 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -600,9 +600,9 @@ discard block |
||
600 | 600 | if ($i > 0) { |
601 | 601 | try { |
602 | 602 | |
603 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
603 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
604 | 604 | $sth->execute(); |
605 | - } catch(PDOException $e) { |
|
605 | + } catch (PDOException $e) { |
|
606 | 606 | return "error"; |
607 | 607 | } |
608 | 608 | } |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | |
616 | 616 | $sth = $this->db->prepare($query); |
617 | 617 | $sth->execute(); |
618 | - } catch(PDOException $e) { |
|
618 | + } catch (PDOException $e) { |
|
619 | 619 | return "error"; |
620 | 620 | } |
621 | 621 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -663,13 +663,13 @@ discard block |
||
663 | 663 | public function deleteLiveMarineDataByIdent($ident) |
664 | 664 | { |
665 | 665 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
666 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
666 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
667 | 667 | |
668 | 668 | try { |
669 | 669 | |
670 | 670 | $sth = $this->db->prepare($query); |
671 | 671 | $sth->execute(array(':ident' => $ident)); |
672 | - } catch(PDOException $e) { |
|
672 | + } catch (PDOException $e) { |
|
673 | 673 | return "error"; |
674 | 674 | } |
675 | 675 | |
@@ -685,13 +685,13 @@ discard block |
||
685 | 685 | public function deleteLiveMarineDataById($id) |
686 | 686 | { |
687 | 687 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
688 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
688 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
689 | 689 | |
690 | 690 | try { |
691 | 691 | |
692 | 692 | $sth = $this->db->prepare($query); |
693 | 693 | $sth->execute(array(':id' => $id)); |
694 | - } catch(PDOException $e) { |
|
694 | + } catch (PDOException $e) { |
|
695 | 695 | return "error"; |
696 | 696 | } |
697 | 697 | |
@@ -709,13 +709,13 @@ discard block |
||
709 | 709 | { |
710 | 710 | global $globalDBdriver, $globalTimezone; |
711 | 711 | if ($globalDBdriver == 'mysql') { |
712 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
712 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
713 | 713 | WHERE marine_live.ident = :ident |
714 | 714 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
715 | 715 | AND marine_live.date < UTC_TIMESTAMP()'; |
716 | 716 | $query_data = array(':ident' => $ident); |
717 | 717 | } else { |
718 | - $query = "SELECT marine_live.ident FROM marine_live |
|
718 | + $query = "SELECT marine_live.ident FROM marine_live |
|
719 | 719 | WHERE marine_live.ident = :ident |
720 | 720 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
721 | 721 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -724,8 +724,8 @@ discard block |
||
724 | 724 | |
725 | 725 | $sth = $this->db->prepare($query); |
726 | 726 | $sth->execute($query_data); |
727 | - $ident_result=''; |
|
728 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
727 | + $ident_result = ''; |
|
728 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
729 | 729 | { |
730 | 730 | $ident_result = $row['ident']; |
731 | 731 | } |
@@ -742,13 +742,13 @@ discard block |
||
742 | 742 | { |
743 | 743 | global $globalDBdriver, $globalTimezone; |
744 | 744 | if ($globalDBdriver == 'mysql') { |
745 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
745 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
746 | 746 | WHERE marine_live.ident = :ident |
747 | 747 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
748 | 748 | // AND marine_live.date < UTC_TIMESTAMP()"; |
749 | 749 | $query_data = array(':ident' => $ident); |
750 | 750 | } else { |
751 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
751 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
752 | 752 | WHERE marine_live.ident = :ident |
753 | 753 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
754 | 754 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -757,8 +757,8 @@ discard block |
||
757 | 757 | |
758 | 758 | $sth = $this->db->prepare($query); |
759 | 759 | $sth->execute($query_data); |
760 | - $ident_result=''; |
|
761 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
760 | + $ident_result = ''; |
|
761 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
762 | 762 | { |
763 | 763 | $ident_result = $row['fammarine_id']; |
764 | 764 | } |
@@ -775,13 +775,13 @@ discard block |
||
775 | 775 | { |
776 | 776 | global $globalDBdriver, $globalTimezone; |
777 | 777 | if ($globalDBdriver == 'mysql') { |
778 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
778 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
779 | 779 | WHERE marine_live.fammarine_id = :id |
780 | 780 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
781 | 781 | // AND marine_live.date < UTC_TIMESTAMP()"; |
782 | 782 | $query_data = array(':id' => $id); |
783 | 783 | } else { |
784 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
784 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
785 | 785 | WHERE marine_live.fammarine_id = :id |
786 | 786 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
787 | 787 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -790,8 +790,8 @@ discard block |
||
790 | 790 | |
791 | 791 | $sth = $this->db->prepare($query); |
792 | 792 | $sth->execute($query_data); |
793 | - $ident_result=''; |
|
794 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
793 | + $ident_result = ''; |
|
794 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
795 | 795 | { |
796 | 796 | $ident_result = $row['fammarine_id']; |
797 | 797 | } |
@@ -808,13 +808,13 @@ discard block |
||
808 | 808 | { |
809 | 809 | global $globalDBdriver, $globalTimezone; |
810 | 810 | if ($globalDBdriver == 'mysql') { |
811 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
811 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
812 | 812 | WHERE marine_live.mmsi = :mmsi |
813 | 813 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
814 | 814 | // AND marine_live.date < UTC_TIMESTAMP()"; |
815 | 815 | $query_data = array(':mmsi' => $mmsi); |
816 | 816 | } else { |
817 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
817 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
818 | 818 | WHERE marine_live.mmsi = :mmsi |
819 | 819 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
820 | 820 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -823,8 +823,8 @@ discard block |
||
823 | 823 | |
824 | 824 | $sth = $this->db->prepare($query); |
825 | 825 | $sth->execute($query_data); |
826 | - $ident_result=''; |
|
827 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
826 | + $ident_result = ''; |
|
827 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
828 | 828 | { |
829 | 829 | $ident_result = $row['fammarine_id']; |
830 | 830 | } |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | * @return String success or false |
843 | 843 | * |
844 | 844 | */ |
845 | - 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 = '') |
|
845 | + 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 = '') |
|
846 | 846 | { |
847 | 847 | global $globalURL, $globalArchive, $globalDebug; |
848 | 848 | $Common = new Common(); |
@@ -894,26 +894,26 @@ discard block |
||
894 | 894 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
895 | 895 | |
896 | 896 | |
897 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
898 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
899 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
900 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
901 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
902 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
903 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
904 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
905 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
906 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
907 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
908 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
909 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
910 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
911 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
912 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
897 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
898 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
899 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
900 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
901 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
902 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
903 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
904 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
905 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
906 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
907 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
908 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
909 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
910 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
911 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
912 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
913 | 913 | |
914 | 914 | |
915 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
916 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
915 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
916 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
917 | 917 | if ($arrival_date == '') $arrival_date = NULL; |
918 | 918 | $query = ''; |
919 | 919 | if ($globalArchive) { |
@@ -923,18 +923,18 @@ discard block |
||
923 | 923 | $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) |
924 | 924 | 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)'; |
925 | 925 | |
926 | - $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); |
|
926 | + $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); |
|
927 | 927 | try { |
928 | 928 | $sth = $this->db->prepare($query); |
929 | 929 | $sth->execute($query_values); |
930 | - } catch(PDOException $e) { |
|
930 | + } catch (PDOException $e) { |
|
931 | 931 | return "error : ".$e->getMessage(); |
932 | 932 | } |
933 | 933 | |
934 | 934 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
935 | 935 | if ($globalDebug) echo '(Add to Marine archive : '; |
936 | 936 | $MarineArchive = new MarineArchive($this->db); |
937 | - $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); |
|
937 | + $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); |
|
938 | 938 | if ($globalDebug) echo $result.')'; |
939 | 939 | } |
940 | 940 | return "success"; |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | |
943 | 943 | public function getOrderBy() |
944 | 944 | { |
945 | - $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")); |
|
945 | + $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")); |
|
946 | 946 | return $orderby; |
947 | 947 | } |
948 | 948 |