@@ -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 spotter_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 spotter_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 | |
@@ -792,11 +792,11 @@ discard block |
||
| 792 | 792 | * @return Array list of source name |
| 793 | 793 | * |
| 794 | 794 | */ |
| 795 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 795 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 796 | 796 | { |
| 797 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 797 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 798 | 798 | $query_values = array(); |
| 799 | - $query = "SELECT DISTINCT marine_output.source_name |
|
| 799 | + $query = "SELECT DISTINCT marine_output.source_name |
|
| 800 | 800 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
| 801 | 801 | if ($type != '') { |
| 802 | 802 | $query_values = array(':type' => $type); |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | $source_array = array(); |
| 812 | 812 | $temp_array = array(); |
| 813 | 813 | |
| 814 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 814 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 815 | 815 | { |
| 816 | 816 | $temp_array['source_name'] = $row['source_name']; |
| 817 | 817 | $source_array[] = $temp_array; |
@@ -828,8 +828,8 @@ discard block |
||
| 828 | 828 | */ |
| 829 | 829 | public function getAllIdents($filters = array()) |
| 830 | 830 | { |
| 831 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 832 | - $query = "SELECT DISTINCT marine_output.ident |
|
| 831 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 832 | + $query = "SELECT DISTINCT marine_output.ident |
|
| 833 | 833 | FROM marine_output".$filter_query." marine_output.ident <> '' |
| 834 | 834 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
| 835 | 835 | |
@@ -839,7 +839,7 @@ discard block |
||
| 839 | 839 | $ident_array = array(); |
| 840 | 840 | $temp_array = array(); |
| 841 | 841 | |
| 842 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 842 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 843 | 843 | { |
| 844 | 844 | $temp_array['ident'] = $row['ident']; |
| 845 | 845 | $ident_array[] = $temp_array; |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | */ |
| 857 | 857 | public function getIdentity($mmsi) |
| 858 | 858 | { |
| 859 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 859 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 860 | 860 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
| 861 | 861 | $sth = $this->db->prepare($query); |
| 862 | 862 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -869,23 +869,23 @@ discard block |
||
| 869 | 869 | * Add identity |
| 870 | 870 | * |
| 871 | 871 | */ |
| 872 | - public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
|
| 872 | + public function addIdentity($mmsi, $imo, $ident, $callsign, $type) |
|
| 873 | 873 | { |
| 874 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 874 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 875 | 875 | if ($mmsi != '') { |
| 876 | - $imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT); |
|
| 877 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 878 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 879 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 876 | + $imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT); |
|
| 877 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 878 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 879 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 880 | 880 | $identinfo = $this->getIdentity($mmsi); |
| 881 | 881 | if (empty($identinfo)) { |
| 882 | - $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
| 882 | + $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
| 883 | 883 | $sth = $this->db->prepare($query); |
| 884 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type)); |
|
| 884 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type)); |
|
| 885 | 885 | } elseif ($ident != '' && $identinfo['ship_name'] != $ident) { |
| 886 | - $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
| 886 | + $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
| 887 | 887 | $sth = $this->db->prepare($query); |
| 888 | - $sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type)); |
|
| 888 | + $sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type)); |
|
| 889 | 889 | } |
| 890 | 890 | } |
| 891 | 891 | } |
@@ -906,12 +906,12 @@ discard block |
||
| 906 | 906 | } else $offset = '+00:00'; |
| 907 | 907 | |
| 908 | 908 | if ($globalDBdriver == 'mysql') { |
| 909 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 909 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 910 | 910 | FROM marine_output |
| 911 | 911 | WHERE marine_output.date <> '' |
| 912 | 912 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
| 913 | 913 | } else { |
| 914 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 914 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 915 | 915 | FROM marine_output |
| 916 | 916 | WHERE marine_output.date <> '' |
| 917 | 917 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
@@ -923,7 +923,7 @@ discard block |
||
| 923 | 923 | $date_array = array(); |
| 924 | 924 | $temp_array = array(); |
| 925 | 925 | |
| 926 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 926 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 927 | 927 | { |
| 928 | 928 | $temp_array['date'] = $row['date']; |
| 929 | 929 | |
@@ -941,10 +941,10 @@ discard block |
||
| 941 | 941 | * @return String success or false |
| 942 | 942 | * |
| 943 | 943 | */ |
| 944 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
| 944 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
| 945 | 945 | { |
| 946 | 946 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 947 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 947 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
| 948 | 948 | try { |
| 949 | 949 | $sth = $this->db->prepare($query); |
| 950 | 950 | $sth->execute($query_values); |
@@ -962,10 +962,10 @@ discard block |
||
| 962 | 962 | * @return String success or false |
| 963 | 963 | * |
| 964 | 964 | */ |
| 965 | - public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
|
| 965 | + public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL) |
|
| 966 | 966 | { |
| 967 | 967 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
| 968 | - $query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code); |
|
| 968 | + $query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code); |
|
| 969 | 969 | try { |
| 970 | 970 | $sth = $this->db->prepare($query); |
| 971 | 971 | $sth->execute($query_values); |
@@ -984,11 +984,11 @@ discard block |
||
| 984 | 984 | * @return String success or false |
| 985 | 985 | * |
| 986 | 986 | */ |
| 987 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
| 987 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
| 988 | 988 | { |
| 989 | 989 | |
| 990 | 990 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
| 991 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 991 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
| 992 | 992 | |
| 993 | 993 | try { |
| 994 | 994 | $sth = $this->db->prepare($query); |
@@ -1008,17 +1008,17 @@ discard block |
||
| 1008 | 1008 | * @return String success or false |
| 1009 | 1009 | * |
| 1010 | 1010 | */ |
| 1011 | - public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
|
| 1011 | + public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '', $distance = NULL, $race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
|
| 1012 | 1012 | { |
| 1013 | 1013 | if ($latitude == '') $latitude = NULL; |
| 1014 | 1014 | if ($longitude == '') $longitude = NULL; |
| 1015 | 1015 | $groundspeed = round($groundspeed); |
| 1016 | 1016 | if ($race_begin != '') { |
| 1017 | 1017 | $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'; |
| 1018 | - $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); |
|
| 1018 | + $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 | 1019 | } else { |
| 1020 | 1020 | $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'; |
| 1021 | - $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); |
|
| 1021 | + $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 | 1022 | } |
| 1023 | 1023 | try { |
| 1024 | 1024 | $sth = $this->db->prepare($query); |
@@ -1057,7 +1057,7 @@ discard block |
||
| 1057 | 1057 | * @param String $verticalrate vertival rate of flight |
| 1058 | 1058 | * @return String success or false |
| 1059 | 1059 | */ |
| 1060 | - 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 = '') |
|
| 1060 | + 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 | 1061 | { |
| 1062 | 1062 | global $globalURL, $globalMarineImageFetch; |
| 1063 | 1063 | |
@@ -1129,34 +1129,34 @@ discard block |
||
| 1129 | 1129 | $date = date("Y-m-d H:i:s", time()); |
| 1130 | 1130 | } |
| 1131 | 1131 | |
| 1132 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1133 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1134 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1135 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1136 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 1137 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1138 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 1139 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 1140 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 1141 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 1142 | - $type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
| 1143 | - $status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
| 1144 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 1145 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 1146 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 1147 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 1148 | - $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
| 1149 | - $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
| 1150 | - $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
| 1151 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
| 1152 | - $race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT); |
|
| 1153 | - $race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1154 | - $distance = filter_var($distance,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1132 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1133 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1134 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1135 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1136 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 1137 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1138 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 1139 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 1140 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 1141 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 1142 | + $type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
| 1143 | + $status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
| 1144 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 1145 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 1146 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 1147 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 1148 | + $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
| 1149 | + $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
| 1150 | + $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
| 1151 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
| 1152 | + $race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT); |
|
| 1153 | + $race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1154 | + $distance = filter_var($distance, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1155 | 1155 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
| 1156 | 1156 | $Image = new Image($this->db); |
| 1157 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
| 1157 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
| 1158 | 1158 | if (!isset($image_array[0]['mmsi'])) { |
| 1159 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
| 1159 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
| 1160 | 1160 | } |
| 1161 | 1161 | unset($Image); |
| 1162 | 1162 | } |
@@ -1172,10 +1172,10 @@ discard block |
||
| 1172 | 1172 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 1173 | 1173 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 1174 | 1174 | if ($arrival_date == '') $arrival_date = NULL; |
| 1175 | - $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) |
|
| 1175 | + $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 | 1176 | 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)"; |
| 1177 | 1177 | |
| 1178 | - $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); |
|
| 1178 | + $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 | 1179 | try { |
| 1180 | 1180 | $sth = $this->db->prepare($query); |
| 1181 | 1181 | $sth->execute($query_values); |
@@ -1199,13 +1199,13 @@ discard block |
||
| 1199 | 1199 | { |
| 1200 | 1200 | global $globalDBdriver, $globalTimezone; |
| 1201 | 1201 | if ($globalDBdriver == 'mysql') { |
| 1202 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 1202 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 1203 | 1203 | WHERE marine_output.ident = :ident |
| 1204 | 1204 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 1205 | 1205 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 1206 | 1206 | $query_data = array(':ident' => $ident); |
| 1207 | 1207 | } else { |
| 1208 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 1208 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 1209 | 1209 | WHERE marine_output.ident = :ident |
| 1210 | 1210 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 1211 | 1211 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -1214,8 +1214,8 @@ discard block |
||
| 1214 | 1214 | |
| 1215 | 1215 | $sth = $this->db->prepare($query); |
| 1216 | 1216 | $sth->execute($query_data); |
| 1217 | - $ident_result=''; |
|
| 1218 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1217 | + $ident_result = ''; |
|
| 1218 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1219 | 1219 | { |
| 1220 | 1220 | $ident_result = $row['ident']; |
| 1221 | 1221 | } |
@@ -1241,8 +1241,8 @@ discard block |
||
| 1241 | 1241 | return false; |
| 1242 | 1242 | } else { |
| 1243 | 1243 | $q_array = explode(" ", $q); |
| 1244 | - foreach ($q_array as $q_item){ |
|
| 1245 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 1244 | + foreach ($q_array as $q_item) { |
|
| 1245 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 1246 | 1246 | $additional_query .= " AND ("; |
| 1247 | 1247 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
| 1248 | 1248 | $additional_query .= ")"; |
@@ -1250,11 +1250,11 @@ discard block |
||
| 1250 | 1250 | } |
| 1251 | 1251 | } |
| 1252 | 1252 | if ($globalDBdriver == 'mysql') { |
| 1253 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 1253 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 1254 | 1254 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 1255 | 1255 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 1256 | 1256 | } else { |
| 1257 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 1257 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 1258 | 1258 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 1259 | 1259 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 1260 | 1260 | } |
@@ -1273,16 +1273,16 @@ discard block |
||
| 1273 | 1273 | * |
| 1274 | 1274 | */ |
| 1275 | 1275 | |
| 1276 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 1276 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 1277 | 1277 | { |
| 1278 | 1278 | global $globalDBdriver, $globalArchive; |
| 1279 | 1279 | //$filter_query = $this->getFilter($filters,true,true); |
| 1280 | - $Connection= new Connection($this->db); |
|
| 1280 | + $Connection = new Connection($this->db); |
|
| 1281 | 1281 | if (!$Connection->tableExists('countries')) return array(); |
| 1282 | 1282 | require_once('class.SpotterLive.php'); |
| 1283 | 1283 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 1284 | 1284 | $MarineLive = new MarineLive($this->db); |
| 1285 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
| 1285 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
| 1286 | 1286 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
| 1287 | 1287 | if ($olderthanmonths > 0) { |
| 1288 | 1288 | if ($globalDBdriver == 'mysql') { |
@@ -1302,7 +1302,7 @@ discard block |
||
| 1302 | 1302 | } else { |
| 1303 | 1303 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
| 1304 | 1304 | $MarineArchive = new MarineArchive($this->db); |
| 1305 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
| 1305 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
| 1306 | 1306 | $filter_query .= " over_country <> ''"; |
| 1307 | 1307 | if ($olderthanmonths > 0) { |
| 1308 | 1308 | if ($globalDBdriver == 'mysql') { |
@@ -1330,7 +1330,7 @@ discard block |
||
| 1330 | 1330 | $flight_array = array(); |
| 1331 | 1331 | $temp_array = array(); |
| 1332 | 1332 | |
| 1333 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1333 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1334 | 1334 | { |
| 1335 | 1335 | $temp_array['marine_count'] = $row['nb']; |
| 1336 | 1336 | $temp_array['marine_country'] = $row['name']; |
@@ -1349,11 +1349,11 @@ discard block |
||
| 1349 | 1349 | * @return Array the callsign list |
| 1350 | 1350 | * |
| 1351 | 1351 | */ |
| 1352 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 1352 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 1353 | 1353 | { |
| 1354 | 1354 | global $globalDBdriver; |
| 1355 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1356 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 1355 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1356 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 1357 | 1357 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 1358 | 1358 | if ($olderthanmonths > 0) { |
| 1359 | 1359 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -1367,28 +1367,28 @@ discard block |
||
| 1367 | 1367 | if ($year != '') { |
| 1368 | 1368 | if ($globalDBdriver == 'mysql') { |
| 1369 | 1369 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1370 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1370 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1371 | 1371 | } else { |
| 1372 | 1372 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1373 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1373 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1374 | 1374 | } |
| 1375 | 1375 | } |
| 1376 | 1376 | if ($month != '') { |
| 1377 | 1377 | if ($globalDBdriver == 'mysql') { |
| 1378 | 1378 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1379 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1379 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1380 | 1380 | } else { |
| 1381 | 1381 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1382 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1382 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1383 | 1383 | } |
| 1384 | 1384 | } |
| 1385 | 1385 | if ($day != '') { |
| 1386 | 1386 | if ($globalDBdriver == 'mysql') { |
| 1387 | 1387 | $query .= " AND DAY(marine_output.date) = :day"; |
| 1388 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1388 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1389 | 1389 | } else { |
| 1390 | 1390 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 1391 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1391 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1392 | 1392 | } |
| 1393 | 1393 | } |
| 1394 | 1394 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -1400,7 +1400,7 @@ discard block |
||
| 1400 | 1400 | $callsign_array = array(); |
| 1401 | 1401 | $temp_array = array(); |
| 1402 | 1402 | |
| 1403 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1403 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1404 | 1404 | { |
| 1405 | 1405 | $temp_array['callsign_icao'] = $row['ident']; |
| 1406 | 1406 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -1452,7 +1452,7 @@ discard block |
||
| 1452 | 1452 | $date_array = array(); |
| 1453 | 1453 | $temp_array = array(); |
| 1454 | 1454 | |
| 1455 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1455 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1456 | 1456 | { |
| 1457 | 1457 | $temp_array['date_name'] = $row['date_name']; |
| 1458 | 1458 | $temp_array['date_count'] = $row['date_count']; |
@@ -1478,7 +1478,7 @@ discard block |
||
| 1478 | 1478 | $datetime = new DateTime(); |
| 1479 | 1479 | $offset = $datetime->format('P'); |
| 1480 | 1480 | } else $offset = '+00:00'; |
| 1481 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1481 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1482 | 1482 | if ($globalDBdriver == 'mysql') { |
| 1483 | 1483 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1484 | 1484 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1499,7 +1499,7 @@ discard block |
||
| 1499 | 1499 | $date_array = array(); |
| 1500 | 1500 | $temp_array = array(); |
| 1501 | 1501 | |
| 1502 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1502 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1503 | 1503 | { |
| 1504 | 1504 | $temp_array['date_name'] = $row['date_name']; |
| 1505 | 1505 | $temp_array['date_count'] = $row['date_count']; |
@@ -1524,7 +1524,7 @@ discard block |
||
| 1524 | 1524 | $datetime = new DateTime(); |
| 1525 | 1525 | $offset = $datetime->format('P'); |
| 1526 | 1526 | } else $offset = '+00:00'; |
| 1527 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1527 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1528 | 1528 | if ($globalDBdriver == 'mysql') { |
| 1529 | 1529 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1530 | 1530 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1545,7 +1545,7 @@ discard block |
||
| 1545 | 1545 | $date_array = array(); |
| 1546 | 1546 | $temp_array = array(); |
| 1547 | 1547 | |
| 1548 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1548 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1549 | 1549 | { |
| 1550 | 1550 | $temp_array['date_name'] = $row['date_name']; |
| 1551 | 1551 | $temp_array['date_count'] = $row['date_count']; |
@@ -1592,7 +1592,7 @@ discard block |
||
| 1592 | 1592 | $date_array = array(); |
| 1593 | 1593 | $temp_array = array(); |
| 1594 | 1594 | |
| 1595 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1595 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1596 | 1596 | { |
| 1597 | 1597 | $temp_array['month_name'] = $row['month_name']; |
| 1598 | 1598 | $temp_array['year_name'] = $row['year_name']; |
@@ -1621,7 +1621,7 @@ discard block |
||
| 1621 | 1621 | $datetime = new DateTime(); |
| 1622 | 1622 | $offset = $datetime->format('P'); |
| 1623 | 1623 | } else $offset = '+00:00'; |
| 1624 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1624 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1625 | 1625 | if ($globalDBdriver == 'mysql') { |
| 1626 | 1626 | $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 |
| 1627 | 1627 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1642,7 +1642,7 @@ discard block |
||
| 1642 | 1642 | $date_array = array(); |
| 1643 | 1643 | $temp_array = array(); |
| 1644 | 1644 | |
| 1645 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1645 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1646 | 1646 | { |
| 1647 | 1647 | $temp_array['year_name'] = $row['year_name']; |
| 1648 | 1648 | $temp_array['month_name'] = $row['month_name']; |
@@ -1662,7 +1662,7 @@ discard block |
||
| 1662 | 1662 | * @return Array the hour list |
| 1663 | 1663 | * |
| 1664 | 1664 | */ |
| 1665 | - public function countAllHours($orderby,$filters = array()) |
|
| 1665 | + public function countAllHours($orderby, $filters = array()) |
|
| 1666 | 1666 | { |
| 1667 | 1667 | global $globalTimezone, $globalDBdriver; |
| 1668 | 1668 | if ($globalTimezone != '') { |
@@ -1710,7 +1710,7 @@ discard block |
||
| 1710 | 1710 | $hour_array = array(); |
| 1711 | 1711 | $temp_array = array(); |
| 1712 | 1712 | |
| 1713 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1713 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1714 | 1714 | { |
| 1715 | 1715 | $temp_array['hour_name'] = $row['hour_name']; |
| 1716 | 1716 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1732,8 +1732,8 @@ discard block |
||
| 1732 | 1732 | public function countAllHoursByDate($date, $filters = array()) |
| 1733 | 1733 | { |
| 1734 | 1734 | global $globalTimezone, $globalDBdriver; |
| 1735 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1736 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1735 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1736 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1737 | 1737 | if ($globalTimezone != '') { |
| 1738 | 1738 | date_default_timezone_set($globalTimezone); |
| 1739 | 1739 | $datetime = new DateTime($date); |
@@ -1741,12 +1741,12 @@ discard block |
||
| 1741 | 1741 | } else $offset = '+00:00'; |
| 1742 | 1742 | |
| 1743 | 1743 | if ($globalDBdriver == 'mysql') { |
| 1744 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1744 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1745 | 1745 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
| 1746 | 1746 | GROUP BY hour_name |
| 1747 | 1747 | ORDER BY hour_name ASC"; |
| 1748 | 1748 | } else { |
| 1749 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1749 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1750 | 1750 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1751 | 1751 | GROUP BY hour_name |
| 1752 | 1752 | ORDER BY hour_name ASC"; |
@@ -1758,7 +1758,7 @@ discard block |
||
| 1758 | 1758 | $hour_array = array(); |
| 1759 | 1759 | $temp_array = array(); |
| 1760 | 1760 | |
| 1761 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1761 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1762 | 1762 | { |
| 1763 | 1763 | $temp_array['hour_name'] = $row['hour_name']; |
| 1764 | 1764 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1780,8 +1780,8 @@ discard block |
||
| 1780 | 1780 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1781 | 1781 | { |
| 1782 | 1782 | global $globalTimezone, $globalDBdriver; |
| 1783 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1784 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1783 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1784 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1785 | 1785 | if ($globalTimezone != '') { |
| 1786 | 1786 | date_default_timezone_set($globalTimezone); |
| 1787 | 1787 | $datetime = new DateTime(); |
@@ -1789,12 +1789,12 @@ discard block |
||
| 1789 | 1789 | } else $offset = '+00:00'; |
| 1790 | 1790 | |
| 1791 | 1791 | if ($globalDBdriver == 'mysql') { |
| 1792 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1792 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1793 | 1793 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1794 | 1794 | GROUP BY hour_name |
| 1795 | 1795 | ORDER BY hour_name ASC"; |
| 1796 | 1796 | } else { |
| 1797 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1797 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1798 | 1798 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1799 | 1799 | GROUP BY hour_name |
| 1800 | 1800 | ORDER BY hour_name ASC"; |
@@ -1802,12 +1802,12 @@ discard block |
||
| 1802 | 1802 | |
| 1803 | 1803 | |
| 1804 | 1804 | $sth = $this->db->prepare($query); |
| 1805 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1805 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1806 | 1806 | |
| 1807 | 1807 | $hour_array = array(); |
| 1808 | 1808 | $temp_array = array(); |
| 1809 | 1809 | |
| 1810 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1810 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1811 | 1811 | { |
| 1812 | 1812 | $temp_array['hour_name'] = $row['hour_name']; |
| 1813 | 1813 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1826,33 +1826,33 @@ discard block |
||
| 1826 | 1826 | * @return Integer the number of vessels |
| 1827 | 1827 | * |
| 1828 | 1828 | */ |
| 1829 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
| 1829 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
| 1830 | 1830 | { |
| 1831 | 1831 | global $globalDBdriver; |
| 1832 | 1832 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
| 1833 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 1833 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 1834 | 1834 | $query_values = array(); |
| 1835 | 1835 | $query = ''; |
| 1836 | 1836 | if ($year != '') { |
| 1837 | 1837 | if ($globalDBdriver == 'mysql') { |
| 1838 | 1838 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1839 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1839 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1840 | 1840 | } else { |
| 1841 | 1841 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1842 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1842 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1843 | 1843 | } |
| 1844 | 1844 | } |
| 1845 | 1845 | if ($month != '') { |
| 1846 | 1846 | if ($globalDBdriver == 'mysql') { |
| 1847 | 1847 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1848 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1848 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1849 | 1849 | } else { |
| 1850 | 1850 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1851 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1851 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1852 | 1852 | } |
| 1853 | 1853 | } |
| 1854 | 1854 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1855 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1855 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1856 | 1856 | |
| 1857 | 1857 | $sth = $this->db->prepare($queryi); |
| 1858 | 1858 | $sth->execute($query_values); |
@@ -1865,32 +1865,32 @@ discard block |
||
| 1865 | 1865 | * @return Integer the number of vessels |
| 1866 | 1866 | * |
| 1867 | 1867 | */ |
| 1868 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
| 1868 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
| 1869 | 1869 | { |
| 1870 | 1870 | global $globalDBdriver; |
| 1871 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 1871 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 1872 | 1872 | $query_values = array(); |
| 1873 | 1873 | $query = ''; |
| 1874 | 1874 | if ($year != '') { |
| 1875 | 1875 | if ($globalDBdriver == 'mysql') { |
| 1876 | 1876 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1877 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1877 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1878 | 1878 | } else { |
| 1879 | 1879 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1880 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1880 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1881 | 1881 | } |
| 1882 | 1882 | } |
| 1883 | 1883 | if ($month != '') { |
| 1884 | 1884 | if ($globalDBdriver == 'mysql') { |
| 1885 | 1885 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1886 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1886 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1887 | 1887 | } else { |
| 1888 | 1888 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1889 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1889 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1890 | 1890 | } |
| 1891 | 1891 | } |
| 1892 | 1892 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1893 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1893 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1894 | 1894 | |
| 1895 | 1895 | $sth = $this->db->prepare($queryi); |
| 1896 | 1896 | $sth->execute($query_values); |
@@ -1907,7 +1907,7 @@ discard block |
||
| 1907 | 1907 | public function countAllHoursFromToday($filters = array()) |
| 1908 | 1908 | { |
| 1909 | 1909 | global $globalTimezone, $globalDBdriver; |
| 1910 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1910 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1911 | 1911 | if ($globalTimezone != '') { |
| 1912 | 1912 | date_default_timezone_set($globalTimezone); |
| 1913 | 1913 | $datetime = new DateTime(); |
@@ -1915,12 +1915,12 @@ discard block |
||
| 1915 | 1915 | } else $offset = '+00:00'; |
| 1916 | 1916 | |
| 1917 | 1917 | if ($globalDBdriver == 'mysql') { |
| 1918 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1918 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1919 | 1919 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
| 1920 | 1920 | GROUP BY hour_name |
| 1921 | 1921 | ORDER BY hour_name ASC"; |
| 1922 | 1922 | } else { |
| 1923 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1923 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1924 | 1924 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 1925 | 1925 | GROUP BY hour_name |
| 1926 | 1926 | ORDER BY hour_name ASC"; |
@@ -1932,7 +1932,7 @@ discard block |
||
| 1932 | 1932 | $hour_array = array(); |
| 1933 | 1933 | $temp_array = array(); |
| 1934 | 1934 | |
| 1935 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1935 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1936 | 1936 | { |
| 1937 | 1937 | $temp_array['hour_name'] = $row['hour_name']; |
| 1938 | 1938 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1951,9 +1951,9 @@ discard block |
||
| 1951 | 1951 | */ |
| 1952 | 1952 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1953 | 1953 | { |
| 1954 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1954 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1955 | 1955 | |
| 1956 | - $query = "SELECT marine_output.marine_id |
|
| 1956 | + $query = "SELECT marine_output.marine_id |
|
| 1957 | 1957 | FROM marine_output |
| 1958 | 1958 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
| 1959 | 1959 | |
@@ -1961,7 +1961,7 @@ discard block |
||
| 1961 | 1961 | $sth = $this->db->prepare($query); |
| 1962 | 1962 | $sth->execute(); |
| 1963 | 1963 | |
| 1964 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1964 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1965 | 1965 | { |
| 1966 | 1966 | return $row['marine_id']; |
| 1967 | 1967 | } |
@@ -1986,23 +1986,23 @@ discard block |
||
| 1986 | 1986 | } |
| 1987 | 1987 | |
| 1988 | 1988 | $current_date = date("Y-m-d H:i:s"); |
| 1989 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 1989 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 1990 | 1990 | |
| 1991 | 1991 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 1992 | 1992 | |
| 1993 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 1993 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 1994 | 1994 | $years = $time_array['years']; |
| 1995 | 1995 | |
| 1996 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 1996 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 1997 | 1997 | $months = $time_array['months']; |
| 1998 | 1998 | |
| 1999 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 1999 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 2000 | 2000 | $days = $time_array['days']; |
| 2001 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 2001 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 2002 | 2002 | $hours = $time_array['hours']; |
| 2003 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 2003 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 2004 | 2004 | $minutes = $time_array['minutes']; |
| 2005 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 2005 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 2006 | 2006 | |
| 2007 | 2007 | return $time_array; |
| 2008 | 2008 | } |
@@ -2025,63 +2025,63 @@ discard block |
||
| 2025 | 2025 | $temp_array['direction_degree'] = $direction; |
| 2026 | 2026 | $temp_array['direction_shortname'] = "N"; |
| 2027 | 2027 | $temp_array['direction_fullname'] = "North"; |
| 2028 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 2028 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 2029 | 2029 | $temp_array['direction_degree'] = $direction; |
| 2030 | 2030 | $temp_array['direction_shortname'] = "NNE"; |
| 2031 | 2031 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 2032 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 2032 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 2033 | 2033 | $temp_array['direction_degree'] = $direction; |
| 2034 | 2034 | $temp_array['direction_shortname'] = "NE"; |
| 2035 | 2035 | $temp_array['direction_fullname'] = "Northeast"; |
| 2036 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 2036 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 2037 | 2037 | $temp_array['direction_degree'] = $direction; |
| 2038 | 2038 | $temp_array['direction_shortname'] = "ENE"; |
| 2039 | 2039 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 2040 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 2040 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 2041 | 2041 | $temp_array['direction_degree'] = $direction; |
| 2042 | 2042 | $temp_array['direction_shortname'] = "E"; |
| 2043 | 2043 | $temp_array['direction_fullname'] = "East"; |
| 2044 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 2044 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 2045 | 2045 | $temp_array['direction_degree'] = $direction; |
| 2046 | 2046 | $temp_array['direction_shortname'] = "ESE"; |
| 2047 | 2047 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 2048 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 2048 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 2049 | 2049 | $temp_array['direction_degree'] = $direction; |
| 2050 | 2050 | $temp_array['direction_shortname'] = "SE"; |
| 2051 | 2051 | $temp_array['direction_fullname'] = "Southeast"; |
| 2052 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 2052 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 2053 | 2053 | $temp_array['direction_degree'] = $direction; |
| 2054 | 2054 | $temp_array['direction_shortname'] = "SSE"; |
| 2055 | 2055 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 2056 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 2056 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 2057 | 2057 | $temp_array['direction_degree'] = $direction; |
| 2058 | 2058 | $temp_array['direction_shortname'] = "S"; |
| 2059 | 2059 | $temp_array['direction_fullname'] = "South"; |
| 2060 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 2060 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 2061 | 2061 | $temp_array['direction_degree'] = $direction; |
| 2062 | 2062 | $temp_array['direction_shortname'] = "SSW"; |
| 2063 | 2063 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 2064 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 2064 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 2065 | 2065 | $temp_array['direction_degree'] = $direction; |
| 2066 | 2066 | $temp_array['direction_shortname'] = "SW"; |
| 2067 | 2067 | $temp_array['direction_fullname'] = "Southwest"; |
| 2068 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 2068 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 2069 | 2069 | $temp_array['direction_degree'] = $direction; |
| 2070 | 2070 | $temp_array['direction_shortname'] = "WSW"; |
| 2071 | 2071 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 2072 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 2072 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 2073 | 2073 | $temp_array['direction_degree'] = $direction; |
| 2074 | 2074 | $temp_array['direction_shortname'] = "W"; |
| 2075 | 2075 | $temp_array['direction_fullname'] = "West"; |
| 2076 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 2076 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 2077 | 2077 | $temp_array['direction_degree'] = $direction; |
| 2078 | 2078 | $temp_array['direction_shortname'] = "WNW"; |
| 2079 | 2079 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 2080 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 2080 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 2081 | 2081 | $temp_array['direction_degree'] = $direction; |
| 2082 | 2082 | $temp_array['direction_shortname'] = "NW"; |
| 2083 | 2083 | $temp_array['direction_fullname'] = "Northwest"; |
| 2084 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 2084 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 2085 | 2085 | $temp_array['direction_degree'] = $direction; |
| 2086 | 2086 | $temp_array['direction_shortname'] = "NNW"; |
| 2087 | 2087 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -2098,11 +2098,11 @@ discard block |
||
| 2098 | 2098 | * @param Float $longitude longitute of the flight |
| 2099 | 2099 | * @return String the countrie |
| 2100 | 2100 | */ |
| 2101 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 2101 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 2102 | 2102 | { |
| 2103 | 2103 | global $globalDBdriver, $globalDebug; |
| 2104 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2105 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2104 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2105 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2106 | 2106 | |
| 2107 | 2107 | $Connection = new Connection($this->db); |
| 2108 | 2108 | if (!$Connection->tableExists('countries')) return ''; |
@@ -2142,7 +2142,7 @@ discard block |
||
| 2142 | 2142 | public function getCountryFromISO2($iso2) |
| 2143 | 2143 | { |
| 2144 | 2144 | global $globalDBdriver, $globalDebug; |
| 2145 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 2145 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 2146 | 2146 | |
| 2147 | 2147 | $Connection = new Connection($this->db); |
| 2148 | 2148 | if (!$Connection->tableExists('countries')) return ''; |
@@ -2190,7 +2190,7 @@ discard block |
||
| 2190 | 2190 | |
| 2191 | 2191 | $bitly_data = json_decode($bitly_data); |
| 2192 | 2192 | $bitly_url = ''; |
| 2193 | - if ($bitly_data->status_txt = "OK"){ |
|
| 2193 | + if ($bitly_data->status_txt = "OK") { |
|
| 2194 | 2194 | $bitly_url = $bitly_data->data->url; |
| 2195 | 2195 | } |
| 2196 | 2196 | |
@@ -2204,11 +2204,11 @@ discard block |
||
| 2204 | 2204 | * @return Array the vessel type list |
| 2205 | 2205 | * |
| 2206 | 2206 | */ |
| 2207 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
| 2207 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 2208 | 2208 | { |
| 2209 | 2209 | global $globalDBdriver; |
| 2210 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2211 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
| 2210 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2211 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
| 2212 | 2212 | FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL"; |
| 2213 | 2213 | if ($olderthanmonths > 0) { |
| 2214 | 2214 | if ($globalDBdriver == 'mysql') { |
@@ -2228,28 +2228,28 @@ discard block |
||
| 2228 | 2228 | if ($year != '') { |
| 2229 | 2229 | if ($globalDBdriver == 'mysql') { |
| 2230 | 2230 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 2231 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2231 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2232 | 2232 | } else { |
| 2233 | 2233 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 2234 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2234 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2235 | 2235 | } |
| 2236 | 2236 | } |
| 2237 | 2237 | if ($month != '') { |
| 2238 | 2238 | if ($globalDBdriver == 'mysql') { |
| 2239 | 2239 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 2240 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2240 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2241 | 2241 | } else { |
| 2242 | 2242 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 2243 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2243 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2244 | 2244 | } |
| 2245 | 2245 | } |
| 2246 | 2246 | if ($day != '') { |
| 2247 | 2247 | if ($globalDBdriver == 'mysql') { |
| 2248 | 2248 | $query .= " AND DAY(marine_output.date) = :day"; |
| 2249 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 2249 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 2250 | 2250 | } else { |
| 2251 | 2251 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 2252 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 2252 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 2253 | 2253 | } |
| 2254 | 2254 | } |
| 2255 | 2255 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
@@ -2258,9 +2258,9 @@ discard block |
||
| 2258 | 2258 | $sth->execute($query_values); |
| 2259 | 2259 | $marine_array = array(); |
| 2260 | 2260 | $temp_array = array(); |
| 2261 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2261 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2262 | 2262 | { |
| 2263 | - $temp_array['marine_type'] = html_entity_decode($row['marine_type'],ENT_QUOTES); |
|
| 2263 | + $temp_array['marine_type'] = html_entity_decode($row['marine_type'], ENT_QUOTES); |
|
| 2264 | 2264 | $temp_array['marine_type_id'] = $row['marine_type_id']; |
| 2265 | 2265 | $temp_array['marine_type_count'] = $row['marine_type_count']; |
| 2266 | 2266 | $marine_array[] = $temp_array; |
@@ -2274,13 +2274,13 @@ discard block |
||
| 2274 | 2274 | * @return Array the tracker information |
| 2275 | 2275 | * |
| 2276 | 2276 | */ |
| 2277 | - public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
|
| 2277 | + public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 2278 | 2278 | { |
| 2279 | 2279 | global $globalTimezone, $globalDBdriver; |
| 2280 | 2280 | date_default_timezone_set('UTC'); |
| 2281 | 2281 | $query_values = array(); |
| 2282 | 2282 | $additional_query = ''; |
| 2283 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2283 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2284 | 2284 | if ($q != "") |
| 2285 | 2285 | { |
| 2286 | 2286 | if (!is_string($q)) |
@@ -2288,8 +2288,8 @@ discard block |
||
| 2288 | 2288 | return false; |
| 2289 | 2289 | } else { |
| 2290 | 2290 | $q_array = explode(" ", $q); |
| 2291 | - foreach ($q_array as $q_item){ |
|
| 2292 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 2291 | + foreach ($q_array as $q_item) { |
|
| 2292 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 2293 | 2293 | $additional_query .= " AND ("; |
| 2294 | 2294 | if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
| 2295 | 2295 | if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
@@ -2301,42 +2301,42 @@ discard block |
||
| 2301 | 2301 | } |
| 2302 | 2302 | if ($callsign != "") |
| 2303 | 2303 | { |
| 2304 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 2304 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 2305 | 2305 | if (!is_string($callsign)) |
| 2306 | 2306 | { |
| 2307 | 2307 | return false; |
| 2308 | 2308 | } else { |
| 2309 | 2309 | $additional_query .= " AND marine_output.ident = :callsign"; |
| 2310 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
| 2310 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
| 2311 | 2311 | } |
| 2312 | 2312 | } |
| 2313 | 2313 | if ($mmsi != "") |
| 2314 | 2314 | { |
| 2315 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 2315 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 2316 | 2316 | if (!is_numeric($mmsi)) |
| 2317 | 2317 | { |
| 2318 | 2318 | return false; |
| 2319 | 2319 | } else { |
| 2320 | 2320 | $additional_query .= " AND marine_output.mmsi = :mmsi"; |
| 2321 | - $query_values = array_merge($query_values,array(':mmsi' => $mmsi)); |
|
| 2321 | + $query_values = array_merge($query_values, array(':mmsi' => $mmsi)); |
|
| 2322 | 2322 | } |
| 2323 | 2323 | } |
| 2324 | 2324 | if ($imo != "") |
| 2325 | 2325 | { |
| 2326 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 2326 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 2327 | 2327 | if (!is_numeric($imo)) |
| 2328 | 2328 | { |
| 2329 | 2329 | return false; |
| 2330 | 2330 | } else { |
| 2331 | 2331 | $additional_query .= " AND marine_output.imo = :imo"; |
| 2332 | - $query_values = array_merge($query_values,array(':imo' => $imo)); |
|
| 2332 | + $query_values = array_merge($query_values, array(':imo' => $imo)); |
|
| 2333 | 2333 | } |
| 2334 | 2334 | } |
| 2335 | 2335 | if ($date_posted != "") |
| 2336 | 2336 | { |
| 2337 | 2337 | $date_array = explode(",", $date_posted); |
| 2338 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 2339 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 2338 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 2339 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 2340 | 2340 | if ($globalTimezone != '') { |
| 2341 | 2341 | date_default_timezone_set($globalTimezone); |
| 2342 | 2342 | $datetime = new DateTime(); |
@@ -2363,8 +2363,8 @@ discard block |
||
| 2363 | 2363 | if ($limit != "") |
| 2364 | 2364 | { |
| 2365 | 2365 | $limit_array = explode(",", $limit); |
| 2366 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 2367 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 2366 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 2367 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 2368 | 2368 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 2369 | 2369 | { |
| 2370 | 2370 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -2382,22 +2382,22 @@ discard block |
||
| 2382 | 2382 | } |
| 2383 | 2383 | } |
| 2384 | 2384 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 2385 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
| 2385 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
| 2386 | 2386 | if ($globalDBdriver == 'mysql') { |
| 2387 | - $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 |
|
| 2387 | + $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 |
|
| 2388 | 2388 | 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)) |
| 2389 | 2389 | 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; |
| 2390 | 2390 | } else { |
| 2391 | - $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 |
|
| 2391 | + $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 |
|
| 2392 | 2392 | 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)) |
| 2393 | 2393 | 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; |
| 2394 | 2394 | } |
| 2395 | 2395 | } else { |
| 2396 | - $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
| 2396 | + $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
| 2397 | 2397 | ".$additional_query." |
| 2398 | 2398 | ".$orderby_query; |
| 2399 | 2399 | } |
| 2400 | - $marine_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
| 2400 | + $marine_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
| 2401 | 2401 | return $marine_array; |
| 2402 | 2402 | } |
| 2403 | 2403 | |
@@ -2410,12 +2410,12 @@ discard block |
||
| 2410 | 2410 | public function checkId($id) |
| 2411 | 2411 | { |
| 2412 | 2412 | global $globalDBdriver, $globalTimezone; |
| 2413 | - $query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id'; |
|
| 2413 | + $query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id'; |
|
| 2414 | 2414 | $query_data = array(':id' => $id); |
| 2415 | 2415 | $sth = $this->db->prepare($query); |
| 2416 | 2416 | $sth->execute($query_data); |
| 2417 | - $ident_result=''; |
|
| 2418 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2417 | + $ident_result = ''; |
|
| 2418 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2419 | 2419 | { |
| 2420 | 2420 | $ident_result = $row['fammarine_id']; |
| 2421 | 2421 | } |
@@ -2430,7 +2430,7 @@ discard block |
||
| 2430 | 2430 | */ |
| 2431 | 2431 | public function getRaceByName($race_name) |
| 2432 | 2432 | { |
| 2433 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
| 2433 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
| 2434 | 2434 | $query = "SELECT * FROM marine_race WHERE race_name = :race_name LIMIT 1"; |
| 2435 | 2435 | $sth = $this->db->prepare($query); |
| 2436 | 2436 | $sth->execute(array(':race_name' => $race_name)); |
@@ -2447,7 +2447,7 @@ discard block |
||
| 2447 | 2447 | */ |
| 2448 | 2448 | public function getRace($race_id) |
| 2449 | 2449 | { |
| 2450 | - $race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 2450 | + $race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 2451 | 2451 | $query = "SELECT * FROM marine_race WHERE race_id = :race_id LIMIT 1"; |
| 2452 | 2452 | $sth = $this->db->prepare($query); |
| 2453 | 2453 | $sth->execute(array(':race_id' => $race_id)); |
@@ -2460,24 +2460,24 @@ discard block |
||
| 2460 | 2460 | * Add race |
| 2461 | 2461 | * |
| 2462 | 2462 | */ |
| 2463 | - public function addRace($race_id,$race_name,$race_creator,$race_desc,$race_startdate,$race_markers) |
|
| 2463 | + public function addRace($race_id, $race_name, $race_creator, $race_desc, $race_startdate, $race_markers) |
|
| 2464 | 2464 | { |
| 2465 | - $race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 2465 | + $race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 2466 | 2466 | if ($race_id != '') { |
| 2467 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
| 2468 | - $race_creator = filter_var($race_creator,FILTER_SANITIZE_STRING); |
|
| 2469 | - $race_desc = filter_var($race_desc,FILTER_SANITIZE_STRING); |
|
| 2470 | - $race_startdate = filter_var($race_startdate,FILTER_SANITIZE_STRING); |
|
| 2467 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
| 2468 | + $race_creator = filter_var($race_creator, FILTER_SANITIZE_STRING); |
|
| 2469 | + $race_desc = filter_var($race_desc, FILTER_SANITIZE_STRING); |
|
| 2470 | + $race_startdate = filter_var($race_startdate, FILTER_SANITIZE_STRING); |
|
| 2471 | 2471 | //$race_markers = filter_var($race_markers,FILTER_SANITIZE_STRING); |
| 2472 | 2472 | $allrace = $this->getRace($race_id); |
| 2473 | 2473 | if (empty($allrace)) { |
| 2474 | 2474 | $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)"; |
| 2475 | 2475 | $sth = $this->db->prepare($query); |
| 2476 | - $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)); |
|
| 2476 | + $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)); |
|
| 2477 | 2477 | } elseif ($race_id != '') { |
| 2478 | - $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"; |
|
| 2478 | + $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"; |
|
| 2479 | 2479 | $sth = $this->db->prepare($query); |
| 2480 | - $sth->execute(array(':race_id' => $race_id,':race_name' => $race_name,':race_desc' => $race_desc,':race_startdate' => $race_startdate,':race_markers' => $race_markers)); |
|
| 2480 | + $sth->execute(array(':race_id' => $race_id, ':race_name' => $race_name, ':race_desc' => $race_desc, ':race_startdate' => $race_startdate, ':race_markers' => $race_markers)); |
|
| 2481 | 2481 | } |
| 2482 | 2482 | } |
| 2483 | 2483 | } |
@@ -2486,7 +2486,7 @@ discard block |
||
| 2486 | 2486 | |
| 2487 | 2487 | public function getOrderBy() |
| 2488 | 2488 | { |
| 2489 | - $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")); |
|
| 2489 | + $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")); |
|
| 2490 | 2490 | |
| 2491 | 2491 | return $orderby; |
| 2492 | 2492 | |
@@ -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 | /** |
@@ -805,8 +871,11 @@ discard block |
||
| 805 | 871 | $query .= " ORDER BY marine_output.source_name ASC"; |
| 806 | 872 | |
| 807 | 873 | $sth = $this->db->prepare($query); |
| 808 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 809 | - else $sth->execute(); |
|
| 874 | + if (!empty($query_values)) { |
|
| 875 | + $sth->execute($query_values); |
|
| 876 | + } else { |
|
| 877 | + $sth->execute(); |
|
| 878 | + } |
|
| 810 | 879 | |
| 811 | 880 | $source_array = array(); |
| 812 | 881 | $temp_array = array(); |
@@ -861,8 +930,11 @@ discard block |
||
| 861 | 930 | $sth = $this->db->prepare($query); |
| 862 | 931 | $sth->execute(array(':mmsi' => $mmsi)); |
| 863 | 932 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 864 | - if (isset($result[0])) return $result[0]; |
|
| 865 | - else return array(); |
|
| 933 | + if (isset($result[0])) { |
|
| 934 | + return $result[0]; |
|
| 935 | + } else { |
|
| 936 | + return array(); |
|
| 937 | + } |
|
| 866 | 938 | } |
| 867 | 939 | |
| 868 | 940 | /** |
@@ -903,7 +975,9 @@ discard block |
||
| 903 | 975 | date_default_timezone_set($globalTimezone); |
| 904 | 976 | $datetime = new DateTime(); |
| 905 | 977 | $offset = $datetime->format('P'); |
| 906 | - } else $offset = '+00:00'; |
|
| 978 | + } else { |
|
| 979 | + $offset = '+00:00'; |
|
| 980 | + } |
|
| 907 | 981 | |
| 908 | 982 | if ($globalDBdriver == 'mysql') { |
| 909 | 983 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -1010,8 +1084,12 @@ discard block |
||
| 1010 | 1084 | */ |
| 1011 | 1085 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
| 1012 | 1086 | { |
| 1013 | - if ($latitude == '') $latitude = NULL; |
|
| 1014 | - if ($longitude == '') $longitude = NULL; |
|
| 1087 | + if ($latitude == '') { |
|
| 1088 | + $latitude = NULL; |
|
| 1089 | + } |
|
| 1090 | + if ($longitude == '') { |
|
| 1091 | + $longitude = NULL; |
|
| 1092 | + } |
|
| 1015 | 1093 | $groundspeed = round($groundspeed); |
| 1016 | 1094 | if ($race_begin != '') { |
| 1017 | 1095 | $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'; |
@@ -1164,14 +1242,28 @@ discard block |
||
| 1164 | 1242 | $latitude = 0; |
| 1165 | 1243 | $longitude = 0; |
| 1166 | 1244 | } |
| 1167 | - if ($type_id == '') $type_id = NULL; |
|
| 1168 | - if ($status_id == '') $status_id = NULL; |
|
| 1169 | - if ($distance == '') $distance = NULL; |
|
| 1170 | - if ($race_rank == '') $race_rank = NULL; |
|
| 1171 | - if ($race_time == '') $race_time = NULL; |
|
| 1172 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 1245 | + if ($type_id == '') { |
|
| 1246 | + $type_id = NULL; |
|
| 1247 | + } |
|
| 1248 | + if ($status_id == '') { |
|
| 1249 | + $status_id = NULL; |
|
| 1250 | + } |
|
| 1251 | + if ($distance == '') { |
|
| 1252 | + $distance = NULL; |
|
| 1253 | + } |
|
| 1254 | + if ($race_rank == '') { |
|
| 1255 | + $race_rank = NULL; |
|
| 1256 | + } |
|
| 1257 | + if ($race_time == '') { |
|
| 1258 | + $race_time = NULL; |
|
| 1259 | + } |
|
| 1260 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 1261 | + $heading = 0; |
|
| 1262 | + } |
|
| 1173 | 1263 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 1174 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 1264 | + if ($arrival_date == '') { |
|
| 1265 | + $arrival_date = NULL; |
|
| 1266 | + } |
|
| 1175 | 1267 | $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 | 1268 | 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)"; |
| 1177 | 1269 | |
@@ -1278,7 +1370,9 @@ discard block |
||
| 1278 | 1370 | global $globalDBdriver, $globalArchive; |
| 1279 | 1371 | //$filter_query = $this->getFilter($filters,true,true); |
| 1280 | 1372 | $Connection= new Connection($this->db); |
| 1281 | - if (!$Connection->tableExists('countries')) return array(); |
|
| 1373 | + if (!$Connection->tableExists('countries')) { |
|
| 1374 | + return array(); |
|
| 1375 | + } |
|
| 1282 | 1376 | require_once('class.SpotterLive.php'); |
| 1283 | 1377 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 1284 | 1378 | $MarineLive = new MarineLive($this->db); |
@@ -1322,7 +1416,9 @@ discard block |
||
| 1322 | 1416 | $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 "; |
| 1323 | 1417 | } |
| 1324 | 1418 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
| 1325 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1419 | + if ($limit) { |
|
| 1420 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1421 | + } |
|
| 1326 | 1422 | |
| 1327 | 1423 | $sth = $this->db->prepare($query); |
| 1328 | 1424 | $sth->execute(); |
@@ -1356,12 +1452,18 @@ discard block |
||
| 1356 | 1452 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
| 1357 | 1453 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 1358 | 1454 | if ($olderthanmonths > 0) { |
| 1359 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 1360 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 1455 | + if ($globalDBdriver == 'mysql') { |
|
| 1456 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 1457 | + } else { |
|
| 1458 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 1459 | + } |
|
| 1361 | 1460 | } |
| 1362 | 1461 | if ($sincedate != '') { |
| 1363 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 1364 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 1462 | + if ($globalDBdriver == 'mysql') { |
|
| 1463 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 1464 | + } else { |
|
| 1465 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 1466 | + } |
|
| 1365 | 1467 | } |
| 1366 | 1468 | $query_values = array(); |
| 1367 | 1469 | if ($year != '') { |
@@ -1392,7 +1494,9 @@ discard block |
||
| 1392 | 1494 | } |
| 1393 | 1495 | } |
| 1394 | 1496 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
| 1395 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1497 | + if ($limit) { |
|
| 1498 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1499 | + } |
|
| 1396 | 1500 | |
| 1397 | 1501 | $sth = $this->db->prepare($query); |
| 1398 | 1502 | $sth->execute($query_values); |
@@ -1427,7 +1531,9 @@ discard block |
||
| 1427 | 1531 | date_default_timezone_set($globalTimezone); |
| 1428 | 1532 | $datetime = new DateTime(); |
| 1429 | 1533 | $offset = $datetime->format('P'); |
| 1430 | - } else $offset = '+00:00'; |
|
| 1534 | + } else { |
|
| 1535 | + $offset = '+00:00'; |
|
| 1536 | + } |
|
| 1431 | 1537 | |
| 1432 | 1538 | if ($globalDBdriver == 'mysql') { |
| 1433 | 1539 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1477,7 +1583,9 @@ discard block |
||
| 1477 | 1583 | date_default_timezone_set($globalTimezone); |
| 1478 | 1584 | $datetime = new DateTime(); |
| 1479 | 1585 | $offset = $datetime->format('P'); |
| 1480 | - } else $offset = '+00:00'; |
|
| 1586 | + } else { |
|
| 1587 | + $offset = '+00:00'; |
|
| 1588 | + } |
|
| 1481 | 1589 | $filter_query = $this->getFilter($filters,true,true); |
| 1482 | 1590 | if ($globalDBdriver == 'mysql') { |
| 1483 | 1591 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1523,7 +1631,9 @@ discard block |
||
| 1523 | 1631 | date_default_timezone_set($globalTimezone); |
| 1524 | 1632 | $datetime = new DateTime(); |
| 1525 | 1633 | $offset = $datetime->format('P'); |
| 1526 | - } else $offset = '+00:00'; |
|
| 1634 | + } else { |
|
| 1635 | + $offset = '+00:00'; |
|
| 1636 | + } |
|
| 1527 | 1637 | $filter_query = $this->getFilter($filters,true,true); |
| 1528 | 1638 | if ($globalDBdriver == 'mysql') { |
| 1529 | 1639 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1571,7 +1681,9 @@ discard block |
||
| 1571 | 1681 | date_default_timezone_set($globalTimezone); |
| 1572 | 1682 | $datetime = new DateTime(); |
| 1573 | 1683 | $offset = $datetime->format('P'); |
| 1574 | - } else $offset = '+00:00'; |
|
| 1684 | + } else { |
|
| 1685 | + $offset = '+00:00'; |
|
| 1686 | + } |
|
| 1575 | 1687 | |
| 1576 | 1688 | if ($globalDBdriver == 'mysql') { |
| 1577 | 1689 | $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 |
@@ -1620,7 +1732,9 @@ discard block |
||
| 1620 | 1732 | date_default_timezone_set($globalTimezone); |
| 1621 | 1733 | $datetime = new DateTime(); |
| 1622 | 1734 | $offset = $datetime->format('P'); |
| 1623 | - } else $offset = '+00:00'; |
|
| 1735 | + } else { |
|
| 1736 | + $offset = '+00:00'; |
|
| 1737 | + } |
|
| 1624 | 1738 | $filter_query = $this->getFilter($filters,true,true); |
| 1625 | 1739 | if ($globalDBdriver == 'mysql') { |
| 1626 | 1740 | $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 |
@@ -1669,7 +1783,9 @@ discard block |
||
| 1669 | 1783 | date_default_timezone_set($globalTimezone); |
| 1670 | 1784 | $datetime = new DateTime(); |
| 1671 | 1785 | $offset = $datetime->format('P'); |
| 1672 | - } else $offset = '+00:00'; |
|
| 1786 | + } else { |
|
| 1787 | + $offset = '+00:00'; |
|
| 1788 | + } |
|
| 1673 | 1789 | |
| 1674 | 1790 | $orderby_sql = ''; |
| 1675 | 1791 | if ($orderby == "hour") |
@@ -1738,7 +1854,9 @@ discard block |
||
| 1738 | 1854 | date_default_timezone_set($globalTimezone); |
| 1739 | 1855 | $datetime = new DateTime($date); |
| 1740 | 1856 | $offset = $datetime->format('P'); |
| 1741 | - } else $offset = '+00:00'; |
|
| 1857 | + } else { |
|
| 1858 | + $offset = '+00:00'; |
|
| 1859 | + } |
|
| 1742 | 1860 | |
| 1743 | 1861 | if ($globalDBdriver == 'mysql') { |
| 1744 | 1862 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1786,7 +1904,9 @@ discard block |
||
| 1786 | 1904 | date_default_timezone_set($globalTimezone); |
| 1787 | 1905 | $datetime = new DateTime(); |
| 1788 | 1906 | $offset = $datetime->format('P'); |
| 1789 | - } else $offset = '+00:00'; |
|
| 1907 | + } else { |
|
| 1908 | + $offset = '+00:00'; |
|
| 1909 | + } |
|
| 1790 | 1910 | |
| 1791 | 1911 | if ($globalDBdriver == 'mysql') { |
| 1792 | 1912 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1851,8 +1971,11 @@ discard block |
||
| 1851 | 1971 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1852 | 1972 | } |
| 1853 | 1973 | } |
| 1854 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1855 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1974 | + if (empty($query_values)) { |
|
| 1975 | + $queryi .= $this->getFilter($filters); |
|
| 1976 | + } else { |
|
| 1977 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1978 | + } |
|
| 1856 | 1979 | |
| 1857 | 1980 | $sth = $this->db->prepare($queryi); |
| 1858 | 1981 | $sth->execute($query_values); |
@@ -1889,8 +2012,11 @@ discard block |
||
| 1889 | 2012 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1890 | 2013 | } |
| 1891 | 2014 | } |
| 1892 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1893 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2015 | + if (empty($query_values)) { |
|
| 2016 | + $queryi .= $this->getFilter($filters); |
|
| 2017 | + } else { |
|
| 2018 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2019 | + } |
|
| 1894 | 2020 | |
| 1895 | 2021 | $sth = $this->db->prepare($queryi); |
| 1896 | 2022 | $sth->execute($query_values); |
@@ -1912,7 +2038,9 @@ discard block |
||
| 1912 | 2038 | date_default_timezone_set($globalTimezone); |
| 1913 | 2039 | $datetime = new DateTime(); |
| 1914 | 2040 | $offset = $datetime->format('P'); |
| 1915 | - } else $offset = '+00:00'; |
|
| 2041 | + } else { |
|
| 2042 | + $offset = '+00:00'; |
|
| 2043 | + } |
|
| 1916 | 2044 | |
| 1917 | 2045 | if ($globalDBdriver == 'mysql') { |
| 1918 | 2046 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -2016,7 +2144,9 @@ discard block |
||
| 2016 | 2144 | */ |
| 2017 | 2145 | public function parseDirection($direction = 0) |
| 2018 | 2146 | { |
| 2019 | - if ($direction == '') $direction = 0; |
|
| 2147 | + if ($direction == '') { |
|
| 2148 | + $direction = 0; |
|
| 2149 | + } |
|
| 2020 | 2150 | $direction_array = array(); |
| 2021 | 2151 | $temp_array = array(); |
| 2022 | 2152 | |
@@ -2105,7 +2235,9 @@ discard block |
||
| 2105 | 2235 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 2106 | 2236 | |
| 2107 | 2237 | $Connection = new Connection($this->db); |
| 2108 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 2238 | + if (!$Connection->tableExists('countries')) { |
|
| 2239 | + return ''; |
|
| 2240 | + } |
|
| 2109 | 2241 | |
| 2110 | 2242 | try { |
| 2111 | 2243 | /* |
@@ -2125,9 +2257,13 @@ discard block |
||
| 2125 | 2257 | $sth->closeCursor(); |
| 2126 | 2258 | if (count($row) > 0) { |
| 2127 | 2259 | return $row; |
| 2128 | - } else return ''; |
|
| 2260 | + } else { |
|
| 2261 | + return ''; |
|
| 2262 | + } |
|
| 2129 | 2263 | } catch (PDOException $e) { |
| 2130 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 2264 | + if (isset($globalDebug) && $globalDebug) { |
|
| 2265 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 2266 | + } |
|
| 2131 | 2267 | return ''; |
| 2132 | 2268 | } |
| 2133 | 2269 | |
@@ -2145,7 +2281,9 @@ discard block |
||
| 2145 | 2281 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 2146 | 2282 | |
| 2147 | 2283 | $Connection = new Connection($this->db); |
| 2148 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 2284 | + if (!$Connection->tableExists('countries')) { |
|
| 2285 | + return ''; |
|
| 2286 | + } |
|
| 2149 | 2287 | |
| 2150 | 2288 | try { |
| 2151 | 2289 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -2157,9 +2295,13 @@ discard block |
||
| 2157 | 2295 | $sth->closeCursor(); |
| 2158 | 2296 | if (count($row) > 0) { |
| 2159 | 2297 | return $row; |
| 2160 | - } else return ''; |
|
| 2298 | + } else { |
|
| 2299 | + return ''; |
|
| 2300 | + } |
|
| 2161 | 2301 | } catch (PDOException $e) { |
| 2162 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 2302 | + if (isset($globalDebug) && $globalDebug) { |
|
| 2303 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 2304 | + } |
|
| 2163 | 2305 | return ''; |
| 2164 | 2306 | } |
| 2165 | 2307 | |
@@ -2177,7 +2319,9 @@ discard block |
||
| 2177 | 2319 | { |
| 2178 | 2320 | global $globalBitlyAccessToken; |
| 2179 | 2321 | |
| 2180 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 2322 | + if ($globalBitlyAccessToken == '') { |
|
| 2323 | + return $url; |
|
| 2324 | + } |
|
| 2181 | 2325 | |
| 2182 | 2326 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 2183 | 2327 | |
@@ -2253,7 +2397,9 @@ discard block |
||
| 2253 | 2397 | } |
| 2254 | 2398 | } |
| 2255 | 2399 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
| 2256 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 2400 | + if ($limit) { |
|
| 2401 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 2402 | + } |
|
| 2257 | 2403 | $sth = $this->db->prepare($query); |
| 2258 | 2404 | $sth->execute($query_values); |
| 2259 | 2405 | $marine_array = array(); |
@@ -2291,9 +2437,15 @@ discard block |
||
| 2291 | 2437 | foreach ($q_array as $q_item){ |
| 2292 | 2438 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
| 2293 | 2439 | $additional_query .= " AND ("; |
| 2294 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
| 2295 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
| 2296 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
| 2440 | + if (is_int($q_item)) { |
|
| 2441 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
| 2442 | + } |
|
| 2443 | + if (is_int($q_item)) { |
|
| 2444 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
| 2445 | + } |
|
| 2446 | + if (is_int($q_item)) { |
|
| 2447 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
| 2448 | + } |
|
| 2297 | 2449 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
| 2298 | 2450 | $additional_query .= ")"; |
| 2299 | 2451 | } |
@@ -2341,7 +2493,9 @@ discard block |
||
| 2341 | 2493 | date_default_timezone_set($globalTimezone); |
| 2342 | 2494 | $datetime = new DateTime(); |
| 2343 | 2495 | $offset = $datetime->format('P'); |
| 2344 | - } else $offset = '+00:00'; |
|
| 2496 | + } else { |
|
| 2497 | + $offset = '+00:00'; |
|
| 2498 | + } |
|
| 2345 | 2499 | if ($date_array[1] != "") |
| 2346 | 2500 | { |
| 2347 | 2501 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -2368,8 +2522,12 @@ discard block |
||
| 2368 | 2522 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 2369 | 2523 | { |
| 2370 | 2524 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 2371 | - } else $limit_query = ""; |
|
| 2372 | - } else $limit_query = ""; |
|
| 2525 | + } else { |
|
| 2526 | + $limit_query = ""; |
|
| 2527 | + } |
|
| 2528 | + } else { |
|
| 2529 | + $limit_query = ""; |
|
| 2530 | + } |
|
| 2373 | 2531 | if ($sort != "") |
| 2374 | 2532 | { |
| 2375 | 2533 | $search_orderby_array = $this->getOrderBy(); |
@@ -2435,8 +2593,11 @@ discard block |
||
| 2435 | 2593 | $sth = $this->db->prepare($query); |
| 2436 | 2594 | $sth->execute(array(':race_name' => $race_name)); |
| 2437 | 2595 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 2438 | - if (isset($result[0])) return $result[0]; |
|
| 2439 | - else return array(); |
|
| 2596 | + if (isset($result[0])) { |
|
| 2597 | + return $result[0]; |
|
| 2598 | + } else { |
|
| 2599 | + return array(); |
|
| 2600 | + } |
|
| 2440 | 2601 | } |
| 2441 | 2602 | |
| 2442 | 2603 | /** |
@@ -2452,8 +2613,11 @@ discard block |
||
| 2452 | 2613 | $sth = $this->db->prepare($query); |
| 2453 | 2614 | $sth->execute(array(':race_id' => $race_id)); |
| 2454 | 2615 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 2455 | - if (isset($result[0])) return $result[0]; |
|
| 2456 | - else return array(); |
|
| 2616 | + if (isset($result[0])) { |
|
| 2617 | + return $result[0]; |
|
| 2618 | + } else { |
|
| 2619 | + return array(); |
|
| 2620 | + } |
|
| 2457 | 2621 | } |
| 2458 | 2622 | |
| 2459 | 2623 | /** |