|
@@ -9,7 +9,7 @@ discard block |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
24
|
24
|
* @return Array the SQL part |
|
25
|
25
|
*/ |
|
26
|
26
|
|
|
27
|
|
- public function getFilter($filter = array(),$where = false,$and = false) { |
|
|
27
|
+ public function getFilter($filter = array(), $where = false, $and = false) { |
|
28
|
28
|
global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
|
29
|
29
|
$filters = array(); |
|
30
|
30
|
if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
|
31
|
31
|
if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
|
32
|
32
|
$filters = $globalStatsFilters[$globalFilterName]; |
|
33
|
33
|
} else { |
|
34
|
|
- $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
|
34
|
+ $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
35
|
35
|
} |
|
36
|
36
|
} |
|
37
|
37
|
if (isset($filter[0]['source'])) { |
|
38
|
|
- $filters = array_merge($filters,$filter); |
|
|
38
|
+ $filters = array_merge($filters, $filter); |
|
39
|
39
|
} |
|
40
|
|
- if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
|
40
|
+ if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
41
|
41
|
$filter_query_join = ''; |
|
42
|
42
|
$filter_query_where = ''; |
|
43
|
|
- foreach($filters as $flt) { |
|
|
43
|
+ foreach ($filters as $flt) { |
|
44
|
44
|
if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
45
|
45
|
if (isset($flt['source'])) { |
|
46
|
|
- $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
|
46
|
+ $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
47
|
47
|
} else { |
|
48
|
|
- $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
|
48
|
+ $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
49
|
49
|
} |
|
50
|
50
|
} |
|
51
|
51
|
} |
|
52
|
52
|
if (isset($filter['source']) && !empty($filter['source'])) { |
|
53
|
|
- $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
|
53
|
+ $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
54
|
54
|
} |
|
55
|
55
|
if (isset($filter['ident']) && !empty($filter['ident'])) { |
|
56
|
56
|
$filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
@@ -88,7 +88,7 @@ discard block |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
567
|
567
|
* @return Integer number of race for a captain |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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
|
|
|
@@ -755,38 +755,38 @@ discard block |
|
|
block discarded – undo |
|
755
|
755
|
* @return String Duration of all race |
|
756
|
756
|
* |
|
757
|
757
|
*/ |
|
758
|
|
- public function getRaceDurationByCaptains($limit = true,$filters = array(),$year = '',$month = '',$day = '') |
|
|
758
|
+ public function getRaceDurationByCaptains($limit = true, $filters = array(), $year = '', $month = '', $day = '') |
|
759
|
759
|
{ |
|
760
|
760
|
global $globalDBdriver; |
|
761
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
762
|
|
- $query = "SELECT SUM(last_seen - date) AS duration, captain_id, captain_name |
|
|
761
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
|
762
|
+ $query = "SELECT SUM(last_seen - date) AS duration, captain_id, captain_name |
|
763
|
763
|
FROM marine_output".$filter_query." last_seen > date"; |
|
764
|
764
|
$query_values = array(); |
|
765
|
765
|
if ($year != '') { |
|
766
|
766
|
if ($globalDBdriver == 'mysql') { |
|
767
|
767
|
$query .= " AND YEAR(marine_output.date) = :year"; |
|
768
|
|
- $query_values = array_merge($query_values,array(':year' => $year)); |
|
|
768
|
+ $query_values = array_merge($query_values, array(':year' => $year)); |
|
769
|
769
|
} else { |
|
770
|
770
|
$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
|
771
|
|
- $query_values = array_merge($query_values,array(':year' => $year)); |
|
|
771
|
+ $query_values = array_merge($query_values, array(':year' => $year)); |
|
772
|
772
|
} |
|
773
|
773
|
} |
|
774
|
774
|
if ($month != '') { |
|
775
|
775
|
if ($globalDBdriver == 'mysql') { |
|
776
|
776
|
$query .= " AND MONTH(marine_output.date) = :month"; |
|
777
|
|
- $query_values = array_merge($query_values,array(':month' => $month)); |
|
|
777
|
+ $query_values = array_merge($query_values, array(':month' => $month)); |
|
778
|
778
|
} else { |
|
779
|
779
|
$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
|
780
|
|
- $query_values = array_merge($query_values,array(':month' => $month)); |
|
|
780
|
+ $query_values = array_merge($query_values, array(':month' => $month)); |
|
781
|
781
|
} |
|
782
|
782
|
} |
|
783
|
783
|
if ($day != '') { |
|
784
|
784
|
if ($globalDBdriver == 'mysql') { |
|
785
|
785
|
$query .= " AND DAY(marine_output.date) = :day"; |
|
786
|
|
- $query_values = array_merge($query_values,array(':day' => $day)); |
|
|
786
|
+ $query_values = array_merge($query_values, array(':day' => $day)); |
|
787
|
787
|
} else { |
|
788
|
788
|
$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
|
789
|
|
- $query_values = array_merge($query_values,array(':day' => $day)); |
|
|
789
|
+ $query_values = array_merge($query_values, array(':day' => $day)); |
|
790
|
790
|
} |
|
791
|
791
|
} |
|
792
|
792
|
$query .= " GROUP BY marine_output.captain_id,marine_output.captain_name ORDER BY duration DESC"; |
|
@@ -798,7 +798,7 @@ discard block |
|
|
block discarded – undo |
|
798
|
798
|
$duration_array = array(); |
|
799
|
799
|
$temp_array = array(); |
|
800
|
800
|
|
|
801
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
801
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
802
|
802
|
{ |
|
803
|
803
|
if ($row['duration'] != '') { |
|
804
|
804
|
$temp_array['marine_duration_days'] = $row['duration']; |
|
@@ -820,8 +820,8 @@ discard block |
|
|
block discarded – undo |
|
820
|
820
|
*/ |
|
821
|
821
|
public function getAllCaptainNames($filters = array()) |
|
822
|
822
|
{ |
|
823
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
824
|
|
- $query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id |
|
|
823
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
|
824
|
+ $query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id |
|
825
|
825
|
FROM marine_output".$filter_query." marine_output.captain_name <> '' |
|
826
|
826
|
ORDER BY marine_output.captain_name ASC"; |
|
827
|
827
|
|
|
@@ -838,8 +838,8 @@ discard block |
|
|
block discarded – undo |
|
838
|
838
|
*/ |
|
839
|
839
|
public function getAllRaceNames($filters = array()) |
|
840
|
840
|
{ |
|
841
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
842
|
|
- $query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id |
|
|
841
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
|
842
|
+ $query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id |
|
843
|
843
|
FROM marine_output".$filter_query." marine_output.race_name <> '' |
|
844
|
844
|
ORDER BY marine_output.race_name ASC"; |
|
845
|
845
|
|
|
@@ -856,11 +856,11 @@ discard block |
|
|
block discarded – undo |
|
856
|
856
|
* @return Array list of source name |
|
857
|
857
|
* |
|
858
|
858
|
*/ |
|
859
|
|
- public function getAllSourceName($type = '',$filters = array()) |
|
|
859
|
+ public function getAllSourceName($type = '', $filters = array()) |
|
860
|
860
|
{ |
|
861
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
|
861
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
862
|
862
|
$query_values = array(); |
|
863
|
|
- $query = "SELECT DISTINCT marine_output.source_name |
|
|
863
|
+ $query = "SELECT DISTINCT marine_output.source_name |
|
864
|
864
|
FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
|
865
|
865
|
if ($type != '') { |
|
866
|
866
|
$query_values = array(':type' => $type); |
|
@@ -875,7 +875,7 @@ discard block |
|
|
block discarded – undo |
|
875
|
875
|
$source_array = array(); |
|
876
|
876
|
$temp_array = array(); |
|
877
|
877
|
|
|
878
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
878
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
879
|
879
|
{ |
|
880
|
880
|
$temp_array['source_name'] = $row['source_name']; |
|
881
|
881
|
$source_array[] = $temp_array; |
|
@@ -892,8 +892,8 @@ discard block |
|
|
block discarded – undo |
|
892
|
892
|
*/ |
|
893
|
893
|
public function getAllIdents($filters = array()) |
|
894
|
894
|
{ |
|
895
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
896
|
|
- $query = "SELECT DISTINCT marine_output.ident |
|
|
895
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
|
896
|
+ $query = "SELECT DISTINCT marine_output.ident |
|
897
|
897
|
FROM marine_output".$filter_query." marine_output.ident <> '' |
|
898
|
898
|
ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
|
899
|
899
|
|
|
@@ -903,7 +903,7 @@ discard block |
|
|
block discarded – undo |
|
903
|
903
|
$ident_array = array(); |
|
904
|
904
|
$temp_array = array(); |
|
905
|
905
|
|
|
906
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
906
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
907
|
907
|
{ |
|
908
|
908
|
$temp_array['ident'] = $row['ident']; |
|
909
|
909
|
$ident_array[] = $temp_array; |
|
@@ -920,7 +920,7 @@ discard block |
|
|
block discarded – undo |
|
920
|
920
|
*/ |
|
921
|
921
|
public function getIdentity($mmsi) |
|
922
|
922
|
{ |
|
923
|
|
- $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
|
923
|
+ $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
924
|
924
|
$query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
|
925
|
925
|
$sth = $this->db->prepare($query); |
|
926
|
926
|
$sth->execute(array(':mmsi' => $mmsi)); |
|
@@ -933,23 +933,23 @@ discard block |
|
|
block discarded – undo |
|
933
|
933
|
* Add identity |
|
934
|
934
|
* |
|
935
|
935
|
*/ |
|
936
|
|
- public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
|
|
936
|
+ public function addIdentity($mmsi, $imo, $ident, $callsign, $type) |
|
937
|
937
|
{ |
|
938
|
|
- $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
|
938
|
+ $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
939
|
939
|
if ($mmsi != '') { |
|
940
|
|
- $imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT); |
|
941
|
|
- $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
942
|
|
- $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
943
|
|
- $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
|
940
|
+ $imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT); |
|
|
941
|
+ $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
|
942
|
+ $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
|
943
|
+ $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
944
|
944
|
$identinfo = $this->getIdentity($mmsi); |
|
945
|
945
|
if (empty($identinfo)) { |
|
946
|
|
- $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
|
946
|
+ $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
947
|
947
|
$sth = $this->db->prepare($query); |
|
948
|
|
- $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type)); |
|
|
948
|
+ $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type)); |
|
949
|
949
|
} elseif ($ident != '' && $identinfo['ship_name'] != $ident) { |
|
950
|
|
- $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
|
950
|
+ $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
951
|
951
|
$sth = $this->db->prepare($query); |
|
952
|
|
- $sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type)); |
|
|
952
|
+ $sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type)); |
|
953
|
953
|
} |
|
954
|
954
|
} |
|
955
|
955
|
} |
|
@@ -970,12 +970,12 @@ discard block |
|
|
block discarded – undo |
|
970
|
970
|
} else $offset = '+00:00'; |
|
971
|
971
|
|
|
972
|
972
|
if ($globalDBdriver == 'mysql') { |
|
973
|
|
- $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
|
973
|
+ $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
974
|
974
|
FROM marine_output |
|
975
|
975
|
WHERE marine_output.date <> '' |
|
976
|
976
|
ORDER BY marine_output.date ASC LIMIT 0,100"; |
|
977
|
977
|
} else { |
|
978
|
|
- $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
|
978
|
+ $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
979
|
979
|
FROM marine_output |
|
980
|
980
|
WHERE marine_output.date <> '' |
|
981
|
981
|
ORDER BY marine_output.date ASC LIMIT 0,100"; |
|
@@ -987,7 +987,7 @@ discard block |
|
|
block discarded – undo |
|
987
|
987
|
$date_array = array(); |
|
988
|
988
|
$temp_array = array(); |
|
989
|
989
|
|
|
990
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
990
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
991
|
991
|
{ |
|
992
|
992
|
$temp_array['date'] = $row['date']; |
|
993
|
993
|
|
|
@@ -1005,10 +1005,10 @@ discard block |
|
|
block discarded – undo |
|
1005
|
1005
|
* @return String success or false |
|
1006
|
1006
|
* |
|
1007
|
1007
|
*/ |
|
1008
|
|
- public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
|
1008
|
+ public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
1009
|
1009
|
{ |
|
1010
|
1010
|
$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
|
1011
|
|
- $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
|
1011
|
+ $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
1012
|
1012
|
try { |
|
1013
|
1013
|
$sth = $this->db->prepare($query); |
|
1014
|
1014
|
$sth->execute($query_values); |
|
@@ -1026,10 +1026,10 @@ discard block |
|
|
block discarded – undo |
|
1026
|
1026
|
* @return String success or false |
|
1027
|
1027
|
* |
|
1028
|
1028
|
*/ |
|
1029
|
|
- public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
|
|
1029
|
+ public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL) |
|
1030
|
1030
|
{ |
|
1031
|
1031
|
$query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
|
1032
|
|
- $query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code); |
|
|
1032
|
+ $query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code); |
|
1033
|
1033
|
try { |
|
1034
|
1034
|
$sth = $this->db->prepare($query); |
|
1035
|
1035
|
$sth->execute($query_values); |
|
@@ -1048,11 +1048,11 @@ discard block |
|
|
block discarded – undo |
|
1048
|
1048
|
* @return String success or false |
|
1049
|
1049
|
* |
|
1050
|
1050
|
*/ |
|
1051
|
|
- public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
|
1051
|
+ public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
1052
|
1052
|
{ |
|
1053
|
1053
|
|
|
1054
|
1054
|
$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
|
1055
|
|
- $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
|
1055
|
+ $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
1056
|
1056
|
|
|
1057
|
1057
|
try { |
|
1058
|
1058
|
$sth = $this->db->prepare($query); |
|
@@ -1072,17 +1072,17 @@ discard block |
|
|
block discarded – undo |
|
1072
|
1072
|
* @return String success or false |
|
1073
|
1073
|
* |
|
1074
|
1074
|
*/ |
|
1075
|
|
- public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
|
|
1075
|
+ public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '', $distance = NULL, $race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
|
1076
|
1076
|
{ |
|
1077
|
1077
|
if ($latitude == '') $latitude = NULL; |
|
1078
|
1078
|
if ($longitude == '') $longitude = NULL; |
|
1079
|
1079
|
$groundspeed = round($groundspeed); |
|
1080
|
1080
|
if ($race_begin != '') { |
|
1081
|
1081
|
$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'; |
|
1082
|
|
- $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); |
|
|
1082
|
+ $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); |
|
1083
|
1083
|
} else { |
|
1084
|
1084
|
$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'; |
|
1085
|
|
- $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); |
|
|
1085
|
+ $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); |
|
1086
|
1086
|
} |
|
1087
|
1087
|
try { |
|
1088
|
1088
|
$sth = $this->db->prepare($query); |
|
@@ -1121,7 +1121,7 @@ discard block |
|
|
block discarded – undo |
|
1121
|
1121
|
* @param String $verticalrate vertival rate of flight |
|
1122
|
1122
|
* @return String success or false |
|
1123
|
1123
|
*/ |
|
1124
|
|
- 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 = '') |
|
|
1124
|
+ 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 = '') |
|
1125
|
1125
|
{ |
|
1126
|
1126
|
global $globalURL, $globalMarineImageFetch; |
|
1127
|
1127
|
|
|
@@ -1193,34 +1193,34 @@ discard block |
|
|
block discarded – undo |
|
1193
|
1193
|
$date = date("Y-m-d H:i:s", time()); |
|
1194
|
1194
|
} |
|
1195
|
1195
|
|
|
1196
|
|
- $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
1197
|
|
- $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1198
|
|
- $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1199
|
|
- $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1200
|
|
- $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
1201
|
|
- $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1202
|
|
- $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
1203
|
|
- $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
1204
|
|
- $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
1205
|
|
- $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
1206
|
|
- $type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
1207
|
|
- $status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
1208
|
|
- $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
1209
|
|
- $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
1210
|
|
- $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
1211
|
|
- $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
1212
|
|
- $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
1213
|
|
- $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
1214
|
|
- $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
1215
|
|
- $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
1216
|
|
- $race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT); |
|
1217
|
|
- $race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1218
|
|
- $distance = filter_var($distance,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
|
1196
|
+ $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
|
1197
|
+ $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
|
1198
|
+ $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
|
1199
|
+ $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
|
1200
|
+ $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
|
1201
|
+ $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
|
1202
|
+ $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
|
1203
|
+ $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
|
1204
|
+ $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
|
1205
|
+ $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
|
1206
|
+ $type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
|
1207
|
+ $status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
|
1208
|
+ $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
|
1209
|
+ $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
|
1210
|
+ $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
|
1211
|
+ $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
|
1212
|
+ $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
|
1213
|
+ $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
|
1214
|
+ $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
|
1215
|
+ $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
|
1216
|
+ $race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT); |
|
|
1217
|
+ $race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
|
1218
|
+ $distance = filter_var($distance, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1219
|
1219
|
if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
|
1220
|
1220
|
$Image = new Image($this->db); |
|
1221
|
|
- $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
|
1221
|
+ $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
1222
|
1222
|
if (!isset($image_array[0]['mmsi'])) { |
|
1223
|
|
- $Image->addMarineImage($mmsi,$imo,$ident); |
|
|
1223
|
+ $Image->addMarineImage($mmsi, $imo, $ident); |
|
1224
|
1224
|
} |
|
1225
|
1225
|
unset($Image); |
|
1226
|
1226
|
} |
|
@@ -1236,10 +1236,10 @@ discard block |
|
|
block discarded – undo |
|
1236
|
1236
|
if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1237
|
1237
|
//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
1238
|
1238
|
if ($arrival_date == '') $arrival_date = NULL; |
|
1239
|
|
- $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) |
|
|
1239
|
+ $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) |
|
1240
|
1240
|
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)"; |
|
1241
|
1241
|
|
|
1242
|
|
- $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); |
|
|
1242
|
+ $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); |
|
1243
|
1243
|
try { |
|
1244
|
1244
|
$sth = $this->db->prepare($query); |
|
1245
|
1245
|
$sth->execute($query_values); |
|
@@ -1263,13 +1263,13 @@ discard block |
|
|
block discarded – undo |
|
1263
|
1263
|
{ |
|
1264
|
1264
|
global $globalDBdriver, $globalTimezone; |
|
1265
|
1265
|
if ($globalDBdriver == 'mysql') { |
|
1266
|
|
- $query = "SELECT marine_output.ident FROM marine_output |
|
|
1266
|
+ $query = "SELECT marine_output.ident FROM marine_output |
|
1267
|
1267
|
WHERE marine_output.ident = :ident |
|
1268
|
1268
|
AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
|
1269
|
1269
|
AND marine_output.date < UTC_TIMESTAMP()"; |
|
1270
|
1270
|
$query_data = array(':ident' => $ident); |
|
1271
|
1271
|
} else { |
|
1272
|
|
- $query = "SELECT marine_output.ident FROM marine_output |
|
|
1272
|
+ $query = "SELECT marine_output.ident FROM marine_output |
|
1273
|
1273
|
WHERE marine_output.ident = :ident |
|
1274
|
1274
|
AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
|
1275
|
1275
|
AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
|
@@ -1278,8 +1278,8 @@ discard block |
|
|
block discarded – undo |
|
1278
|
1278
|
|
|
1279
|
1279
|
$sth = $this->db->prepare($query); |
|
1280
|
1280
|
$sth->execute($query_data); |
|
1281
|
|
- $ident_result=''; |
|
1282
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1281
|
+ $ident_result = ''; |
|
|
1282
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1283
|
1283
|
{ |
|
1284
|
1284
|
$ident_result = $row['ident']; |
|
1285
|
1285
|
} |
|
@@ -1305,8 +1305,8 @@ discard block |
|
|
block discarded – undo |
|
1305
|
1305
|
return false; |
|
1306
|
1306
|
} else { |
|
1307
|
1307
|
$q_array = explode(" ", $q); |
|
1308
|
|
- foreach ($q_array as $q_item){ |
|
1309
|
|
- $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
|
1308
|
+ foreach ($q_array as $q_item) { |
|
|
1309
|
+ $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
1310
|
1310
|
$additional_query .= " AND ("; |
|
1311
|
1311
|
$additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
|
1312
|
1312
|
$additional_query .= ")"; |
|
@@ -1314,11 +1314,11 @@ discard block |
|
|
block discarded – undo |
|
1314
|
1314
|
} |
|
1315
|
1315
|
} |
|
1316
|
1316
|
if ($globalDBdriver == 'mysql') { |
|
1317
|
|
- $query = "SELECT marine_output.* FROM marine_output |
|
|
1317
|
+ $query = "SELECT marine_output.* FROM marine_output |
|
1318
|
1318
|
WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
|
1319
|
1319
|
AND marine_output.date < UTC_TIMESTAMP()"; |
|
1320
|
1320
|
} else { |
|
1321
|
|
- $query = "SELECT marine_output.* FROM marine_output |
|
|
1321
|
+ $query = "SELECT marine_output.* FROM marine_output |
|
1322
|
1322
|
WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
|
1323
|
1323
|
AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
|
1324
|
1324
|
} |
|
@@ -1337,16 +1337,16 @@ discard block |
|
|
block discarded – undo |
|
1337
|
1337
|
* |
|
1338
|
1338
|
*/ |
|
1339
|
1339
|
|
|
1340
|
|
- public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
|
1340
|
+ public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
1341
|
1341
|
{ |
|
1342
|
1342
|
global $globalDBdriver, $globalArchive; |
|
1343
|
1343
|
//$filter_query = $this->getFilter($filters,true,true); |
|
1344
|
|
- $Connection= new Connection($this->db); |
|
|
1344
|
+ $Connection = new Connection($this->db); |
|
1345
|
1345
|
if (!$Connection->tableExists('countries')) return array(); |
|
1346
|
1346
|
require_once('class.SpotterLive.php'); |
|
1347
|
1347
|
if (!isset($globalArchive) || $globalArchive !== TRUE) { |
|
1348
|
1348
|
$MarineLive = new MarineLive($this->db); |
|
1349
|
|
- $filter_query = $MarineLive->getFilter($filters,true,true); |
|
|
1349
|
+ $filter_query = $MarineLive->getFilter($filters, true, true); |
|
1350
|
1350
|
$filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
|
1351
|
1351
|
if ($olderthanmonths > 0) { |
|
1352
|
1352
|
if ($globalDBdriver == 'mysql') { |
|
@@ -1366,7 +1366,7 @@ discard block |
|
|
block discarded – undo |
|
1366
|
1366
|
} else { |
|
1367
|
1367
|
require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
|
1368
|
1368
|
$MarineArchive = new MarineArchive($this->db); |
|
1369
|
|
- $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
|
1369
|
+ $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
1370
|
1370
|
$filter_query .= " over_country <> ''"; |
|
1371
|
1371
|
if ($olderthanmonths > 0) { |
|
1372
|
1372
|
if ($globalDBdriver == 'mysql') { |
|
@@ -1394,7 +1394,7 @@ discard block |
|
|
block discarded – undo |
|
1394
|
1394
|
$flight_array = array(); |
|
1395
|
1395
|
$temp_array = array(); |
|
1396
|
1396
|
|
|
1397
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1397
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1398
|
1398
|
{ |
|
1399
|
1399
|
$temp_array['marine_count'] = $row['nb']; |
|
1400
|
1400
|
$temp_array['marine_country'] = $row['name']; |
|
@@ -1413,11 +1413,11 @@ discard block |
|
|
block discarded – undo |
|
1413
|
1413
|
* @return Array the callsign list |
|
1414
|
1414
|
* |
|
1415
|
1415
|
*/ |
|
1416
|
|
- public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
|
1416
|
+ public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1417
|
1417
|
{ |
|
1418
|
1418
|
global $globalDBdriver; |
|
1419
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
1420
|
|
- $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
|
1419
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
|
1420
|
+ $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
1421
|
1421
|
FROM marine_output".$filter_query." marine_output.ident <> ''"; |
|
1422
|
1422
|
if ($olderthanmonths > 0) { |
|
1423
|
1423
|
if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
@@ -1431,28 +1431,28 @@ discard block |
|
|
block discarded – undo |
|
1431
|
1431
|
if ($year != '') { |
|
1432
|
1432
|
if ($globalDBdriver == 'mysql') { |
|
1433
|
1433
|
$query .= " AND YEAR(marine_output.date) = :year"; |
|
1434
|
|
- $query_values = array_merge($query_values,array(':year' => $year)); |
|
|
1434
|
+ $query_values = array_merge($query_values, array(':year' => $year)); |
|
1435
|
1435
|
} else { |
|
1436
|
1436
|
$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
|
1437
|
|
- $query_values = array_merge($query_values,array(':year' => $year)); |
|
|
1437
|
+ $query_values = array_merge($query_values, array(':year' => $year)); |
|
1438
|
1438
|
} |
|
1439
|
1439
|
} |
|
1440
|
1440
|
if ($month != '') { |
|
1441
|
1441
|
if ($globalDBdriver == 'mysql') { |
|
1442
|
1442
|
$query .= " AND MONTH(marine_output.date) = :month"; |
|
1443
|
|
- $query_values = array_merge($query_values,array(':month' => $month)); |
|
|
1443
|
+ $query_values = array_merge($query_values, array(':month' => $month)); |
|
1444
|
1444
|
} else { |
|
1445
|
1445
|
$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
|
1446
|
|
- $query_values = array_merge($query_values,array(':month' => $month)); |
|
|
1446
|
+ $query_values = array_merge($query_values, array(':month' => $month)); |
|
1447
|
1447
|
} |
|
1448
|
1448
|
} |
|
1449
|
1449
|
if ($day != '') { |
|
1450
|
1450
|
if ($globalDBdriver == 'mysql') { |
|
1451
|
1451
|
$query .= " AND DAY(marine_output.date) = :day"; |
|
1452
|
|
- $query_values = array_merge($query_values,array(':day' => $day)); |
|
|
1452
|
+ $query_values = array_merge($query_values, array(':day' => $day)); |
|
1453
|
1453
|
} else { |
|
1454
|
1454
|
$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
|
1455
|
|
- $query_values = array_merge($query_values,array(':day' => $day)); |
|
|
1455
|
+ $query_values = array_merge($query_values, array(':day' => $day)); |
|
1456
|
1456
|
} |
|
1457
|
1457
|
} |
|
1458
|
1458
|
$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
|
@@ -1464,7 +1464,7 @@ discard block |
|
|
block discarded – undo |
|
1464
|
1464
|
$callsign_array = array(); |
|
1465
|
1465
|
$temp_array = array(); |
|
1466
|
1466
|
|
|
1467
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1467
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1468
|
1468
|
{ |
|
1469
|
1469
|
$temp_array['callsign_icao'] = $row['ident']; |
|
1470
|
1470
|
$temp_array['airline_name'] = $row['airline_name']; |
|
@@ -1516,7 +1516,7 @@ discard block |
|
|
block discarded – undo |
|
1516
|
1516
|
$date_array = array(); |
|
1517
|
1517
|
$temp_array = array(); |
|
1518
|
1518
|
|
|
1519
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1519
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1520
|
1520
|
{ |
|
1521
|
1521
|
$temp_array['date_name'] = $row['date_name']; |
|
1522
|
1522
|
$temp_array['date_count'] = $row['date_count']; |
|
@@ -1542,7 +1542,7 @@ discard block |
|
|
block discarded – undo |
|
1542
|
1542
|
$datetime = new DateTime(); |
|
1543
|
1543
|
$offset = $datetime->format('P'); |
|
1544
|
1544
|
} else $offset = '+00:00'; |
|
1545
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
|
1545
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
1546
|
1546
|
if ($globalDBdriver == 'mysql') { |
|
1547
|
1547
|
$query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
|
1548
|
1548
|
FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
|
@@ -1563,7 +1563,7 @@ discard block |
|
|
block discarded – undo |
|
1563
|
1563
|
$date_array = array(); |
|
1564
|
1564
|
$temp_array = array(); |
|
1565
|
1565
|
|
|
1566
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1566
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1567
|
1567
|
{ |
|
1568
|
1568
|
$temp_array['date_name'] = $row['date_name']; |
|
1569
|
1569
|
$temp_array['date_count'] = $row['date_count']; |
|
@@ -1588,7 +1588,7 @@ discard block |
|
|
block discarded – undo |
|
1588
|
1588
|
$datetime = new DateTime(); |
|
1589
|
1589
|
$offset = $datetime->format('P'); |
|
1590
|
1590
|
} else $offset = '+00:00'; |
|
1591
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
|
1591
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
1592
|
1592
|
if ($globalDBdriver == 'mysql') { |
|
1593
|
1593
|
$query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
|
1594
|
1594
|
FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
|
@@ -1609,7 +1609,7 @@ discard block |
|
|
block discarded – undo |
|
1609
|
1609
|
$date_array = array(); |
|
1610
|
1610
|
$temp_array = array(); |
|
1611
|
1611
|
|
|
1612
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1612
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1613
|
1613
|
{ |
|
1614
|
1614
|
$temp_array['date_name'] = $row['date_name']; |
|
1615
|
1615
|
$temp_array['date_count'] = $row['date_count']; |
|
@@ -1656,7 +1656,7 @@ discard block |
|
|
block discarded – undo |
|
1656
|
1656
|
$date_array = array(); |
|
1657
|
1657
|
$temp_array = array(); |
|
1658
|
1658
|
|
|
1659
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1659
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1660
|
1660
|
{ |
|
1661
|
1661
|
$temp_array['month_name'] = $row['month_name']; |
|
1662
|
1662
|
$temp_array['year_name'] = $row['year_name']; |
|
@@ -1685,7 +1685,7 @@ discard block |
|
|
block discarded – undo |
|
1685
|
1685
|
$datetime = new DateTime(); |
|
1686
|
1686
|
$offset = $datetime->format('P'); |
|
1687
|
1687
|
} else $offset = '+00:00'; |
|
1688
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
|
1688
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
1689
|
1689
|
if ($globalDBdriver == 'mysql') { |
|
1690
|
1690
|
$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 |
|
1691
|
1691
|
FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
|
@@ -1706,7 +1706,7 @@ discard block |
|
|
block discarded – undo |
|
1706
|
1706
|
$date_array = array(); |
|
1707
|
1707
|
$temp_array = array(); |
|
1708
|
1708
|
|
|
1709
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1709
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1710
|
1710
|
{ |
|
1711
|
1711
|
$temp_array['year_name'] = $row['year_name']; |
|
1712
|
1712
|
$temp_array['month_name'] = $row['month_name']; |
|
@@ -1726,7 +1726,7 @@ discard block |
|
|
block discarded – undo |
|
1726
|
1726
|
* @return Array the hour list |
|
1727
|
1727
|
* |
|
1728
|
1728
|
*/ |
|
1729
|
|
- public function countAllHours($orderby,$filters = array()) |
|
|
1729
|
+ public function countAllHours($orderby, $filters = array()) |
|
1730
|
1730
|
{ |
|
1731
|
1731
|
global $globalTimezone, $globalDBdriver; |
|
1732
|
1732
|
if ($globalTimezone != '') { |
|
@@ -1774,7 +1774,7 @@ discard block |
|
|
block discarded – undo |
|
1774
|
1774
|
$hour_array = array(); |
|
1775
|
1775
|
$temp_array = array(); |
|
1776
|
1776
|
|
|
1777
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1777
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1778
|
1778
|
{ |
|
1779
|
1779
|
$temp_array['hour_name'] = $row['hour_name']; |
|
1780
|
1780
|
$temp_array['hour_count'] = $row['hour_count']; |
|
@@ -1796,8 +1796,8 @@ discard block |
|
|
block discarded – undo |
|
1796
|
1796
|
public function countAllHoursByDate($date, $filters = array()) |
|
1797
|
1797
|
{ |
|
1798
|
1798
|
global $globalTimezone, $globalDBdriver; |
|
1799
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
1800
|
|
- $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
|
1799
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
|
1800
|
+ $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1801
|
1801
|
if ($globalTimezone != '') { |
|
1802
|
1802
|
date_default_timezone_set($globalTimezone); |
|
1803
|
1803
|
$datetime = new DateTime($date); |
|
@@ -1805,12 +1805,12 @@ discard block |
|
|
block discarded – undo |
|
1805
|
1805
|
} else $offset = '+00:00'; |
|
1806
|
1806
|
|
|
1807
|
1807
|
if ($globalDBdriver == 'mysql') { |
|
1808
|
|
- $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
|
1808
|
+ $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1809
|
1809
|
FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
|
1810
|
1810
|
GROUP BY hour_name |
|
1811
|
1811
|
ORDER BY hour_name ASC"; |
|
1812
|
1812
|
} else { |
|
1813
|
|
- $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
|
1813
|
+ $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1814
|
1814
|
FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
|
1815
|
1815
|
GROUP BY hour_name |
|
1816
|
1816
|
ORDER BY hour_name ASC"; |
|
@@ -1822,7 +1822,7 @@ discard block |
|
|
block discarded – undo |
|
1822
|
1822
|
$hour_array = array(); |
|
1823
|
1823
|
$temp_array = array(); |
|
1824
|
1824
|
|
|
1825
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1825
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1826
|
1826
|
{ |
|
1827
|
1827
|
$temp_array['hour_name'] = $row['hour_name']; |
|
1828
|
1828
|
$temp_array['hour_count'] = $row['hour_count']; |
|
@@ -1844,8 +1844,8 @@ discard block |
|
|
block discarded – undo |
|
1844
|
1844
|
public function countAllHoursByIdent($ident, $filters = array()) |
|
1845
|
1845
|
{ |
|
1846
|
1846
|
global $globalTimezone, $globalDBdriver; |
|
1847
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
1848
|
|
- $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
|
1847
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
|
1848
|
+ $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1849
|
1849
|
if ($globalTimezone != '') { |
|
1850
|
1850
|
date_default_timezone_set($globalTimezone); |
|
1851
|
1851
|
$datetime = new DateTime(); |
|
@@ -1853,12 +1853,12 @@ discard block |
|
|
block discarded – undo |
|
1853
|
1853
|
} else $offset = '+00:00'; |
|
1854
|
1854
|
|
|
1855
|
1855
|
if ($globalDBdriver == 'mysql') { |
|
1856
|
|
- $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
|
1856
|
+ $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1857
|
1857
|
FROM marine_output".$filter_query." marine_output.ident = :ident |
|
1858
|
1858
|
GROUP BY hour_name |
|
1859
|
1859
|
ORDER BY hour_name ASC"; |
|
1860
|
1860
|
} else { |
|
1861
|
|
- $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
|
1861
|
+ $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1862
|
1862
|
FROM marine_output".$filter_query." marine_output.ident = :ident |
|
1863
|
1863
|
GROUP BY hour_name |
|
1864
|
1864
|
ORDER BY hour_name ASC"; |
|
@@ -1866,12 +1866,12 @@ discard block |
|
|
block discarded – undo |
|
1866
|
1866
|
|
|
1867
|
1867
|
|
|
1868
|
1868
|
$sth = $this->db->prepare($query); |
|
1869
|
|
- $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
|
1869
|
+ $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1870
|
1870
|
|
|
1871
|
1871
|
$hour_array = array(); |
|
1872
|
1872
|
$temp_array = array(); |
|
1873
|
1873
|
|
|
1874
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1874
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1875
|
1875
|
{ |
|
1876
|
1876
|
$temp_array['hour_name'] = $row['hour_name']; |
|
1877
|
1877
|
$temp_array['hour_count'] = $row['hour_count']; |
|
@@ -1888,11 +1888,11 @@ discard block |
|
|
block discarded – undo |
|
1888
|
1888
|
* @return Array the aircraft list |
|
1889
|
1889
|
* |
|
1890
|
1890
|
*/ |
|
1891
|
|
- public function countAllCaptainsByRaces($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
|
1891
|
+ public function countAllCaptainsByRaces($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
1892
|
1892
|
{ |
|
1893
|
1893
|
global $globalDBdriver; |
|
1894
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
1895
|
|
- $query = "SELECT DISTINCT marine_output.race_id, marine_output.race_name, COUNT(marine_output.captain_id) AS captain_count |
|
|
1894
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
|
1895
|
+ $query = "SELECT DISTINCT marine_output.race_id, marine_output.race_name, COUNT(marine_output.captain_id) AS captain_count |
|
1896
|
1896
|
FROM marine_output".$filter_query." race_id IS NOT NULL"; |
|
1897
|
1897
|
if ($olderthanmonths > 0) { |
|
1898
|
1898
|
if ($globalDBdriver == 'mysql') { |
|
@@ -1915,7 +1915,7 @@ discard block |
|
|
block discarded – undo |
|
1915
|
1915
|
$marine_array = array(); |
|
1916
|
1916
|
$temp_array = array(); |
|
1917
|
1917
|
|
|
1918
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
1918
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1919
|
1919
|
{ |
|
1920
|
1920
|
$temp_array['marine_race_id'] = $row['race_id']; |
|
1921
|
1921
|
$temp_array['marine_race_name'] = $row['race_name']; |
|
@@ -1931,33 +1931,33 @@ discard block |
|
|
block discarded – undo |
|
1931
|
1931
|
* @return Integer the number of vessels |
|
1932
|
1932
|
* |
|
1933
|
1933
|
*/ |
|
1934
|
|
- public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
|
1934
|
+ public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
1935
|
1935
|
{ |
|
1936
|
1936
|
global $globalDBdriver; |
|
1937
|
1937
|
//$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
|
1938
|
|
- $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
|
1938
|
+ $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1939
|
1939
|
$query_values = array(); |
|
1940
|
1940
|
$query = ''; |
|
1941
|
1941
|
if ($year != '') { |
|
1942
|
1942
|
if ($globalDBdriver == 'mysql') { |
|
1943
|
1943
|
$query .= " AND YEAR(marine_output.date) = :year"; |
|
1944
|
|
- $query_values = array_merge($query_values,array(':year' => $year)); |
|
|
1944
|
+ $query_values = array_merge($query_values, array(':year' => $year)); |
|
1945
|
1945
|
} else { |
|
1946
|
1946
|
$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
|
1947
|
|
- $query_values = array_merge($query_values,array(':year' => $year)); |
|
|
1947
|
+ $query_values = array_merge($query_values, array(':year' => $year)); |
|
1948
|
1948
|
} |
|
1949
|
1949
|
} |
|
1950
|
1950
|
if ($month != '') { |
|
1951
|
1951
|
if ($globalDBdriver == 'mysql') { |
|
1952
|
1952
|
$query .= " AND MONTH(marine_output.date) = :month"; |
|
1953
|
|
- $query_values = array_merge($query_values,array(':month' => $month)); |
|
|
1953
|
+ $query_values = array_merge($query_values, array(':month' => $month)); |
|
1954
|
1954
|
} else { |
|
1955
|
1955
|
$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
|
1956
|
|
- $query_values = array_merge($query_values,array(':month' => $month)); |
|
|
1956
|
+ $query_values = array_merge($query_values, array(':month' => $month)); |
|
1957
|
1957
|
} |
|
1958
|
1958
|
} |
|
1959
|
1959
|
if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1960
|
|
- else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
|
1960
|
+ else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1961
|
1961
|
|
|
1962
|
1962
|
$sth = $this->db->prepare($queryi); |
|
1963
|
1963
|
$sth->execute($query_values); |
|
@@ -1970,32 +1970,32 @@ discard block |
|
|
block discarded – undo |
|
1970
|
1970
|
* @return Integer the number of vessels |
|
1971
|
1971
|
* |
|
1972
|
1972
|
*/ |
|
1973
|
|
- public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
|
1973
|
+ public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
1974
|
1974
|
{ |
|
1975
|
1975
|
global $globalDBdriver; |
|
1976
|
|
- $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
|
1976
|
+ $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1977
|
1977
|
$query_values = array(); |
|
1978
|
1978
|
$query = ''; |
|
1979
|
1979
|
if ($year != '') { |
|
1980
|
1980
|
if ($globalDBdriver == 'mysql') { |
|
1981
|
1981
|
$query .= " AND YEAR(marine_output.date) = :year"; |
|
1982
|
|
- $query_values = array_merge($query_values,array(':year' => $year)); |
|
|
1982
|
+ $query_values = array_merge($query_values, array(':year' => $year)); |
|
1983
|
1983
|
} else { |
|
1984
|
1984
|
$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
|
1985
|
|
- $query_values = array_merge($query_values,array(':year' => $year)); |
|
|
1985
|
+ $query_values = array_merge($query_values, array(':year' => $year)); |
|
1986
|
1986
|
} |
|
1987
|
1987
|
} |
|
1988
|
1988
|
if ($month != '') { |
|
1989
|
1989
|
if ($globalDBdriver == 'mysql') { |
|
1990
|
1990
|
$query .= " AND MONTH(marine_output.date) = :month"; |
|
1991
|
|
- $query_values = array_merge($query_values,array(':month' => $month)); |
|
|
1991
|
+ $query_values = array_merge($query_values, array(':month' => $month)); |
|
1992
|
1992
|
} else { |
|
1993
|
1993
|
$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
|
1994
|
|
- $query_values = array_merge($query_values,array(':month' => $month)); |
|
|
1994
|
+ $query_values = array_merge($query_values, array(':month' => $month)); |
|
1995
|
1995
|
} |
|
1996
|
1996
|
} |
|
1997
|
1997
|
if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1998
|
|
- else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
|
1998
|
+ else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1999
|
1999
|
|
|
2000
|
2000
|
$sth = $this->db->prepare($queryi); |
|
2001
|
2001
|
$sth->execute($query_values); |
|
@@ -2008,32 +2008,32 @@ discard block |
|
|
block discarded – undo |
|
2008
|
2008
|
* @return Integer number of races |
|
2009
|
2009
|
* |
|
2010
|
2010
|
*/ |
|
2011
|
|
- public function countOverallMarineRaces($filters = array(),$year = '',$month = '') |
|
|
2011
|
+ public function countOverallMarineRaces($filters = array(), $year = '', $month = '') |
|
2012
|
2012
|
{ |
|
2013
|
2013
|
global $globalDBdriver; |
|
2014
|
|
- $queryi = "SELECT COUNT(DISTINCT marine_output.race_id) AS marine_count FROM marine_output"; |
|
|
2014
|
+ $queryi = "SELECT COUNT(DISTINCT marine_output.race_id) AS marine_count FROM marine_output"; |
|
2015
|
2015
|
$query_values = array(); |
|
2016
|
2016
|
$query = ''; |
|
2017
|
2017
|
if ($year != '') { |
|
2018
|
2018
|
if ($globalDBdriver == 'mysql') { |
|
2019
|
2019
|
$query .= " AND YEAR(marine_output.date) = :year"; |
|
2020
|
|
- $query_values = array_merge($query_values,array(':year' => $year)); |
|
|
2020
|
+ $query_values = array_merge($query_values, array(':year' => $year)); |
|
2021
|
2021
|
} else { |
|
2022
|
2022
|
$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
|
2023
|
|
- $query_values = array_merge($query_values,array(':year' => $year)); |
|
|
2023
|
+ $query_values = array_merge($query_values, array(':year' => $year)); |
|
2024
|
2024
|
} |
|
2025
|
2025
|
} |
|
2026
|
2026
|
if ($month != '') { |
|
2027
|
2027
|
if ($globalDBdriver == 'mysql') { |
|
2028
|
2028
|
$query .= " AND MONTH(marine_output.date) = :month"; |
|
2029
|
|
- $query_values = array_merge($query_values,array(':month' => $month)); |
|
|
2029
|
+ $query_values = array_merge($query_values, array(':month' => $month)); |
|
2030
|
2030
|
} else { |
|
2031
|
2031
|
$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
|
2032
|
|
- $query_values = array_merge($query_values,array(':month' => $month)); |
|
|
2032
|
+ $query_values = array_merge($query_values, array(':month' => $month)); |
|
2033
|
2033
|
} |
|
2034
|
2034
|
} |
|
2035
|
2035
|
if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
2036
|
|
- else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
|
2036
|
+ else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
2037
|
2037
|
|
|
2038
|
2038
|
$sth = $this->db->prepare($queryi); |
|
2039
|
2039
|
$sth->execute($query_values); |
|
@@ -2046,32 +2046,32 @@ discard block |
|
|
block discarded – undo |
|
2046
|
2046
|
* @return Integer number of captain |
|
2047
|
2047
|
* |
|
2048
|
2048
|
*/ |
|
2049
|
|
- public function countOverallMarineCaptains($filters = array(),$year = '',$month = '') |
|
|
2049
|
+ public function countOverallMarineCaptains($filters = array(), $year = '', $month = '') |
|
2050
|
2050
|
{ |
|
2051
|
2051
|
global $globalDBdriver; |
|
2052
|
|
- $queryi = "SELECT COUNT(DISTINCT marine_output.captain_id) AS marine_count FROM marine_output"; |
|
|
2052
|
+ $queryi = "SELECT COUNT(DISTINCT marine_output.captain_id) AS marine_count FROM marine_output"; |
|
2053
|
2053
|
$query_values = array(); |
|
2054
|
2054
|
$query = ''; |
|
2055
|
2055
|
if ($year != '') { |
|
2056
|
2056
|
if ($globalDBdriver == 'mysql') { |
|
2057
|
2057
|
$query .= " AND YEAR(marine_output.date) = :year"; |
|
2058
|
|
- $query_values = array_merge($query_values,array(':year' => $year)); |
|
|
2058
|
+ $query_values = array_merge($query_values, array(':year' => $year)); |
|
2059
|
2059
|
} else { |
|
2060
|
2060
|
$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
|
2061
|
|
- $query_values = array_merge($query_values,array(':year' => $year)); |
|
|
2061
|
+ $query_values = array_merge($query_values, array(':year' => $year)); |
|
2062
|
2062
|
} |
|
2063
|
2063
|
} |
|
2064
|
2064
|
if ($month != '') { |
|
2065
|
2065
|
if ($globalDBdriver == 'mysql') { |
|
2066
|
2066
|
$query .= " AND MONTH(marine_output.date) = :month"; |
|
2067
|
|
- $query_values = array_merge($query_values,array(':month' => $month)); |
|
|
2067
|
+ $query_values = array_merge($query_values, array(':month' => $month)); |
|
2068
|
2068
|
} else { |
|
2069
|
2069
|
$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
|
2070
|
|
- $query_values = array_merge($query_values,array(':month' => $month)); |
|
|
2070
|
+ $query_values = array_merge($query_values, array(':month' => $month)); |
|
2071
|
2071
|
} |
|
2072
|
2072
|
} |
|
2073
|
2073
|
if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
2074
|
|
- else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
|
2074
|
+ else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
2075
|
2075
|
|
|
2076
|
2076
|
$sth = $this->db->prepare($queryi); |
|
2077
|
2077
|
$sth->execute($query_values); |
|
@@ -2087,7 +2087,7 @@ discard block |
|
|
block discarded – undo |
|
2087
|
2087
|
public function countAllHoursFromToday($filters = array()) |
|
2088
|
2088
|
{ |
|
2089
|
2089
|
global $globalTimezone, $globalDBdriver; |
|
2090
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
|
2090
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
2091
|
2091
|
if ($globalTimezone != '') { |
|
2092
|
2092
|
date_default_timezone_set($globalTimezone); |
|
2093
|
2093
|
$datetime = new DateTime(); |
|
@@ -2095,12 +2095,12 @@ discard block |
|
|
block discarded – undo |
|
2095
|
2095
|
} else $offset = '+00:00'; |
|
2096
|
2096
|
|
|
2097
|
2097
|
if ($globalDBdriver == 'mysql') { |
|
2098
|
|
- $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
|
2098
|
+ $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
2099
|
2099
|
FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
|
2100
|
2100
|
GROUP BY hour_name |
|
2101
|
2101
|
ORDER BY hour_name ASC"; |
|
2102
|
2102
|
} else { |
|
2103
|
|
- $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
|
2103
|
+ $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
2104
|
2104
|
FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
|
2105
|
2105
|
GROUP BY hour_name |
|
2106
|
2106
|
ORDER BY hour_name ASC"; |
|
@@ -2112,7 +2112,7 @@ discard block |
|
|
block discarded – undo |
|
2112
|
2112
|
$hour_array = array(); |
|
2113
|
2113
|
$temp_array = array(); |
|
2114
|
2114
|
|
|
2115
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
2115
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2116
|
2116
|
{ |
|
2117
|
2117
|
$temp_array['hour_name'] = $row['hour_name']; |
|
2118
|
2118
|
$temp_array['hour_count'] = $row['hour_count']; |
|
@@ -2131,9 +2131,9 @@ discard block |
|
|
block discarded – undo |
|
2131
|
2131
|
*/ |
|
2132
|
2132
|
public function getMarineIDBasedOnFamMarineID($fammarine_id) |
|
2133
|
2133
|
{ |
|
2134
|
|
- $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
|
2134
|
+ $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
2135
|
2135
|
|
|
2136
|
|
- $query = "SELECT marine_output.marine_id |
|
|
2136
|
+ $query = "SELECT marine_output.marine_id |
|
2137
|
2137
|
FROM marine_output |
|
2138
|
2138
|
WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
|
2139
|
2139
|
|
|
@@ -2141,7 +2141,7 @@ discard block |
|
|
block discarded – undo |
|
2141
|
2141
|
$sth = $this->db->prepare($query); |
|
2142
|
2142
|
$sth->execute(); |
|
2143
|
2143
|
|
|
2144
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
2144
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2145
|
2145
|
{ |
|
2146
|
2146
|
return $row['marine_id']; |
|
2147
|
2147
|
} |
|
@@ -2166,23 +2166,23 @@ discard block |
|
|
block discarded – undo |
|
2166
|
2166
|
} |
|
2167
|
2167
|
|
|
2168
|
2168
|
$current_date = date("Y-m-d H:i:s"); |
|
2169
|
|
- $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
|
2169
|
+ $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
2170
|
2170
|
|
|
2171
|
2171
|
$diff = abs(strtotime($current_date) - strtotime($date)); |
|
2172
|
2172
|
|
|
2173
|
|
- $time_array['years'] = floor($diff / (365*60*60*24)); |
|
|
2173
|
+ $time_array['years'] = floor($diff/(365*60*60*24)); |
|
2174
|
2174
|
$years = $time_array['years']; |
|
2175
|
2175
|
|
|
2176
|
|
- $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
|
2176
|
+ $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
2177
|
2177
|
$months = $time_array['months']; |
|
2178
|
2178
|
|
|
2179
|
|
- $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
|
2179
|
+ $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
2180
|
2180
|
$days = $time_array['days']; |
|
2181
|
|
- $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
|
2181
|
+ $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
2182
|
2182
|
$hours = $time_array['hours']; |
|
2183
|
|
- $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
|
2183
|
+ $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
2184
|
2184
|
$minutes = $time_array['minutes']; |
|
2185
|
|
- $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
|
2185
|
+ $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
2186
|
2186
|
|
|
2187
|
2187
|
return $time_array; |
|
2188
|
2188
|
} |
|
@@ -2205,63 +2205,63 @@ discard block |
|
|
block discarded – undo |
|
2205
|
2205
|
$temp_array['direction_degree'] = $direction; |
|
2206
|
2206
|
$temp_array['direction_shortname'] = "N"; |
|
2207
|
2207
|
$temp_array['direction_fullname'] = "North"; |
|
2208
|
|
- } elseif ($direction >= 22.5 && $direction < 45){ |
|
|
2208
|
+ } elseif ($direction >= 22.5 && $direction < 45) { |
|
2209
|
2209
|
$temp_array['direction_degree'] = $direction; |
|
2210
|
2210
|
$temp_array['direction_shortname'] = "NNE"; |
|
2211
|
2211
|
$temp_array['direction_fullname'] = "North-Northeast"; |
|
2212
|
|
- } elseif ($direction >= 45 && $direction < 67.5){ |
|
|
2212
|
+ } elseif ($direction >= 45 && $direction < 67.5) { |
|
2213
|
2213
|
$temp_array['direction_degree'] = $direction; |
|
2214
|
2214
|
$temp_array['direction_shortname'] = "NE"; |
|
2215
|
2215
|
$temp_array['direction_fullname'] = "Northeast"; |
|
2216
|
|
- } elseif ($direction >= 67.5 && $direction < 90){ |
|
|
2216
|
+ } elseif ($direction >= 67.5 && $direction < 90) { |
|
2217
|
2217
|
$temp_array['direction_degree'] = $direction; |
|
2218
|
2218
|
$temp_array['direction_shortname'] = "ENE"; |
|
2219
|
2219
|
$temp_array['direction_fullname'] = "East-Northeast"; |
|
2220
|
|
- } elseif ($direction >= 90 && $direction < 112.5){ |
|
|
2220
|
+ } elseif ($direction >= 90 && $direction < 112.5) { |
|
2221
|
2221
|
$temp_array['direction_degree'] = $direction; |
|
2222
|
2222
|
$temp_array['direction_shortname'] = "E"; |
|
2223
|
2223
|
$temp_array['direction_fullname'] = "East"; |
|
2224
|
|
- } elseif ($direction >= 112.5 && $direction < 135){ |
|
|
2224
|
+ } elseif ($direction >= 112.5 && $direction < 135) { |
|
2225
|
2225
|
$temp_array['direction_degree'] = $direction; |
|
2226
|
2226
|
$temp_array['direction_shortname'] = "ESE"; |
|
2227
|
2227
|
$temp_array['direction_fullname'] = "East-Southeast"; |
|
2228
|
|
- } elseif ($direction >= 135 && $direction < 157.5){ |
|
|
2228
|
+ } elseif ($direction >= 135 && $direction < 157.5) { |
|
2229
|
2229
|
$temp_array['direction_degree'] = $direction; |
|
2230
|
2230
|
$temp_array['direction_shortname'] = "SE"; |
|
2231
|
2231
|
$temp_array['direction_fullname'] = "Southeast"; |
|
2232
|
|
- } elseif ($direction >= 157.5 && $direction < 180){ |
|
|
2232
|
+ } elseif ($direction >= 157.5 && $direction < 180) { |
|
2233
|
2233
|
$temp_array['direction_degree'] = $direction; |
|
2234
|
2234
|
$temp_array['direction_shortname'] = "SSE"; |
|
2235
|
2235
|
$temp_array['direction_fullname'] = "South-Southeast"; |
|
2236
|
|
- } elseif ($direction >= 180 && $direction < 202.5){ |
|
|
2236
|
+ } elseif ($direction >= 180 && $direction < 202.5) { |
|
2237
|
2237
|
$temp_array['direction_degree'] = $direction; |
|
2238
|
2238
|
$temp_array['direction_shortname'] = "S"; |
|
2239
|
2239
|
$temp_array['direction_fullname'] = "South"; |
|
2240
|
|
- } elseif ($direction >= 202.5 && $direction < 225){ |
|
|
2240
|
+ } elseif ($direction >= 202.5 && $direction < 225) { |
|
2241
|
2241
|
$temp_array['direction_degree'] = $direction; |
|
2242
|
2242
|
$temp_array['direction_shortname'] = "SSW"; |
|
2243
|
2243
|
$temp_array['direction_fullname'] = "South-Southwest"; |
|
2244
|
|
- } elseif ($direction >= 225 && $direction < 247.5){ |
|
|
2244
|
+ } elseif ($direction >= 225 && $direction < 247.5) { |
|
2245
|
2245
|
$temp_array['direction_degree'] = $direction; |
|
2246
|
2246
|
$temp_array['direction_shortname'] = "SW"; |
|
2247
|
2247
|
$temp_array['direction_fullname'] = "Southwest"; |
|
2248
|
|
- } elseif ($direction >= 247.5 && $direction < 270){ |
|
|
2248
|
+ } elseif ($direction >= 247.5 && $direction < 270) { |
|
2249
|
2249
|
$temp_array['direction_degree'] = $direction; |
|
2250
|
2250
|
$temp_array['direction_shortname'] = "WSW"; |
|
2251
|
2251
|
$temp_array['direction_fullname'] = "West-Southwest"; |
|
2252
|
|
- } elseif ($direction >= 270 && $direction < 292.5){ |
|
|
2252
|
+ } elseif ($direction >= 270 && $direction < 292.5) { |
|
2253
|
2253
|
$temp_array['direction_degree'] = $direction; |
|
2254
|
2254
|
$temp_array['direction_shortname'] = "W"; |
|
2255
|
2255
|
$temp_array['direction_fullname'] = "West"; |
|
2256
|
|
- } elseif ($direction >= 292.5 && $direction < 315){ |
|
|
2256
|
+ } elseif ($direction >= 292.5 && $direction < 315) { |
|
2257
|
2257
|
$temp_array['direction_degree'] = $direction; |
|
2258
|
2258
|
$temp_array['direction_shortname'] = "WNW"; |
|
2259
|
2259
|
$temp_array['direction_fullname'] = "West-Northwest"; |
|
2260
|
|
- } elseif ($direction >= 315 && $direction < 337.5){ |
|
|
2260
|
+ } elseif ($direction >= 315 && $direction < 337.5) { |
|
2261
|
2261
|
$temp_array['direction_degree'] = $direction; |
|
2262
|
2262
|
$temp_array['direction_shortname'] = "NW"; |
|
2263
|
2263
|
$temp_array['direction_fullname'] = "Northwest"; |
|
2264
|
|
- } elseif ($direction >= 337.5 && $direction < 360){ |
|
|
2264
|
+ } elseif ($direction >= 337.5 && $direction < 360) { |
|
2265
|
2265
|
$temp_array['direction_degree'] = $direction; |
|
2266
|
2266
|
$temp_array['direction_shortname'] = "NNW"; |
|
2267
|
2267
|
$temp_array['direction_fullname'] = "North-Northwest"; |
|
@@ -2278,11 +2278,11 @@ discard block |
|
|
block discarded – undo |
|
2278
|
2278
|
* @param Float $longitude longitute of the flight |
|
2279
|
2279
|
* @return String the countrie |
|
2280
|
2280
|
*/ |
|
2281
|
|
- public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
|
2281
|
+ public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
2282
|
2282
|
{ |
|
2283
|
2283
|
global $globalDBdriver, $globalDebug; |
|
2284
|
|
- $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
2285
|
|
- $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
|
2284
|
+ $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
|
2285
|
+ $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
2286
|
2286
|
|
|
2287
|
2287
|
$Connection = new Connection($this->db); |
|
2288
|
2288
|
if (!$Connection->tableExists('countries')) return ''; |
|
@@ -2322,7 +2322,7 @@ discard block |
|
|
block discarded – undo |
|
2322
|
2322
|
public function getCountryFromISO2($iso2) |
|
2323
|
2323
|
{ |
|
2324
|
2324
|
global $globalDBdriver, $globalDebug; |
|
2325
|
|
- $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
|
2325
|
+ $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
2326
|
2326
|
|
|
2327
|
2327
|
$Connection = new Connection($this->db); |
|
2328
|
2328
|
if (!$Connection->tableExists('countries')) return ''; |
|
@@ -2370,7 +2370,7 @@ discard block |
|
|
block discarded – undo |
|
2370
|
2370
|
|
|
2371
|
2371
|
$bitly_data = json_decode($bitly_data); |
|
2372
|
2372
|
$bitly_url = ''; |
|
2373
|
|
- if ($bitly_data->status_txt = "OK"){ |
|
|
2373
|
+ if ($bitly_data->status_txt = "OK") { |
|
2374
|
2374
|
$bitly_url = $bitly_data->data->url; |
|
2375
|
2375
|
} |
|
2376
|
2376
|
|
|
@@ -2384,11 +2384,11 @@ discard block |
|
|
block discarded – undo |
|
2384
|
2384
|
* @return Array the vessel type list |
|
2385
|
2385
|
* |
|
2386
|
2386
|
*/ |
|
2387
|
|
- public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
|
2387
|
+ public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
2388
|
2388
|
{ |
|
2389
|
2389
|
global $globalDBdriver; |
|
2390
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
2391
|
|
- $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
|
2390
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
|
2391
|
+ $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
2392
|
2392
|
FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL"; |
|
2393
|
2393
|
if ($olderthanmonths > 0) { |
|
2394
|
2394
|
if ($globalDBdriver == 'mysql') { |
|
@@ -2408,28 +2408,28 @@ discard block |
|
|
block discarded – undo |
|
2408
|
2408
|
if ($year != '') { |
|
2409
|
2409
|
if ($globalDBdriver == 'mysql') { |
|
2410
|
2410
|
$query .= " AND YEAR(marine_output.date) = :year"; |
|
2411
|
|
- $query_values = array_merge($query_values,array(':year' => $year)); |
|
|
2411
|
+ $query_values = array_merge($query_values, array(':year' => $year)); |
|
2412
|
2412
|
} else { |
|
2413
|
2413
|
$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
|
2414
|
|
- $query_values = array_merge($query_values,array(':year' => $year)); |
|
|
2414
|
+ $query_values = array_merge($query_values, array(':year' => $year)); |
|
2415
|
2415
|
} |
|
2416
|
2416
|
} |
|
2417
|
2417
|
if ($month != '') { |
|
2418
|
2418
|
if ($globalDBdriver == 'mysql') { |
|
2419
|
2419
|
$query .= " AND MONTH(marine_output.date) = :month"; |
|
2420
|
|
- $query_values = array_merge($query_values,array(':month' => $month)); |
|
|
2420
|
+ $query_values = array_merge($query_values, array(':month' => $month)); |
|
2421
|
2421
|
} else { |
|
2422
|
2422
|
$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
|
2423
|
|
- $query_values = array_merge($query_values,array(':month' => $month)); |
|
|
2423
|
+ $query_values = array_merge($query_values, array(':month' => $month)); |
|
2424
|
2424
|
} |
|
2425
|
2425
|
} |
|
2426
|
2426
|
if ($day != '') { |
|
2427
|
2427
|
if ($globalDBdriver == 'mysql') { |
|
2428
|
2428
|
$query .= " AND DAY(marine_output.date) = :day"; |
|
2429
|
|
- $query_values = array_merge($query_values,array(':day' => $day)); |
|
|
2429
|
+ $query_values = array_merge($query_values, array(':day' => $day)); |
|
2430
|
2430
|
} else { |
|
2431
|
2431
|
$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
|
2432
|
|
- $query_values = array_merge($query_values,array(':day' => $day)); |
|
|
2432
|
+ $query_values = array_merge($query_values, array(':day' => $day)); |
|
2433
|
2433
|
} |
|
2434
|
2434
|
} |
|
2435
|
2435
|
$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
|
@@ -2438,9 +2438,9 @@ discard block |
|
|
block discarded – undo |
|
2438
|
2438
|
$sth->execute($query_values); |
|
2439
|
2439
|
$marine_array = array(); |
|
2440
|
2440
|
$temp_array = array(); |
|
2441
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
2441
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2442
|
2442
|
{ |
|
2443
|
|
- $temp_array['marine_type'] = html_entity_decode($row['marine_type'],ENT_QUOTES); |
|
|
2443
|
+ $temp_array['marine_type'] = html_entity_decode($row['marine_type'], ENT_QUOTES); |
|
2444
|
2444
|
$temp_array['marine_type_id'] = $row['marine_type_id']; |
|
2445
|
2445
|
$temp_array['marine_type_count'] = $row['marine_type_count']; |
|
2446
|
2446
|
$marine_array[] = $temp_array; |
|
@@ -2454,13 +2454,13 @@ discard block |
|
|
block discarded – undo |
|
2454
|
2454
|
* @return Array the tracker information |
|
2455
|
2455
|
* |
|
2456
|
2456
|
*/ |
|
2457
|
|
- public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$captain_id = '',$captain_name = '',$race_id = '',$race_name = '',$filters = array()) |
|
|
2457
|
+ public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $filters = array()) |
|
2458
|
2458
|
{ |
|
2459
|
2459
|
global $globalTimezone, $globalDBdriver; |
|
2460
|
2460
|
date_default_timezone_set('UTC'); |
|
2461
|
2461
|
$query_values = array(); |
|
2462
|
2462
|
$additional_query = ''; |
|
2463
|
|
- $filter_query = $this->getFilter($filters,true,true); |
|
|
2463
|
+ $filter_query = $this->getFilter($filters, true, true); |
|
2464
|
2464
|
if ($q != "") |
|
2465
|
2465
|
{ |
|
2466
|
2466
|
if (!is_string($q)) |
|
@@ -2468,8 +2468,8 @@ discard block |
|
|
block discarded – undo |
|
2468
|
2468
|
return false; |
|
2469
|
2469
|
} else { |
|
2470
|
2470
|
$q_array = explode(" ", $q); |
|
2471
|
|
- foreach ($q_array as $q_item){ |
|
2472
|
|
- $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
|
2471
|
+ foreach ($q_array as $q_item) { |
|
|
2472
|
+ $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
2473
|
2473
|
$additional_query .= " AND ("; |
|
2474
|
2474
|
if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
2475
|
2475
|
if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
@@ -2485,86 +2485,86 @@ discard block |
|
|
block discarded – undo |
|
2485
|
2485
|
} |
|
2486
|
2486
|
if ($callsign != "") |
|
2487
|
2487
|
{ |
|
2488
|
|
- $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
|
2488
|
+ $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
2489
|
2489
|
if (!is_string($callsign)) |
|
2490
|
2490
|
{ |
|
2491
|
2491
|
return false; |
|
2492
|
2492
|
} else { |
|
2493
|
2493
|
$additional_query .= " AND marine_output.ident = :callsign"; |
|
2494
|
|
- $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
|
2494
|
+ $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
2495
|
2495
|
} |
|
2496
|
2496
|
} |
|
2497
|
2497
|
if ($mmsi != "") |
|
2498
|
2498
|
{ |
|
2499
|
|
- $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
|
2499
|
+ $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
2500
|
2500
|
if (!is_numeric($mmsi)) |
|
2501
|
2501
|
{ |
|
2502
|
2502
|
return false; |
|
2503
|
2503
|
} else { |
|
2504
|
2504
|
$additional_query .= " AND marine_output.mmsi = :mmsi"; |
|
2505
|
|
- $query_values = array_merge($query_values,array(':mmsi' => $mmsi)); |
|
|
2505
|
+ $query_values = array_merge($query_values, array(':mmsi' => $mmsi)); |
|
2506
|
2506
|
} |
|
2507
|
2507
|
} |
|
2508
|
2508
|
if ($imo != "") |
|
2509
|
2509
|
{ |
|
2510
|
|
- $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
|
2510
|
+ $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
2511
|
2511
|
if (!is_numeric($imo)) |
|
2512
|
2512
|
{ |
|
2513
|
2513
|
return false; |
|
2514
|
2514
|
} else { |
|
2515
|
2515
|
$additional_query .= " AND marine_output.imo = :imo"; |
|
2516
|
|
- $query_values = array_merge($query_values,array(':imo' => $imo)); |
|
|
2516
|
+ $query_values = array_merge($query_values, array(':imo' => $imo)); |
|
2517
|
2517
|
} |
|
2518
|
2518
|
} |
|
2519
|
2519
|
if ($captain_id != "") |
|
2520
|
2520
|
{ |
|
2521
|
|
- $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
|
2521
|
+ $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
2522
|
2522
|
if (!is_numeric($captain_id)) |
|
2523
|
2523
|
{ |
|
2524
|
2524
|
return false; |
|
2525
|
2525
|
} else { |
|
2526
|
2526
|
$additional_query .= " AND marine_output.captain_id = :captain_id"; |
|
2527
|
|
- $query_values = array_merge($query_values,array(':captain_id' => $captain_id)); |
|
|
2527
|
+ $query_values = array_merge($query_values, array(':captain_id' => $captain_id)); |
|
2528
|
2528
|
} |
|
2529
|
2529
|
} |
|
2530
|
2530
|
if ($race_id != "") |
|
2531
|
2531
|
{ |
|
2532
|
|
- $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
|
2532
|
+ $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
2533
|
2533
|
if (!is_numeric($race_id)) |
|
2534
|
2534
|
{ |
|
2535
|
2535
|
return false; |
|
2536
|
2536
|
} else { |
|
2537
|
2537
|
$additional_query .= " AND marine_output.race_id = :race_id"; |
|
2538
|
|
- $query_values = array_merge($query_values,array(':race_id' => $race_id)); |
|
|
2538
|
+ $query_values = array_merge($query_values, array(':race_id' => $race_id)); |
|
2539
|
2539
|
} |
|
2540
|
2540
|
} |
|
2541
|
2541
|
if ($captain_name != "") |
|
2542
|
2542
|
{ |
|
2543
|
|
- $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
|
2543
|
+ $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
2544
|
2544
|
if (!is_string($captain_name)) |
|
2545
|
2545
|
{ |
|
2546
|
2546
|
return false; |
|
2547
|
2547
|
} else { |
|
2548
|
2548
|
$additional_query .= " AND marine_output.captain_name = :captain_name"; |
|
2549
|
|
- $query_values = array_merge($query_values,array(':captain_name' => $captain_name)); |
|
|
2549
|
+ $query_values = array_merge($query_values, array(':captain_name' => $captain_name)); |
|
2550
|
2550
|
} |
|
2551
|
2551
|
} |
|
2552
|
2552
|
if ($race_name != "") |
|
2553
|
2553
|
{ |
|
2554
|
|
- $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
|
2554
|
+ $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
2555
|
2555
|
if (!is_numeric($race_name)) |
|
2556
|
2556
|
{ |
|
2557
|
2557
|
return false; |
|
2558
|
2558
|
} else { |
|
2559
|
2559
|
$additional_query .= " AND marine_output.race_name = :race_name"; |
|
2560
|
|
- $query_values = array_merge($query_values,array(':race_name' => $race_name)); |
|
|
2560
|
+ $query_values = array_merge($query_values, array(':race_name' => $race_name)); |
|
2561
|
2561
|
} |
|
2562
|
2562
|
} |
|
2563
|
2563
|
if ($date_posted != "") |
|
2564
|
2564
|
{ |
|
2565
|
2565
|
$date_array = explode(",", $date_posted); |
|
2566
|
|
- $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
2567
|
|
- $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
|
2566
|
+ $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
|
2567
|
+ $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
2568
|
2568
|
if ($globalTimezone != '') { |
|
2569
|
2569
|
date_default_timezone_set($globalTimezone); |
|
2570
|
2570
|
$datetime = new DateTime(); |
|
@@ -2591,8 +2591,8 @@ discard block |
|
|
block discarded – undo |
|
2591
|
2591
|
if ($limit != "") |
|
2592
|
2592
|
{ |
|
2593
|
2593
|
$limit_array = explode(",", $limit); |
|
2594
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
2595
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
2594
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
2595
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
2596
|
2596
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
2597
|
2597
|
{ |
|
2598
|
2598
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
@@ -2610,22 +2610,22 @@ discard block |
|
|
block discarded – undo |
|
2610
|
2610
|
} |
|
2611
|
2611
|
} |
|
2612
|
2612
|
if ($origLat != "" && $origLon != "" && $dist != "") { |
|
2613
|
|
- $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
|
2613
|
+ $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
2614
|
2614
|
if ($globalDBdriver == 'mysql') { |
|
2615
|
|
- $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 |
|
|
2615
|
+ $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 |
|
2616
|
2616
|
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)) |
|
2617
|
2617
|
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; |
|
2618
|
2618
|
} else { |
|
2619
|
|
- $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 |
|
|
2619
|
+ $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 |
|
2620
|
2620
|
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)) |
|
2621
|
2621
|
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; |
|
2622
|
2622
|
} |
|
2623
|
2623
|
} else { |
|
2624
|
|
- $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
|
2624
|
+ $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
2625
|
2625
|
".$additional_query." |
|
2626
|
2626
|
".$orderby_query; |
|
2627
|
2627
|
} |
|
2628
|
|
- $marine_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
|
2628
|
+ $marine_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
2629
|
2629
|
return $marine_array; |
|
2630
|
2630
|
} |
|
2631
|
2631
|
|
|
@@ -2638,12 +2638,12 @@ discard block |
|
|
block discarded – undo |
|
2638
|
2638
|
public function checkId($id) |
|
2639
|
2639
|
{ |
|
2640
|
2640
|
global $globalDBdriver, $globalTimezone; |
|
2641
|
|
- $query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id'; |
|
|
2641
|
+ $query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id'; |
|
2642
|
2642
|
$query_data = array(':id' => $id); |
|
2643
|
2643
|
$sth = $this->db->prepare($query); |
|
2644
|
2644
|
$sth->execute($query_data); |
|
2645
|
|
- $ident_result=''; |
|
2646
|
|
- while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
|
2645
|
+ $ident_result = ''; |
|
|
2646
|
+ while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2647
|
2647
|
{ |
|
2648
|
2648
|
$ident_result = $row['fammarine_id']; |
|
2649
|
2649
|
} |
|
@@ -2658,7 +2658,7 @@ discard block |
|
|
block discarded – undo |
|
2658
|
2658
|
*/ |
|
2659
|
2659
|
public function getRaceByName($race_name) |
|
2660
|
2660
|
{ |
|
2661
|
|
- $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
|
2661
|
+ $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
2662
|
2662
|
$query = "SELECT * FROM marine_race WHERE race_name = :race_name LIMIT 1"; |
|
2663
|
2663
|
$sth = $this->db->prepare($query); |
|
2664
|
2664
|
$sth->execute(array(':race_name' => $race_name)); |
|
@@ -2675,7 +2675,7 @@ discard block |
|
|
block discarded – undo |
|
2675
|
2675
|
*/ |
|
2676
|
2676
|
public function getRace($race_id) |
|
2677
|
2677
|
{ |
|
2678
|
|
- $race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT); |
|
|
2678
|
+ $race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT); |
|
2679
|
2679
|
$query = "SELECT * FROM marine_race WHERE race_id = :race_id LIMIT 1"; |
|
2680
|
2680
|
$sth = $this->db->prepare($query); |
|
2681
|
2681
|
$sth->execute(array(':race_id' => $race_id)); |
|
@@ -2688,24 +2688,24 @@ discard block |
|
|
block discarded – undo |
|
2688
|
2688
|
* Add race |
|
2689
|
2689
|
* |
|
2690
|
2690
|
*/ |
|
2691
|
|
- public function addRace($race_id,$race_name,$race_creator,$race_desc,$race_startdate,$race_markers) |
|
|
2691
|
+ public function addRace($race_id, $race_name, $race_creator, $race_desc, $race_startdate, $race_markers) |
|
2692
|
2692
|
{ |
|
2693
|
|
- $race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT); |
|
|
2693
|
+ $race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT); |
|
2694
|
2694
|
if ($race_id != '') { |
|
2695
|
|
- $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
2696
|
|
- $race_creator = filter_var($race_creator,FILTER_SANITIZE_STRING); |
|
2697
|
|
- $race_desc = filter_var($race_desc,FILTER_SANITIZE_STRING); |
|
2698
|
|
- $race_startdate = filter_var($race_startdate,FILTER_SANITIZE_STRING); |
|
|
2695
|
+ $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
|
2696
|
+ $race_creator = filter_var($race_creator, FILTER_SANITIZE_STRING); |
|
|
2697
|
+ $race_desc = filter_var($race_desc, FILTER_SANITIZE_STRING); |
|
|
2698
|
+ $race_startdate = filter_var($race_startdate, FILTER_SANITIZE_STRING); |
|
2699
|
2699
|
//$race_markers = filter_var($race_markers,FILTER_SANITIZE_STRING); |
|
2700
|
2700
|
$allrace = $this->getRace($race_id); |
|
2701
|
2701
|
if (empty($allrace)) { |
|
2702
|
2702
|
$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)"; |
|
2703
|
2703
|
$sth = $this->db->prepare($query); |
|
2704
|
|
- $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)); |
|
|
2704
|
+ $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)); |
|
2705
|
2705
|
} elseif ($race_id != '') { |
|
2706
|
|
- $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"; |
|
|
2706
|
+ $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"; |
|
2707
|
2707
|
$sth = $this->db->prepare($query); |
|
2708
|
|
- $sth->execute(array(':race_id' => $race_id,':race_name' => $race_name,':race_desc' => $race_desc,':race_startdate' => $race_startdate,':race_markers' => $race_markers)); |
|
|
2708
|
+ $sth->execute(array(':race_id' => $race_id, ':race_name' => $race_name, ':race_desc' => $race_desc, ':race_startdate' => $race_startdate, ':race_markers' => $race_markers)); |
|
2709
|
2709
|
} |
|
2710
|
2710
|
} |
|
2711
|
2711
|
} |
|
@@ -2714,7 +2714,7 @@ discard block |
|
|
block discarded – undo |
|
2714
|
2714
|
|
|
2715
|
2715
|
public function getOrderBy() |
|
2716
|
2716
|
{ |
|
2717
|
|
- $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")); |
|
|
2717
|
+ $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")); |
|
2718
|
2718
|
|
|
2719
|
2719
|
return $orderby; |
|
2720
|
2720
|
|