@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
3 | 3 | $global_query = "SELECT marine_output.* FROM marine_output"; |
4 | 4 | |
5 | -class Marine{ |
|
5 | +class Marine { |
|
6 | 6 | public $db; |
7 | 7 | |
8 | 8 | public function __construct($dbc = null) { |
@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | 19 | |
20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
26 | 26 | } else { |
27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | if (isset($filter[0]['source'])) { |
31 | - $filters = array_merge($filters,$filter); |
|
31 | + $filters = array_merge($filters, $filter); |
|
32 | 32 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
34 | 34 | $filter_query_join = ''; |
35 | 35 | $filter_query_where = ''; |
36 | - foreach($filters as $flt) { |
|
36 | + foreach ($filters as $flt) { |
|
37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
39 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
40 | 40 | } else { |
41 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
47 | 47 | } |
48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
76 | 76 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
77 | 77 | if ($filter_query_where != '') { |
78 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
78 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
79 | 79 | } |
80 | 80 | $filter_query = $filter_query_join.$filter_query_where; |
81 | 81 | return $filter_query; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @return Array the spotter information |
91 | 91 | * |
92 | 92 | */ |
93 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
93 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
94 | 94 | { |
95 | 95 | date_default_timezone_set('UTC'); |
96 | 96 | if (!is_string($query)) |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | $sth = $this->db->prepare($query.$limitQuery); |
111 | 111 | $sth->execute($params); |
112 | 112 | } catch (PDOException $e) { |
113 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
113 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
114 | 114 | exit(); |
115 | 115 | } |
116 | 116 | |
117 | 117 | $num_rows = 0; |
118 | 118 | $spotter_array = array(); |
119 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
119 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
120 | 120 | { |
121 | 121 | $num_rows++; |
122 | 122 | $temp_array = array(); |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | } |
152 | 152 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
153 | 153 | |
154 | - if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
154 | + if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
155 | 155 | { |
156 | 156 | $Image = new Image($this->db); |
157 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
157 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
158 | 158 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
159 | 159 | unset($Image); |
160 | 160 | if (count($image_array) > 0) { |
@@ -190,17 +190,17 @@ discard block |
||
190 | 190 | { |
191 | 191 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
192 | 192 | } else { |
193 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
193 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
194 | 194 | } |
195 | 195 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
196 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
197 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
196 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
197 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
198 | 198 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
199 | 199 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
200 | 200 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
201 | 201 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
202 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
203 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
202 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
203 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
204 | 204 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
205 | 205 | } |
206 | 206 | } |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | if ($limit != "") |
234 | 234 | { |
235 | 235 | $limit_array = explode(",", $limit); |
236 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
237 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
236 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
237 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
238 | 238 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
239 | 239 | { |
240 | 240 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | } else { |
249 | 249 | $orderby_query = " ORDER BY marine_output.date DESC"; |
250 | 250 | } |
251 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
252 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
251 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
252 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
253 | 253 | return $spotter_array; |
254 | 254 | } |
255 | 255 | |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | if ($id == '') return array(); |
268 | 268 | $additional_query = "marine_output.fammarine_id = :id"; |
269 | 269 | $query_values = array(':id' => $id); |
270 | - $query = $global_query." WHERE ".$additional_query." "; |
|
271 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
270 | + $query = $global_query." WHERE ".$additional_query." "; |
|
271 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
272 | 272 | return $spotter_array; |
273 | 273 | } |
274 | 274 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $query_values = array(); |
288 | 288 | $limit_query = ''; |
289 | 289 | $additional_query = ''; |
290 | - $filter_query = $this->getFilter($filter,true,true); |
|
290 | + $filter_query = $this->getFilter($filter, true, true); |
|
291 | 291 | if ($ident != "") |
292 | 292 | { |
293 | 293 | if (!is_string($ident)) |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | { |
304 | 304 | $limit_array = explode(",", $limit); |
305 | 305 | |
306 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
307 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
306 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
307 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
308 | 308 | |
309 | 309 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
310 | 310 | { |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $query_values = array(); |
344 | 344 | $limit_query = ''; |
345 | 345 | $additional_query = ''; |
346 | - $filter_query = $this->getFilter($filter,true,true); |
|
346 | + $filter_query = $this->getFilter($filter, true, true); |
|
347 | 347 | if (!is_string($type)) |
348 | 348 | { |
349 | 349 | return false; |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | { |
357 | 357 | $limit_array = explode(",", $limit); |
358 | 358 | |
359 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
360 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
359 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
360 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
361 | 361 | |
362 | 362 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
363 | 363 | { |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | return $spotter_array; |
382 | 382 | } |
383 | 383 | |
384 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
384 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
385 | 385 | { |
386 | 386 | global $global_query, $globalTimezone, $globalDBdriver; |
387 | 387 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $limit_query = ''; |
390 | 390 | $additional_query = ''; |
391 | 391 | |
392 | - $filter_query = $this->getFilter($filter,true,true); |
|
392 | + $filter_query = $this->getFilter($filter, true, true); |
|
393 | 393 | |
394 | 394 | if ($date != "") |
395 | 395 | { |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | { |
416 | 416 | $limit_array = explode(",", $limit); |
417 | 417 | |
418 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
419 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
418 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
419 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
420 | 420 | |
421 | 421 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
422 | 422 | { |
@@ -447,11 +447,11 @@ discard block |
||
447 | 447 | * @return Array list of source name |
448 | 448 | * |
449 | 449 | */ |
450 | - public function getAllSourceName($type = '',$filters = array()) |
|
450 | + public function getAllSourceName($type = '', $filters = array()) |
|
451 | 451 | { |
452 | - $filter_query = $this->getFilter($filters,true,true); |
|
452 | + $filter_query = $this->getFilter($filters, true, true); |
|
453 | 453 | $query_values = array(); |
454 | - $query = "SELECT DISTINCT marine_output.source_name |
|
454 | + $query = "SELECT DISTINCT marine_output.source_name |
|
455 | 455 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
456 | 456 | if ($type != '') { |
457 | 457 | $query_values = array(':type' => $type); |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | $source_array = array(); |
467 | 467 | $temp_array = array(); |
468 | 468 | |
469 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
469 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
470 | 470 | { |
471 | 471 | $temp_array['source_name'] = $row['source_name']; |
472 | 472 | $source_array[] = $temp_array; |
@@ -483,8 +483,8 @@ discard block |
||
483 | 483 | */ |
484 | 484 | public function getAllIdents($filters = array()) |
485 | 485 | { |
486 | - $filter_query = $this->getFilter($filters,true,true); |
|
487 | - $query = "SELECT DISTINCT marine_output.ident |
|
486 | + $filter_query = $this->getFilter($filters, true, true); |
|
487 | + $query = "SELECT DISTINCT marine_output.ident |
|
488 | 488 | FROM marine_output".$filter_query." marine_output.ident <> '' |
489 | 489 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
490 | 490 | |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | $ident_array = array(); |
495 | 495 | $temp_array = array(); |
496 | 496 | |
497 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
497 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
498 | 498 | { |
499 | 499 | $temp_array['ident'] = $row['ident']; |
500 | 500 | $ident_array[] = $temp_array; |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | */ |
512 | 512 | public function getIdentity($mmsi) |
513 | 513 | { |
514 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
514 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
515 | 515 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
516 | 516 | $sth = $this->db->prepare($query); |
517 | 517 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -524,23 +524,23 @@ discard block |
||
524 | 524 | * Add identity |
525 | 525 | * |
526 | 526 | */ |
527 | - public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
|
527 | + public function addIdentity($mmsi, $imo, $ident, $callsign, $type) |
|
528 | 528 | { |
529 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
529 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
530 | 530 | if ($mmsi != '') { |
531 | - $imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT); |
|
532 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
533 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
534 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
531 | + $imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT); |
|
532 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
533 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
534 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
535 | 535 | $identinfo = $this->getIdentity($mmsi); |
536 | 536 | if (empty($identinfo)) { |
537 | - $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
537 | + $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
538 | 538 | $sth = $this->db->prepare($query); |
539 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type)); |
|
539 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type)); |
|
540 | 540 | } elseif ($ident != '' && $identinfo['ship_name'] != $ident) { |
541 | - $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
541 | + $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
542 | 542 | $sth = $this->db->prepare($query); |
543 | - $sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type)); |
|
543 | + $sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type)); |
|
544 | 544 | } |
545 | 545 | } |
546 | 546 | } |
@@ -561,12 +561,12 @@ discard block |
||
561 | 561 | } else $offset = '+00:00'; |
562 | 562 | |
563 | 563 | if ($globalDBdriver == 'mysql') { |
564 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
564 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
565 | 565 | FROM marine_output |
566 | 566 | WHERE marine_output.date <> '' |
567 | 567 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
568 | 568 | } else { |
569 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
569 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
570 | 570 | FROM marine_output |
571 | 571 | WHERE marine_output.date <> '' |
572 | 572 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | $date_array = array(); |
579 | 579 | $temp_array = array(); |
580 | 580 | |
581 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
581 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
582 | 582 | { |
583 | 583 | $temp_array['date'] = $row['date']; |
584 | 584 | |
@@ -596,10 +596,10 @@ discard block |
||
596 | 596 | * @return String success or false |
597 | 597 | * |
598 | 598 | */ |
599 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
599 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
600 | 600 | { |
601 | 601 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
602 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
602 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
603 | 603 | try { |
604 | 604 | $sth = $this->db->prepare($query); |
605 | 605 | $sth->execute($query_values); |
@@ -617,10 +617,10 @@ discard block |
||
617 | 617 | * @return String success or false |
618 | 618 | * |
619 | 619 | */ |
620 | - public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
|
620 | + public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL) |
|
621 | 621 | { |
622 | 622 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
623 | - $query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code); |
|
623 | + $query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code); |
|
624 | 624 | try { |
625 | 625 | $sth = $this->db->prepare($query); |
626 | 626 | $sth->execute($query_values); |
@@ -639,11 +639,11 @@ discard block |
||
639 | 639 | * @return String success or false |
640 | 640 | * |
641 | 641 | */ |
642 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
642 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
643 | 643 | { |
644 | 644 | |
645 | 645 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
646 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
646 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
647 | 647 | |
648 | 648 | try { |
649 | 649 | $sth = $this->db->prepare($query); |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
667 | 667 | { |
668 | 668 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
669 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
669 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
670 | 670 | |
671 | 671 | try { |
672 | 672 | $sth = $this->db->prepare($query); |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | * @param String $verticalrate vertival rate of flight |
705 | 705 | * @return String success or false |
706 | 706 | */ |
707 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
|
707 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '') |
|
708 | 708 | { |
709 | 709 | global $globalURL, $globalMarineImageFetch; |
710 | 710 | |
@@ -771,32 +771,32 @@ discard block |
||
771 | 771 | } |
772 | 772 | |
773 | 773 | |
774 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
774 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
775 | 775 | { |
776 | 776 | $date = date("Y-m-d H:i:s", time()); |
777 | 777 | } |
778 | 778 | |
779 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
780 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
781 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
782 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
783 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
784 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
785 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
786 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
787 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
788 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
789 | - $type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
790 | - $status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
791 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
792 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
793 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
794 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
779 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
780 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
781 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
782 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
783 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
784 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
785 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
786 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
787 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
788 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
789 | + $type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
790 | + $status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
791 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
792 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
793 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
794 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
795 | 795 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
796 | 796 | $Image = new Image($this->db); |
797 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
797 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
798 | 798 | if (!isset($image_array[0]['mmsi'])) { |
799 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
799 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
800 | 800 | } |
801 | 801 | unset($Image); |
802 | 802 | } |
@@ -809,10 +809,10 @@ discard block |
||
809 | 809 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
810 | 810 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
811 | 811 | if ($arrival_date == '') $arrival_date = NULL; |
812 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date) |
|
812 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date) |
|
813 | 813 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date)"; |
814 | 814 | |
815 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':type_id' => $type_id,':status' => $status,':status_id' => $status_id,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
815 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $type_id, ':status' => $status, ':status_id' => $status_id, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
816 | 816 | try { |
817 | 817 | $sth = $this->db->prepare($query); |
818 | 818 | $sth->execute($query_values); |
@@ -836,13 +836,13 @@ discard block |
||
836 | 836 | { |
837 | 837 | global $globalDBdriver, $globalTimezone; |
838 | 838 | if ($globalDBdriver == 'mysql') { |
839 | - $query = "SELECT marine_output.ident FROM marine_output |
|
839 | + $query = "SELECT marine_output.ident FROM marine_output |
|
840 | 840 | WHERE marine_output.ident = :ident |
841 | 841 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
842 | 842 | AND marine_output.date < UTC_TIMESTAMP()"; |
843 | 843 | $query_data = array(':ident' => $ident); |
844 | 844 | } else { |
845 | - $query = "SELECT marine_output.ident FROM marine_output |
|
845 | + $query = "SELECT marine_output.ident FROM marine_output |
|
846 | 846 | WHERE marine_output.ident = :ident |
847 | 847 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
848 | 848 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -851,8 +851,8 @@ discard block |
||
851 | 851 | |
852 | 852 | $sth = $this->db->prepare($query); |
853 | 853 | $sth->execute($query_data); |
854 | - $ident_result=''; |
|
855 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
854 | + $ident_result = ''; |
|
855 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
856 | 856 | { |
857 | 857 | $ident_result = $row['ident']; |
858 | 858 | } |
@@ -878,8 +878,8 @@ discard block |
||
878 | 878 | return false; |
879 | 879 | } else { |
880 | 880 | $q_array = explode(" ", $q); |
881 | - foreach ($q_array as $q_item){ |
|
882 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
881 | + foreach ($q_array as $q_item) { |
|
882 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
883 | 883 | $additional_query .= " AND ("; |
884 | 884 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
885 | 885 | $additional_query .= ")"; |
@@ -887,11 +887,11 @@ discard block |
||
887 | 887 | } |
888 | 888 | } |
889 | 889 | if ($globalDBdriver == 'mysql') { |
890 | - $query = "SELECT marine_output.* FROM marine_output |
|
890 | + $query = "SELECT marine_output.* FROM marine_output |
|
891 | 891 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
892 | 892 | AND marine_output.date < UTC_TIMESTAMP()"; |
893 | 893 | } else { |
894 | - $query = "SELECT marine_output.* FROM marine_output |
|
894 | + $query = "SELECT marine_output.* FROM marine_output |
|
895 | 895 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
896 | 896 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
897 | 897 | } |
@@ -910,16 +910,16 @@ discard block |
||
910 | 910 | * |
911 | 911 | */ |
912 | 912 | |
913 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
913 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
914 | 914 | { |
915 | 915 | global $globalDBdriver, $globalArchive; |
916 | 916 | //$filter_query = $this->getFilter($filters,true,true); |
917 | - $Connection= new Connection($this->db); |
|
917 | + $Connection = new Connection($this->db); |
|
918 | 918 | if (!$Connection->tableExists('countries')) return array(); |
919 | 919 | require_once('class.SpotterLive.php'); |
920 | 920 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
921 | 921 | $MarineLive = new MarineLive($this->db); |
922 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
922 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
923 | 923 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
924 | 924 | if ($olderthanmonths > 0) { |
925 | 925 | if ($globalDBdriver == 'mysql') { |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | } else { |
940 | 940 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
941 | 941 | $MarineArchive = new MarineArchive($this->db); |
942 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
942 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
943 | 943 | $filter_query .= " over_country <> ''"; |
944 | 944 | if ($olderthanmonths > 0) { |
945 | 945 | if ($globalDBdriver == 'mysql') { |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | $flight_array = array(); |
968 | 968 | $temp_array = array(); |
969 | 969 | |
970 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
970 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
971 | 971 | { |
972 | 972 | $temp_array['marine_count'] = $row['nb']; |
973 | 973 | $temp_array['marine_country'] = $row['name']; |
@@ -986,11 +986,11 @@ discard block |
||
986 | 986 | * @return Array the callsign list |
987 | 987 | * |
988 | 988 | */ |
989 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
989 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
990 | 990 | { |
991 | 991 | global $globalDBdriver; |
992 | - $filter_query = $this->getFilter($filters,true,true); |
|
993 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
992 | + $filter_query = $this->getFilter($filters, true, true); |
|
993 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
994 | 994 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
995 | 995 | if ($olderthanmonths > 0) { |
996 | 996 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -1004,28 +1004,28 @@ discard block |
||
1004 | 1004 | if ($year != '') { |
1005 | 1005 | if ($globalDBdriver == 'mysql') { |
1006 | 1006 | $query .= " AND YEAR(marine_output.date) = :year"; |
1007 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1007 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1008 | 1008 | } else { |
1009 | 1009 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1010 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1010 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1011 | 1011 | } |
1012 | 1012 | } |
1013 | 1013 | if ($month != '') { |
1014 | 1014 | if ($globalDBdriver == 'mysql') { |
1015 | 1015 | $query .= " AND MONTH(marine_output.date) = :month"; |
1016 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1016 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1017 | 1017 | } else { |
1018 | 1018 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1019 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1019 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1020 | 1020 | } |
1021 | 1021 | } |
1022 | 1022 | if ($day != '') { |
1023 | 1023 | if ($globalDBdriver == 'mysql') { |
1024 | 1024 | $query .= " AND DAY(marine_output.date) = :day"; |
1025 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1025 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1026 | 1026 | } else { |
1027 | 1027 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
1028 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1028 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1029 | 1029 | } |
1030 | 1030 | } |
1031 | 1031 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | $callsign_array = array(); |
1038 | 1038 | $temp_array = array(); |
1039 | 1039 | |
1040 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1040 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1041 | 1041 | { |
1042 | 1042 | $temp_array['callsign_icao'] = $row['ident']; |
1043 | 1043 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | $date_array = array(); |
1090 | 1090 | $temp_array = array(); |
1091 | 1091 | |
1092 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1092 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1093 | 1093 | { |
1094 | 1094 | $temp_array['date_name'] = $row['date_name']; |
1095 | 1095 | $temp_array['date_count'] = $row['date_count']; |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | $datetime = new DateTime(); |
1116 | 1116 | $offset = $datetime->format('P'); |
1117 | 1117 | } else $offset = '+00:00'; |
1118 | - $filter_query = $this->getFilter($filters,true,true); |
|
1118 | + $filter_query = $this->getFilter($filters, true, true); |
|
1119 | 1119 | if ($globalDBdriver == 'mysql') { |
1120 | 1120 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1121 | 1121 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1136,7 +1136,7 @@ discard block |
||
1136 | 1136 | $date_array = array(); |
1137 | 1137 | $temp_array = array(); |
1138 | 1138 | |
1139 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1139 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1140 | 1140 | { |
1141 | 1141 | $temp_array['date_name'] = $row['date_name']; |
1142 | 1142 | $temp_array['date_count'] = $row['date_count']; |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | $datetime = new DateTime(); |
1162 | 1162 | $offset = $datetime->format('P'); |
1163 | 1163 | } else $offset = '+00:00'; |
1164 | - $filter_query = $this->getFilter($filters,true,true); |
|
1164 | + $filter_query = $this->getFilter($filters, true, true); |
|
1165 | 1165 | if ($globalDBdriver == 'mysql') { |
1166 | 1166 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1167 | 1167 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1182,7 +1182,7 @@ discard block |
||
1182 | 1182 | $date_array = array(); |
1183 | 1183 | $temp_array = array(); |
1184 | 1184 | |
1185 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1185 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1186 | 1186 | { |
1187 | 1187 | $temp_array['date_name'] = $row['date_name']; |
1188 | 1188 | $temp_array['date_count'] = $row['date_count']; |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | $date_array = array(); |
1230 | 1230 | $temp_array = array(); |
1231 | 1231 | |
1232 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1232 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1233 | 1233 | { |
1234 | 1234 | $temp_array['month_name'] = $row['month_name']; |
1235 | 1235 | $temp_array['year_name'] = $row['year_name']; |
@@ -1258,7 +1258,7 @@ discard block |
||
1258 | 1258 | $datetime = new DateTime(); |
1259 | 1259 | $offset = $datetime->format('P'); |
1260 | 1260 | } else $offset = '+00:00'; |
1261 | - $filter_query = $this->getFilter($filters,true,true); |
|
1261 | + $filter_query = $this->getFilter($filters, true, true); |
|
1262 | 1262 | if ($globalDBdriver == 'mysql') { |
1263 | 1263 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
1264 | 1264 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1279,7 +1279,7 @@ discard block |
||
1279 | 1279 | $date_array = array(); |
1280 | 1280 | $temp_array = array(); |
1281 | 1281 | |
1282 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1282 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1283 | 1283 | { |
1284 | 1284 | $temp_array['year_name'] = $row['year_name']; |
1285 | 1285 | $temp_array['month_name'] = $row['month_name']; |
@@ -1299,7 +1299,7 @@ discard block |
||
1299 | 1299 | * @return Array the hour list |
1300 | 1300 | * |
1301 | 1301 | */ |
1302 | - public function countAllHours($orderby,$filters = array()) |
|
1302 | + public function countAllHours($orderby, $filters = array()) |
|
1303 | 1303 | { |
1304 | 1304 | global $globalTimezone, $globalDBdriver; |
1305 | 1305 | if ($globalTimezone != '') { |
@@ -1347,7 +1347,7 @@ discard block |
||
1347 | 1347 | $hour_array = array(); |
1348 | 1348 | $temp_array = array(); |
1349 | 1349 | |
1350 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1350 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1351 | 1351 | { |
1352 | 1352 | $temp_array['hour_name'] = $row['hour_name']; |
1353 | 1353 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1369,8 +1369,8 @@ discard block |
||
1369 | 1369 | public function countAllHoursByDate($date, $filters = array()) |
1370 | 1370 | { |
1371 | 1371 | global $globalTimezone, $globalDBdriver; |
1372 | - $filter_query = $this->getFilter($filters,true,true); |
|
1373 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1372 | + $filter_query = $this->getFilter($filters, true, true); |
|
1373 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1374 | 1374 | if ($globalTimezone != '') { |
1375 | 1375 | date_default_timezone_set($globalTimezone); |
1376 | 1376 | $datetime = new DateTime($date); |
@@ -1378,12 +1378,12 @@ discard block |
||
1378 | 1378 | } else $offset = '+00:00'; |
1379 | 1379 | |
1380 | 1380 | if ($globalDBdriver == 'mysql') { |
1381 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1381 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1382 | 1382 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
1383 | 1383 | GROUP BY hour_name |
1384 | 1384 | ORDER BY hour_name ASC"; |
1385 | 1385 | } else { |
1386 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1386 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1387 | 1387 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1388 | 1388 | GROUP BY hour_name |
1389 | 1389 | ORDER BY hour_name ASC"; |
@@ -1395,7 +1395,7 @@ discard block |
||
1395 | 1395 | $hour_array = array(); |
1396 | 1396 | $temp_array = array(); |
1397 | 1397 | |
1398 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1398 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1399 | 1399 | { |
1400 | 1400 | $temp_array['hour_name'] = $row['hour_name']; |
1401 | 1401 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1417,8 +1417,8 @@ discard block |
||
1417 | 1417 | public function countAllHoursByIdent($ident, $filters = array()) |
1418 | 1418 | { |
1419 | 1419 | global $globalTimezone, $globalDBdriver; |
1420 | - $filter_query = $this->getFilter($filters,true,true); |
|
1421 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1420 | + $filter_query = $this->getFilter($filters, true, true); |
|
1421 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1422 | 1422 | if ($globalTimezone != '') { |
1423 | 1423 | date_default_timezone_set($globalTimezone); |
1424 | 1424 | $datetime = new DateTime(); |
@@ -1426,12 +1426,12 @@ discard block |
||
1426 | 1426 | } else $offset = '+00:00'; |
1427 | 1427 | |
1428 | 1428 | if ($globalDBdriver == 'mysql') { |
1429 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1429 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1430 | 1430 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1431 | 1431 | GROUP BY hour_name |
1432 | 1432 | ORDER BY hour_name ASC"; |
1433 | 1433 | } else { |
1434 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1434 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1435 | 1435 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1436 | 1436 | GROUP BY hour_name |
1437 | 1437 | ORDER BY hour_name ASC"; |
@@ -1439,12 +1439,12 @@ discard block |
||
1439 | 1439 | |
1440 | 1440 | |
1441 | 1441 | $sth = $this->db->prepare($query); |
1442 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1442 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1443 | 1443 | |
1444 | 1444 | $hour_array = array(); |
1445 | 1445 | $temp_array = array(); |
1446 | 1446 | |
1447 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1447 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1448 | 1448 | { |
1449 | 1449 | $temp_array['hour_name'] = $row['hour_name']; |
1450 | 1450 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1463,33 +1463,33 @@ discard block |
||
1463 | 1463 | * @return Integer the number of vessels |
1464 | 1464 | * |
1465 | 1465 | */ |
1466 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
1466 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
1467 | 1467 | { |
1468 | 1468 | global $globalDBdriver; |
1469 | 1469 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
1470 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1470 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1471 | 1471 | $query_values = array(); |
1472 | 1472 | $query = ''; |
1473 | 1473 | if ($year != '') { |
1474 | 1474 | if ($globalDBdriver == 'mysql') { |
1475 | 1475 | $query .= " AND YEAR(marine_output.date) = :year"; |
1476 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1476 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1477 | 1477 | } else { |
1478 | 1478 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1479 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1479 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1480 | 1480 | } |
1481 | 1481 | } |
1482 | 1482 | if ($month != '') { |
1483 | 1483 | if ($globalDBdriver == 'mysql') { |
1484 | 1484 | $query .= " AND MONTH(marine_output.date) = :month"; |
1485 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1485 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1486 | 1486 | } else { |
1487 | 1487 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1488 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1488 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1489 | 1489 | } |
1490 | 1490 | } |
1491 | 1491 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1492 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1492 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1493 | 1493 | |
1494 | 1494 | $sth = $this->db->prepare($queryi); |
1495 | 1495 | $sth->execute($query_values); |
@@ -1502,32 +1502,32 @@ discard block |
||
1502 | 1502 | * @return Integer the number of vessels |
1503 | 1503 | * |
1504 | 1504 | */ |
1505 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
1505 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
1506 | 1506 | { |
1507 | 1507 | global $globalDBdriver; |
1508 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1508 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1509 | 1509 | $query_values = array(); |
1510 | 1510 | $query = ''; |
1511 | 1511 | if ($year != '') { |
1512 | 1512 | if ($globalDBdriver == 'mysql') { |
1513 | 1513 | $query .= " AND YEAR(marine_output.date) = :year"; |
1514 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1514 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1515 | 1515 | } else { |
1516 | 1516 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1517 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1517 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1518 | 1518 | } |
1519 | 1519 | } |
1520 | 1520 | if ($month != '') { |
1521 | 1521 | if ($globalDBdriver == 'mysql') { |
1522 | 1522 | $query .= " AND MONTH(marine_output.date) = :month"; |
1523 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1523 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1524 | 1524 | } else { |
1525 | 1525 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1526 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1526 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1527 | 1527 | } |
1528 | 1528 | } |
1529 | 1529 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1530 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1530 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1531 | 1531 | |
1532 | 1532 | $sth = $this->db->prepare($queryi); |
1533 | 1533 | $sth->execute($query_values); |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | public function countAllHoursFromToday($filters = array()) |
1545 | 1545 | { |
1546 | 1546 | global $globalTimezone, $globalDBdriver; |
1547 | - $filter_query = $this->getFilter($filters,true,true); |
|
1547 | + $filter_query = $this->getFilter($filters, true, true); |
|
1548 | 1548 | if ($globalTimezone != '') { |
1549 | 1549 | date_default_timezone_set($globalTimezone); |
1550 | 1550 | $datetime = new DateTime(); |
@@ -1552,12 +1552,12 @@ discard block |
||
1552 | 1552 | } else $offset = '+00:00'; |
1553 | 1553 | |
1554 | 1554 | if ($globalDBdriver == 'mysql') { |
1555 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1555 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1556 | 1556 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
1557 | 1557 | GROUP BY hour_name |
1558 | 1558 | ORDER BY hour_name ASC"; |
1559 | 1559 | } else { |
1560 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1560 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1561 | 1561 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1562 | 1562 | GROUP BY hour_name |
1563 | 1563 | ORDER BY hour_name ASC"; |
@@ -1569,7 +1569,7 @@ discard block |
||
1569 | 1569 | $hour_array = array(); |
1570 | 1570 | $temp_array = array(); |
1571 | 1571 | |
1572 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1572 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1573 | 1573 | { |
1574 | 1574 | $temp_array['hour_name'] = $row['hour_name']; |
1575 | 1575 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1588,9 +1588,9 @@ discard block |
||
1588 | 1588 | */ |
1589 | 1589 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1590 | 1590 | { |
1591 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
1591 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
1592 | 1592 | |
1593 | - $query = "SELECT marine_output.marine_id |
|
1593 | + $query = "SELECT marine_output.marine_id |
|
1594 | 1594 | FROM marine_output |
1595 | 1595 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
1596 | 1596 | |
@@ -1598,7 +1598,7 @@ discard block |
||
1598 | 1598 | $sth = $this->db->prepare($query); |
1599 | 1599 | $sth->execute(); |
1600 | 1600 | |
1601 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1601 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1602 | 1602 | { |
1603 | 1603 | return $row['marine_id']; |
1604 | 1604 | } |
@@ -1623,23 +1623,23 @@ discard block |
||
1623 | 1623 | } |
1624 | 1624 | |
1625 | 1625 | $current_date = date("Y-m-d H:i:s"); |
1626 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1626 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1627 | 1627 | |
1628 | 1628 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1629 | 1629 | |
1630 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1630 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1631 | 1631 | $years = $time_array['years']; |
1632 | 1632 | |
1633 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1633 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1634 | 1634 | $months = $time_array['months']; |
1635 | 1635 | |
1636 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1636 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1637 | 1637 | $days = $time_array['days']; |
1638 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1638 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1639 | 1639 | $hours = $time_array['hours']; |
1640 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1640 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1641 | 1641 | $minutes = $time_array['minutes']; |
1642 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1642 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1643 | 1643 | |
1644 | 1644 | return $time_array; |
1645 | 1645 | } |
@@ -1662,63 +1662,63 @@ discard block |
||
1662 | 1662 | $temp_array['direction_degree'] = $direction; |
1663 | 1663 | $temp_array['direction_shortname'] = "N"; |
1664 | 1664 | $temp_array['direction_fullname'] = "North"; |
1665 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1665 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1666 | 1666 | $temp_array['direction_degree'] = $direction; |
1667 | 1667 | $temp_array['direction_shortname'] = "NNE"; |
1668 | 1668 | $temp_array['direction_fullname'] = "North-Northeast"; |
1669 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1669 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1670 | 1670 | $temp_array['direction_degree'] = $direction; |
1671 | 1671 | $temp_array['direction_shortname'] = "NE"; |
1672 | 1672 | $temp_array['direction_fullname'] = "Northeast"; |
1673 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1673 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1674 | 1674 | $temp_array['direction_degree'] = $direction; |
1675 | 1675 | $temp_array['direction_shortname'] = "ENE"; |
1676 | 1676 | $temp_array['direction_fullname'] = "East-Northeast"; |
1677 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1677 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1678 | 1678 | $temp_array['direction_degree'] = $direction; |
1679 | 1679 | $temp_array['direction_shortname'] = "E"; |
1680 | 1680 | $temp_array['direction_fullname'] = "East"; |
1681 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1681 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1682 | 1682 | $temp_array['direction_degree'] = $direction; |
1683 | 1683 | $temp_array['direction_shortname'] = "ESE"; |
1684 | 1684 | $temp_array['direction_fullname'] = "East-Southeast"; |
1685 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1685 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1686 | 1686 | $temp_array['direction_degree'] = $direction; |
1687 | 1687 | $temp_array['direction_shortname'] = "SE"; |
1688 | 1688 | $temp_array['direction_fullname'] = "Southeast"; |
1689 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1689 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1690 | 1690 | $temp_array['direction_degree'] = $direction; |
1691 | 1691 | $temp_array['direction_shortname'] = "SSE"; |
1692 | 1692 | $temp_array['direction_fullname'] = "South-Southeast"; |
1693 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1693 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1694 | 1694 | $temp_array['direction_degree'] = $direction; |
1695 | 1695 | $temp_array['direction_shortname'] = "S"; |
1696 | 1696 | $temp_array['direction_fullname'] = "South"; |
1697 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1697 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1698 | 1698 | $temp_array['direction_degree'] = $direction; |
1699 | 1699 | $temp_array['direction_shortname'] = "SSW"; |
1700 | 1700 | $temp_array['direction_fullname'] = "South-Southwest"; |
1701 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1701 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1702 | 1702 | $temp_array['direction_degree'] = $direction; |
1703 | 1703 | $temp_array['direction_shortname'] = "SW"; |
1704 | 1704 | $temp_array['direction_fullname'] = "Southwest"; |
1705 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1705 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1706 | 1706 | $temp_array['direction_degree'] = $direction; |
1707 | 1707 | $temp_array['direction_shortname'] = "WSW"; |
1708 | 1708 | $temp_array['direction_fullname'] = "West-Southwest"; |
1709 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1709 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1710 | 1710 | $temp_array['direction_degree'] = $direction; |
1711 | 1711 | $temp_array['direction_shortname'] = "W"; |
1712 | 1712 | $temp_array['direction_fullname'] = "West"; |
1713 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1713 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1714 | 1714 | $temp_array['direction_degree'] = $direction; |
1715 | 1715 | $temp_array['direction_shortname'] = "WNW"; |
1716 | 1716 | $temp_array['direction_fullname'] = "West-Northwest"; |
1717 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1717 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1718 | 1718 | $temp_array['direction_degree'] = $direction; |
1719 | 1719 | $temp_array['direction_shortname'] = "NW"; |
1720 | 1720 | $temp_array['direction_fullname'] = "Northwest"; |
1721 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1721 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1722 | 1722 | $temp_array['direction_degree'] = $direction; |
1723 | 1723 | $temp_array['direction_shortname'] = "NNW"; |
1724 | 1724 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1735,11 +1735,11 @@ discard block |
||
1735 | 1735 | * @param Float $longitude longitute of the flight |
1736 | 1736 | * @return String the countrie |
1737 | 1737 | */ |
1738 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1738 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1739 | 1739 | { |
1740 | 1740 | global $globalDBdriver, $globalDebug; |
1741 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1742 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1741 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1742 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1743 | 1743 | |
1744 | 1744 | $Connection = new Connection($this->db); |
1745 | 1745 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1779,7 +1779,7 @@ discard block |
||
1779 | 1779 | public function getCountryFromISO2($iso2) |
1780 | 1780 | { |
1781 | 1781 | global $globalDBdriver, $globalDebug; |
1782 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1782 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1783 | 1783 | |
1784 | 1784 | $Connection = new Connection($this->db); |
1785 | 1785 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1827,7 +1827,7 @@ discard block |
||
1827 | 1827 | |
1828 | 1828 | $bitly_data = json_decode($bitly_data); |
1829 | 1829 | $bitly_url = ''; |
1830 | - if ($bitly_data->status_txt = "OK"){ |
|
1830 | + if ($bitly_data->status_txt = "OK") { |
|
1831 | 1831 | $bitly_url = $bitly_data->data->url; |
1832 | 1832 | } |
1833 | 1833 | |
@@ -1841,11 +1841,11 @@ discard block |
||
1841 | 1841 | * @return Array the vessel type list |
1842 | 1842 | * |
1843 | 1843 | */ |
1844 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
1844 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1845 | 1845 | { |
1846 | 1846 | global $globalDBdriver; |
1847 | - $filter_query = $this->getFilter($filters,true,true); |
|
1848 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
1847 | + $filter_query = $this->getFilter($filters, true, true); |
|
1848 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
1849 | 1849 | FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL"; |
1850 | 1850 | if ($olderthanmonths > 0) { |
1851 | 1851 | if ($globalDBdriver == 'mysql') { |
@@ -1865,28 +1865,28 @@ discard block |
||
1865 | 1865 | if ($year != '') { |
1866 | 1866 | if ($globalDBdriver == 'mysql') { |
1867 | 1867 | $query .= " AND YEAR(marine_output.date) = :year"; |
1868 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1868 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1869 | 1869 | } else { |
1870 | 1870 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1871 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1871 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1872 | 1872 | } |
1873 | 1873 | } |
1874 | 1874 | if ($month != '') { |
1875 | 1875 | if ($globalDBdriver == 'mysql') { |
1876 | 1876 | $query .= " AND MONTH(marine_output.date) = :month"; |
1877 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1877 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1878 | 1878 | } else { |
1879 | 1879 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1880 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1880 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1881 | 1881 | } |
1882 | 1882 | } |
1883 | 1883 | if ($day != '') { |
1884 | 1884 | if ($globalDBdriver == 'mysql') { |
1885 | 1885 | $query .= " AND DAY(marine_output.date) = :day"; |
1886 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1886 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1887 | 1887 | } else { |
1888 | 1888 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
1889 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1889 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1890 | 1890 | } |
1891 | 1891 | } |
1892 | 1892 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
@@ -1895,7 +1895,7 @@ discard block |
||
1895 | 1895 | $sth->execute($query_values); |
1896 | 1896 | $marine_array = array(); |
1897 | 1897 | $temp_array = array(); |
1898 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1898 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1899 | 1899 | { |
1900 | 1900 | $temp_array['marine_type'] = $row['marine_type']; |
1901 | 1901 | $temp_array['marine_type_id'] = $row['marine_type_id']; |
@@ -1911,13 +1911,13 @@ discard block |
||
1911 | 1911 | * @return Array the tracker information |
1912 | 1912 | * |
1913 | 1913 | */ |
1914 | - public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
|
1914 | + public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
1915 | 1915 | { |
1916 | 1916 | global $globalTimezone, $globalDBdriver; |
1917 | 1917 | date_default_timezone_set('UTC'); |
1918 | 1918 | $query_values = array(); |
1919 | 1919 | $additional_query = ''; |
1920 | - $filter_query = $this->getFilter($filters,true,true); |
|
1920 | + $filter_query = $this->getFilter($filters, true, true); |
|
1921 | 1921 | if ($q != "") |
1922 | 1922 | { |
1923 | 1923 | if (!is_string($q)) |
@@ -1925,8 +1925,8 @@ discard block |
||
1925 | 1925 | return false; |
1926 | 1926 | } else { |
1927 | 1927 | $q_array = explode(" ", $q); |
1928 | - foreach ($q_array as $q_item){ |
|
1929 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
1928 | + foreach ($q_array as $q_item) { |
|
1929 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
1930 | 1930 | $additional_query .= " AND ("; |
1931 | 1931 | if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
1932 | 1932 | if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
@@ -1938,42 +1938,42 @@ discard block |
||
1938 | 1938 | } |
1939 | 1939 | if ($callsign != "") |
1940 | 1940 | { |
1941 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
1941 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
1942 | 1942 | if (!is_string($callsign)) |
1943 | 1943 | { |
1944 | 1944 | return false; |
1945 | 1945 | } else { |
1946 | 1946 | $additional_query .= " AND marine_output.ident = :callsign"; |
1947 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
1947 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
1948 | 1948 | } |
1949 | 1949 | } |
1950 | 1950 | if ($mmsi != "") |
1951 | 1951 | { |
1952 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
1952 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
1953 | 1953 | if (!is_numeric($mmsi)) |
1954 | 1954 | { |
1955 | 1955 | return false; |
1956 | 1956 | } else { |
1957 | 1957 | $additional_query .= " AND marine_output.mmsi = :mmsi"; |
1958 | - $query_values = array_merge($query_values,array(':mmsi' => $mmsi)); |
|
1958 | + $query_values = array_merge($query_values, array(':mmsi' => $mmsi)); |
|
1959 | 1959 | } |
1960 | 1960 | } |
1961 | 1961 | if ($imo != "") |
1962 | 1962 | { |
1963 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
1963 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
1964 | 1964 | if (!is_numeric($imo)) |
1965 | 1965 | { |
1966 | 1966 | return false; |
1967 | 1967 | } else { |
1968 | 1968 | $additional_query .= " AND marine_output.imo = :imo"; |
1969 | - $query_values = array_merge($query_values,array(':imo' => $imo)); |
|
1969 | + $query_values = array_merge($query_values, array(':imo' => $imo)); |
|
1970 | 1970 | } |
1971 | 1971 | } |
1972 | 1972 | if ($date_posted != "") |
1973 | 1973 | { |
1974 | 1974 | $date_array = explode(",", $date_posted); |
1975 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
1976 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
1975 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
1976 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
1977 | 1977 | if ($globalTimezone != '') { |
1978 | 1978 | date_default_timezone_set($globalTimezone); |
1979 | 1979 | $datetime = new DateTime(); |
@@ -2000,8 +2000,8 @@ discard block |
||
2000 | 2000 | if ($limit != "") |
2001 | 2001 | { |
2002 | 2002 | $limit_array = explode(",", $limit); |
2003 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
2004 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
2003 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
2004 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
2005 | 2005 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
2006 | 2006 | { |
2007 | 2007 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -2019,28 +2019,28 @@ discard block |
||
2019 | 2019 | } |
2020 | 2020 | } |
2021 | 2021 | if ($origLat != "" && $origLon != "" && $dist != "") { |
2022 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
2022 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
2023 | 2023 | if ($globalDBdriver == 'mysql') { |
2024 | - $query="SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
2024 | + $query = "SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
2025 | 2025 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND marine_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and marine_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
2026 | 2026 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; |
2027 | 2027 | } else { |
2028 | - $query="SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
2028 | + $query = "SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
2029 | 2029 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
2030 | 2030 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query; |
2031 | 2031 | } |
2032 | 2032 | } else { |
2033 | - $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
2033 | + $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
2034 | 2034 | ".$additional_query." |
2035 | 2035 | ".$orderby_query; |
2036 | 2036 | } |
2037 | - $marine_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
2037 | + $marine_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
2038 | 2038 | return $marine_array; |
2039 | 2039 | } |
2040 | 2040 | |
2041 | 2041 | public function getOrderBy() |
2042 | 2042 | { |
2043 | - $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
2043 | + $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
2044 | 2044 | |
2045 | 2045 | return $orderby; |
2046 | 2046 |
@@ -8,15 +8,15 @@ discard block |
||
8 | 8 | die(); |
9 | 9 | } |
10 | 10 | |
11 | -$aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING); |
|
11 | +$aircraft_type = filter_input(INPUT_GET, 'aircraft_type', FILTER_SANITIZE_STRING); |
|
12 | 12 | |
13 | 13 | $Spotter = new Spotter(); |
14 | -$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type,"0,1",""); |
|
14 | +$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type, "0,1", ""); |
|
15 | 15 | |
16 | 16 | |
17 | 17 | if (!empty($spotter_array)) |
18 | 18 | { |
19 | - $title = sprintf(_("Most Common Time of Day from %s (%s)"),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']); |
|
19 | + $title = sprintf(_("Most Common Time of Day from %s (%s)"), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']); |
|
20 | 20 | require_once('header.php'); |
21 | 21 | print '<div class="select-item">'; |
22 | 22 | print '<form action="'.$globalURL.'/aircraft" method="get">'; |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | $Stats = new Stats(); |
26 | 26 | $aircraft_types = $Stats->getAllAircraftTypes(); |
27 | 27 | if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
28 | - foreach($aircraft_types as $aircrafttype) |
|
28 | + foreach ($aircraft_types as $aircrafttype) |
|
29 | 29 | { |
30 | - if($aircraft_type == $aircrafttype['aircraft_icao']) |
|
30 | + if ($aircraft_type == $aircrafttype['aircraft_icao']) |
|
31 | 31 | { |
32 | 32 | print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
33 | 33 | } else { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | include('aircraft-sub-menu.php'); |
54 | 54 | print '<div class="column">'; |
55 | 55 | print '<h2>'._("Most Common Time of Day").'</h2>'; |
56 | - print '<p>'.sprintf(_("The statistic below shows the most common time of day from <strong>%s</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>'; |
|
56 | + print '<p>'.sprintf(_("The statistic below shows the most common time of day from <strong>%s</strong>."), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']).'</p>'; |
|
57 | 57 | |
58 | 58 | $hour_array = $Spotter->countAllHoursByAircraft($aircraft_type); |
59 | 59 | print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">'; |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | $hour_data = ''; |
64 | 64 | $hour_cnt = ''; |
65 | 65 | $last = 0; |
66 | - foreach($hour_array as $hour_item) |
|
66 | + foreach ($hour_array as $hour_item) |
|
67 | 67 | { |
68 | - while($last != $hour_item['hour_name']) { |
|
68 | + while ($last != $hour_item['hour_name']) { |
|
69 | 69 | $hour_data .= '"'.$last.':00",'; |
70 | 70 | $hour_cnt .= '0,'; |
71 | 71 | $last++; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $hour_cnt .= $hour_item['hour_count'].','; |
76 | 76 | } |
77 | 77 | $hour_data = "[".substr($hour_data, 0, -1)."]"; |
78 | - $hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]"; |
|
78 | + $hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]"; |
|
79 | 79 | print 'c3.generate({ |
80 | 80 | bindto: "#chartHour", |
81 | 81 | data: { |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | print '</thead>'; |
99 | 99 | print '<tbody>'; |
100 | 100 | $i = 1; |
101 | - foreach($hour_array as $hour_item) |
|
101 | + foreach ($hour_array as $hour_item) |
|
102 | 102 | { |
103 | 103 | print '<tr>'; |
104 | 104 | print '<td>'.$hour_item['hour_name'].':00</td>'; |
@@ -9,15 +9,15 @@ discard block |
||
9 | 9 | die(); |
10 | 10 | } |
11 | 11 | |
12 | -$aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING); |
|
12 | +$aircraft_type = filter_input(INPUT_GET, 'aircraft_type', FILTER_SANITIZE_STRING); |
|
13 | 13 | |
14 | 14 | $Spotter = new Spotter(); |
15 | -$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type,"0,1",""); |
|
15 | +$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type, "0,1", ""); |
|
16 | 16 | |
17 | 17 | |
18 | 18 | if (!empty($spotter_array)) |
19 | 19 | { |
20 | - $title = sprintf(_("Most Common Arrival Airports for %s (%s)"),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']); |
|
20 | + $title = sprintf(_("Most Common Arrival Airports for %s (%s)"), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']); |
|
21 | 21 | require_once('header.php'); |
22 | 22 | print '<div class="select-item">'; |
23 | 23 | print '<form action="'.$globalURL.'/aircraft" method="get">'; |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | $Stats = new Stats(); |
27 | 27 | $aircraft_types = $Stats->getAllAircraftTypes(); |
28 | 28 | if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
29 | - foreach($aircraft_types as $aircrafttype) |
|
29 | + foreach ($aircraft_types as $aircrafttype) |
|
30 | 30 | { |
31 | - if($aircraft_type == $aircrafttype['aircraft_icao']) |
|
31 | + if ($aircraft_type == $aircrafttype['aircraft_icao']) |
|
32 | 32 | { |
33 | 33 | print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
34 | 34 | } else { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | include('aircraft-sub-menu.php'); |
56 | 56 | print '<div class="column">'; |
57 | 57 | print '<h2>'._("Most Common Arrival Airports").'</h2>'; |
58 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights from <strong>%s (%s)</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>'; |
|
58 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights from <strong>%s (%s)</strong>."), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']).'</p>'; |
|
59 | 59 | $airport_airport_array = $Spotter->countAllArrivalAirportsByAircraft($aircraft_type); |
60 | 60 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
61 | 61 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | print '<script>'; |
65 | 65 | print 'var series = ['; |
66 | 66 | $airport_data = ''; |
67 | - foreach($airport_airport_array as $airport_item) |
|
67 | + foreach ($airport_airport_array as $airport_item) |
|
68 | 68 | { |
69 | 69 | $airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_name'].' ('.$airport_item['airport_arrival_icao'].')",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],'; |
70 | 70 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | print '</thead>'; |
120 | 120 | print '<tbody>'; |
121 | 121 | $i = 1; |
122 | - foreach($airport_airport_array as $airport_item) |
|
122 | + foreach ($airport_airport_array as $airport_item) |
|
123 | 123 | { |
124 | 124 | print '<tr>'; |
125 | 125 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -7,14 +7,14 @@ discard block |
||
7 | 7 | header('Location: '.$globalURL.'/aircraft'); |
8 | 8 | die(); |
9 | 9 | } |
10 | -$aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING); |
|
10 | +$aircraft_type = filter_input(INPUT_GET, 'aircraft_type', FILTER_SANITIZE_STRING); |
|
11 | 11 | $Spotter = new Spotter(); |
12 | -$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type,"0,1",""); |
|
12 | +$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type, "0,1", ""); |
|
13 | 13 | |
14 | 14 | |
15 | 15 | if (!empty($spotter_array)) |
16 | 16 | { |
17 | - $title = sprintf(_("Most Common Departure Airports by Country for %s (%s)"),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']); |
|
17 | + $title = sprintf(_("Most Common Departure Airports by Country for %s (%s)"), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']); |
|
18 | 18 | require_once('header.php'); |
19 | 19 | print '<div class="select-item">'; |
20 | 20 | print '<form action="'.$globalURL.'/aircraft" method="get">'; |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | $Stats = new Stats(); |
24 | 24 | $aircraft_types = $Stats->getAllAircraftTypes(); |
25 | 25 | if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
26 | - foreach($aircraft_types as $aircrafttype) |
|
26 | + foreach ($aircraft_types as $aircrafttype) |
|
27 | 27 | { |
28 | - if($aircraft_type == $aircrafttype['aircraft_icao']) |
|
28 | + if ($aircraft_type == $aircrafttype['aircraft_icao']) |
|
29 | 29 | { |
30 | 30 | print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
31 | 31 | } else { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | include('aircraft-sub-menu.php'); |
52 | 52 | print '<div class="column">'; |
53 | 53 | print '<h2>'._("Most Common Departure Airports by Country").'</h2>'; |
54 | - print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights from <strong>%s (%s)</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>'; |
|
54 | + print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights from <strong>%s (%s)</strong>."), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']).'</p>'; |
|
55 | 55 | $airport_country_array = $Spotter->countAllDepartureAirportCountriesByAircraft($aircraft_type); |
56 | 56 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
57 | 57 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
60 | 60 | print 'var series = ['; |
61 | 61 | $country_data = ''; |
62 | - foreach($airport_country_array as $airport_item) |
|
62 | + foreach ($airport_country_array as $airport_item) |
|
63 | 63 | { |
64 | 64 | $country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],'; |
65 | 65 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | print '</thead>'; |
108 | 108 | print '<tbody>'; |
109 | 109 | $i = 1; |
110 | - foreach($airport_country_array as $airport_item) |
|
110 | + foreach ($airport_country_array as $airport_item) |
|
111 | 111 | { |
112 | 112 | print '<tr>'; |
113 | 113 | print '<td><strong>'.$i.'</strong></td>'; |