@@ -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 |
@@ -10,7 +10,9 @@ discard block |
||
10 | 10 | public function __construct($dbc = null) { |
11 | 11 | $Connection = new Connection($dbc); |
12 | 12 | $this->db = $Connection->db(); |
13 | - if ($this->db === null) die('Error: No DB connection.'); |
|
13 | + if ($this->db === null) { |
|
14 | + die('Error: No DB connection.'); |
|
15 | + } |
|
14 | 16 | } |
15 | 17 | |
16 | 18 | /** |
@@ -32,7 +34,9 @@ discard block |
||
32 | 34 | if (isset($filter[0]['source'])) { |
33 | 35 | $filters = array_merge($filters,$filter); |
34 | 36 | } |
35 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
37 | + if (is_array($globalFilter)) { |
|
38 | + $filter = array_merge($filter,$globalFilter); |
|
39 | + } |
|
36 | 40 | $filter_query_join = ''; |
37 | 41 | $filter_query_where = ''; |
38 | 42 | foreach($filters as $flt) { |
@@ -71,8 +75,11 @@ discard block |
||
71 | 75 | $filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
72 | 76 | } |
73 | 77 | } |
74 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
75 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
78 | + if ($filter_query_where == '' && $where) { |
|
79 | + $filter_query_where = ' WHERE'; |
|
80 | + } elseif ($filter_query_where != '' && $and) { |
|
81 | + $filter_query_where .= ' AND'; |
|
82 | + } |
|
76 | 83 | if ($filter_query_where != '') { |
77 | 84 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
78 | 85 | } |
@@ -126,26 +133,43 @@ discard block |
||
126 | 133 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
127 | 134 | } elseif (isset($row['spotter_archive_output_id'])) { |
128 | 135 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
129 | - */} |
|
130 | - elseif (isset($row['trackerid'])) { |
|
136 | + */} elseif (isset($row['trackerid'])) { |
|
131 | 137 | $temp_array['trackerid'] = $row['trackerid']; |
132 | 138 | } else { |
133 | 139 | $temp_array['trackerid'] = ''; |
134 | 140 | } |
135 | - if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid']; |
|
136 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
137 | - if (isset($row['comment'])) $temp_array['comment'] = $row['comment']; |
|
141 | + if (isset($row['famtrackid'])) { |
|
142 | + $temp_array['famtrackid'] = $row['famtrackid']; |
|
143 | + } |
|
144 | + if (isset($row['type'])) { |
|
145 | + $temp_array['type'] = $row['type']; |
|
146 | + } |
|
147 | + if (isset($row['comment'])) { |
|
148 | + $temp_array['comment'] = $row['comment']; |
|
149 | + } |
|
138 | 150 | $temp_array['ident'] = $row['ident']; |
139 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
140 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
141 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
142 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
151 | + if (isset($row['latitude'])) { |
|
152 | + $temp_array['latitude'] = $row['latitude']; |
|
153 | + } |
|
154 | + if (isset($row['longitude'])) { |
|
155 | + $temp_array['longitude'] = $row['longitude']; |
|
156 | + } |
|
157 | + if (isset($row['format_source'])) { |
|
158 | + $temp_array['format_source'] = $row['format_source']; |
|
159 | + } |
|
160 | + if (isset($row['altitude'])) { |
|
161 | + $temp_array['altitude'] = $row['altitude']; |
|
162 | + } |
|
143 | 163 | if (isset($row['heading'])) { |
144 | 164 | $temp_array['heading'] = $row['heading']; |
145 | 165 | $heading_direction = $this->parseDirection($row['heading']); |
146 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
166 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
167 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
168 | + } |
|
169 | + } |
|
170 | + if (isset($row['ground_speed'])) { |
|
171 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
147 | 172 | } |
148 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
149 | 173 | |
150 | 174 | if (isset($row['date'])) { |
151 | 175 | $dateArray = $this->parseDateString($row['date']); |
@@ -188,13 +212,21 @@ discard block |
||
188 | 212 | } |
189 | 213 | |
190 | 214 | $fromsource = NULL; |
191 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
192 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
193 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
215 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
216 | + $temp_array['source_name'] = $row['source_name']; |
|
217 | + } |
|
218 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
219 | + $temp_array['over_country'] = $row['over_country']; |
|
220 | + } |
|
221 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
222 | + $temp_array['distance'] = $row['distance']; |
|
223 | + } |
|
194 | 224 | $temp_array['query_number_rows'] = $num_rows; |
195 | 225 | $spotter_array[] = $temp_array; |
196 | 226 | } |
197 | - if ($num_rows == 0) return array(); |
|
227 | + if ($num_rows == 0) { |
|
228 | + return array(); |
|
229 | + } |
|
198 | 230 | $spotter_array[0]['query_number_rows'] = $num_rows; |
199 | 231 | return $spotter_array; |
200 | 232 | } |
@@ -225,8 +257,12 @@ discard block |
||
225 | 257 | { |
226 | 258 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
227 | 259 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
228 | - } else $limit_query = ""; |
|
229 | - } else $limit_query = ""; |
|
260 | + } else { |
|
261 | + $limit_query = ""; |
|
262 | + } |
|
263 | + } else { |
|
264 | + $limit_query = ""; |
|
265 | + } |
|
230 | 266 | |
231 | 267 | if ($sort != "") |
232 | 268 | { |
@@ -254,7 +290,9 @@ discard block |
||
254 | 290 | global $global_query; |
255 | 291 | |
256 | 292 | date_default_timezone_set('UTC'); |
257 | - if ($id == '') return array(); |
|
293 | + if ($id == '') { |
|
294 | + return array(); |
|
295 | + } |
|
258 | 296 | $additional_query = "tracker_output.famtrackid = :id"; |
259 | 297 | $query_values = array(':id' => $id); |
260 | 298 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -397,8 +435,11 @@ discard block |
||
397 | 435 | $query .= " ORDER BY tracker_output.source_name ASC"; |
398 | 436 | |
399 | 437 | $sth = $this->db->prepare($query); |
400 | - if (!empty($query_values)) $sth->execute($query_values); |
|
401 | - else $sth->execute(); |
|
438 | + if (!empty($query_values)) { |
|
439 | + $sth->execute($query_values); |
|
440 | + } else { |
|
441 | + $sth->execute(); |
|
442 | + } |
|
402 | 443 | |
403 | 444 | $source_array = array(); |
404 | 445 | $temp_array = array(); |
@@ -453,7 +494,9 @@ discard block |
||
453 | 494 | date_default_timezone_set($globalTimezone); |
454 | 495 | $datetime = new DateTime(); |
455 | 496 | $offset = $datetime->format('P'); |
456 | - } else $offset = '+00:00'; |
|
497 | + } else { |
|
498 | + $offset = '+00:00'; |
|
499 | + } |
|
457 | 500 | |
458 | 501 | if ($globalDBdriver == 'mysql') { |
459 | 502 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
@@ -609,7 +652,9 @@ discard block |
||
609 | 652 | { |
610 | 653 | return false; |
611 | 654 | } |
612 | - } else $altitude = 0; |
|
655 | + } else { |
|
656 | + $altitude = 0; |
|
657 | + } |
|
613 | 658 | |
614 | 659 | if ($heading != "") |
615 | 660 | { |
@@ -648,8 +693,12 @@ discard block |
||
648 | 693 | $latitude = 0; |
649 | 694 | $longitude = 0; |
650 | 695 | } |
651 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
652 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
696 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
697 | + $heading = 0; |
|
698 | + } |
|
699 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
700 | + $groundspeed = 0; |
|
701 | + } |
|
653 | 702 | $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
654 | 703 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
655 | 704 | |
@@ -758,7 +807,9 @@ discard block |
||
758 | 807 | global $globalDBdriver, $globalArchive; |
759 | 808 | //$filter_query = $this->getFilter($filters,true,true); |
760 | 809 | $Connection= new Connection($this->db); |
761 | - if (!$Connection->tableExists('countries')) return array(); |
|
810 | + if (!$Connection->tableExists('countries')) { |
|
811 | + return array(); |
|
812 | + } |
|
762 | 813 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
763 | 814 | require_once('class.TrackerLive.php'); |
764 | 815 | $TrackerLive = new TrackerLive($this->db); |
@@ -801,7 +852,9 @@ discard block |
||
801 | 852 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
802 | 853 | } |
803 | 854 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
804 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
855 | + if ($limit) { |
|
856 | + $query .= " LIMIT 10 OFFSET 0"; |
|
857 | + } |
|
805 | 858 | |
806 | 859 | |
807 | 860 | $sth = $this->db->prepare($query); |
@@ -834,12 +887,18 @@ discard block |
||
834 | 887 | $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
835 | 888 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
836 | 889 | if ($olderthanmonths > 0) { |
837 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
838 | - else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
890 | + if ($globalDBdriver == 'mysql') { |
|
891 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
892 | + } else { |
|
893 | + $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
894 | + } |
|
839 | 895 | } |
840 | 896 | if ($sincedate != '') { |
841 | - if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
842 | - else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
897 | + if ($globalDBdriver == 'mysql') { |
|
898 | + $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
899 | + } else { |
|
900 | + $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
901 | + } |
|
843 | 902 | } |
844 | 903 | $query_values = array(); |
845 | 904 | if ($year != '') { |
@@ -870,7 +929,9 @@ discard block |
||
870 | 929 | } |
871 | 930 | } |
872 | 931 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
873 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
932 | + if ($limit) { |
|
933 | + $query .= " LIMIT 10 OFFSET 0"; |
|
934 | + } |
|
874 | 935 | |
875 | 936 | $sth = $this->db->prepare($query); |
876 | 937 | $sth->execute($query_values); |
@@ -905,7 +966,9 @@ discard block |
||
905 | 966 | date_default_timezone_set($globalTimezone); |
906 | 967 | $datetime = new DateTime(); |
907 | 968 | $offset = $datetime->format('P'); |
908 | - } else $offset = '+00:00'; |
|
969 | + } else { |
|
970 | + $offset = '+00:00'; |
|
971 | + } |
|
909 | 972 | |
910 | 973 | if ($globalDBdriver == 'mysql') { |
911 | 974 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -955,7 +1018,9 @@ discard block |
||
955 | 1018 | date_default_timezone_set($globalTimezone); |
956 | 1019 | $datetime = new DateTime(); |
957 | 1020 | $offset = $datetime->format('P'); |
958 | - } else $offset = '+00:00'; |
|
1021 | + } else { |
|
1022 | + $offset = '+00:00'; |
|
1023 | + } |
|
959 | 1024 | $filter_query = $this->getFilter($filters,true,true); |
960 | 1025 | if ($globalDBdriver == 'mysql') { |
961 | 1026 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1001,7 +1066,9 @@ discard block |
||
1001 | 1066 | date_default_timezone_set($globalTimezone); |
1002 | 1067 | $datetime = new DateTime(); |
1003 | 1068 | $offset = $datetime->format('P'); |
1004 | - } else $offset = '+00:00'; |
|
1069 | + } else { |
|
1070 | + $offset = '+00:00'; |
|
1071 | + } |
|
1005 | 1072 | $filter_query = $this->getFilter($filters,true,true); |
1006 | 1073 | if ($globalDBdriver == 'mysql') { |
1007 | 1074 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1049,7 +1116,9 @@ discard block |
||
1049 | 1116 | date_default_timezone_set($globalTimezone); |
1050 | 1117 | $datetime = new DateTime(); |
1051 | 1118 | $offset = $datetime->format('P'); |
1052 | - } else $offset = '+00:00'; |
|
1119 | + } else { |
|
1120 | + $offset = '+00:00'; |
|
1121 | + } |
|
1053 | 1122 | |
1054 | 1123 | if ($globalDBdriver == 'mysql') { |
1055 | 1124 | $query = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1098,7 +1167,9 @@ discard block |
||
1098 | 1167 | date_default_timezone_set($globalTimezone); |
1099 | 1168 | $datetime = new DateTime(); |
1100 | 1169 | $offset = $datetime->format('P'); |
1101 | - } else $offset = '+00:00'; |
|
1170 | + } else { |
|
1171 | + $offset = '+00:00'; |
|
1172 | + } |
|
1102 | 1173 | $filter_query = $this->getFilter($filters,true,true); |
1103 | 1174 | if ($globalDBdriver == 'mysql') { |
1104 | 1175 | $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 |
@@ -1147,7 +1218,9 @@ discard block |
||
1147 | 1218 | date_default_timezone_set($globalTimezone); |
1148 | 1219 | $datetime = new DateTime(); |
1149 | 1220 | $offset = $datetime->format('P'); |
1150 | - } else $offset = '+00:00'; |
|
1221 | + } else { |
|
1222 | + $offset = '+00:00'; |
|
1223 | + } |
|
1151 | 1224 | |
1152 | 1225 | $orderby_sql = ''; |
1153 | 1226 | if ($orderby == "hour") |
@@ -1216,7 +1289,9 @@ discard block |
||
1216 | 1289 | date_default_timezone_set($globalTimezone); |
1217 | 1290 | $datetime = new DateTime($date); |
1218 | 1291 | $offset = $datetime->format('P'); |
1219 | - } else $offset = '+00:00'; |
|
1292 | + } else { |
|
1293 | + $offset = '+00:00'; |
|
1294 | + } |
|
1220 | 1295 | |
1221 | 1296 | if ($globalDBdriver == 'mysql') { |
1222 | 1297 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1264,7 +1339,9 @@ discard block |
||
1264 | 1339 | date_default_timezone_set($globalTimezone); |
1265 | 1340 | $datetime = new DateTime(); |
1266 | 1341 | $offset = $datetime->format('P'); |
1267 | - } else $offset = '+00:00'; |
|
1342 | + } else { |
|
1343 | + $offset = '+00:00'; |
|
1344 | + } |
|
1268 | 1345 | |
1269 | 1346 | if ($globalDBdriver == 'mysql') { |
1270 | 1347 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1329,8 +1406,11 @@ discard block |
||
1329 | 1406 | $query_values = array_merge($query_values,array(':month' => $month)); |
1330 | 1407 | } |
1331 | 1408 | } |
1332 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1333 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1409 | + if (empty($query_values)) { |
|
1410 | + $queryi .= $this->getFilter($filters); |
|
1411 | + } else { |
|
1412 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1413 | + } |
|
1334 | 1414 | |
1335 | 1415 | $sth = $this->db->prepare($queryi); |
1336 | 1416 | $sth->execute($query_values); |
@@ -1367,8 +1447,11 @@ discard block |
||
1367 | 1447 | $query_values = array_merge($query_values,array(':month' => $month)); |
1368 | 1448 | } |
1369 | 1449 | } |
1370 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1371 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1450 | + if (empty($query_values)) { |
|
1451 | + $queryi .= $this->getFilter($filters); |
|
1452 | + } else { |
|
1453 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1454 | + } |
|
1372 | 1455 | |
1373 | 1456 | $sth = $this->db->prepare($queryi); |
1374 | 1457 | $sth->execute($query_values); |
@@ -1390,7 +1473,9 @@ discard block |
||
1390 | 1473 | date_default_timezone_set($globalTimezone); |
1391 | 1474 | $datetime = new DateTime(); |
1392 | 1475 | $offset = $datetime->format('P'); |
1393 | - } else $offset = '+00:00'; |
|
1476 | + } else { |
|
1477 | + $offset = '+00:00'; |
|
1478 | + } |
|
1394 | 1479 | |
1395 | 1480 | if ($globalDBdriver == 'mysql') { |
1396 | 1481 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1494,7 +1579,9 @@ discard block |
||
1494 | 1579 | */ |
1495 | 1580 | public function parseDirection($direction = 0) |
1496 | 1581 | { |
1497 | - if ($direction == '') $direction = 0; |
|
1582 | + if ($direction == '') { |
|
1583 | + $direction = 0; |
|
1584 | + } |
|
1498 | 1585 | $direction_array = array(); |
1499 | 1586 | $temp_array = array(); |
1500 | 1587 | |
@@ -1583,7 +1670,9 @@ discard block |
||
1583 | 1670 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1584 | 1671 | |
1585 | 1672 | $Connection = new Connection($this->db); |
1586 | - if (!$Connection->tableExists('countries')) return ''; |
|
1673 | + if (!$Connection->tableExists('countries')) { |
|
1674 | + return ''; |
|
1675 | + } |
|
1587 | 1676 | |
1588 | 1677 | try { |
1589 | 1678 | /* |
@@ -1603,9 +1692,13 @@ discard block |
||
1603 | 1692 | $sth->closeCursor(); |
1604 | 1693 | if (count($row) > 0) { |
1605 | 1694 | return $row; |
1606 | - } else return ''; |
|
1695 | + } else { |
|
1696 | + return ''; |
|
1697 | + } |
|
1607 | 1698 | } catch (PDOException $e) { |
1608 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1699 | + if (isset($globalDebug) && $globalDebug) { |
|
1700 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1701 | + } |
|
1609 | 1702 | return ''; |
1610 | 1703 | } |
1611 | 1704 | |
@@ -1623,7 +1716,9 @@ discard block |
||
1623 | 1716 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1624 | 1717 | |
1625 | 1718 | $Connection = new Connection($this->db); |
1626 | - if (!$Connection->tableExists('countries')) return ''; |
|
1719 | + if (!$Connection->tableExists('countries')) { |
|
1720 | + return ''; |
|
1721 | + } |
|
1627 | 1722 | |
1628 | 1723 | try { |
1629 | 1724 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1635,9 +1730,13 @@ discard block |
||
1635 | 1730 | $sth->closeCursor(); |
1636 | 1731 | if (count($row) > 0) { |
1637 | 1732 | return $row; |
1638 | - } else return ''; |
|
1733 | + } else { |
|
1734 | + return ''; |
|
1735 | + } |
|
1639 | 1736 | } catch (PDOException $e) { |
1640 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1737 | + if (isset($globalDebug) && $globalDebug) { |
|
1738 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1739 | + } |
|
1641 | 1740 | return ''; |
1642 | 1741 | } |
1643 | 1742 | |
@@ -1698,7 +1797,9 @@ discard block |
||
1698 | 1797 | } |
1699 | 1798 | } |
1700 | 1799 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
1701 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1800 | + if ($limit) { |
|
1801 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1802 | + } |
|
1702 | 1803 | $sth = $this->db->prepare($query); |
1703 | 1804 | $sth->execute($query_values); |
1704 | 1805 | $tracker_array = array(); |
@@ -1725,7 +1826,9 @@ discard block |
||
1725 | 1826 | { |
1726 | 1827 | global $globalBitlyAccessToken; |
1727 | 1828 | |
1728 | - if ($globalBitlyAccessToken == '') return $url; |
|
1829 | + if ($globalBitlyAccessToken == '') { |
|
1830 | + return $url; |
|
1831 | + } |
|
1729 | 1832 | |
1730 | 1833 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1731 | 1834 |