@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Image.php'); |
10 | 10 | $global_marine_query = "SELECT marine_output.* FROM marine_output"; |
11 | 11 | |
12 | -class Marine{ |
|
12 | +class Marine { |
|
13 | 13 | public $db; |
14 | 14 | |
15 | 15 | public function __construct($dbc = null) { |
@@ -24,33 +24,33 @@ discard block |
||
24 | 24 | * @return Array the SQL part |
25 | 25 | */ |
26 | 26 | |
27 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
27 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
28 | 28 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
29 | 29 | $filters = array(); |
30 | 30 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
31 | 31 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
32 | 32 | $filters = $globalStatsFilters[$globalFilterName]; |
33 | 33 | } else { |
34 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
34 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | if (isset($filter[0]['source'])) { |
38 | - $filters = array_merge($filters,$filter); |
|
38 | + $filters = array_merge($filters, $filter); |
|
39 | 39 | } |
40 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
40 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
41 | 41 | $filter_query_join = ''; |
42 | 42 | $filter_query_where = ''; |
43 | - foreach($filters as $flt) { |
|
43 | + foreach ($filters as $flt) { |
|
44 | 44 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
45 | 45 | if (isset($flt['source'])) { |
46 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
46 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
47 | 47 | } else { |
48 | - $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"; |
|
48 | + $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"; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | } |
52 | 52 | if (isset($filter['source']) && !empty($filter['source'])) { |
53 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
53 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
54 | 54 | } |
55 | 55 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
56 | 56 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
89 | 89 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
90 | 90 | if ($filter_query_where != '') { |
91 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
91 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
92 | 92 | } |
93 | 93 | $filter_query = $filter_query_join.$filter_query_where; |
94 | 94 | return $filter_query; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @return Array the spotter information |
104 | 104 | * |
105 | 105 | */ |
106 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
106 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
107 | 107 | { |
108 | 108 | global $globalVM; |
109 | 109 | date_default_timezone_set('UTC'); |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | $sth = $this->db->prepare($query.$limitQuery); |
125 | 125 | $sth->execute($params); |
126 | 126 | } catch (PDOException $e) { |
127 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
127 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
128 | 128 | exit(); |
129 | 129 | } |
130 | 130 | |
131 | 131 | $num_rows = 0; |
132 | 132 | $spotter_array = array(); |
133 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
133 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
134 | 134 | { |
135 | 135 | $num_rows++; |
136 | 136 | $temp_array = array(); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | } |
150 | 150 | if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
151 | 151 | if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
152 | - if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES); |
|
152 | + if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'], ENT_QUOTES); |
|
153 | 153 | if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
154 | 154 | if (isset($row['status'])) $temp_array['status'] = $row['status']; |
155 | 155 | if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id']; |
@@ -172,10 +172,10 @@ discard block |
||
172 | 172 | } |
173 | 173 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
174 | 174 | |
175 | - if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
175 | + if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
176 | 176 | { |
177 | 177 | $Image = new Image($this->db); |
178 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
178 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
179 | 179 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
180 | 180 | unset($Image); |
181 | 181 | if (count($image_array) > 0) { |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | $temp_array['image_source_website'] = $image_array[0]['image_source_website']; |
186 | 186 | $temp_array['image_copyright'] = $image_array[0]['image_copyright']; |
187 | 187 | } |
188 | - } elseif(isset($temp_array['type']) && $temp_array['type'] != "") |
|
188 | + } elseif (isset($temp_array['type']) && $temp_array['type'] != "") |
|
189 | 189 | { |
190 | 190 | $Image = new Image($this->db); |
191 | - $image_array = $Image->getMarineImage('','','',$temp_array['type']); |
|
191 | + $image_array = $Image->getMarineImage('', '', '', $temp_array['type']); |
|
192 | 192 | unset($Image); |
193 | 193 | if (count($image_array) > 0) { |
194 | 194 | $temp_array['image'] = $image_array[0]['image']; |
@@ -223,17 +223,17 @@ discard block |
||
223 | 223 | { |
224 | 224 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
225 | 225 | } else { |
226 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
226 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
227 | 227 | } |
228 | 228 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
229 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
230 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
229 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
230 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
231 | 231 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
232 | 232 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
233 | 233 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
234 | 234 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
235 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
236 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
235 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
236 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
237 | 237 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
238 | 238 | } |
239 | 239 | } |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | if ($limit != "") |
267 | 267 | { |
268 | 268 | $limit_array = explode(",", $limit); |
269 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
270 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
269 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
270 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
271 | 271 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
272 | 272 | { |
273 | 273 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | } else { |
282 | 282 | $orderby_query = " ORDER BY marine_output.date DESC"; |
283 | 283 | } |
284 | - $query = $global_marine_query.$filter_query." ".$orderby_query; |
|
285 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
284 | + $query = $global_marine_query.$filter_query." ".$orderby_query; |
|
285 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
286 | 286 | return $spotter_array; |
287 | 287 | } |
288 | 288 | |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | if ($id == '') return array(); |
301 | 301 | $additional_query = "marine_output.fammarine_id = :id"; |
302 | 302 | $query_values = array(':id' => $id); |
303 | - $query = $global_marine_query." WHERE ".$additional_query." "; |
|
304 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
303 | + $query = $global_marine_query." WHERE ".$additional_query." "; |
|
304 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
305 | 305 | return $spotter_array; |
306 | 306 | } |
307 | 307 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $query_values = array(); |
321 | 321 | $limit_query = ''; |
322 | 322 | $additional_query = ''; |
323 | - $filter_query = $this->getFilter($filter,true,true); |
|
323 | + $filter_query = $this->getFilter($filter, true, true); |
|
324 | 324 | if ($ident != "") |
325 | 325 | { |
326 | 326 | if (!is_string($ident)) |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | { |
337 | 337 | $limit_array = explode(",", $limit); |
338 | 338 | |
339 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
340 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
339 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
340 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
341 | 341 | |
342 | 342 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
343 | 343 | { |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | $query_values = array(); |
377 | 377 | $limit_query = ''; |
378 | 378 | $additional_query = ''; |
379 | - $filter_query = $this->getFilter($filter,true,true); |
|
379 | + $filter_query = $this->getFilter($filter, true, true); |
|
380 | 380 | if (!is_string($type)) |
381 | 381 | { |
382 | 382 | return false; |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | { |
390 | 390 | $limit_array = explode(",", $limit); |
391 | 391 | |
392 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
393 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
392 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
393 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
394 | 394 | |
395 | 395 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
396 | 396 | { |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | return $spotter_array; |
415 | 415 | } |
416 | 416 | |
417 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
417 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
418 | 418 | { |
419 | 419 | global $global_marine_query, $globalTimezone, $globalDBdriver; |
420 | 420 | |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $limit_query = ''; |
423 | 423 | $additional_query = ''; |
424 | 424 | |
425 | - $filter_query = $this->getFilter($filter,true,true); |
|
425 | + $filter_query = $this->getFilter($filter, true, true); |
|
426 | 426 | |
427 | 427 | if ($date != "") |
428 | 428 | { |
@@ -448,8 +448,8 @@ discard block |
||
448 | 448 | { |
449 | 449 | $limit_array = explode(",", $limit); |
450 | 450 | |
451 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
452 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
451 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
452 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
453 | 453 | |
454 | 454 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
455 | 455 | { |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | $query_values = array(); |
485 | 485 | $limit_query = ''; |
486 | 486 | $additional_query = ''; |
487 | - $filter_query = $this->getFilter($filter,true,true); |
|
488 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
487 | + $filter_query = $this->getFilter($filter, true, true); |
|
488 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
489 | 489 | if ($captain != "") |
490 | 490 | { |
491 | 491 | $additional_query = " AND (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)"; |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | if ($limit != "") |
495 | 495 | { |
496 | 496 | $limit_array = explode(",", $limit); |
497 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
498 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
497 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
498 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
499 | 499 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
500 | 500 | { |
501 | 501 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -522,13 +522,13 @@ discard block |
||
522 | 522 | */ |
523 | 523 | public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array()) |
524 | 524 | { |
525 | - global $global_marine_query,$globalDBdriver; |
|
525 | + global $global_marine_query, $globalDBdriver; |
|
526 | 526 | date_default_timezone_set('UTC'); |
527 | 527 | $query_values = array(); |
528 | 528 | $limit_query = ''; |
529 | 529 | $additional_query = ''; |
530 | - $filter_query = $this->getFilter($filter,true,true); |
|
531 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
530 | + $filter_query = $this->getFilter($filter, true, true); |
|
531 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
532 | 532 | if ($race != "") |
533 | 533 | { |
534 | 534 | $additional_query = " AND (marine_output.race_name = :race OR marine_output.race_id = :race)"; |
@@ -537,8 +537,8 @@ discard block |
||
537 | 537 | if ($limit != "") |
538 | 538 | { |
539 | 539 | $limit_array = explode(",", $limit); |
540 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
541 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
540 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
541 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
542 | 542 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
543 | 543 | { |
544 | 544 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -567,14 +567,14 @@ discard block |
||
567 | 567 | * @return String Duration of all races |
568 | 568 | * |
569 | 569 | */ |
570 | - public function countRacesByCaptain($captain,$filters = array()) |
|
570 | + public function countRacesByCaptain($captain, $filters = array()) |
|
571 | 571 | { |
572 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
573 | - $filter_query = $this->getFilter($filters,true,true); |
|
574 | - $query = "SELECT COUNT(*) AS nb |
|
572 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
573 | + $filter_query = $this->getFilter($filters, true, true); |
|
574 | + $query = "SELECT COUNT(*) AS nb |
|
575 | 575 | FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)"; |
576 | 576 | $query_values = array(); |
577 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
577 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
578 | 578 | $sth = $this->db->prepare($query); |
579 | 579 | $sth->execute($query_values); |
580 | 580 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -587,14 +587,14 @@ discard block |
||
587 | 587 | * @return String Duration of all races |
588 | 588 | * |
589 | 589 | */ |
590 | - public function countCaptainsByRace($race,$filters = array()) |
|
590 | + public function countCaptainsByRace($race, $filters = array()) |
|
591 | 591 | { |
592 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
593 | - $filter_query = $this->getFilter($filters,true,true); |
|
594 | - $query = "SELECT COUNT(*) AS nb |
|
592 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
593 | + $filter_query = $this->getFilter($filters, true, true); |
|
594 | + $query = "SELECT COUNT(*) AS nb |
|
595 | 595 | FROM marine_output".$filter_query." (marine_output.race_name = :race OR marine_output.race_id = :race)"; |
596 | 596 | $query_values = array(); |
597 | - $query_values = array_merge($query_values,array(':race' => $race)); |
|
597 | + $query_values = array_merge($query_values, array(':race' => $race)); |
|
598 | 598 | $sth = $this->db->prepare($query); |
599 | 599 | $sth->execute($query_values); |
600 | 600 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -607,44 +607,44 @@ discard block |
||
607 | 607 | * @return Array the boat list |
608 | 608 | * |
609 | 609 | */ |
610 | - public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
|
610 | + public function countAllBoatTypesByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '') |
|
611 | 611 | { |
612 | 612 | global $globalDBdriver; |
613 | - $filter_query = $this->getFilter($filters,true,true); |
|
614 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
615 | - $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
613 | + $filter_query = $this->getFilter($filters, true, true); |
|
614 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
615 | + $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
616 | 616 | FROM marine_output".$filter_query." (marine_output.captain_id = :captain OR marine_output.captain_name = :captain)"; |
617 | 617 | $query_values = array(); |
618 | 618 | if ($year != '') { |
619 | 619 | if ($globalDBdriver == 'mysql') { |
620 | 620 | $query .= " AND YEAR(marine_output.date) = :year"; |
621 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
621 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
622 | 622 | } else { |
623 | 623 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
624 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
624 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
625 | 625 | } |
626 | 626 | } |
627 | 627 | if ($month != '') { |
628 | 628 | if ($globalDBdriver == 'mysql') { |
629 | 629 | $query .= " AND MONTH(marine_output.date) = :month"; |
630 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
630 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
631 | 631 | } else { |
632 | 632 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
633 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
633 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
634 | 634 | } |
635 | 635 | } |
636 | 636 | if ($day != '') { |
637 | 637 | if ($globalDBdriver == 'mysql') { |
638 | 638 | $query .= " AND DAY(marine_output.date) = :day"; |
639 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
639 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
640 | 640 | } else { |
641 | 641 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
642 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
642 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
643 | 643 | } |
644 | 644 | } |
645 | 645 | $query .= " GROUP BY marine_output.type |
646 | 646 | ORDER BY type_count DESC"; |
647 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
647 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
648 | 648 | $sth = $this->db->prepare($query); |
649 | 649 | $sth->execute($query_values); |
650 | 650 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -656,44 +656,44 @@ discard block |
||
656 | 656 | * @return Array the boat list |
657 | 657 | * |
658 | 658 | */ |
659 | - public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '') |
|
659 | + public function countAllBoatTypesByRace($race, $filters = array(), $year = '', $month = '', $day = '') |
|
660 | 660 | { |
661 | 661 | global $globalDBdriver; |
662 | - $filter_query = $this->getFilter($filters,true,true); |
|
663 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
664 | - $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
662 | + $filter_query = $this->getFilter($filters, true, true); |
|
663 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
664 | + $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
665 | 665 | FROM marine_output".$filter_query." (marine_output.race_id = :race OR marine_output.race_name = :race)"; |
666 | 666 | $query_values = array(); |
667 | 667 | if ($year != '') { |
668 | 668 | if ($globalDBdriver == 'mysql') { |
669 | 669 | $query .= " AND YEAR(marine_output.date) = :year"; |
670 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
670 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
671 | 671 | } else { |
672 | 672 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
673 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
673 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | if ($month != '') { |
677 | 677 | if ($globalDBdriver == 'mysql') { |
678 | 678 | $query .= " AND MONTH(marine_output.date) = :month"; |
679 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
679 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
680 | 680 | } else { |
681 | 681 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
682 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
682 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
683 | 683 | } |
684 | 684 | } |
685 | 685 | if ($day != '') { |
686 | 686 | if ($globalDBdriver == 'mysql') { |
687 | 687 | $query .= " AND DAY(marine_output.date) = :day"; |
688 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
688 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
689 | 689 | } else { |
690 | 690 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
691 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
691 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
692 | 692 | } |
693 | 693 | } |
694 | 694 | $query .= " GROUP BY marine_output.type |
695 | 695 | ORDER BY type_count DESC"; |
696 | - $query_values = array_merge($query_values,array(':race' => $race)); |
|
696 | + $query_values = array_merge($query_values, array(':race' => $race)); |
|
697 | 697 | $sth = $this->db->prepare($query); |
698 | 698 | $sth->execute($query_values); |
699 | 699 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -705,47 +705,47 @@ discard block |
||
705 | 705 | * @return String Duration of all race |
706 | 706 | * |
707 | 707 | */ |
708 | - public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
|
708 | + public function getRaceDurationByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '') |
|
709 | 709 | { |
710 | 710 | global $globalDBdriver; |
711 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
712 | - $filter_query = $this->getFilter($filters,true,true); |
|
713 | - $query = "SELECT SUM(last_seen - date) AS duration |
|
711 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
712 | + $filter_query = $this->getFilter($filters, true, true); |
|
713 | + $query = "SELECT SUM(last_seen - date) AS duration |
|
714 | 714 | FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain) |
715 | 715 | AND last_seen > date"; |
716 | 716 | $query_values = array(); |
717 | 717 | if ($year != '') { |
718 | 718 | if ($globalDBdriver == 'mysql') { |
719 | 719 | $query .= " AND YEAR(marine_output.date) = :year"; |
720 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
720 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
721 | 721 | } else { |
722 | 722 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
723 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
723 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
724 | 724 | } |
725 | 725 | } |
726 | 726 | if ($month != '') { |
727 | 727 | if ($globalDBdriver == 'mysql') { |
728 | 728 | $query .= " AND MONTH(marine_output.date) = :month"; |
729 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
729 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
730 | 730 | } else { |
731 | 731 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
732 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
732 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
733 | 733 | } |
734 | 734 | } |
735 | 735 | if ($day != '') { |
736 | 736 | if ($globalDBdriver == 'mysql') { |
737 | 737 | $query .= " AND DAY(marine_output.date) = :day"; |
738 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
738 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
739 | 739 | } else { |
740 | 740 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
741 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
741 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
742 | 742 | } |
743 | 743 | } |
744 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
744 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
745 | 745 | $sth = $this->db->prepare($query); |
746 | 746 | $sth->execute($query_values); |
747 | 747 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
748 | - if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
748 | + if (is_int($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']); |
|
749 | 749 | else return $result[0]['duration']; |
750 | 750 | } |
751 | 751 | |
@@ -757,8 +757,8 @@ discard block |
||
757 | 757 | */ |
758 | 758 | public function getAllCaptainNames($filters = array()) |
759 | 759 | { |
760 | - $filter_query = $this->getFilter($filters,true,true); |
|
761 | - $query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id |
|
760 | + $filter_query = $this->getFilter($filters, true, true); |
|
761 | + $query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id |
|
762 | 762 | FROM marine_output".$filter_query." marine_output.captain_name <> '' |
763 | 763 | ORDER BY marine_output.captain_name ASC"; |
764 | 764 | |
@@ -775,8 +775,8 @@ discard block |
||
775 | 775 | */ |
776 | 776 | public function getAllRaceNames($filters = array()) |
777 | 777 | { |
778 | - $filter_query = $this->getFilter($filters,true,true); |
|
779 | - $query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id |
|
778 | + $filter_query = $this->getFilter($filters, true, true); |
|
779 | + $query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id |
|
780 | 780 | FROM marine_output".$filter_query." marine_output.race_name <> '' |
781 | 781 | ORDER BY marine_output.race_name ASC"; |
782 | 782 | |
@@ -793,11 +793,11 @@ discard block |
||
793 | 793 | * @return Array list of source name |
794 | 794 | * |
795 | 795 | */ |
796 | - public function getAllSourceName($type = '',$filters = array()) |
|
796 | + public function getAllSourceName($type = '', $filters = array()) |
|
797 | 797 | { |
798 | - $filter_query = $this->getFilter($filters,true,true); |
|
798 | + $filter_query = $this->getFilter($filters, true, true); |
|
799 | 799 | $query_values = array(); |
800 | - $query = "SELECT DISTINCT marine_output.source_name |
|
800 | + $query = "SELECT DISTINCT marine_output.source_name |
|
801 | 801 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
802 | 802 | if ($type != '') { |
803 | 803 | $query_values = array(':type' => $type); |
@@ -812,7 +812,7 @@ discard block |
||
812 | 812 | $source_array = array(); |
813 | 813 | $temp_array = array(); |
814 | 814 | |
815 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
815 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
816 | 816 | { |
817 | 817 | $temp_array['source_name'] = $row['source_name']; |
818 | 818 | $source_array[] = $temp_array; |
@@ -829,8 +829,8 @@ discard block |
||
829 | 829 | */ |
830 | 830 | public function getAllIdents($filters = array()) |
831 | 831 | { |
832 | - $filter_query = $this->getFilter($filters,true,true); |
|
833 | - $query = "SELECT DISTINCT marine_output.ident |
|
832 | + $filter_query = $this->getFilter($filters, true, true); |
|
833 | + $query = "SELECT DISTINCT marine_output.ident |
|
834 | 834 | FROM marine_output".$filter_query." marine_output.ident <> '' |
835 | 835 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
836 | 836 | |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | $ident_array = array(); |
841 | 841 | $temp_array = array(); |
842 | 842 | |
843 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
843 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
844 | 844 | { |
845 | 845 | $temp_array['ident'] = $row['ident']; |
846 | 846 | $ident_array[] = $temp_array; |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | */ |
858 | 858 | public function getIdentity($mmsi) |
859 | 859 | { |
860 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
860 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
861 | 861 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
862 | 862 | $sth = $this->db->prepare($query); |
863 | 863 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -870,23 +870,23 @@ discard block |
||
870 | 870 | * Add identity |
871 | 871 | * |
872 | 872 | */ |
873 | - public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
|
873 | + public function addIdentity($mmsi, $imo, $ident, $callsign, $type) |
|
874 | 874 | { |
875 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
875 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
876 | 876 | if ($mmsi != '') { |
877 | - $imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT); |
|
878 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
879 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
880 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
877 | + $imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT); |
|
878 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
879 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
880 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
881 | 881 | $identinfo = $this->getIdentity($mmsi); |
882 | 882 | if (empty($identinfo)) { |
883 | - $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
883 | + $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
884 | 884 | $sth = $this->db->prepare($query); |
885 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type)); |
|
885 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type)); |
|
886 | 886 | } elseif ($ident != '' && $identinfo['ship_name'] != $ident) { |
887 | - $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
887 | + $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
888 | 888 | $sth = $this->db->prepare($query); |
889 | - $sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type)); |
|
889 | + $sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type)); |
|
890 | 890 | } |
891 | 891 | } |
892 | 892 | } |
@@ -907,12 +907,12 @@ discard block |
||
907 | 907 | } else $offset = '+00:00'; |
908 | 908 | |
909 | 909 | if ($globalDBdriver == 'mysql') { |
910 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
910 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
911 | 911 | FROM marine_output |
912 | 912 | WHERE marine_output.date <> '' |
913 | 913 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
914 | 914 | } else { |
915 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
915 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
916 | 916 | FROM marine_output |
917 | 917 | WHERE marine_output.date <> '' |
918 | 918 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | $date_array = array(); |
925 | 925 | $temp_array = array(); |
926 | 926 | |
927 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
927 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
928 | 928 | { |
929 | 929 | $temp_array['date'] = $row['date']; |
930 | 930 | |
@@ -942,10 +942,10 @@ discard block |
||
942 | 942 | * @return String success or false |
943 | 943 | * |
944 | 944 | */ |
945 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
945 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
946 | 946 | { |
947 | 947 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
948 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
948 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
949 | 949 | try { |
950 | 950 | $sth = $this->db->prepare($query); |
951 | 951 | $sth->execute($query_values); |
@@ -963,10 +963,10 @@ discard block |
||
963 | 963 | * @return String success or false |
964 | 964 | * |
965 | 965 | */ |
966 | - public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
|
966 | + public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL) |
|
967 | 967 | { |
968 | 968 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
969 | - $query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code); |
|
969 | + $query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code); |
|
970 | 970 | try { |
971 | 971 | $sth = $this->db->prepare($query); |
972 | 972 | $sth->execute($query_values); |
@@ -985,11 +985,11 @@ discard block |
||
985 | 985 | * @return String success or false |
986 | 986 | * |
987 | 987 | */ |
988 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
988 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
989 | 989 | { |
990 | 990 | |
991 | 991 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
992 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
992 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
993 | 993 | |
994 | 994 | try { |
995 | 995 | $sth = $this->db->prepare($query); |
@@ -1009,17 +1009,17 @@ discard block |
||
1009 | 1009 | * @return String success or false |
1010 | 1010 | * |
1011 | 1011 | */ |
1012 | - public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
|
1012 | + public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '', $distance = NULL, $race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
|
1013 | 1013 | { |
1014 | 1014 | if ($latitude == '') $latitude = NULL; |
1015 | 1015 | if ($longitude == '') $longitude = NULL; |
1016 | 1016 | $groundspeed = round($groundspeed); |
1017 | 1017 | if ($race_begin != '') { |
1018 | 1018 | $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, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status, date = :race_begin WHERE fammarine_id = :fammarine_id'; |
1019 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time,':status' => $status,':race_begin' => $race_begin); |
|
1019 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time, ':status' => $status, ':race_begin' => $race_begin); |
|
1020 | 1020 | } else { |
1021 | 1021 | $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, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status WHERE fammarine_id = :fammarine_id'; |
1022 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time,':status' => $status); |
|
1022 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time, ':status' => $status); |
|
1023 | 1023 | } |
1024 | 1024 | try { |
1025 | 1025 | $sth = $this->db->prepare($query); |
@@ -1058,7 +1058,7 @@ discard block |
||
1058 | 1058 | * @param String $verticalrate vertival rate of flight |
1059 | 1059 | * @return String success or false |
1060 | 1060 | */ |
1061 | - 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 = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '') |
|
1061 | + 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 = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') |
|
1062 | 1062 | { |
1063 | 1063 | global $globalURL, $globalMarineImageFetch; |
1064 | 1064 | |
@@ -1130,34 +1130,34 @@ discard block |
||
1130 | 1130 | $date = date("Y-m-d H:i:s", time()); |
1131 | 1131 | } |
1132 | 1132 | |
1133 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
1134 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1135 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1136 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1137 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
1138 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1139 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
1140 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
1141 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
1142 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
1143 | - $type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
1144 | - $status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
1145 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
1146 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
1147 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
1148 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
1149 | - $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
1150 | - $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
1151 | - $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
1152 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
1153 | - $race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT); |
|
1154 | - $race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1155 | - $distance = filter_var($distance,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1133 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
1134 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1135 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1136 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1137 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
1138 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1139 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
1140 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
1141 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
1142 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
1143 | + $type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
1144 | + $status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
1145 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
1146 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
1147 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
1148 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
1149 | + $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
1150 | + $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
1151 | + $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
1152 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
1153 | + $race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT); |
|
1154 | + $race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1155 | + $distance = filter_var($distance, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1156 | 1156 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
1157 | 1157 | $Image = new Image($this->db); |
1158 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
1158 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
1159 | 1159 | if (!isset($image_array[0]['mmsi'])) { |
1160 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
1160 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
1161 | 1161 | } |
1162 | 1162 | unset($Image); |
1163 | 1163 | } |
@@ -1173,10 +1173,10 @@ discard block |
||
1173 | 1173 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
1174 | 1174 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
1175 | 1175 | if ($arrival_date == '') $arrival_date = NULL; |
1176 | - $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,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
|
1176 | + $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,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
|
1177 | 1177 | 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,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)"; |
1178 | 1178 | |
1179 | - $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,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
1179 | + $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, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time); |
|
1180 | 1180 | try { |
1181 | 1181 | $sth = $this->db->prepare($query); |
1182 | 1182 | $sth->execute($query_values); |
@@ -1200,13 +1200,13 @@ discard block |
||
1200 | 1200 | { |
1201 | 1201 | global $globalDBdriver, $globalTimezone; |
1202 | 1202 | if ($globalDBdriver == 'mysql') { |
1203 | - $query = "SELECT marine_output.ident FROM marine_output |
|
1203 | + $query = "SELECT marine_output.ident FROM marine_output |
|
1204 | 1204 | WHERE marine_output.ident = :ident |
1205 | 1205 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
1206 | 1206 | AND marine_output.date < UTC_TIMESTAMP()"; |
1207 | 1207 | $query_data = array(':ident' => $ident); |
1208 | 1208 | } else { |
1209 | - $query = "SELECT marine_output.ident FROM marine_output |
|
1209 | + $query = "SELECT marine_output.ident FROM marine_output |
|
1210 | 1210 | WHERE marine_output.ident = :ident |
1211 | 1211 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
1212 | 1212 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -1215,8 +1215,8 @@ discard block |
||
1215 | 1215 | |
1216 | 1216 | $sth = $this->db->prepare($query); |
1217 | 1217 | $sth->execute($query_data); |
1218 | - $ident_result=''; |
|
1219 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1218 | + $ident_result = ''; |
|
1219 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1220 | 1220 | { |
1221 | 1221 | $ident_result = $row['ident']; |
1222 | 1222 | } |
@@ -1242,8 +1242,8 @@ discard block |
||
1242 | 1242 | return false; |
1243 | 1243 | } else { |
1244 | 1244 | $q_array = explode(" ", $q); |
1245 | - foreach ($q_array as $q_item){ |
|
1246 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
1245 | + foreach ($q_array as $q_item) { |
|
1246 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
1247 | 1247 | $additional_query .= " AND ("; |
1248 | 1248 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
1249 | 1249 | $additional_query .= ")"; |
@@ -1251,11 +1251,11 @@ discard block |
||
1251 | 1251 | } |
1252 | 1252 | } |
1253 | 1253 | if ($globalDBdriver == 'mysql') { |
1254 | - $query = "SELECT marine_output.* FROM marine_output |
|
1254 | + $query = "SELECT marine_output.* FROM marine_output |
|
1255 | 1255 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
1256 | 1256 | AND marine_output.date < UTC_TIMESTAMP()"; |
1257 | 1257 | } else { |
1258 | - $query = "SELECT marine_output.* FROM marine_output |
|
1258 | + $query = "SELECT marine_output.* FROM marine_output |
|
1259 | 1259 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
1260 | 1260 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
1261 | 1261 | } |
@@ -1274,16 +1274,16 @@ discard block |
||
1274 | 1274 | * |
1275 | 1275 | */ |
1276 | 1276 | |
1277 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
1277 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
1278 | 1278 | { |
1279 | 1279 | global $globalDBdriver, $globalArchive; |
1280 | 1280 | //$filter_query = $this->getFilter($filters,true,true); |
1281 | - $Connection= new Connection($this->db); |
|
1281 | + $Connection = new Connection($this->db); |
|
1282 | 1282 | if (!$Connection->tableExists('countries')) return array(); |
1283 | 1283 | require_once('class.SpotterLive.php'); |
1284 | 1284 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
1285 | 1285 | $MarineLive = new MarineLive($this->db); |
1286 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
1286 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
1287 | 1287 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
1288 | 1288 | if ($olderthanmonths > 0) { |
1289 | 1289 | if ($globalDBdriver == 'mysql') { |
@@ -1303,7 +1303,7 @@ discard block |
||
1303 | 1303 | } else { |
1304 | 1304 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
1305 | 1305 | $MarineArchive = new MarineArchive($this->db); |
1306 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
1306 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
1307 | 1307 | $filter_query .= " over_country <> ''"; |
1308 | 1308 | if ($olderthanmonths > 0) { |
1309 | 1309 | if ($globalDBdriver == 'mysql') { |
@@ -1331,7 +1331,7 @@ discard block |
||
1331 | 1331 | $flight_array = array(); |
1332 | 1332 | $temp_array = array(); |
1333 | 1333 | |
1334 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1334 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1335 | 1335 | { |
1336 | 1336 | $temp_array['marine_count'] = $row['nb']; |
1337 | 1337 | $temp_array['marine_country'] = $row['name']; |
@@ -1350,11 +1350,11 @@ discard block |
||
1350 | 1350 | * @return Array the callsign list |
1351 | 1351 | * |
1352 | 1352 | */ |
1353 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
1353 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1354 | 1354 | { |
1355 | 1355 | global $globalDBdriver; |
1356 | - $filter_query = $this->getFilter($filters,true,true); |
|
1357 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
1356 | + $filter_query = $this->getFilter($filters, true, true); |
|
1357 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
1358 | 1358 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
1359 | 1359 | if ($olderthanmonths > 0) { |
1360 | 1360 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -1368,28 +1368,28 @@ discard block |
||
1368 | 1368 | if ($year != '') { |
1369 | 1369 | if ($globalDBdriver == 'mysql') { |
1370 | 1370 | $query .= " AND YEAR(marine_output.date) = :year"; |
1371 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1371 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1372 | 1372 | } else { |
1373 | 1373 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1374 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1374 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1375 | 1375 | } |
1376 | 1376 | } |
1377 | 1377 | if ($month != '') { |
1378 | 1378 | if ($globalDBdriver == 'mysql') { |
1379 | 1379 | $query .= " AND MONTH(marine_output.date) = :month"; |
1380 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1380 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1381 | 1381 | } else { |
1382 | 1382 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1383 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1383 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1384 | 1384 | } |
1385 | 1385 | } |
1386 | 1386 | if ($day != '') { |
1387 | 1387 | if ($globalDBdriver == 'mysql') { |
1388 | 1388 | $query .= " AND DAY(marine_output.date) = :day"; |
1389 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1389 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1390 | 1390 | } else { |
1391 | 1391 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
1392 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1392 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1393 | 1393 | } |
1394 | 1394 | } |
1395 | 1395 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | $callsign_array = array(); |
1402 | 1402 | $temp_array = array(); |
1403 | 1403 | |
1404 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1404 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1405 | 1405 | { |
1406 | 1406 | $temp_array['callsign_icao'] = $row['ident']; |
1407 | 1407 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -1453,7 +1453,7 @@ discard block |
||
1453 | 1453 | $date_array = array(); |
1454 | 1454 | $temp_array = array(); |
1455 | 1455 | |
1456 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1456 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1457 | 1457 | { |
1458 | 1458 | $temp_array['date_name'] = $row['date_name']; |
1459 | 1459 | $temp_array['date_count'] = $row['date_count']; |
@@ -1479,7 +1479,7 @@ discard block |
||
1479 | 1479 | $datetime = new DateTime(); |
1480 | 1480 | $offset = $datetime->format('P'); |
1481 | 1481 | } else $offset = '+00:00'; |
1482 | - $filter_query = $this->getFilter($filters,true,true); |
|
1482 | + $filter_query = $this->getFilter($filters, true, true); |
|
1483 | 1483 | if ($globalDBdriver == 'mysql') { |
1484 | 1484 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1485 | 1485 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1500,7 +1500,7 @@ discard block |
||
1500 | 1500 | $date_array = array(); |
1501 | 1501 | $temp_array = array(); |
1502 | 1502 | |
1503 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1503 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1504 | 1504 | { |
1505 | 1505 | $temp_array['date_name'] = $row['date_name']; |
1506 | 1506 | $temp_array['date_count'] = $row['date_count']; |
@@ -1525,7 +1525,7 @@ discard block |
||
1525 | 1525 | $datetime = new DateTime(); |
1526 | 1526 | $offset = $datetime->format('P'); |
1527 | 1527 | } else $offset = '+00:00'; |
1528 | - $filter_query = $this->getFilter($filters,true,true); |
|
1528 | + $filter_query = $this->getFilter($filters, true, true); |
|
1529 | 1529 | if ($globalDBdriver == 'mysql') { |
1530 | 1530 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1531 | 1531 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1546,7 +1546,7 @@ discard block |
||
1546 | 1546 | $date_array = array(); |
1547 | 1547 | $temp_array = array(); |
1548 | 1548 | |
1549 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1549 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1550 | 1550 | { |
1551 | 1551 | $temp_array['date_name'] = $row['date_name']; |
1552 | 1552 | $temp_array['date_count'] = $row['date_count']; |
@@ -1593,7 +1593,7 @@ discard block |
||
1593 | 1593 | $date_array = array(); |
1594 | 1594 | $temp_array = array(); |
1595 | 1595 | |
1596 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1596 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1597 | 1597 | { |
1598 | 1598 | $temp_array['month_name'] = $row['month_name']; |
1599 | 1599 | $temp_array['year_name'] = $row['year_name']; |
@@ -1622,7 +1622,7 @@ discard block |
||
1622 | 1622 | $datetime = new DateTime(); |
1623 | 1623 | $offset = $datetime->format('P'); |
1624 | 1624 | } else $offset = '+00:00'; |
1625 | - $filter_query = $this->getFilter($filters,true,true); |
|
1625 | + $filter_query = $this->getFilter($filters, true, true); |
|
1626 | 1626 | if ($globalDBdriver == 'mysql') { |
1627 | 1627 | $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 |
1628 | 1628 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1643,7 +1643,7 @@ discard block |
||
1643 | 1643 | $date_array = array(); |
1644 | 1644 | $temp_array = array(); |
1645 | 1645 | |
1646 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1646 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1647 | 1647 | { |
1648 | 1648 | $temp_array['year_name'] = $row['year_name']; |
1649 | 1649 | $temp_array['month_name'] = $row['month_name']; |
@@ -1663,7 +1663,7 @@ discard block |
||
1663 | 1663 | * @return Array the hour list |
1664 | 1664 | * |
1665 | 1665 | */ |
1666 | - public function countAllHours($orderby,$filters = array()) |
|
1666 | + public function countAllHours($orderby, $filters = array()) |
|
1667 | 1667 | { |
1668 | 1668 | global $globalTimezone, $globalDBdriver; |
1669 | 1669 | if ($globalTimezone != '') { |
@@ -1711,7 +1711,7 @@ discard block |
||
1711 | 1711 | $hour_array = array(); |
1712 | 1712 | $temp_array = array(); |
1713 | 1713 | |
1714 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1714 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1715 | 1715 | { |
1716 | 1716 | $temp_array['hour_name'] = $row['hour_name']; |
1717 | 1717 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1733,8 +1733,8 @@ discard block |
||
1733 | 1733 | public function countAllHoursByDate($date, $filters = array()) |
1734 | 1734 | { |
1735 | 1735 | global $globalTimezone, $globalDBdriver; |
1736 | - $filter_query = $this->getFilter($filters,true,true); |
|
1737 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1736 | + $filter_query = $this->getFilter($filters, true, true); |
|
1737 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1738 | 1738 | if ($globalTimezone != '') { |
1739 | 1739 | date_default_timezone_set($globalTimezone); |
1740 | 1740 | $datetime = new DateTime($date); |
@@ -1742,12 +1742,12 @@ discard block |
||
1742 | 1742 | } else $offset = '+00:00'; |
1743 | 1743 | |
1744 | 1744 | if ($globalDBdriver == 'mysql') { |
1745 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1745 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1746 | 1746 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
1747 | 1747 | GROUP BY hour_name |
1748 | 1748 | ORDER BY hour_name ASC"; |
1749 | 1749 | } else { |
1750 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1750 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1751 | 1751 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1752 | 1752 | GROUP BY hour_name |
1753 | 1753 | ORDER BY hour_name ASC"; |
@@ -1759,7 +1759,7 @@ discard block |
||
1759 | 1759 | $hour_array = array(); |
1760 | 1760 | $temp_array = array(); |
1761 | 1761 | |
1762 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1762 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1763 | 1763 | { |
1764 | 1764 | $temp_array['hour_name'] = $row['hour_name']; |
1765 | 1765 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1781,8 +1781,8 @@ discard block |
||
1781 | 1781 | public function countAllHoursByIdent($ident, $filters = array()) |
1782 | 1782 | { |
1783 | 1783 | global $globalTimezone, $globalDBdriver; |
1784 | - $filter_query = $this->getFilter($filters,true,true); |
|
1785 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1784 | + $filter_query = $this->getFilter($filters, true, true); |
|
1785 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1786 | 1786 | if ($globalTimezone != '') { |
1787 | 1787 | date_default_timezone_set($globalTimezone); |
1788 | 1788 | $datetime = new DateTime(); |
@@ -1790,12 +1790,12 @@ discard block |
||
1790 | 1790 | } else $offset = '+00:00'; |
1791 | 1791 | |
1792 | 1792 | if ($globalDBdriver == 'mysql') { |
1793 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1793 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1794 | 1794 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1795 | 1795 | GROUP BY hour_name |
1796 | 1796 | ORDER BY hour_name ASC"; |
1797 | 1797 | } else { |
1798 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1798 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1799 | 1799 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1800 | 1800 | GROUP BY hour_name |
1801 | 1801 | ORDER BY hour_name ASC"; |
@@ -1803,12 +1803,12 @@ discard block |
||
1803 | 1803 | |
1804 | 1804 | |
1805 | 1805 | $sth = $this->db->prepare($query); |
1806 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1806 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1807 | 1807 | |
1808 | 1808 | $hour_array = array(); |
1809 | 1809 | $temp_array = array(); |
1810 | 1810 | |
1811 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1811 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1812 | 1812 | { |
1813 | 1813 | $temp_array['hour_name'] = $row['hour_name']; |
1814 | 1814 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1825,11 +1825,11 @@ discard block |
||
1825 | 1825 | * @return Array the aircraft list |
1826 | 1826 | * |
1827 | 1827 | */ |
1828 | - public function countAllCaptainsByRaces($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
1828 | + public function countAllCaptainsByRaces($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
1829 | 1829 | { |
1830 | 1830 | global $globalDBdriver; |
1831 | - $filter_query = $this->getFilter($filters,true,true); |
|
1832 | - $query = "SELECT DISTINCT marine_output.race_id, marine_output.race_name, COUNT(marine_output.captain_id) AS captain_count |
|
1831 | + $filter_query = $this->getFilter($filters, true, true); |
|
1832 | + $query = "SELECT DISTINCT marine_output.race_id, marine_output.race_name, COUNT(marine_output.captain_id) AS captain_count |
|
1833 | 1833 | FROM marine_output".$filter_query." race_id IS NOT NULL"; |
1834 | 1834 | if ($olderthanmonths > 0) { |
1835 | 1835 | if ($globalDBdriver == 'mysql') { |
@@ -1852,7 +1852,7 @@ discard block |
||
1852 | 1852 | $marine_array = array(); |
1853 | 1853 | $temp_array = array(); |
1854 | 1854 | |
1855 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1855 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1856 | 1856 | { |
1857 | 1857 | $temp_array['marine_race_id'] = $row['race_id']; |
1858 | 1858 | $temp_array['marine_race_name'] = $row['race_name']; |
@@ -1868,33 +1868,33 @@ discard block |
||
1868 | 1868 | * @return Integer the number of vessels |
1869 | 1869 | * |
1870 | 1870 | */ |
1871 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
1871 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
1872 | 1872 | { |
1873 | 1873 | global $globalDBdriver; |
1874 | 1874 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
1875 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1875 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1876 | 1876 | $query_values = array(); |
1877 | 1877 | $query = ''; |
1878 | 1878 | if ($year != '') { |
1879 | 1879 | if ($globalDBdriver == 'mysql') { |
1880 | 1880 | $query .= " AND YEAR(marine_output.date) = :year"; |
1881 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1881 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1882 | 1882 | } else { |
1883 | 1883 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1884 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1884 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1885 | 1885 | } |
1886 | 1886 | } |
1887 | 1887 | if ($month != '') { |
1888 | 1888 | if ($globalDBdriver == 'mysql') { |
1889 | 1889 | $query .= " AND MONTH(marine_output.date) = :month"; |
1890 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1890 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1891 | 1891 | } else { |
1892 | 1892 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1893 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1893 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1894 | 1894 | } |
1895 | 1895 | } |
1896 | 1896 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1897 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1897 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1898 | 1898 | |
1899 | 1899 | $sth = $this->db->prepare($queryi); |
1900 | 1900 | $sth->execute($query_values); |
@@ -1907,32 +1907,32 @@ discard block |
||
1907 | 1907 | * @return Integer the number of vessels |
1908 | 1908 | * |
1909 | 1909 | */ |
1910 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
1910 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
1911 | 1911 | { |
1912 | 1912 | global $globalDBdriver; |
1913 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1913 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1914 | 1914 | $query_values = array(); |
1915 | 1915 | $query = ''; |
1916 | 1916 | if ($year != '') { |
1917 | 1917 | if ($globalDBdriver == 'mysql') { |
1918 | 1918 | $query .= " AND YEAR(marine_output.date) = :year"; |
1919 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1919 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1920 | 1920 | } else { |
1921 | 1921 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1922 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1922 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1923 | 1923 | } |
1924 | 1924 | } |
1925 | 1925 | if ($month != '') { |
1926 | 1926 | if ($globalDBdriver == 'mysql') { |
1927 | 1927 | $query .= " AND MONTH(marine_output.date) = :month"; |
1928 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1928 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1929 | 1929 | } else { |
1930 | 1930 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1931 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1931 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1932 | 1932 | } |
1933 | 1933 | } |
1934 | 1934 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1935 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1935 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1936 | 1936 | |
1937 | 1937 | $sth = $this->db->prepare($queryi); |
1938 | 1938 | $sth->execute($query_values); |
@@ -1945,32 +1945,32 @@ discard block |
||
1945 | 1945 | * @return Integer number of races |
1946 | 1946 | * |
1947 | 1947 | */ |
1948 | - public function countOverallMarineRaces($filters = array(),$year = '',$month = '') |
|
1948 | + public function countOverallMarineRaces($filters = array(), $year = '', $month = '') |
|
1949 | 1949 | { |
1950 | 1950 | global $globalDBdriver; |
1951 | - $queryi = "SELECT COUNT(DISTINCT marine_output.race_id) AS marine_count FROM marine_output"; |
|
1951 | + $queryi = "SELECT COUNT(DISTINCT marine_output.race_id) AS marine_count FROM marine_output"; |
|
1952 | 1952 | $query_values = array(); |
1953 | 1953 | $query = ''; |
1954 | 1954 | if ($year != '') { |
1955 | 1955 | if ($globalDBdriver == 'mysql') { |
1956 | 1956 | $query .= " AND YEAR(marine_output.date) = :year"; |
1957 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1957 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1958 | 1958 | } else { |
1959 | 1959 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1960 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1960 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1961 | 1961 | } |
1962 | 1962 | } |
1963 | 1963 | if ($month != '') { |
1964 | 1964 | if ($globalDBdriver == 'mysql') { |
1965 | 1965 | $query .= " AND MONTH(marine_output.date) = :month"; |
1966 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1966 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1967 | 1967 | } else { |
1968 | 1968 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1969 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1969 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1970 | 1970 | } |
1971 | 1971 | } |
1972 | 1972 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1973 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1973 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1974 | 1974 | |
1975 | 1975 | $sth = $this->db->prepare($queryi); |
1976 | 1976 | $sth->execute($query_values); |
@@ -1983,32 +1983,32 @@ discard block |
||
1983 | 1983 | * @return Integer number of captain |
1984 | 1984 | * |
1985 | 1985 | */ |
1986 | - public function countOverallMarineCaptains($filters = array(),$year = '',$month = '') |
|
1986 | + public function countOverallMarineCaptains($filters = array(), $year = '', $month = '') |
|
1987 | 1987 | { |
1988 | 1988 | global $globalDBdriver; |
1989 | - $queryi = "SELECT COUNT(DISTINCT marine_output.captain_id) AS marine_count FROM marine_output"; |
|
1989 | + $queryi = "SELECT COUNT(DISTINCT marine_output.captain_id) AS marine_count FROM marine_output"; |
|
1990 | 1990 | $query_values = array(); |
1991 | 1991 | $query = ''; |
1992 | 1992 | if ($year != '') { |
1993 | 1993 | if ($globalDBdriver == 'mysql') { |
1994 | 1994 | $query .= " AND YEAR(marine_output.date) = :year"; |
1995 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1995 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1996 | 1996 | } else { |
1997 | 1997 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1998 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1998 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1999 | 1999 | } |
2000 | 2000 | } |
2001 | 2001 | if ($month != '') { |
2002 | 2002 | if ($globalDBdriver == 'mysql') { |
2003 | 2003 | $query .= " AND MONTH(marine_output.date) = :month"; |
2004 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
2004 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
2005 | 2005 | } else { |
2006 | 2006 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
2007 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
2007 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
2008 | 2008 | } |
2009 | 2009 | } |
2010 | 2010 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
2011 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
2011 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
2012 | 2012 | |
2013 | 2013 | $sth = $this->db->prepare($queryi); |
2014 | 2014 | $sth->execute($query_values); |
@@ -2024,7 +2024,7 @@ discard block |
||
2024 | 2024 | public function countAllHoursFromToday($filters = array()) |
2025 | 2025 | { |
2026 | 2026 | global $globalTimezone, $globalDBdriver; |
2027 | - $filter_query = $this->getFilter($filters,true,true); |
|
2027 | + $filter_query = $this->getFilter($filters, true, true); |
|
2028 | 2028 | if ($globalTimezone != '') { |
2029 | 2029 | date_default_timezone_set($globalTimezone); |
2030 | 2030 | $datetime = new DateTime(); |
@@ -2032,12 +2032,12 @@ discard block |
||
2032 | 2032 | } else $offset = '+00:00'; |
2033 | 2033 | |
2034 | 2034 | if ($globalDBdriver == 'mysql') { |
2035 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
2035 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
2036 | 2036 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
2037 | 2037 | GROUP BY hour_name |
2038 | 2038 | ORDER BY hour_name ASC"; |
2039 | 2039 | } else { |
2040 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
2040 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
2041 | 2041 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
2042 | 2042 | GROUP BY hour_name |
2043 | 2043 | ORDER BY hour_name ASC"; |
@@ -2049,7 +2049,7 @@ discard block |
||
2049 | 2049 | $hour_array = array(); |
2050 | 2050 | $temp_array = array(); |
2051 | 2051 | |
2052 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2052 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2053 | 2053 | { |
2054 | 2054 | $temp_array['hour_name'] = $row['hour_name']; |
2055 | 2055 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -2068,9 +2068,9 @@ discard block |
||
2068 | 2068 | */ |
2069 | 2069 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
2070 | 2070 | { |
2071 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
2071 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
2072 | 2072 | |
2073 | - $query = "SELECT marine_output.marine_id |
|
2073 | + $query = "SELECT marine_output.marine_id |
|
2074 | 2074 | FROM marine_output |
2075 | 2075 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
2076 | 2076 | |
@@ -2078,7 +2078,7 @@ discard block |
||
2078 | 2078 | $sth = $this->db->prepare($query); |
2079 | 2079 | $sth->execute(); |
2080 | 2080 | |
2081 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2081 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2082 | 2082 | { |
2083 | 2083 | return $row['marine_id']; |
2084 | 2084 | } |
@@ -2103,23 +2103,23 @@ discard block |
||
2103 | 2103 | } |
2104 | 2104 | |
2105 | 2105 | $current_date = date("Y-m-d H:i:s"); |
2106 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
2106 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
2107 | 2107 | |
2108 | 2108 | $diff = abs(strtotime($current_date) - strtotime($date)); |
2109 | 2109 | |
2110 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
2110 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
2111 | 2111 | $years = $time_array['years']; |
2112 | 2112 | |
2113 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
2113 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
2114 | 2114 | $months = $time_array['months']; |
2115 | 2115 | |
2116 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
2116 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
2117 | 2117 | $days = $time_array['days']; |
2118 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
2118 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
2119 | 2119 | $hours = $time_array['hours']; |
2120 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
2120 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
2121 | 2121 | $minutes = $time_array['minutes']; |
2122 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
2122 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
2123 | 2123 | |
2124 | 2124 | return $time_array; |
2125 | 2125 | } |
@@ -2142,63 +2142,63 @@ discard block |
||
2142 | 2142 | $temp_array['direction_degree'] = $direction; |
2143 | 2143 | $temp_array['direction_shortname'] = "N"; |
2144 | 2144 | $temp_array['direction_fullname'] = "North"; |
2145 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
2145 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
2146 | 2146 | $temp_array['direction_degree'] = $direction; |
2147 | 2147 | $temp_array['direction_shortname'] = "NNE"; |
2148 | 2148 | $temp_array['direction_fullname'] = "North-Northeast"; |
2149 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
2149 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
2150 | 2150 | $temp_array['direction_degree'] = $direction; |
2151 | 2151 | $temp_array['direction_shortname'] = "NE"; |
2152 | 2152 | $temp_array['direction_fullname'] = "Northeast"; |
2153 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
2153 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
2154 | 2154 | $temp_array['direction_degree'] = $direction; |
2155 | 2155 | $temp_array['direction_shortname'] = "ENE"; |
2156 | 2156 | $temp_array['direction_fullname'] = "East-Northeast"; |
2157 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
2157 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
2158 | 2158 | $temp_array['direction_degree'] = $direction; |
2159 | 2159 | $temp_array['direction_shortname'] = "E"; |
2160 | 2160 | $temp_array['direction_fullname'] = "East"; |
2161 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
2161 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
2162 | 2162 | $temp_array['direction_degree'] = $direction; |
2163 | 2163 | $temp_array['direction_shortname'] = "ESE"; |
2164 | 2164 | $temp_array['direction_fullname'] = "East-Southeast"; |
2165 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
2165 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
2166 | 2166 | $temp_array['direction_degree'] = $direction; |
2167 | 2167 | $temp_array['direction_shortname'] = "SE"; |
2168 | 2168 | $temp_array['direction_fullname'] = "Southeast"; |
2169 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
2169 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
2170 | 2170 | $temp_array['direction_degree'] = $direction; |
2171 | 2171 | $temp_array['direction_shortname'] = "SSE"; |
2172 | 2172 | $temp_array['direction_fullname'] = "South-Southeast"; |
2173 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
2173 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
2174 | 2174 | $temp_array['direction_degree'] = $direction; |
2175 | 2175 | $temp_array['direction_shortname'] = "S"; |
2176 | 2176 | $temp_array['direction_fullname'] = "South"; |
2177 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
2177 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
2178 | 2178 | $temp_array['direction_degree'] = $direction; |
2179 | 2179 | $temp_array['direction_shortname'] = "SSW"; |
2180 | 2180 | $temp_array['direction_fullname'] = "South-Southwest"; |
2181 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
2181 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
2182 | 2182 | $temp_array['direction_degree'] = $direction; |
2183 | 2183 | $temp_array['direction_shortname'] = "SW"; |
2184 | 2184 | $temp_array['direction_fullname'] = "Southwest"; |
2185 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
2185 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
2186 | 2186 | $temp_array['direction_degree'] = $direction; |
2187 | 2187 | $temp_array['direction_shortname'] = "WSW"; |
2188 | 2188 | $temp_array['direction_fullname'] = "West-Southwest"; |
2189 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
2189 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
2190 | 2190 | $temp_array['direction_degree'] = $direction; |
2191 | 2191 | $temp_array['direction_shortname'] = "W"; |
2192 | 2192 | $temp_array['direction_fullname'] = "West"; |
2193 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
2193 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
2194 | 2194 | $temp_array['direction_degree'] = $direction; |
2195 | 2195 | $temp_array['direction_shortname'] = "WNW"; |
2196 | 2196 | $temp_array['direction_fullname'] = "West-Northwest"; |
2197 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
2197 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
2198 | 2198 | $temp_array['direction_degree'] = $direction; |
2199 | 2199 | $temp_array['direction_shortname'] = "NW"; |
2200 | 2200 | $temp_array['direction_fullname'] = "Northwest"; |
2201 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
2201 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
2202 | 2202 | $temp_array['direction_degree'] = $direction; |
2203 | 2203 | $temp_array['direction_shortname'] = "NNW"; |
2204 | 2204 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -2215,11 +2215,11 @@ discard block |
||
2215 | 2215 | * @param Float $longitude longitute of the flight |
2216 | 2216 | * @return String the countrie |
2217 | 2217 | */ |
2218 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
2218 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
2219 | 2219 | { |
2220 | 2220 | global $globalDBdriver, $globalDebug; |
2221 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
2222 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
2221 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
2222 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
2223 | 2223 | |
2224 | 2224 | $Connection = new Connection($this->db); |
2225 | 2225 | if (!$Connection->tableExists('countries')) return ''; |
@@ -2259,7 +2259,7 @@ discard block |
||
2259 | 2259 | public function getCountryFromISO2($iso2) |
2260 | 2260 | { |
2261 | 2261 | global $globalDBdriver, $globalDebug; |
2262 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
2262 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
2263 | 2263 | |
2264 | 2264 | $Connection = new Connection($this->db); |
2265 | 2265 | if (!$Connection->tableExists('countries')) return ''; |
@@ -2307,7 +2307,7 @@ discard block |
||
2307 | 2307 | |
2308 | 2308 | $bitly_data = json_decode($bitly_data); |
2309 | 2309 | $bitly_url = ''; |
2310 | - if ($bitly_data->status_txt = "OK"){ |
|
2310 | + if ($bitly_data->status_txt = "OK") { |
|
2311 | 2311 | $bitly_url = $bitly_data->data->url; |
2312 | 2312 | } |
2313 | 2313 | |
@@ -2321,11 +2321,11 @@ discard block |
||
2321 | 2321 | * @return Array the vessel type list |
2322 | 2322 | * |
2323 | 2323 | */ |
2324 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
2324 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
2325 | 2325 | { |
2326 | 2326 | global $globalDBdriver; |
2327 | - $filter_query = $this->getFilter($filters,true,true); |
|
2328 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
2327 | + $filter_query = $this->getFilter($filters, true, true); |
|
2328 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
2329 | 2329 | FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL"; |
2330 | 2330 | if ($olderthanmonths > 0) { |
2331 | 2331 | if ($globalDBdriver == 'mysql') { |
@@ -2345,28 +2345,28 @@ discard block |
||
2345 | 2345 | if ($year != '') { |
2346 | 2346 | if ($globalDBdriver == 'mysql') { |
2347 | 2347 | $query .= " AND YEAR(marine_output.date) = :year"; |
2348 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
2348 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
2349 | 2349 | } else { |
2350 | 2350 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
2351 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
2351 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
2352 | 2352 | } |
2353 | 2353 | } |
2354 | 2354 | if ($month != '') { |
2355 | 2355 | if ($globalDBdriver == 'mysql') { |
2356 | 2356 | $query .= " AND MONTH(marine_output.date) = :month"; |
2357 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
2357 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
2358 | 2358 | } else { |
2359 | 2359 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
2360 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
2360 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
2361 | 2361 | } |
2362 | 2362 | } |
2363 | 2363 | if ($day != '') { |
2364 | 2364 | if ($globalDBdriver == 'mysql') { |
2365 | 2365 | $query .= " AND DAY(marine_output.date) = :day"; |
2366 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
2366 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
2367 | 2367 | } else { |
2368 | 2368 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
2369 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
2369 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
2370 | 2370 | } |
2371 | 2371 | } |
2372 | 2372 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
@@ -2375,9 +2375,9 @@ discard block |
||
2375 | 2375 | $sth->execute($query_values); |
2376 | 2376 | $marine_array = array(); |
2377 | 2377 | $temp_array = array(); |
2378 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2378 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2379 | 2379 | { |
2380 | - $temp_array['marine_type'] = html_entity_decode($row['marine_type'],ENT_QUOTES); |
|
2380 | + $temp_array['marine_type'] = html_entity_decode($row['marine_type'], ENT_QUOTES); |
|
2381 | 2381 | $temp_array['marine_type_id'] = $row['marine_type_id']; |
2382 | 2382 | $temp_array['marine_type_count'] = $row['marine_type_count']; |
2383 | 2383 | $marine_array[] = $temp_array; |
@@ -2391,13 +2391,13 @@ discard block |
||
2391 | 2391 | * @return Array the tracker information |
2392 | 2392 | * |
2393 | 2393 | */ |
2394 | - public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
|
2394 | + public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
2395 | 2395 | { |
2396 | 2396 | global $globalTimezone, $globalDBdriver; |
2397 | 2397 | date_default_timezone_set('UTC'); |
2398 | 2398 | $query_values = array(); |
2399 | 2399 | $additional_query = ''; |
2400 | - $filter_query = $this->getFilter($filters,true,true); |
|
2400 | + $filter_query = $this->getFilter($filters, true, true); |
|
2401 | 2401 | if ($q != "") |
2402 | 2402 | { |
2403 | 2403 | if (!is_string($q)) |
@@ -2405,8 +2405,8 @@ discard block |
||
2405 | 2405 | return false; |
2406 | 2406 | } else { |
2407 | 2407 | $q_array = explode(" ", $q); |
2408 | - foreach ($q_array as $q_item){ |
|
2409 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
2408 | + foreach ($q_array as $q_item) { |
|
2409 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
2410 | 2410 | $additional_query .= " AND ("; |
2411 | 2411 | if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
2412 | 2412 | if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
@@ -2418,42 +2418,42 @@ discard block |
||
2418 | 2418 | } |
2419 | 2419 | if ($callsign != "") |
2420 | 2420 | { |
2421 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
2421 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
2422 | 2422 | if (!is_string($callsign)) |
2423 | 2423 | { |
2424 | 2424 | return false; |
2425 | 2425 | } else { |
2426 | 2426 | $additional_query .= " AND marine_output.ident = :callsign"; |
2427 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
2427 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
2428 | 2428 | } |
2429 | 2429 | } |
2430 | 2430 | if ($mmsi != "") |
2431 | 2431 | { |
2432 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
2432 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
2433 | 2433 | if (!is_numeric($mmsi)) |
2434 | 2434 | { |
2435 | 2435 | return false; |
2436 | 2436 | } else { |
2437 | 2437 | $additional_query .= " AND marine_output.mmsi = :mmsi"; |
2438 | - $query_values = array_merge($query_values,array(':mmsi' => $mmsi)); |
|
2438 | + $query_values = array_merge($query_values, array(':mmsi' => $mmsi)); |
|
2439 | 2439 | } |
2440 | 2440 | } |
2441 | 2441 | if ($imo != "") |
2442 | 2442 | { |
2443 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
2443 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
2444 | 2444 | if (!is_numeric($imo)) |
2445 | 2445 | { |
2446 | 2446 | return false; |
2447 | 2447 | } else { |
2448 | 2448 | $additional_query .= " AND marine_output.imo = :imo"; |
2449 | - $query_values = array_merge($query_values,array(':imo' => $imo)); |
|
2449 | + $query_values = array_merge($query_values, array(':imo' => $imo)); |
|
2450 | 2450 | } |
2451 | 2451 | } |
2452 | 2452 | if ($date_posted != "") |
2453 | 2453 | { |
2454 | 2454 | $date_array = explode(",", $date_posted); |
2455 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
2456 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
2455 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
2456 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
2457 | 2457 | if ($globalTimezone != '') { |
2458 | 2458 | date_default_timezone_set($globalTimezone); |
2459 | 2459 | $datetime = new DateTime(); |
@@ -2480,8 +2480,8 @@ discard block |
||
2480 | 2480 | if ($limit != "") |
2481 | 2481 | { |
2482 | 2482 | $limit_array = explode(",", $limit); |
2483 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
2484 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
2483 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
2484 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
2485 | 2485 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
2486 | 2486 | { |
2487 | 2487 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -2499,22 +2499,22 @@ discard block |
||
2499 | 2499 | } |
2500 | 2500 | } |
2501 | 2501 | if ($origLat != "" && $origLon != "" && $dist != "") { |
2502 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
2502 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
2503 | 2503 | if ($globalDBdriver == 'mysql') { |
2504 | - $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 |
|
2504 | + $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 |
|
2505 | 2505 | 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)) |
2506 | 2506 | 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; |
2507 | 2507 | } else { |
2508 | - $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 |
|
2508 | + $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 |
|
2509 | 2509 | 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)) |
2510 | 2510 | 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; |
2511 | 2511 | } |
2512 | 2512 | } else { |
2513 | - $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
2513 | + $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
2514 | 2514 | ".$additional_query." |
2515 | 2515 | ".$orderby_query; |
2516 | 2516 | } |
2517 | - $marine_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
2517 | + $marine_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
2518 | 2518 | return $marine_array; |
2519 | 2519 | } |
2520 | 2520 | |
@@ -2527,12 +2527,12 @@ discard block |
||
2527 | 2527 | public function checkId($id) |
2528 | 2528 | { |
2529 | 2529 | global $globalDBdriver, $globalTimezone; |
2530 | - $query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id'; |
|
2530 | + $query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id'; |
|
2531 | 2531 | $query_data = array(':id' => $id); |
2532 | 2532 | $sth = $this->db->prepare($query); |
2533 | 2533 | $sth->execute($query_data); |
2534 | - $ident_result=''; |
|
2535 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2534 | + $ident_result = ''; |
|
2535 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2536 | 2536 | { |
2537 | 2537 | $ident_result = $row['fammarine_id']; |
2538 | 2538 | } |
@@ -2547,7 +2547,7 @@ discard block |
||
2547 | 2547 | */ |
2548 | 2548 | public function getRaceByName($race_name) |
2549 | 2549 | { |
2550 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
2550 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
2551 | 2551 | $query = "SELECT * FROM marine_race WHERE race_name = :race_name LIMIT 1"; |
2552 | 2552 | $sth = $this->db->prepare($query); |
2553 | 2553 | $sth->execute(array(':race_name' => $race_name)); |
@@ -2564,7 +2564,7 @@ discard block |
||
2564 | 2564 | */ |
2565 | 2565 | public function getRace($race_id) |
2566 | 2566 | { |
2567 | - $race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT); |
|
2567 | + $race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT); |
|
2568 | 2568 | $query = "SELECT * FROM marine_race WHERE race_id = :race_id LIMIT 1"; |
2569 | 2569 | $sth = $this->db->prepare($query); |
2570 | 2570 | $sth->execute(array(':race_id' => $race_id)); |
@@ -2577,24 +2577,24 @@ discard block |
||
2577 | 2577 | * Add race |
2578 | 2578 | * |
2579 | 2579 | */ |
2580 | - public function addRace($race_id,$race_name,$race_creator,$race_desc,$race_startdate,$race_markers) |
|
2580 | + public function addRace($race_id, $race_name, $race_creator, $race_desc, $race_startdate, $race_markers) |
|
2581 | 2581 | { |
2582 | - $race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT); |
|
2582 | + $race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT); |
|
2583 | 2583 | if ($race_id != '') { |
2584 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
2585 | - $race_creator = filter_var($race_creator,FILTER_SANITIZE_STRING); |
|
2586 | - $race_desc = filter_var($race_desc,FILTER_SANITIZE_STRING); |
|
2587 | - $race_startdate = filter_var($race_startdate,FILTER_SANITIZE_STRING); |
|
2584 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
2585 | + $race_creator = filter_var($race_creator, FILTER_SANITIZE_STRING); |
|
2586 | + $race_desc = filter_var($race_desc, FILTER_SANITIZE_STRING); |
|
2587 | + $race_startdate = filter_var($race_startdate, FILTER_SANITIZE_STRING); |
|
2588 | 2588 | //$race_markers = filter_var($race_markers,FILTER_SANITIZE_STRING); |
2589 | 2589 | $allrace = $this->getRace($race_id); |
2590 | 2590 | if (empty($allrace)) { |
2591 | 2591 | $query = "INSERT INTO marine_race (race_id,race_name,race_creator,race_desc,race_startdate,race_markers) VALUES (:race_id,:race_name,:race_creator,:race_desc,:race_startdate,:race_markers)"; |
2592 | 2592 | $sth = $this->db->prepare($query); |
2593 | - $sth->execute(array(':race_id' => $race_id,':race_name' => $race_name,':race_creator' => $race_creator,':race_desc' => $race_desc,':race_startdate' => $race_startdate,':race_markers' => $race_markers)); |
|
2593 | + $sth->execute(array(':race_id' => $race_id, ':race_name' => $race_name, ':race_creator' => $race_creator, ':race_desc' => $race_desc, ':race_startdate' => $race_startdate, ':race_markers' => $race_markers)); |
|
2594 | 2594 | } elseif ($race_id != '') { |
2595 | - $query = "UPDATE marine_race SET race_name = :race_name,race_desc = :race_desc,race_startdate = :race_startdate,race_markers = :race_markers WHERE race_id = :race_id"; |
|
2595 | + $query = "UPDATE marine_race SET race_name = :race_name,race_desc = :race_desc,race_startdate = :race_startdate,race_markers = :race_markers WHERE race_id = :race_id"; |
|
2596 | 2596 | $sth = $this->db->prepare($query); |
2597 | - $sth->execute(array(':race_id' => $race_id,':race_name' => $race_name,':race_desc' => $race_desc,':race_startdate' => $race_startdate,':race_markers' => $race_markers)); |
|
2597 | + $sth->execute(array(':race_id' => $race_id, ':race_name' => $race_name, ':race_desc' => $race_desc, ':race_startdate' => $race_startdate, ':race_markers' => $race_markers)); |
|
2598 | 2598 | } |
2599 | 2599 | } |
2600 | 2600 | } |
@@ -2603,7 +2603,7 @@ discard block |
||
2603 | 2603 | |
2604 | 2604 | public function getOrderBy() |
2605 | 2605 | { |
2606 | - $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 port - ASC", "sql" => "ORDER BY marine_output.departure_port_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")); |
|
2606 | + $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 port - ASC", "sql" => "ORDER BY marine_output.departure_port_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")); |
|
2607 | 2607 | |
2608 | 2608 | return $orderby; |
2609 | 2609 |
@@ -15,7 +15,9 @@ discard block |
||
15 | 15 | public function __construct($dbc = null) { |
16 | 16 | $Connection = new Connection($dbc); |
17 | 17 | $this->db = $Connection->db(); |
18 | - if ($this->db === null) die('Error: No DB connection. (Marine)'); |
|
18 | + if ($this->db === null) { |
|
19 | + die('Error: No DB connection. (Marine)'); |
|
20 | + } |
|
19 | 21 | } |
20 | 22 | |
21 | 23 | /** |
@@ -37,7 +39,9 @@ discard block |
||
37 | 39 | if (isset($filter[0]['source'])) { |
38 | 40 | $filters = array_merge($filters,$filter); |
39 | 41 | } |
40 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
42 | + if (is_array($globalFilter)) { |
|
43 | + $filter = array_merge($filter,$globalFilter); |
|
44 | + } |
|
41 | 45 | $filter_query_join = ''; |
42 | 46 | $filter_query_where = ''; |
43 | 47 | foreach($filters as $flt) { |
@@ -85,8 +89,11 @@ discard block |
||
85 | 89 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
86 | 90 | } |
87 | 91 | } |
88 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
89 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
92 | + if ($filter_query_where == '' && $where) { |
|
93 | + $filter_query_where = ' WHERE'; |
|
94 | + } elseif ($filter_query_where != '' && $and) { |
|
95 | + $filter_query_where .= ' AND'; |
|
96 | + } |
|
90 | 97 | if ($filter_query_where != '') { |
91 | 98 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
92 | 99 | } |
@@ -141,42 +148,84 @@ discard block |
||
141 | 148 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
142 | 149 | } elseif (isset($row['spotter_archive_output_id'])) { |
143 | 150 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
144 | - */} |
|
145 | - elseif (isset($row['marineid'])) { |
|
151 | + */} elseif (isset($row['marineid'])) { |
|
146 | 152 | $temp_array['marine_id'] = $row['marineid']; |
147 | 153 | } else { |
148 | 154 | $temp_array['marine_id'] = ''; |
149 | 155 | } |
150 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
151 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
152 | - if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES); |
|
153 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
154 | - if (isset($row['status'])) $temp_array['status'] = $row['status']; |
|
155 | - if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id']; |
|
156 | - if (isset($row['captain_id'])) $temp_array['captain_id'] = $row['captain_id']; |
|
157 | - if (isset($row['captain_name'])) $temp_array['captain_name'] = $row['captain_name']; |
|
158 | - if (isset($row['race_id'])) $temp_array['race_id'] = $row['race_id']; |
|
159 | - if (isset($row['race_name'])) $temp_array['race_name'] = $row['race_name']; |
|
160 | - if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) $temp_array['race_time'] = $row['race_time']; |
|
161 | - if (isset($row['race_rank'])) $temp_array['race_rank'] = $row['race_rank']; |
|
162 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
163 | - if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
164 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
165 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
166 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
167 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
156 | + if (isset($row['fammarine_id'])) { |
|
157 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
158 | + } |
|
159 | + if (isset($row['mmsi'])) { |
|
160 | + $temp_array['mmsi'] = $row['mmsi']; |
|
161 | + } |
|
162 | + if (isset($row['type'])) { |
|
163 | + $temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES); |
|
164 | + } |
|
165 | + if (isset($row['type_id'])) { |
|
166 | + $temp_array['type_id'] = $row['type_id']; |
|
167 | + } |
|
168 | + if (isset($row['status'])) { |
|
169 | + $temp_array['status'] = $row['status']; |
|
170 | + } |
|
171 | + if (isset($row['status_id'])) { |
|
172 | + $temp_array['status_id'] = $row['status_id']; |
|
173 | + } |
|
174 | + if (isset($row['captain_id'])) { |
|
175 | + $temp_array['captain_id'] = $row['captain_id']; |
|
176 | + } |
|
177 | + if (isset($row['captain_name'])) { |
|
178 | + $temp_array['captain_name'] = $row['captain_name']; |
|
179 | + } |
|
180 | + if (isset($row['race_id'])) { |
|
181 | + $temp_array['race_id'] = $row['race_id']; |
|
182 | + } |
|
183 | + if (isset($row['race_name'])) { |
|
184 | + $temp_array['race_name'] = $row['race_name']; |
|
185 | + } |
|
186 | + if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) { |
|
187 | + $temp_array['race_time'] = $row['race_time']; |
|
188 | + } |
|
189 | + if (isset($row['race_rank'])) { |
|
190 | + $temp_array['race_rank'] = $row['race_rank']; |
|
191 | + } |
|
192 | + if (isset($row['ident'])) { |
|
193 | + $temp_array['ident'] = $row['ident']; |
|
194 | + } |
|
195 | + if (isset($row['arrival_port_name'])) { |
|
196 | + $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
197 | + } |
|
198 | + if (isset($row['latitude'])) { |
|
199 | + $temp_array['latitude'] = $row['latitude']; |
|
200 | + } |
|
201 | + if (isset($row['longitude'])) { |
|
202 | + $temp_array['longitude'] = $row['longitude']; |
|
203 | + } |
|
204 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
205 | + $temp_array['distance'] = $row['distance']; |
|
206 | + } |
|
207 | + if (isset($row['format_source'])) { |
|
208 | + $temp_array['format_source'] = $row['format_source']; |
|
209 | + } |
|
168 | 210 | if (isset($row['heading'])) { |
169 | 211 | $temp_array['heading'] = $row['heading']; |
170 | 212 | $heading_direction = $this->parseDirection($row['heading']); |
171 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
213 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
214 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
215 | + } |
|
216 | + } |
|
217 | + if (isset($row['ground_speed'])) { |
|
218 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
172 | 219 | } |
173 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
174 | 220 | |
175 | 221 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
176 | 222 | { |
177 | 223 | $Image = new Image($this->db); |
178 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
179 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
224 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
225 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
226 | + } else { |
|
227 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
228 | + } |
|
180 | 229 | unset($Image); |
181 | 230 | if (count($image_array) > 0) { |
182 | 231 | $temp_array['image'] = $image_array[0]['image']; |
@@ -240,13 +289,21 @@ discard block |
||
240 | 289 | } |
241 | 290 | |
242 | 291 | $fromsource = NULL; |
243 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
244 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
245 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
292 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
293 | + $temp_array['source_name'] = $row['source_name']; |
|
294 | + } |
|
295 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
296 | + $temp_array['over_country'] = $row['over_country']; |
|
297 | + } |
|
298 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
299 | + $temp_array['distance'] = $row['distance']; |
|
300 | + } |
|
246 | 301 | $temp_array['query_number_rows'] = $num_rows; |
247 | 302 | $spotter_array[] = $temp_array; |
248 | 303 | } |
249 | - if ($num_rows == 0) return array(); |
|
304 | + if ($num_rows == 0) { |
|
305 | + return array(); |
|
306 | + } |
|
250 | 307 | $spotter_array[0]['query_number_rows'] = $num_rows; |
251 | 308 | return $spotter_array; |
252 | 309 | } |
@@ -272,8 +329,12 @@ discard block |
||
272 | 329 | { |
273 | 330 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
274 | 331 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
275 | - } else $limit_query = ""; |
|
276 | - } else $limit_query = ""; |
|
332 | + } else { |
|
333 | + $limit_query = ""; |
|
334 | + } |
|
335 | + } else { |
|
336 | + $limit_query = ""; |
|
337 | + } |
|
277 | 338 | if ($sort != "") |
278 | 339 | { |
279 | 340 | $search_orderby_array = $this->getOrderBy(); |
@@ -297,7 +358,9 @@ discard block |
||
297 | 358 | global $global_marine_query; |
298 | 359 | |
299 | 360 | date_default_timezone_set('UTC'); |
300 | - if ($id == '') return array(); |
|
361 | + if ($id == '') { |
|
362 | + return array(); |
|
363 | + } |
|
301 | 364 | $additional_query = "marine_output.fammarine_id = :id"; |
302 | 365 | $query_values = array(':id' => $id); |
303 | 366 | $query = $global_marine_query." WHERE ".$additional_query." "; |
@@ -745,8 +808,11 @@ discard block |
||
745 | 808 | $sth = $this->db->prepare($query); |
746 | 809 | $sth->execute($query_values); |
747 | 810 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
748 | - if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
749 | - else return $result[0]['duration']; |
|
811 | + if (is_int($result[0]['duration'])) { |
|
812 | + return gmdate('H:i:s',$result[0]['duration']); |
|
813 | + } else { |
|
814 | + return $result[0]['duration']; |
|
815 | + } |
|
750 | 816 | } |
751 | 817 | |
752 | 818 | /** |
@@ -806,8 +872,11 @@ discard block |
||
806 | 872 | $query .= " ORDER BY marine_output.source_name ASC"; |
807 | 873 | |
808 | 874 | $sth = $this->db->prepare($query); |
809 | - if (!empty($query_values)) $sth->execute($query_values); |
|
810 | - else $sth->execute(); |
|
875 | + if (!empty($query_values)) { |
|
876 | + $sth->execute($query_values); |
|
877 | + } else { |
|
878 | + $sth->execute(); |
|
879 | + } |
|
811 | 880 | |
812 | 881 | $source_array = array(); |
813 | 882 | $temp_array = array(); |
@@ -862,8 +931,11 @@ discard block |
||
862 | 931 | $sth = $this->db->prepare($query); |
863 | 932 | $sth->execute(array(':mmsi' => $mmsi)); |
864 | 933 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
865 | - if (isset($result[0])) return $result[0]; |
|
866 | - else return array(); |
|
934 | + if (isset($result[0])) { |
|
935 | + return $result[0]; |
|
936 | + } else { |
|
937 | + return array(); |
|
938 | + } |
|
867 | 939 | } |
868 | 940 | |
869 | 941 | /** |
@@ -904,7 +976,9 @@ discard block |
||
904 | 976 | date_default_timezone_set($globalTimezone); |
905 | 977 | $datetime = new DateTime(); |
906 | 978 | $offset = $datetime->format('P'); |
907 | - } else $offset = '+00:00'; |
|
979 | + } else { |
|
980 | + $offset = '+00:00'; |
|
981 | + } |
|
908 | 982 | |
909 | 983 | if ($globalDBdriver == 'mysql') { |
910 | 984 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -1011,8 +1085,12 @@ discard block |
||
1011 | 1085 | */ |
1012 | 1086 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
1013 | 1087 | { |
1014 | - if ($latitude == '') $latitude = NULL; |
|
1015 | - if ($longitude == '') $longitude = NULL; |
|
1088 | + if ($latitude == '') { |
|
1089 | + $latitude = NULL; |
|
1090 | + } |
|
1091 | + if ($longitude == '') { |
|
1092 | + $longitude = NULL; |
|
1093 | + } |
|
1016 | 1094 | $groundspeed = round($groundspeed); |
1017 | 1095 | if ($race_begin != '') { |
1018 | 1096 | $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, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status, date = :race_begin WHERE fammarine_id = :fammarine_id'; |
@@ -1165,14 +1243,28 @@ discard block |
||
1165 | 1243 | $latitude = 0; |
1166 | 1244 | $longitude = 0; |
1167 | 1245 | } |
1168 | - if ($type_id == '') $type_id = NULL; |
|
1169 | - if ($status_id == '') $status_id = NULL; |
|
1170 | - if ($distance == '') $distance = NULL; |
|
1171 | - if ($race_rank == '') $race_rank = NULL; |
|
1172 | - if ($race_time == '') $race_time = NULL; |
|
1173 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1246 | + if ($type_id == '') { |
|
1247 | + $type_id = NULL; |
|
1248 | + } |
|
1249 | + if ($status_id == '') { |
|
1250 | + $status_id = NULL; |
|
1251 | + } |
|
1252 | + if ($distance == '') { |
|
1253 | + $distance = NULL; |
|
1254 | + } |
|
1255 | + if ($race_rank == '') { |
|
1256 | + $race_rank = NULL; |
|
1257 | + } |
|
1258 | + if ($race_time == '') { |
|
1259 | + $race_time = NULL; |
|
1260 | + } |
|
1261 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
1262 | + $heading = 0; |
|
1263 | + } |
|
1174 | 1264 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
1175 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1265 | + if ($arrival_date == '') { |
|
1266 | + $arrival_date = NULL; |
|
1267 | + } |
|
1176 | 1268 | $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,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
1177 | 1269 | 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,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)"; |
1178 | 1270 | |
@@ -1279,7 +1371,9 @@ discard block |
||
1279 | 1371 | global $globalDBdriver, $globalArchive; |
1280 | 1372 | //$filter_query = $this->getFilter($filters,true,true); |
1281 | 1373 | $Connection= new Connection($this->db); |
1282 | - if (!$Connection->tableExists('countries')) return array(); |
|
1374 | + if (!$Connection->tableExists('countries')) { |
|
1375 | + return array(); |
|
1376 | + } |
|
1283 | 1377 | require_once('class.SpotterLive.php'); |
1284 | 1378 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
1285 | 1379 | $MarineLive = new MarineLive($this->db); |
@@ -1323,7 +1417,9 @@ discard block |
||
1323 | 1417 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
1324 | 1418 | } |
1325 | 1419 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
1326 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1420 | + if ($limit) { |
|
1421 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1422 | + } |
|
1327 | 1423 | |
1328 | 1424 | $sth = $this->db->prepare($query); |
1329 | 1425 | $sth->execute(); |
@@ -1357,12 +1453,18 @@ discard block |
||
1357 | 1453 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
1358 | 1454 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
1359 | 1455 | if ($olderthanmonths > 0) { |
1360 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
1361 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
1456 | + if ($globalDBdriver == 'mysql') { |
|
1457 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
1458 | + } else { |
|
1459 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
1460 | + } |
|
1362 | 1461 | } |
1363 | 1462 | if ($sincedate != '') { |
1364 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
1365 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
1463 | + if ($globalDBdriver == 'mysql') { |
|
1464 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
1465 | + } else { |
|
1466 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
1467 | + } |
|
1366 | 1468 | } |
1367 | 1469 | $query_values = array(); |
1368 | 1470 | if ($year != '') { |
@@ -1393,7 +1495,9 @@ discard block |
||
1393 | 1495 | } |
1394 | 1496 | } |
1395 | 1497 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
1396 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1498 | + if ($limit) { |
|
1499 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1500 | + } |
|
1397 | 1501 | |
1398 | 1502 | $sth = $this->db->prepare($query); |
1399 | 1503 | $sth->execute($query_values); |
@@ -1428,7 +1532,9 @@ discard block |
||
1428 | 1532 | date_default_timezone_set($globalTimezone); |
1429 | 1533 | $datetime = new DateTime(); |
1430 | 1534 | $offset = $datetime->format('P'); |
1431 | - } else $offset = '+00:00'; |
|
1535 | + } else { |
|
1536 | + $offset = '+00:00'; |
|
1537 | + } |
|
1432 | 1538 | |
1433 | 1539 | if ($globalDBdriver == 'mysql') { |
1434 | 1540 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1478,7 +1584,9 @@ discard block |
||
1478 | 1584 | date_default_timezone_set($globalTimezone); |
1479 | 1585 | $datetime = new DateTime(); |
1480 | 1586 | $offset = $datetime->format('P'); |
1481 | - } else $offset = '+00:00'; |
|
1587 | + } else { |
|
1588 | + $offset = '+00:00'; |
|
1589 | + } |
|
1482 | 1590 | $filter_query = $this->getFilter($filters,true,true); |
1483 | 1591 | if ($globalDBdriver == 'mysql') { |
1484 | 1592 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1524,7 +1632,9 @@ discard block |
||
1524 | 1632 | date_default_timezone_set($globalTimezone); |
1525 | 1633 | $datetime = new DateTime(); |
1526 | 1634 | $offset = $datetime->format('P'); |
1527 | - } else $offset = '+00:00'; |
|
1635 | + } else { |
|
1636 | + $offset = '+00:00'; |
|
1637 | + } |
|
1528 | 1638 | $filter_query = $this->getFilter($filters,true,true); |
1529 | 1639 | if ($globalDBdriver == 'mysql') { |
1530 | 1640 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1572,7 +1682,9 @@ discard block |
||
1572 | 1682 | date_default_timezone_set($globalTimezone); |
1573 | 1683 | $datetime = new DateTime(); |
1574 | 1684 | $offset = $datetime->format('P'); |
1575 | - } else $offset = '+00:00'; |
|
1685 | + } else { |
|
1686 | + $offset = '+00:00'; |
|
1687 | + } |
|
1576 | 1688 | |
1577 | 1689 | if ($globalDBdriver == 'mysql') { |
1578 | 1690 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1621,7 +1733,9 @@ discard block |
||
1621 | 1733 | date_default_timezone_set($globalTimezone); |
1622 | 1734 | $datetime = new DateTime(); |
1623 | 1735 | $offset = $datetime->format('P'); |
1624 | - } else $offset = '+00:00'; |
|
1736 | + } else { |
|
1737 | + $offset = '+00:00'; |
|
1738 | + } |
|
1625 | 1739 | $filter_query = $this->getFilter($filters,true,true); |
1626 | 1740 | if ($globalDBdriver == 'mysql') { |
1627 | 1741 | $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 |
@@ -1670,7 +1784,9 @@ discard block |
||
1670 | 1784 | date_default_timezone_set($globalTimezone); |
1671 | 1785 | $datetime = new DateTime(); |
1672 | 1786 | $offset = $datetime->format('P'); |
1673 | - } else $offset = '+00:00'; |
|
1787 | + } else { |
|
1788 | + $offset = '+00:00'; |
|
1789 | + } |
|
1674 | 1790 | |
1675 | 1791 | $orderby_sql = ''; |
1676 | 1792 | if ($orderby == "hour") |
@@ -1739,7 +1855,9 @@ discard block |
||
1739 | 1855 | date_default_timezone_set($globalTimezone); |
1740 | 1856 | $datetime = new DateTime($date); |
1741 | 1857 | $offset = $datetime->format('P'); |
1742 | - } else $offset = '+00:00'; |
|
1858 | + } else { |
|
1859 | + $offset = '+00:00'; |
|
1860 | + } |
|
1743 | 1861 | |
1744 | 1862 | if ($globalDBdriver == 'mysql') { |
1745 | 1863 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1787,7 +1905,9 @@ discard block |
||
1787 | 1905 | date_default_timezone_set($globalTimezone); |
1788 | 1906 | $datetime = new DateTime(); |
1789 | 1907 | $offset = $datetime->format('P'); |
1790 | - } else $offset = '+00:00'; |
|
1908 | + } else { |
|
1909 | + $offset = '+00:00'; |
|
1910 | + } |
|
1791 | 1911 | |
1792 | 1912 | if ($globalDBdriver == 'mysql') { |
1793 | 1913 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1846,7 +1966,9 @@ discard block |
||
1846 | 1966 | } |
1847 | 1967 | } |
1848 | 1968 | $query .= " GROUP BY marine_output.race_id,marine_output.race_name ORDER BY captain_count DESC"; |
1849 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1969 | + if ($limit) { |
|
1970 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1971 | + } |
|
1850 | 1972 | $sth = $this->db->prepare($query); |
1851 | 1973 | $sth->execute(); |
1852 | 1974 | $marine_array = array(); |
@@ -1893,8 +2015,11 @@ discard block |
||
1893 | 2015 | $query_values = array_merge($query_values,array(':month' => $month)); |
1894 | 2016 | } |
1895 | 2017 | } |
1896 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1897 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
2018 | + if (empty($query_values)) { |
|
2019 | + $queryi .= $this->getFilter($filters); |
|
2020 | + } else { |
|
2021 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
2022 | + } |
|
1898 | 2023 | |
1899 | 2024 | $sth = $this->db->prepare($queryi); |
1900 | 2025 | $sth->execute($query_values); |
@@ -1931,8 +2056,11 @@ discard block |
||
1931 | 2056 | $query_values = array_merge($query_values,array(':month' => $month)); |
1932 | 2057 | } |
1933 | 2058 | } |
1934 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1935 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
2059 | + if (empty($query_values)) { |
|
2060 | + $queryi .= $this->getFilter($filters); |
|
2061 | + } else { |
|
2062 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
2063 | + } |
|
1936 | 2064 | |
1937 | 2065 | $sth = $this->db->prepare($queryi); |
1938 | 2066 | $sth->execute($query_values); |
@@ -1969,8 +2097,11 @@ discard block |
||
1969 | 2097 | $query_values = array_merge($query_values,array(':month' => $month)); |
1970 | 2098 | } |
1971 | 2099 | } |
1972 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1973 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
2100 | + if (empty($query_values)) { |
|
2101 | + $queryi .= $this->getFilter($filters); |
|
2102 | + } else { |
|
2103 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
2104 | + } |
|
1974 | 2105 | |
1975 | 2106 | $sth = $this->db->prepare($queryi); |
1976 | 2107 | $sth->execute($query_values); |
@@ -2007,8 +2138,11 @@ discard block |
||
2007 | 2138 | $query_values = array_merge($query_values,array(':month' => $month)); |
2008 | 2139 | } |
2009 | 2140 | } |
2010 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
2011 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
2141 | + if (empty($query_values)) { |
|
2142 | + $queryi .= $this->getFilter($filters); |
|
2143 | + } else { |
|
2144 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
2145 | + } |
|
2012 | 2146 | |
2013 | 2147 | $sth = $this->db->prepare($queryi); |
2014 | 2148 | $sth->execute($query_values); |
@@ -2029,7 +2163,9 @@ discard block |
||
2029 | 2163 | date_default_timezone_set($globalTimezone); |
2030 | 2164 | $datetime = new DateTime(); |
2031 | 2165 | $offset = $datetime->format('P'); |
2032 | - } else $offset = '+00:00'; |
|
2166 | + } else { |
|
2167 | + $offset = '+00:00'; |
|
2168 | + } |
|
2033 | 2169 | |
2034 | 2170 | if ($globalDBdriver == 'mysql') { |
2035 | 2171 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -2133,7 +2269,9 @@ discard block |
||
2133 | 2269 | */ |
2134 | 2270 | public function parseDirection($direction = 0) |
2135 | 2271 | { |
2136 | - if ($direction == '') $direction = 0; |
|
2272 | + if ($direction == '') { |
|
2273 | + $direction = 0; |
|
2274 | + } |
|
2137 | 2275 | $direction_array = array(); |
2138 | 2276 | $temp_array = array(); |
2139 | 2277 | |
@@ -2222,7 +2360,9 @@ discard block |
||
2222 | 2360 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2223 | 2361 | |
2224 | 2362 | $Connection = new Connection($this->db); |
2225 | - if (!$Connection->tableExists('countries')) return ''; |
|
2363 | + if (!$Connection->tableExists('countries')) { |
|
2364 | + return ''; |
|
2365 | + } |
|
2226 | 2366 | |
2227 | 2367 | try { |
2228 | 2368 | /* |
@@ -2242,9 +2382,13 @@ discard block |
||
2242 | 2382 | $sth->closeCursor(); |
2243 | 2383 | if (count($row) > 0) { |
2244 | 2384 | return $row; |
2245 | - } else return ''; |
|
2385 | + } else { |
|
2386 | + return ''; |
|
2387 | + } |
|
2246 | 2388 | } catch (PDOException $e) { |
2247 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
2389 | + if (isset($globalDebug) && $globalDebug) { |
|
2390 | + echo 'Error : '.$e->getMessage()."\n"; |
|
2391 | + } |
|
2248 | 2392 | return ''; |
2249 | 2393 | } |
2250 | 2394 | |
@@ -2262,7 +2406,9 @@ discard block |
||
2262 | 2406 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
2263 | 2407 | |
2264 | 2408 | $Connection = new Connection($this->db); |
2265 | - if (!$Connection->tableExists('countries')) return ''; |
|
2409 | + if (!$Connection->tableExists('countries')) { |
|
2410 | + return ''; |
|
2411 | + } |
|
2266 | 2412 | |
2267 | 2413 | try { |
2268 | 2414 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -2274,9 +2420,13 @@ discard block |
||
2274 | 2420 | $sth->closeCursor(); |
2275 | 2421 | if (count($row) > 0) { |
2276 | 2422 | return $row; |
2277 | - } else return ''; |
|
2423 | + } else { |
|
2424 | + return ''; |
|
2425 | + } |
|
2278 | 2426 | } catch (PDOException $e) { |
2279 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
2427 | + if (isset($globalDebug) && $globalDebug) { |
|
2428 | + echo 'Error : '.$e->getMessage()."\n"; |
|
2429 | + } |
|
2280 | 2430 | return ''; |
2281 | 2431 | } |
2282 | 2432 | |
@@ -2294,7 +2444,9 @@ discard block |
||
2294 | 2444 | { |
2295 | 2445 | global $globalBitlyAccessToken; |
2296 | 2446 | |
2297 | - if ($globalBitlyAccessToken == '') return $url; |
|
2447 | + if ($globalBitlyAccessToken == '') { |
|
2448 | + return $url; |
|
2449 | + } |
|
2298 | 2450 | |
2299 | 2451 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
2300 | 2452 | |
@@ -2370,7 +2522,9 @@ discard block |
||
2370 | 2522 | } |
2371 | 2523 | } |
2372 | 2524 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
2373 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
2525 | + if ($limit) { |
|
2526 | + $query .= " LIMIT 10 OFFSET 0"; |
|
2527 | + } |
|
2374 | 2528 | $sth = $this->db->prepare($query); |
2375 | 2529 | $sth->execute($query_values); |
2376 | 2530 | $marine_array = array(); |
@@ -2408,9 +2562,15 @@ discard block |
||
2408 | 2562 | foreach ($q_array as $q_item){ |
2409 | 2563 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
2410 | 2564 | $additional_query .= " AND ("; |
2411 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
2412 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
2413 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
2565 | + if (is_int($q_item)) { |
|
2566 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
2567 | + } |
|
2568 | + if (is_int($q_item)) { |
|
2569 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
2570 | + } |
|
2571 | + if (is_int($q_item)) { |
|
2572 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
2573 | + } |
|
2414 | 2574 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
2415 | 2575 | $additional_query .= ")"; |
2416 | 2576 | } |
@@ -2458,7 +2618,9 @@ discard block |
||
2458 | 2618 | date_default_timezone_set($globalTimezone); |
2459 | 2619 | $datetime = new DateTime(); |
2460 | 2620 | $offset = $datetime->format('P'); |
2461 | - } else $offset = '+00:00'; |
|
2621 | + } else { |
|
2622 | + $offset = '+00:00'; |
|
2623 | + } |
|
2462 | 2624 | if ($date_array[1] != "") |
2463 | 2625 | { |
2464 | 2626 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -2485,8 +2647,12 @@ discard block |
||
2485 | 2647 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
2486 | 2648 | { |
2487 | 2649 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
2488 | - } else $limit_query = ""; |
|
2489 | - } else $limit_query = ""; |
|
2650 | + } else { |
|
2651 | + $limit_query = ""; |
|
2652 | + } |
|
2653 | + } else { |
|
2654 | + $limit_query = ""; |
|
2655 | + } |
|
2490 | 2656 | if ($sort != "") |
2491 | 2657 | { |
2492 | 2658 | $search_orderby_array = $this->getOrderBy(); |
@@ -2552,8 +2718,11 @@ discard block |
||
2552 | 2718 | $sth = $this->db->prepare($query); |
2553 | 2719 | $sth->execute(array(':race_name' => $race_name)); |
2554 | 2720 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
2555 | - if (isset($result[0])) return $result[0]; |
|
2556 | - else return array(); |
|
2721 | + if (isset($result[0])) { |
|
2722 | + return $result[0]; |
|
2723 | + } else { |
|
2724 | + return array(); |
|
2725 | + } |
|
2557 | 2726 | } |
2558 | 2727 | |
2559 | 2728 | /** |
@@ -2569,8 +2738,11 @@ discard block |
||
2569 | 2738 | $sth = $this->db->prepare($query); |
2570 | 2739 | $sth->execute(array(':race_id' => $race_id)); |
2571 | 2740 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
2572 | - if (isset($result[0])) return $result[0]; |
|
2573 | - else return array(); |
|
2741 | + if (isset($result[0])) { |
|
2742 | + return $result[0]; |
|
2743 | + } else { |
|
2744 | + return array(); |
|
2745 | + } |
|
2574 | 2746 | } |
2575 | 2747 | |
2576 | 2748 | /** |