@@ -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 tracker_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 tracker_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 tracker 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 | $tracker_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 | - $tracker_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
241 | + $tracker_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
242 | 242 | |
243 | 243 | return $tracker_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 | - $tracker_array = $this->getDataFromDB($query,$query_values); |
|
260 | + $query = $global_query." WHERE ".$additional_query." "; |
|
261 | + $tracker_array = $this->getDataFromDB($query, $query_values); |
|
262 | 262 | return $tracker_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 $tracker_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,100"; |
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,100"; |
@@ -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 | } |
@@ -748,16 +748,16 @@ discard block |
||
748 | 748 | * @return Array the airline country list |
749 | 749 | * |
750 | 750 | */ |
751 | - public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
751 | + public function countAllTrackerOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
752 | 752 | { |
753 | 753 | global $globalDBdriver, $globalArchive; |
754 | 754 | //$filter_query = $this->getFilter($filters,true,true); |
755 | - $Connection= new Connection($this->db); |
|
755 | + $Connection = new Connection($this->db); |
|
756 | 756 | if (!$Connection->tableExists('countries')) return array(); |
757 | 757 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
758 | 758 | require_once('class.TrackerLive.php'); |
759 | 759 | $TrackerLive = new TrackerLive($this->db); |
760 | - $filter_query = $TrackerLive->getFilter($filters,true,true); |
|
760 | + $filter_query = $TrackerLive->getFilter($filters, true, true); |
|
761 | 761 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
762 | 762 | if ($olderthanmonths > 0) { |
763 | 763 | if ($globalDBdriver == 'mysql') { |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | } else { |
778 | 778 | require_once('class.TrackerArchive.php'); |
779 | 779 | $TrackerArchive = new TrackerArchive($this->db); |
780 | - $filter_query = $TrackerArchive->getFilter($filters,true,true); |
|
780 | + $filter_query = $TrackerArchive->getFilter($filters, true, true); |
|
781 | 781 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
782 | 782 | if ($olderthanmonths > 0) { |
783 | 783 | if ($globalDBdriver == 'mysql') { |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | $flight_array = array(); |
806 | 806 | $temp_array = array(); |
807 | 807 | |
808 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
808 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
809 | 809 | { |
810 | 810 | $temp_array['tracker_count'] = $row['nb']; |
811 | 811 | $temp_array['tracker_country'] = $row['name']; |
@@ -822,11 +822,11 @@ discard block |
||
822 | 822 | * @return Array the callsign list |
823 | 823 | * |
824 | 824 | */ |
825 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
825 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
826 | 826 | { |
827 | 827 | global $globalDBdriver; |
828 | - $filter_query = $this->getFilter($filters,true,true); |
|
829 | - $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
828 | + $filter_query = $this->getFilter($filters, true, true); |
|
829 | + $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
830 | 830 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
831 | 831 | if ($olderthanmonths > 0) { |
832 | 832 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -840,28 +840,28 @@ discard block |
||
840 | 840 | if ($year != '') { |
841 | 841 | if ($globalDBdriver == 'mysql') { |
842 | 842 | $query .= " AND YEAR(tracker_output.date) = :year"; |
843 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
843 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
844 | 844 | } else { |
845 | 845 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
846 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
846 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | if ($month != '') { |
850 | 850 | if ($globalDBdriver == 'mysql') { |
851 | 851 | $query .= " AND MONTH(tracker_output.date) = :month"; |
852 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
852 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
853 | 853 | } else { |
854 | 854 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
855 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
855 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
856 | 856 | } |
857 | 857 | } |
858 | 858 | if ($day != '') { |
859 | 859 | if ($globalDBdriver == 'mysql') { |
860 | 860 | $query .= " AND DAY(tracker_output.date) = :day"; |
861 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
861 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
862 | 862 | } else { |
863 | 863 | $query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day"; |
864 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
864 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
865 | 865 | } |
866 | 866 | } |
867 | 867 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -873,7 +873,7 @@ discard block |
||
873 | 873 | $callsign_array = array(); |
874 | 874 | $temp_array = array(); |
875 | 875 | |
876 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
876 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
877 | 877 | { |
878 | 878 | $temp_array['callsign_icao'] = $row['ident']; |
879 | 879 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | $date_array = array(); |
926 | 926 | $temp_array = array(); |
927 | 927 | |
928 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
928 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
929 | 929 | { |
930 | 930 | $temp_array['date_name'] = $row['date_name']; |
931 | 931 | $temp_array['date_count'] = $row['date_count']; |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | $datetime = new DateTime(); |
952 | 952 | $offset = $datetime->format('P'); |
953 | 953 | } else $offset = '+00:00'; |
954 | - $filter_query = $this->getFilter($filters,true,true); |
|
954 | + $filter_query = $this->getFilter($filters, true, true); |
|
955 | 955 | if ($globalDBdriver == 'mysql') { |
956 | 956 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
957 | 957 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | $date_array = array(); |
973 | 973 | $temp_array = array(); |
974 | 974 | |
975 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
975 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
976 | 976 | { |
977 | 977 | $temp_array['date_name'] = $row['date_name']; |
978 | 978 | $temp_array['date_count'] = $row['date_count']; |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | $datetime = new DateTime(); |
998 | 998 | $offset = $datetime->format('P'); |
999 | 999 | } else $offset = '+00:00'; |
1000 | - $filter_query = $this->getFilter($filters,true,true); |
|
1000 | + $filter_query = $this->getFilter($filters, true, true); |
|
1001 | 1001 | if ($globalDBdriver == 'mysql') { |
1002 | 1002 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1003 | 1003 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | $date_array = array(); |
1019 | 1019 | $temp_array = array(); |
1020 | 1020 | |
1021 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1021 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1022 | 1022 | { |
1023 | 1023 | $temp_array['date_name'] = $row['date_name']; |
1024 | 1024 | $temp_array['date_count'] = $row['date_count']; |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | $date_array = array(); |
1066 | 1066 | $temp_array = array(); |
1067 | 1067 | |
1068 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1068 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1069 | 1069 | { |
1070 | 1070 | $temp_array['month_name'] = $row['month_name']; |
1071 | 1071 | $temp_array['year_name'] = $row['year_name']; |
@@ -1094,7 +1094,7 @@ discard block |
||
1094 | 1094 | $datetime = new DateTime(); |
1095 | 1095 | $offset = $datetime->format('P'); |
1096 | 1096 | } else $offset = '+00:00'; |
1097 | - $filter_query = $this->getFilter($filters,true,true); |
|
1097 | + $filter_query = $this->getFilter($filters, true, true); |
|
1098 | 1098 | if ($globalDBdriver == 'mysql') { |
1099 | 1099 | $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 |
1100 | 1100 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | $date_array = array(); |
1116 | 1116 | $temp_array = array(); |
1117 | 1117 | |
1118 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1118 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1119 | 1119 | { |
1120 | 1120 | $temp_array['year_name'] = $row['year_name']; |
1121 | 1121 | $temp_array['month_name'] = $row['month_name']; |
@@ -1135,7 +1135,7 @@ discard block |
||
1135 | 1135 | * @return Array the hour list |
1136 | 1136 | * |
1137 | 1137 | */ |
1138 | - public function countAllHours($orderby,$filters = array()) |
|
1138 | + public function countAllHours($orderby, $filters = array()) |
|
1139 | 1139 | { |
1140 | 1140 | global $globalTimezone, $globalDBdriver; |
1141 | 1141 | if ($globalTimezone != '') { |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | $hour_array = array(); |
1184 | 1184 | $temp_array = array(); |
1185 | 1185 | |
1186 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1186 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1187 | 1187 | { |
1188 | 1188 | $temp_array['hour_name'] = $row['hour_name']; |
1189 | 1189 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1205,8 +1205,8 @@ discard block |
||
1205 | 1205 | public function countAllHoursByDate($date, $filters = array()) |
1206 | 1206 | { |
1207 | 1207 | global $globalTimezone, $globalDBdriver; |
1208 | - $filter_query = $this->getFilter($filters,true,true); |
|
1209 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1208 | + $filter_query = $this->getFilter($filters, true, true); |
|
1209 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1210 | 1210 | if ($globalTimezone != '') { |
1211 | 1211 | date_default_timezone_set($globalTimezone); |
1212 | 1212 | $datetime = new DateTime($date); |
@@ -1214,12 +1214,12 @@ discard block |
||
1214 | 1214 | } else $offset = '+00:00'; |
1215 | 1215 | |
1216 | 1216 | if ($globalDBdriver == 'mysql') { |
1217 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1217 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1218 | 1218 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date |
1219 | 1219 | GROUP BY hour_name |
1220 | 1220 | ORDER BY hour_name ASC"; |
1221 | 1221 | } else { |
1222 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1222 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1223 | 1223 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1224 | 1224 | GROUP BY hour_name |
1225 | 1225 | ORDER BY hour_name ASC"; |
@@ -1231,7 +1231,7 @@ discard block |
||
1231 | 1231 | $hour_array = array(); |
1232 | 1232 | $temp_array = array(); |
1233 | 1233 | |
1234 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1234 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1235 | 1235 | { |
1236 | 1236 | $temp_array['hour_name'] = $row['hour_name']; |
1237 | 1237 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1253,8 +1253,8 @@ discard block |
||
1253 | 1253 | public function countAllHoursByIdent($ident, $filters = array()) |
1254 | 1254 | { |
1255 | 1255 | global $globalTimezone, $globalDBdriver; |
1256 | - $filter_query = $this->getFilter($filters,true,true); |
|
1257 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1256 | + $filter_query = $this->getFilter($filters, true, true); |
|
1257 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1258 | 1258 | if ($globalTimezone != '') { |
1259 | 1259 | date_default_timezone_set($globalTimezone); |
1260 | 1260 | $datetime = new DateTime(); |
@@ -1262,12 +1262,12 @@ discard block |
||
1262 | 1262 | } else $offset = '+00:00'; |
1263 | 1263 | |
1264 | 1264 | if ($globalDBdriver == 'mysql') { |
1265 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1265 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1266 | 1266 | FROM tracker_output".$filter_query." tracker_output.ident = :ident |
1267 | 1267 | GROUP BY hour_name |
1268 | 1268 | ORDER BY hour_name ASC"; |
1269 | 1269 | } else { |
1270 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1270 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :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"; |
@@ -1275,12 +1275,12 @@ discard block |
||
1275 | 1275 | |
1276 | 1276 | |
1277 | 1277 | $sth = $this->db->prepare($query); |
1278 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1278 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1279 | 1279 | |
1280 | 1280 | $hour_array = array(); |
1281 | 1281 | $temp_array = array(); |
1282 | 1282 | |
1283 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1283 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1284 | 1284 | { |
1285 | 1285 | $temp_array['hour_name'] = $row['hour_name']; |
1286 | 1286 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1299,33 +1299,33 @@ discard block |
||
1299 | 1299 | * @return Integer the number of trackers |
1300 | 1300 | * |
1301 | 1301 | */ |
1302 | - public function countOverallTracker($filters = array(),$year = '',$month = '') |
|
1302 | + public function countOverallTracker($filters = array(), $year = '', $month = '') |
|
1303 | 1303 | { |
1304 | 1304 | global $globalDBdriver; |
1305 | 1305 | //$queryi = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output"; |
1306 | - $queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output"; |
|
1306 | + $queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output"; |
|
1307 | 1307 | $query_values = array(); |
1308 | 1308 | $query = ''; |
1309 | 1309 | if ($year != '') { |
1310 | 1310 | if ($globalDBdriver == 'mysql') { |
1311 | 1311 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1312 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1312 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1313 | 1313 | } else { |
1314 | 1314 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1315 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1315 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1316 | 1316 | } |
1317 | 1317 | } |
1318 | 1318 | if ($month != '') { |
1319 | 1319 | if ($globalDBdriver == 'mysql') { |
1320 | 1320 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1321 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1321 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1322 | 1322 | } else { |
1323 | 1323 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1324 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1324 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1325 | 1325 | } |
1326 | 1326 | } |
1327 | 1327 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1328 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1328 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1329 | 1329 | |
1330 | 1330 | $sth = $this->db->prepare($queryi); |
1331 | 1331 | $sth->execute($query_values); |
@@ -1338,32 +1338,32 @@ discard block |
||
1338 | 1338 | * @return Integer the number of flights |
1339 | 1339 | * |
1340 | 1340 | */ |
1341 | - public function countOverallTrackerTypes($filters = array(),$year = '',$month = '') |
|
1341 | + public function countOverallTrackerTypes($filters = array(), $year = '', $month = '') |
|
1342 | 1342 | { |
1343 | 1343 | global $globalDBdriver; |
1344 | - $queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output"; |
|
1344 | + $queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output"; |
|
1345 | 1345 | $query_values = array(); |
1346 | 1346 | $query = ''; |
1347 | 1347 | if ($year != '') { |
1348 | 1348 | if ($globalDBdriver == 'mysql') { |
1349 | 1349 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1350 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1350 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1351 | 1351 | } else { |
1352 | 1352 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1353 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1353 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1354 | 1354 | } |
1355 | 1355 | } |
1356 | 1356 | if ($month != '') { |
1357 | 1357 | if ($globalDBdriver == 'mysql') { |
1358 | 1358 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1359 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1359 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1360 | 1360 | } else { |
1361 | 1361 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1362 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1362 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1363 | 1363 | } |
1364 | 1364 | } |
1365 | 1365 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1366 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1366 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1367 | 1367 | |
1368 | 1368 | $sth = $this->db->prepare($queryi); |
1369 | 1369 | $sth->execute($query_values); |
@@ -1380,7 +1380,7 @@ discard block |
||
1380 | 1380 | public function countAllHoursFromToday($filters = array()) |
1381 | 1381 | { |
1382 | 1382 | global $globalTimezone, $globalDBdriver; |
1383 | - $filter_query = $this->getFilter($filters,true,true); |
|
1383 | + $filter_query = $this->getFilter($filters, true, true); |
|
1384 | 1384 | if ($globalTimezone != '') { |
1385 | 1385 | date_default_timezone_set($globalTimezone); |
1386 | 1386 | $datetime = new DateTime(); |
@@ -1388,12 +1388,12 @@ discard block |
||
1388 | 1388 | } else $offset = '+00:00'; |
1389 | 1389 | |
1390 | 1390 | if ($globalDBdriver == 'mysql') { |
1391 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1391 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1392 | 1392 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE() |
1393 | 1393 | GROUP BY hour_name |
1394 | 1394 | ORDER BY hour_name ASC"; |
1395 | 1395 | } else { |
1396 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1396 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1397 | 1397 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1398 | 1398 | GROUP BY hour_name |
1399 | 1399 | ORDER BY hour_name ASC"; |
@@ -1405,7 +1405,7 @@ discard block |
||
1405 | 1405 | $hour_array = array(); |
1406 | 1406 | $temp_array = array(); |
1407 | 1407 | |
1408 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1408 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1409 | 1409 | { |
1410 | 1410 | $temp_array['hour_name'] = $row['hour_name']; |
1411 | 1411 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1424,9 +1424,9 @@ discard block |
||
1424 | 1424 | */ |
1425 | 1425 | public function getTrackerIDBasedOnFamTrackID($famtrackid) |
1426 | 1426 | { |
1427 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
1427 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
1428 | 1428 | |
1429 | - $query = "SELECT tracker_output.tracker_id |
|
1429 | + $query = "SELECT tracker_output.tracker_id |
|
1430 | 1430 | FROM tracker_output |
1431 | 1431 | WHERE tracker_output.famtrackid = '".$famtrackid."'"; |
1432 | 1432 | |
@@ -1434,7 +1434,7 @@ discard block |
||
1434 | 1434 | $sth = $this->db->prepare($query); |
1435 | 1435 | $sth->execute(); |
1436 | 1436 | |
1437 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1437 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1438 | 1438 | { |
1439 | 1439 | return $row['tracker_id']; |
1440 | 1440 | } |
@@ -1459,23 +1459,23 @@ discard block |
||
1459 | 1459 | } |
1460 | 1460 | |
1461 | 1461 | $current_date = date("Y-m-d H:i:s"); |
1462 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1462 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1463 | 1463 | |
1464 | 1464 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1465 | 1465 | |
1466 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1466 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1467 | 1467 | $years = $time_array['years']; |
1468 | 1468 | |
1469 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1469 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1470 | 1470 | $months = $time_array['months']; |
1471 | 1471 | |
1472 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1472 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1473 | 1473 | $days = $time_array['days']; |
1474 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1474 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1475 | 1475 | $hours = $time_array['hours']; |
1476 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1476 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1477 | 1477 | $minutes = $time_array['minutes']; |
1478 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1478 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1479 | 1479 | |
1480 | 1480 | return $time_array; |
1481 | 1481 | } |
@@ -1498,63 +1498,63 @@ discard block |
||
1498 | 1498 | $temp_array['direction_degree'] = $direction; |
1499 | 1499 | $temp_array['direction_shortname'] = "N"; |
1500 | 1500 | $temp_array['direction_fullname'] = "North"; |
1501 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1501 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1502 | 1502 | $temp_array['direction_degree'] = $direction; |
1503 | 1503 | $temp_array['direction_shortname'] = "NNE"; |
1504 | 1504 | $temp_array['direction_fullname'] = "North-Northeast"; |
1505 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1505 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1506 | 1506 | $temp_array['direction_degree'] = $direction; |
1507 | 1507 | $temp_array['direction_shortname'] = "NE"; |
1508 | 1508 | $temp_array['direction_fullname'] = "Northeast"; |
1509 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1509 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1510 | 1510 | $temp_array['direction_degree'] = $direction; |
1511 | 1511 | $temp_array['direction_shortname'] = "ENE"; |
1512 | 1512 | $temp_array['direction_fullname'] = "East-Northeast"; |
1513 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1513 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1514 | 1514 | $temp_array['direction_degree'] = $direction; |
1515 | 1515 | $temp_array['direction_shortname'] = "E"; |
1516 | 1516 | $temp_array['direction_fullname'] = "East"; |
1517 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1517 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1518 | 1518 | $temp_array['direction_degree'] = $direction; |
1519 | 1519 | $temp_array['direction_shortname'] = "ESE"; |
1520 | 1520 | $temp_array['direction_fullname'] = "East-Southeast"; |
1521 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1521 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1522 | 1522 | $temp_array['direction_degree'] = $direction; |
1523 | 1523 | $temp_array['direction_shortname'] = "SE"; |
1524 | 1524 | $temp_array['direction_fullname'] = "Southeast"; |
1525 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1525 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1526 | 1526 | $temp_array['direction_degree'] = $direction; |
1527 | 1527 | $temp_array['direction_shortname'] = "SSE"; |
1528 | 1528 | $temp_array['direction_fullname'] = "South-Southeast"; |
1529 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1529 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1530 | 1530 | $temp_array['direction_degree'] = $direction; |
1531 | 1531 | $temp_array['direction_shortname'] = "S"; |
1532 | 1532 | $temp_array['direction_fullname'] = "South"; |
1533 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1533 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1534 | 1534 | $temp_array['direction_degree'] = $direction; |
1535 | 1535 | $temp_array['direction_shortname'] = "SSW"; |
1536 | 1536 | $temp_array['direction_fullname'] = "South-Southwest"; |
1537 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1537 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1538 | 1538 | $temp_array['direction_degree'] = $direction; |
1539 | 1539 | $temp_array['direction_shortname'] = "SW"; |
1540 | 1540 | $temp_array['direction_fullname'] = "Southwest"; |
1541 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1541 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1542 | 1542 | $temp_array['direction_degree'] = $direction; |
1543 | 1543 | $temp_array['direction_shortname'] = "WSW"; |
1544 | 1544 | $temp_array['direction_fullname'] = "West-Southwest"; |
1545 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1545 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1546 | 1546 | $temp_array['direction_degree'] = $direction; |
1547 | 1547 | $temp_array['direction_shortname'] = "W"; |
1548 | 1548 | $temp_array['direction_fullname'] = "West"; |
1549 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1549 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1550 | 1550 | $temp_array['direction_degree'] = $direction; |
1551 | 1551 | $temp_array['direction_shortname'] = "WNW"; |
1552 | 1552 | $temp_array['direction_fullname'] = "West-Northwest"; |
1553 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1553 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1554 | 1554 | $temp_array['direction_degree'] = $direction; |
1555 | 1555 | $temp_array['direction_shortname'] = "NW"; |
1556 | 1556 | $temp_array['direction_fullname'] = "Northwest"; |
1557 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1557 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1558 | 1558 | $temp_array['direction_degree'] = $direction; |
1559 | 1559 | $temp_array['direction_shortname'] = "NNW"; |
1560 | 1560 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1571,11 +1571,11 @@ discard block |
||
1571 | 1571 | * @param Float $longitude longitute of the flight |
1572 | 1572 | * @return String the countrie |
1573 | 1573 | */ |
1574 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1574 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1575 | 1575 | { |
1576 | 1576 | global $globalDBdriver, $globalDebug; |
1577 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1578 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1577 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1578 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1579 | 1579 | |
1580 | 1580 | $Connection = new Connection($this->db); |
1581 | 1581 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1615,7 +1615,7 @@ discard block |
||
1615 | 1615 | public function getCountryFromISO2($iso2) |
1616 | 1616 | { |
1617 | 1617 | global $globalDBdriver, $globalDebug; |
1618 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1618 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1619 | 1619 | |
1620 | 1620 | $Connection = new Connection($this->db); |
1621 | 1621 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1644,11 +1644,11 @@ discard block |
||
1644 | 1644 | * @return Array the vessel type list |
1645 | 1645 | * |
1646 | 1646 | */ |
1647 | - public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
1647 | + public function countAllTrackerTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1648 | 1648 | { |
1649 | 1649 | global $globalDBdriver; |
1650 | - $filter_query = $this->getFilter($filters,true,true); |
|
1651 | - $query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count |
|
1650 | + $filter_query = $this->getFilter($filters, true, true); |
|
1651 | + $query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count |
|
1652 | 1652 | FROM tracker_output ".$filter_query." tracker_output.type <> ''"; |
1653 | 1653 | if ($olderthanmonths > 0) { |
1654 | 1654 | if ($globalDBdriver == 'mysql') { |
@@ -1668,28 +1668,28 @@ discard block |
||
1668 | 1668 | if ($year != '') { |
1669 | 1669 | if ($globalDBdriver == 'mysql') { |
1670 | 1670 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1671 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1671 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1672 | 1672 | } else { |
1673 | 1673 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1674 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1674 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1675 | 1675 | } |
1676 | 1676 | } |
1677 | 1677 | if ($month != '') { |
1678 | 1678 | if ($globalDBdriver == 'mysql') { |
1679 | 1679 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1680 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1680 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1681 | 1681 | } else { |
1682 | 1682 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1683 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1683 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1684 | 1684 | } |
1685 | 1685 | } |
1686 | 1686 | if ($day != '') { |
1687 | 1687 | if ($globalDBdriver == 'mysql') { |
1688 | 1688 | $query .= " AND DAY(tracker_output.date) = :day"; |
1689 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1689 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1690 | 1690 | } else { |
1691 | 1691 | $query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day"; |
1692 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1692 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1693 | 1693 | } |
1694 | 1694 | } |
1695 | 1695 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
@@ -1698,7 +1698,7 @@ discard block |
||
1698 | 1698 | $sth->execute($query_values); |
1699 | 1699 | $tracker_array = array(); |
1700 | 1700 | $temp_array = array(); |
1701 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1701 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1702 | 1702 | { |
1703 | 1703 | $temp_array['tracker_type'] = $row['tracker_type']; |
1704 | 1704 | $temp_array['tracker_type_count'] = $row['tracker_type_count']; |
@@ -1713,13 +1713,13 @@ discard block |
||
1713 | 1713 | * @return Array the tracker information |
1714 | 1714 | * |
1715 | 1715 | */ |
1716 | - public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
|
1716 | + public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
1717 | 1717 | { |
1718 | 1718 | global $globalTimezone, $globalDBdriver; |
1719 | 1719 | date_default_timezone_set('UTC'); |
1720 | 1720 | $query_values = array(); |
1721 | 1721 | $additional_query = ''; |
1722 | - $filter_query = $this->getFilter($filters,true,true); |
|
1722 | + $filter_query = $this->getFilter($filters, true, true); |
|
1723 | 1723 | if ($q != "") |
1724 | 1724 | { |
1725 | 1725 | if (!is_string($q)) |
@@ -1727,8 +1727,8 @@ discard block |
||
1727 | 1727 | return false; |
1728 | 1728 | } else { |
1729 | 1729 | $q_array = explode(" ", $q); |
1730 | - foreach ($q_array as $q_item){ |
|
1731 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
1730 | + foreach ($q_array as $q_item) { |
|
1731 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
1732 | 1732 | $additional_query .= " AND ("; |
1733 | 1733 | if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR "; |
1734 | 1734 | $additional_query .= "(tracker_output.ident like '%".$q_item."%') OR "; |
@@ -1738,20 +1738,20 @@ discard block |
||
1738 | 1738 | } |
1739 | 1739 | if ($callsign != "") |
1740 | 1740 | { |
1741 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
1741 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
1742 | 1742 | if (!is_string($callsign)) |
1743 | 1743 | { |
1744 | 1744 | return false; |
1745 | 1745 | } else { |
1746 | 1746 | $additional_query .= " AND tracker_output.ident = :callsign"; |
1747 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
1747 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
1748 | 1748 | } |
1749 | 1749 | } |
1750 | 1750 | if ($date_posted != "") |
1751 | 1751 | { |
1752 | 1752 | $date_array = explode(",", $date_posted); |
1753 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
1754 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
1753 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
1754 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
1755 | 1755 | if ($globalTimezone != '') { |
1756 | 1756 | date_default_timezone_set($globalTimezone); |
1757 | 1757 | $datetime = new DateTime(); |
@@ -1778,8 +1778,8 @@ discard block |
||
1778 | 1778 | if ($limit != "") |
1779 | 1779 | { |
1780 | 1780 | $limit_array = explode(",", $limit); |
1781 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1782 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1781 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1782 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1783 | 1783 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1784 | 1784 | { |
1785 | 1785 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1797,22 +1797,22 @@ discard block |
||
1797 | 1797 | } |
1798 | 1798 | } |
1799 | 1799 | if ($origLat != "" && $origLon != "" && $dist != "") { |
1800 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
1800 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
1801 | 1801 | if ($globalDBdriver == 'mysql') { |
1802 | - $query="SELECT tracker_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - tracker_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(tracker_archive.latitude*pi()/180)*POWER(SIN(($origLon-tracker_archive.longitude)*pi()/180/2),2))) as distance |
|
1802 | + $query = "SELECT tracker_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - tracker_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(tracker_archive.latitude*pi()/180)*POWER(SIN(($origLon-tracker_archive.longitude)*pi()/180/2),2))) as distance |
|
1803 | 1803 | FROM tracker_archive,tracker_output".$filter_query." tracker_output.famtrackid = tracker_archive.famtrackid AND tracker_output.ident <> '' ".$additional_query."AND tracker_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and tracker_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
1804 | 1804 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - tracker_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(tracker_archive.latitude*pi()/180)*POWER(SIN(($origLon-tracker_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; |
1805 | 1805 | } else { |
1806 | - $query="SELECT tracker_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(tracker_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(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 |
|
1806 | + $query = "SELECT tracker_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(tracker_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(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 |
|
1807 | 1807 | FROM tracker_archive,tracker_output".$filter_query." tracker_output.famtrackid = tracker_archive.famtrackid AND tracker_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
1808 | 1808 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(tracker_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(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.$orderby_query; |
1809 | 1809 | } |
1810 | 1810 | } else { |
1811 | - $query = "SELECT tracker_output.* FROM tracker_output".$filter_query." tracker_output.ident <> '' |
|
1811 | + $query = "SELECT tracker_output.* FROM tracker_output".$filter_query." tracker_output.ident <> '' |
|
1812 | 1812 | ".$additional_query." |
1813 | 1813 | ".$orderby_query; |
1814 | 1814 | } |
1815 | - $tracker_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
1815 | + $tracker_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
1816 | 1816 | return $tracker_array; |
1817 | 1817 | } |
1818 | 1818 | |
@@ -1837,7 +1837,7 @@ discard block |
||
1837 | 1837 | curl_close($ch); |
1838 | 1838 | $bitly_data = json_decode($bitly_data); |
1839 | 1839 | $bitly_url = ''; |
1840 | - if ($bitly_data->status_txt = "OK"){ |
|
1840 | + if ($bitly_data->status_txt = "OK") { |
|
1841 | 1841 | $bitly_url = $bitly_data->data->url; |
1842 | 1842 | } |
1843 | 1843 | return $bitly_url; |
@@ -1845,7 +1845,7 @@ discard block |
||
1845 | 1845 | |
1846 | 1846 | public function getOrderBy() |
1847 | 1847 | { |
1848 | - $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY tracker_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY tracker_output.type 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")); |
|
1848 | + $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY tracker_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY tracker_output.type 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")); |
|
1849 | 1849 | |
1850 | 1850 | return $orderby; |
1851 | 1851 |