@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection. (MarineLive)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (MarineLive)'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -86,8 +90,11 @@ discard block |
||
86 | 90 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
87 | 91 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
88 | 92 | } |
89 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
90 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
93 | + if ($filter_query_where == '' && $where) { |
|
94 | + $filter_query_where = ' WHERE'; |
|
95 | + } elseif ($filter_query_where != '' && $and) { |
|
96 | + $filter_query_where .= ' AND'; |
|
97 | + } |
|
91 | 98 | if ($filter_query_where != '') { |
92 | 99 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
93 | 100 | } |
@@ -128,9 +135,13 @@ discard block |
||
128 | 135 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
129 | 136 | } |
130 | 137 | } |
131 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
138 | + if ($orderby_query == '') { |
|
139 | + $orderby_query= ' ORDER BY date DESC'; |
|
140 | + } |
|
132 | 141 | |
133 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
142 | + if (!isset($globalLiveInterval)) { |
|
143 | + $globalLiveInterval = '200'; |
|
144 | + } |
|
134 | 145 | if ($globalDBdriver == 'mysql') { |
135 | 146 | //$query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate"; |
136 | 147 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -155,7 +166,9 @@ discard block |
||
155 | 166 | |
156 | 167 | $filter_query = $this->getFilter($filter,true,true); |
157 | 168 | |
158 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
169 | + if (!isset($globalLiveInterval)) { |
|
170 | + $globalLiveInterval = '200'; |
|
171 | + } |
|
159 | 172 | if ($globalDBdriver == 'mysql') { |
160 | 173 | $query = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id |
161 | 174 | FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0"; |
@@ -197,58 +210,96 @@ discard block |
||
197 | 210 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
198 | 211 | $filter_query = $this->getFilter($filter,true,true); |
199 | 212 | |
200 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
201 | - if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
|
213 | + if (!isset($globalLiveInterval)) { |
|
214 | + $globalLiveInterval = '200'; |
|
215 | + } |
|
216 | + if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') { |
|
217 | + $globalMap3DMarinesLimit = '300'; |
|
218 | + } |
|
202 | 219 | if ($globalDBdriver == 'mysql') { |
203 | 220 | if (isset($globalArchive) && $globalArchive === TRUE) { |
204 | 221 | $query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id |
205 | 222 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
206 | - if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
207 | - if ($id != '') $query .= "OR marine_archive.fammarine_id = :id "; |
|
223 | + if ($usecoord) { |
|
224 | + $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
225 | + } |
|
226 | + if ($id != '') { |
|
227 | + $query .= "OR marine_archive.fammarine_id = :id "; |
|
228 | + } |
|
208 | 229 | $query .= "UNION |
209 | 230 | SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id |
210 | 231 | FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date"; |
211 | - if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
212 | - if ($id != '') $query .= "OR marine_live.fammarine_id = :id "; |
|
232 | + if ($usecoord) { |
|
233 | + $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
234 | + } |
|
235 | + if ($id != '') { |
|
236 | + $query .= "OR marine_live.fammarine_id = :id "; |
|
237 | + } |
|
213 | 238 | $query .= ") AS marine |
214 | 239 | WHERE latitude <> '0' AND longitude <> '0' |
215 | 240 | ORDER BY fammarine_id, date"; |
216 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
241 | + if ($limit) { |
|
242 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
243 | + } |
|
217 | 244 | } else { |
218 | 245 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id |
219 | 246 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date "; |
220 | - if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
221 | - if ($id != '') $query .= "OR marine_live.fammarine_id = :id "; |
|
247 | + if ($usecoord) { |
|
248 | + $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
249 | + } |
|
250 | + if ($id != '') { |
|
251 | + $query .= "OR marine_live.fammarine_id = :id "; |
|
252 | + } |
|
222 | 253 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
223 | 254 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
224 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
255 | + if ($limit) { |
|
256 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
257 | + } |
|
225 | 258 | } |
226 | 259 | } else { |
227 | 260 | if (isset($globalArchive) && $globalArchive === TRUE) { |
228 | 261 | $query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id |
229 | 262 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
230 | - if ($usecoord) $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
231 | - if ($id != '') $query .= "OR marine_archive.fammarine_id = :id "; |
|
263 | + if ($usecoord) { |
|
264 | + $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
265 | + } |
|
266 | + if ($id != '') { |
|
267 | + $query .= "OR marine_archive.fammarine_id = :id "; |
|
268 | + } |
|
232 | 269 | $query .= "UNION |
233 | 270 | SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id |
234 | 271 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date"; |
235 | - if ($usecoord) $query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
236 | - if ($id != '') $query .= " OR marine_live.fammarine_id = :id"; |
|
272 | + if ($usecoord) { |
|
273 | + $query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
274 | + } |
|
275 | + if ($id != '') { |
|
276 | + $query .= " OR marine_live.fammarine_id = :id"; |
|
277 | + } |
|
237 | 278 | $query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' "; |
238 | 279 | $query .= "ORDER BY fammarine_id, date"; |
239 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
280 | + if ($limit) { |
|
281 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
282 | + } |
|
240 | 283 | } else { |
241 | 284 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id |
242 | 285 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date "; |
243 | - if ($usecoord) $query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
244 | - if ($id != '') $query .= "OR marine_live.fammarine_id = :id "; |
|
286 | + if ($usecoord) { |
|
287 | + $query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
288 | + } |
|
289 | + if ($id != '') { |
|
290 | + $query .= "OR marine_live.fammarine_id = :id "; |
|
291 | + } |
|
245 | 292 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
246 | 293 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
247 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
294 | + if ($limit) { |
|
295 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
296 | + } |
|
248 | 297 | } |
249 | 298 | } |
250 | 299 | $query_values = array(); |
251 | - if ($id != '') $query_values = array(':id' => $id); |
|
300 | + if ($id != '') { |
|
301 | + $query_values = array(':id' => $id); |
|
302 | + } |
|
252 | 303 | try { |
253 | 304 | $sth = $this->db->prepare($query); |
254 | 305 | $sth->execute($query_values); |
@@ -271,7 +322,9 @@ discard block |
||
271 | 322 | global $globalDBdriver, $globalLiveInterval; |
272 | 323 | $filter_query = $this->getFilter($filter,true,true); |
273 | 324 | |
274 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
325 | + if (!isset($globalLiveInterval)) { |
|
326 | + $globalLiveInterval = '200'; |
|
327 | + } |
|
275 | 328 | if ($globalDBdriver == 'mysql') { |
276 | 329 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
277 | 330 | } else { |
@@ -299,7 +352,9 @@ discard block |
||
299 | 352 | { |
300 | 353 | global $globalDBdriver, $globalLiveInterval; |
301 | 354 | $Marine = new Marine($this->db); |
302 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
355 | + if (!isset($globalLiveInterval)) { |
|
356 | + $globalLiveInterval = '200'; |
|
357 | + } |
|
303 | 358 | $filter_query = $this->getFilter($filter); |
304 | 359 | |
305 | 360 | if (is_array($coord)) { |
@@ -307,7 +362,9 @@ discard block |
||
307 | 362 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
308 | 363 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
309 | 364 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
310 | - } else return array(); |
|
365 | + } else { |
|
366 | + return array(); |
|
367 | + } |
|
311 | 368 | if ($globalDBdriver == 'mysql') { |
312 | 369 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id ORDER BY date DESC'.$filter_query; |
313 | 370 | } else { |
@@ -327,7 +384,9 @@ discard block |
||
327 | 384 | { |
328 | 385 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
329 | 386 | $Marine = new Marine($this->db); |
330 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
387 | + if (!isset($globalLiveInterval)) { |
|
388 | + $globalLiveInterval = '200'; |
|
389 | + } |
|
331 | 390 | $filter_query = $this->getFilter($filter,true,true); |
332 | 391 | |
333 | 392 | if (is_array($coord)) { |
@@ -335,7 +394,9 @@ discard block |
||
335 | 394 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
336 | 395 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
337 | 396 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
338 | - } else return array(); |
|
397 | + } else { |
|
398 | + return array(); |
|
399 | + } |
|
339 | 400 | /* |
340 | 401 | if ($globalDBdriver == 'mysql') { |
341 | 402 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
@@ -558,11 +619,15 @@ discard block |
||
558 | 619 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date'; |
559 | 620 | if ($globalDBdriver == 'mysql') { |
560 | 621 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
561 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
622 | + if ($liveinterval) { |
|
623 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
624 | + } |
|
562 | 625 | $query .= ' ORDER BY date'; |
563 | 626 | } else { |
564 | 627 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
565 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
628 | + if ($liveinterval) { |
|
629 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
630 | + } |
|
566 | 631 | $query .= ' ORDER BY date'; |
567 | 632 | } |
568 | 633 | |
@@ -657,7 +722,9 @@ discard block |
||
657 | 722 | $i++; |
658 | 723 | $j++; |
659 | 724 | if ($j == 30) { |
660 | - if ($globalDebug) echo "."; |
|
725 | + if ($globalDebug) { |
|
726 | + echo "."; |
|
727 | + } |
|
661 | 728 | try { |
662 | 729 | |
663 | 730 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -951,7 +1018,9 @@ discard block |
||
951 | 1018 | { |
952 | 1019 | return false; |
953 | 1020 | } |
954 | - } else return ''; |
|
1021 | + } else { |
|
1022 | + return ''; |
|
1023 | + } |
|
955 | 1024 | |
956 | 1025 | if ($longitude != '') |
957 | 1026 | { |
@@ -959,7 +1028,9 @@ discard block |
||
959 | 1028 | { |
960 | 1029 | return false; |
961 | 1030 | } |
962 | - } else return ''; |
|
1031 | + } else { |
|
1032 | + return ''; |
|
1033 | + } |
|
963 | 1034 | |
964 | 1035 | |
965 | 1036 | if ($heading != '') |
@@ -968,7 +1039,9 @@ discard block |
||
968 | 1039 | { |
969 | 1040 | return false; |
970 | 1041 | } |
971 | - } else $heading = 0; |
|
1042 | + } else { |
|
1043 | + $heading = 0; |
|
1044 | + } |
|
972 | 1045 | |
973 | 1046 | if ($groundspeed != '') |
974 | 1047 | { |
@@ -976,9 +1049,13 @@ discard block |
||
976 | 1049 | { |
977 | 1050 | return false; |
978 | 1051 | } |
979 | - } else $groundspeed = 0; |
|
1052 | + } else { |
|
1053 | + $groundspeed = 0; |
|
1054 | + } |
|
980 | 1055 | date_default_timezone_set('UTC'); |
981 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1056 | + if ($date == '') { |
|
1057 | + $date = date("Y-m-d H:i:s", time()); |
|
1058 | + } |
|
982 | 1059 | |
983 | 1060 | |
984 | 1061 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1006,16 +1083,28 @@ discard block |
||
1006 | 1083 | $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
1007 | 1084 | $race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT); |
1008 | 1085 | $race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1009 | - if ($typeid == '') $typeid = NULL; |
|
1010 | - if ($statusid == '') $statusid = NULL; |
|
1011 | - if ($distance == '') $distance = NULL; |
|
1086 | + if ($typeid == '') { |
|
1087 | + $typeid = NULL; |
|
1088 | + } |
|
1089 | + if ($statusid == '') { |
|
1090 | + $statusid = NULL; |
|
1091 | + } |
|
1092 | + if ($distance == '') { |
|
1093 | + $distance = NULL; |
|
1094 | + } |
|
1012 | 1095 | |
1013 | 1096 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
1014 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1015 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1097 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1098 | + $heading = 0; |
|
1099 | + } |
|
1100 | + if ($arrival_date == '') { |
|
1101 | + $arrival_date = NULL; |
|
1102 | + } |
|
1016 | 1103 | $query = ''; |
1017 | 1104 | if ($globalArchive) { |
1018 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1105 | + if ($globalDebug) { |
|
1106 | + echo '-- Delete previous data -- '; |
|
1107 | + } |
|
1019 | 1108 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
1020 | 1109 | } |
1021 | 1110 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, 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) |
@@ -1030,10 +1119,14 @@ discard block |
||
1030 | 1119 | } |
1031 | 1120 | |
1032 | 1121 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1033 | - if ($globalDebug) echo '(Add to Marine archive : '; |
|
1122 | + if ($globalDebug) { |
|
1123 | + echo '(Add to Marine archive : '; |
|
1124 | + } |
|
1034 | 1125 | $MarineArchive = new MarineArchive($this->db); |
1035 | 1126 | $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name,$distance,$race_rank,$race_time); |
1036 | - if ($globalDebug) echo $result.')'; |
|
1127 | + if ($globalDebug) { |
|
1128 | + echo $result.')'; |
|
1129 | + } |
|
1037 | 1130 | } |
1038 | 1131 | return "success"; |
1039 | 1132 | } |