@@ -15,7 +15,9 @@ discard block |
||
| 15 | 15 | public function __construct($dbc = null) { |
| 16 | 16 | $Connection = new Connection($dbc); |
| 17 | 17 | $this->db = $Connection->db(); |
| 18 | - if ($this->db === null) die('Error: No DB connection. (Marine)'); |
|
| 18 | + if ($this->db === null) { |
|
| 19 | + die('Error: No DB connection. (Marine)'); |
|
| 20 | + } |
|
| 19 | 21 | } |
| 20 | 22 | |
| 21 | 23 | /** |
@@ -37,7 +39,9 @@ discard block |
||
| 37 | 39 | if (isset($filter[0]['source'])) { |
| 38 | 40 | $filters = array_merge($filters,$filter); |
| 39 | 41 | } |
| 40 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 42 | + if (is_array($globalFilter)) { |
|
| 43 | + $filter = array_merge($filter,$globalFilter); |
|
| 44 | + } |
|
| 41 | 45 | $filter_query_join = ''; |
| 42 | 46 | $filter_query_where = ''; |
| 43 | 47 | foreach($filters as $flt) { |
@@ -85,8 +89,11 @@ discard block |
||
| 85 | 89 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 86 | 90 | } |
| 87 | 91 | } |
| 88 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 89 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 92 | + if ($filter_query_where == '' && $where) { |
|
| 93 | + $filter_query_where = ' WHERE'; |
|
| 94 | + } elseif ($filter_query_where != '' && $and) { |
|
| 95 | + $filter_query_where .= ' AND'; |
|
| 96 | + } |
|
| 90 | 97 | if ($filter_query_where != '') { |
| 91 | 98 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 92 | 99 | } |
@@ -141,42 +148,84 @@ discard block |
||
| 141 | 148 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
| 142 | 149 | } elseif (isset($row['spotter_archive_output_id'])) { |
| 143 | 150 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
| 144 | - */} |
|
| 145 | - elseif (isset($row['marineid'])) { |
|
| 151 | + */} elseif (isset($row['marineid'])) { |
|
| 146 | 152 | $temp_array['marine_id'] = $row['marineid']; |
| 147 | 153 | } else { |
| 148 | 154 | $temp_array['marine_id'] = ''; |
| 149 | 155 | } |
| 150 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 151 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
| 152 | - if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES); |
|
| 153 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
| 154 | - if (isset($row['status'])) $temp_array['status'] = $row['status']; |
|
| 155 | - if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id']; |
|
| 156 | - if (isset($row['captain_id'])) $temp_array['captain_id'] = $row['captain_id']; |
|
| 157 | - if (isset($row['captain_name'])) $temp_array['captain_name'] = $row['captain_name']; |
|
| 158 | - if (isset($row['race_id'])) $temp_array['race_id'] = $row['race_id']; |
|
| 159 | - if (isset($row['race_name'])) $temp_array['race_name'] = $row['race_name']; |
|
| 160 | - if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) $temp_array['race_time'] = $row['race_time']; |
|
| 161 | - if (isset($row['race_rank'])) $temp_array['race_rank'] = $row['race_rank']; |
|
| 162 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
| 163 | - if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
| 164 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
| 165 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
| 166 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 167 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
| 156 | + if (isset($row['fammarine_id'])) { |
|
| 157 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 158 | + } |
|
| 159 | + if (isset($row['mmsi'])) { |
|
| 160 | + $temp_array['mmsi'] = $row['mmsi']; |
|
| 161 | + } |
|
| 162 | + if (isset($row['type'])) { |
|
| 163 | + $temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES); |
|
| 164 | + } |
|
| 165 | + if (isset($row['type_id'])) { |
|
| 166 | + $temp_array['type_id'] = $row['type_id']; |
|
| 167 | + } |
|
| 168 | + if (isset($row['status'])) { |
|
| 169 | + $temp_array['status'] = $row['status']; |
|
| 170 | + } |
|
| 171 | + if (isset($row['status_id'])) { |
|
| 172 | + $temp_array['status_id'] = $row['status_id']; |
|
| 173 | + } |
|
| 174 | + if (isset($row['captain_id'])) { |
|
| 175 | + $temp_array['captain_id'] = $row['captain_id']; |
|
| 176 | + } |
|
| 177 | + if (isset($row['captain_name'])) { |
|
| 178 | + $temp_array['captain_name'] = $row['captain_name']; |
|
| 179 | + } |
|
| 180 | + if (isset($row['race_id'])) { |
|
| 181 | + $temp_array['race_id'] = $row['race_id']; |
|
| 182 | + } |
|
| 183 | + if (isset($row['race_name'])) { |
|
| 184 | + $temp_array['race_name'] = $row['race_name']; |
|
| 185 | + } |
|
| 186 | + if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) { |
|
| 187 | + $temp_array['race_time'] = $row['race_time']; |
|
| 188 | + } |
|
| 189 | + if (isset($row['race_rank'])) { |
|
| 190 | + $temp_array['race_rank'] = $row['race_rank']; |
|
| 191 | + } |
|
| 192 | + if (isset($row['ident'])) { |
|
| 193 | + $temp_array['ident'] = $row['ident']; |
|
| 194 | + } |
|
| 195 | + if (isset($row['arrival_port_name'])) { |
|
| 196 | + $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
| 197 | + } |
|
| 198 | + if (isset($row['latitude'])) { |
|
| 199 | + $temp_array['latitude'] = $row['latitude']; |
|
| 200 | + } |
|
| 201 | + if (isset($row['longitude'])) { |
|
| 202 | + $temp_array['longitude'] = $row['longitude']; |
|
| 203 | + } |
|
| 204 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 205 | + $temp_array['distance'] = $row['distance']; |
|
| 206 | + } |
|
| 207 | + if (isset($row['format_source'])) { |
|
| 208 | + $temp_array['format_source'] = $row['format_source']; |
|
| 209 | + } |
|
| 168 | 210 | if (isset($row['heading'])) { |
| 169 | 211 | $temp_array['heading'] = $row['heading']; |
| 170 | 212 | $heading_direction = $this->parseDirection($row['heading']); |
| 171 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 213 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 214 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + if (isset($row['ground_speed'])) { |
|
| 218 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 172 | 219 | } |
| 173 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 174 | 220 | |
| 175 | 221 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
| 176 | 222 | { |
| 177 | 223 | $Image = new Image($this->db); |
| 178 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 179 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 224 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
| 225 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 226 | + } else { |
|
| 227 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 228 | + } |
|
| 180 | 229 | unset($Image); |
| 181 | 230 | if (count($image_array) > 0) { |
| 182 | 231 | $temp_array['image'] = $image_array[0]['image']; |
@@ -240,13 +289,21 @@ discard block |
||
| 240 | 289 | } |
| 241 | 290 | |
| 242 | 291 | $fromsource = NULL; |
| 243 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 244 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 245 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 292 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 293 | + $temp_array['source_name'] = $row['source_name']; |
|
| 294 | + } |
|
| 295 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 296 | + $temp_array['over_country'] = $row['over_country']; |
|
| 297 | + } |
|
| 298 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 299 | + $temp_array['distance'] = $row['distance']; |
|
| 300 | + } |
|
| 246 | 301 | $temp_array['query_number_rows'] = $num_rows; |
| 247 | 302 | $spotter_array[] = $temp_array; |
| 248 | 303 | } |
| 249 | - if ($num_rows == 0) return array(); |
|
| 304 | + if ($num_rows == 0) { |
|
| 305 | + return array(); |
|
| 306 | + } |
|
| 250 | 307 | $spotter_array[0]['query_number_rows'] = $num_rows; |
| 251 | 308 | return $spotter_array; |
| 252 | 309 | } |
@@ -272,8 +329,12 @@ discard block |
||
| 272 | 329 | { |
| 273 | 330 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 274 | 331 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 275 | - } else $limit_query = ""; |
|
| 276 | - } else $limit_query = ""; |
|
| 332 | + } else { |
|
| 333 | + $limit_query = ""; |
|
| 334 | + } |
|
| 335 | + } else { |
|
| 336 | + $limit_query = ""; |
|
| 337 | + } |
|
| 277 | 338 | if ($sort != "") |
| 278 | 339 | { |
| 279 | 340 | $search_orderby_array = $this->getOrderBy(); |
@@ -297,7 +358,9 @@ discard block |
||
| 297 | 358 | global $global_marine_query; |
| 298 | 359 | |
| 299 | 360 | date_default_timezone_set('UTC'); |
| 300 | - if ($id == '') return array(); |
|
| 361 | + if ($id == '') { |
|
| 362 | + return array(); |
|
| 363 | + } |
|
| 301 | 364 | $additional_query = "marine_output.fammarine_id = :id"; |
| 302 | 365 | $query_values = array(':id' => $id); |
| 303 | 366 | $query = $global_marine_query." WHERE ".$additional_query." "; |
@@ -745,8 +808,11 @@ discard block |
||
| 745 | 808 | $sth = $this->db->prepare($query); |
| 746 | 809 | $sth->execute($query_values); |
| 747 | 810 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 748 | - if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
| 749 | - else return $result[0]['duration']; |
|
| 811 | + if (is_int($result[0]['duration'])) { |
|
| 812 | + return gmdate('H:i:s',$result[0]['duration']); |
|
| 813 | + } else { |
|
| 814 | + return $result[0]['duration']; |
|
| 815 | + } |
|
| 750 | 816 | } |
| 751 | 817 | |
| 752 | 818 | /** |
@@ -805,8 +871,11 @@ discard block |
||
| 805 | 871 | $query .= " ORDER BY marine_output.source_name ASC"; |
| 806 | 872 | |
| 807 | 873 | $sth = $this->db->prepare($query); |
| 808 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 809 | - else $sth->execute(); |
|
| 874 | + if (!empty($query_values)) { |
|
| 875 | + $sth->execute($query_values); |
|
| 876 | + } else { |
|
| 877 | + $sth->execute(); |
|
| 878 | + } |
|
| 810 | 879 | |
| 811 | 880 | $source_array = array(); |
| 812 | 881 | $temp_array = array(); |
@@ -861,8 +930,11 @@ discard block |
||
| 861 | 930 | $sth = $this->db->prepare($query); |
| 862 | 931 | $sth->execute(array(':mmsi' => $mmsi)); |
| 863 | 932 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 864 | - if (isset($result[0])) return $result[0]; |
|
| 865 | - else return array(); |
|
| 933 | + if (isset($result[0])) { |
|
| 934 | + return $result[0]; |
|
| 935 | + } else { |
|
| 936 | + return array(); |
|
| 937 | + } |
|
| 866 | 938 | } |
| 867 | 939 | |
| 868 | 940 | /** |
@@ -903,7 +975,9 @@ discard block |
||
| 903 | 975 | date_default_timezone_set($globalTimezone); |
| 904 | 976 | $datetime = new DateTime(); |
| 905 | 977 | $offset = $datetime->format('P'); |
| 906 | - } else $offset = '+00:00'; |
|
| 978 | + } else { |
|
| 979 | + $offset = '+00:00'; |
|
| 980 | + } |
|
| 907 | 981 | |
| 908 | 982 | if ($globalDBdriver == 'mysql') { |
| 909 | 983 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -1010,8 +1084,12 @@ discard block |
||
| 1010 | 1084 | */ |
| 1011 | 1085 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
| 1012 | 1086 | { |
| 1013 | - if ($latitude == '') $latitude = NULL; |
|
| 1014 | - if ($longitude == '') $longitude = NULL; |
|
| 1087 | + if ($latitude == '') { |
|
| 1088 | + $latitude = NULL; |
|
| 1089 | + } |
|
| 1090 | + if ($longitude == '') { |
|
| 1091 | + $longitude = NULL; |
|
| 1092 | + } |
|
| 1015 | 1093 | $groundspeed = round($groundspeed); |
| 1016 | 1094 | if ($race_begin != '') { |
| 1017 | 1095 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status, date = :race_begin WHERE fammarine_id = :fammarine_id'; |
@@ -1164,14 +1242,28 @@ discard block |
||
| 1164 | 1242 | $latitude = 0; |
| 1165 | 1243 | $longitude = 0; |
| 1166 | 1244 | } |
| 1167 | - if ($type_id == '') $type_id = NULL; |
|
| 1168 | - if ($status_id == '') $status_id = NULL; |
|
| 1169 | - if ($distance == '') $distance = NULL; |
|
| 1170 | - if ($race_rank == '') $race_rank = NULL; |
|
| 1171 | - if ($race_time == '') $race_time = NULL; |
|
| 1172 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 1245 | + if ($type_id == '') { |
|
| 1246 | + $type_id = NULL; |
|
| 1247 | + } |
|
| 1248 | + if ($status_id == '') { |
|
| 1249 | + $status_id = NULL; |
|
| 1250 | + } |
|
| 1251 | + if ($distance == '') { |
|
| 1252 | + $distance = NULL; |
|
| 1253 | + } |
|
| 1254 | + if ($race_rank == '') { |
|
| 1255 | + $race_rank = NULL; |
|
| 1256 | + } |
|
| 1257 | + if ($race_time == '') { |
|
| 1258 | + $race_time = NULL; |
|
| 1259 | + } |
|
| 1260 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 1261 | + $heading = 0; |
|
| 1262 | + } |
|
| 1173 | 1263 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 1174 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 1264 | + if ($arrival_date == '') { |
|
| 1265 | + $arrival_date = NULL; |
|
| 1266 | + } |
|
| 1175 | 1267 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
| 1176 | 1268 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)"; |
| 1177 | 1269 | |
@@ -1278,7 +1370,9 @@ discard block |
||
| 1278 | 1370 | global $globalDBdriver, $globalArchive; |
| 1279 | 1371 | //$filter_query = $this->getFilter($filters,true,true); |
| 1280 | 1372 | $Connection= new Connection($this->db); |
| 1281 | - if (!$Connection->tableExists('countries')) return array(); |
|
| 1373 | + if (!$Connection->tableExists('countries')) { |
|
| 1374 | + return array(); |
|
| 1375 | + } |
|
| 1282 | 1376 | require_once('class.SpotterLive.php'); |
| 1283 | 1377 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 1284 | 1378 | $MarineLive = new MarineLive($this->db); |
@@ -1322,7 +1416,9 @@ discard block |
||
| 1322 | 1416 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
| 1323 | 1417 | } |
| 1324 | 1418 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
| 1325 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1419 | + if ($limit) { |
|
| 1420 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1421 | + } |
|
| 1326 | 1422 | |
| 1327 | 1423 | $sth = $this->db->prepare($query); |
| 1328 | 1424 | $sth->execute(); |
@@ -1356,12 +1452,18 @@ discard block |
||
| 1356 | 1452 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
| 1357 | 1453 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 1358 | 1454 | if ($olderthanmonths > 0) { |
| 1359 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 1360 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 1455 | + if ($globalDBdriver == 'mysql') { |
|
| 1456 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 1457 | + } else { |
|
| 1458 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 1459 | + } |
|
| 1361 | 1460 | } |
| 1362 | 1461 | if ($sincedate != '') { |
| 1363 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 1364 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 1462 | + if ($globalDBdriver == 'mysql') { |
|
| 1463 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 1464 | + } else { |
|
| 1465 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 1466 | + } |
|
| 1365 | 1467 | } |
| 1366 | 1468 | $query_values = array(); |
| 1367 | 1469 | if ($year != '') { |
@@ -1392,7 +1494,9 @@ discard block |
||
| 1392 | 1494 | } |
| 1393 | 1495 | } |
| 1394 | 1496 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
| 1395 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1497 | + if ($limit) { |
|
| 1498 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1499 | + } |
|
| 1396 | 1500 | |
| 1397 | 1501 | $sth = $this->db->prepare($query); |
| 1398 | 1502 | $sth->execute($query_values); |
@@ -1427,7 +1531,9 @@ discard block |
||
| 1427 | 1531 | date_default_timezone_set($globalTimezone); |
| 1428 | 1532 | $datetime = new DateTime(); |
| 1429 | 1533 | $offset = $datetime->format('P'); |
| 1430 | - } else $offset = '+00:00'; |
|
| 1534 | + } else { |
|
| 1535 | + $offset = '+00:00'; |
|
| 1536 | + } |
|
| 1431 | 1537 | |
| 1432 | 1538 | if ($globalDBdriver == 'mysql') { |
| 1433 | 1539 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1477,7 +1583,9 @@ discard block |
||
| 1477 | 1583 | date_default_timezone_set($globalTimezone); |
| 1478 | 1584 | $datetime = new DateTime(); |
| 1479 | 1585 | $offset = $datetime->format('P'); |
| 1480 | - } else $offset = '+00:00'; |
|
| 1586 | + } else { |
|
| 1587 | + $offset = '+00:00'; |
|
| 1588 | + } |
|
| 1481 | 1589 | $filter_query = $this->getFilter($filters,true,true); |
| 1482 | 1590 | if ($globalDBdriver == 'mysql') { |
| 1483 | 1591 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1523,7 +1631,9 @@ discard block |
||
| 1523 | 1631 | date_default_timezone_set($globalTimezone); |
| 1524 | 1632 | $datetime = new DateTime(); |
| 1525 | 1633 | $offset = $datetime->format('P'); |
| 1526 | - } else $offset = '+00:00'; |
|
| 1634 | + } else { |
|
| 1635 | + $offset = '+00:00'; |
|
| 1636 | + } |
|
| 1527 | 1637 | $filter_query = $this->getFilter($filters,true,true); |
| 1528 | 1638 | if ($globalDBdriver == 'mysql') { |
| 1529 | 1639 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1571,7 +1681,9 @@ discard block |
||
| 1571 | 1681 | date_default_timezone_set($globalTimezone); |
| 1572 | 1682 | $datetime = new DateTime(); |
| 1573 | 1683 | $offset = $datetime->format('P'); |
| 1574 | - } else $offset = '+00:00'; |
|
| 1684 | + } else { |
|
| 1685 | + $offset = '+00:00'; |
|
| 1686 | + } |
|
| 1575 | 1687 | |
| 1576 | 1688 | if ($globalDBdriver == 'mysql') { |
| 1577 | 1689 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1620,7 +1732,9 @@ discard block |
||
| 1620 | 1732 | date_default_timezone_set($globalTimezone); |
| 1621 | 1733 | $datetime = new DateTime(); |
| 1622 | 1734 | $offset = $datetime->format('P'); |
| 1623 | - } else $offset = '+00:00'; |
|
| 1735 | + } else { |
|
| 1736 | + $offset = '+00:00'; |
|
| 1737 | + } |
|
| 1624 | 1738 | $filter_query = $this->getFilter($filters,true,true); |
| 1625 | 1739 | if ($globalDBdriver == 'mysql') { |
| 1626 | 1740 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1669,7 +1783,9 @@ discard block |
||
| 1669 | 1783 | date_default_timezone_set($globalTimezone); |
| 1670 | 1784 | $datetime = new DateTime(); |
| 1671 | 1785 | $offset = $datetime->format('P'); |
| 1672 | - } else $offset = '+00:00'; |
|
| 1786 | + } else { |
|
| 1787 | + $offset = '+00:00'; |
|
| 1788 | + } |
|
| 1673 | 1789 | |
| 1674 | 1790 | $orderby_sql = ''; |
| 1675 | 1791 | if ($orderby == "hour") |
@@ -1738,7 +1854,9 @@ discard block |
||
| 1738 | 1854 | date_default_timezone_set($globalTimezone); |
| 1739 | 1855 | $datetime = new DateTime($date); |
| 1740 | 1856 | $offset = $datetime->format('P'); |
| 1741 | - } else $offset = '+00:00'; |
|
| 1857 | + } else { |
|
| 1858 | + $offset = '+00:00'; |
|
| 1859 | + } |
|
| 1742 | 1860 | |
| 1743 | 1861 | if ($globalDBdriver == 'mysql') { |
| 1744 | 1862 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1786,7 +1904,9 @@ discard block |
||
| 1786 | 1904 | date_default_timezone_set($globalTimezone); |
| 1787 | 1905 | $datetime = new DateTime(); |
| 1788 | 1906 | $offset = $datetime->format('P'); |
| 1789 | - } else $offset = '+00:00'; |
|
| 1907 | + } else { |
|
| 1908 | + $offset = '+00:00'; |
|
| 1909 | + } |
|
| 1790 | 1910 | |
| 1791 | 1911 | if ($globalDBdriver == 'mysql') { |
| 1792 | 1912 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1851,8 +1971,11 @@ discard block |
||
| 1851 | 1971 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1852 | 1972 | } |
| 1853 | 1973 | } |
| 1854 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1855 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1974 | + if (empty($query_values)) { |
|
| 1975 | + $queryi .= $this->getFilter($filters); |
|
| 1976 | + } else { |
|
| 1977 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1978 | + } |
|
| 1856 | 1979 | |
| 1857 | 1980 | $sth = $this->db->prepare($queryi); |
| 1858 | 1981 | $sth->execute($query_values); |
@@ -1889,8 +2012,11 @@ discard block |
||
| 1889 | 2012 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1890 | 2013 | } |
| 1891 | 2014 | } |
| 1892 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1893 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2015 | + if (empty($query_values)) { |
|
| 2016 | + $queryi .= $this->getFilter($filters); |
|
| 2017 | + } else { |
|
| 2018 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2019 | + } |
|
| 1894 | 2020 | |
| 1895 | 2021 | $sth = $this->db->prepare($queryi); |
| 1896 | 2022 | $sth->execute($query_values); |
@@ -1912,7 +2038,9 @@ discard block |
||
| 1912 | 2038 | date_default_timezone_set($globalTimezone); |
| 1913 | 2039 | $datetime = new DateTime(); |
| 1914 | 2040 | $offset = $datetime->format('P'); |
| 1915 | - } else $offset = '+00:00'; |
|
| 2041 | + } else { |
|
| 2042 | + $offset = '+00:00'; |
|
| 2043 | + } |
|
| 1916 | 2044 | |
| 1917 | 2045 | if ($globalDBdriver == 'mysql') { |
| 1918 | 2046 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -2016,7 +2144,9 @@ discard block |
||
| 2016 | 2144 | */ |
| 2017 | 2145 | public function parseDirection($direction = 0) |
| 2018 | 2146 | { |
| 2019 | - if ($direction == '') $direction = 0; |
|
| 2147 | + if ($direction == '') { |
|
| 2148 | + $direction = 0; |
|
| 2149 | + } |
|
| 2020 | 2150 | $direction_array = array(); |
| 2021 | 2151 | $temp_array = array(); |
| 2022 | 2152 | |
@@ -2105,7 +2235,9 @@ discard block |
||
| 2105 | 2235 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 2106 | 2236 | |
| 2107 | 2237 | $Connection = new Connection($this->db); |
| 2108 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 2238 | + if (!$Connection->tableExists('countries')) { |
|
| 2239 | + return ''; |
|
| 2240 | + } |
|
| 2109 | 2241 | |
| 2110 | 2242 | try { |
| 2111 | 2243 | /* |
@@ -2125,9 +2257,13 @@ discard block |
||
| 2125 | 2257 | $sth->closeCursor(); |
| 2126 | 2258 | if (count($row) > 0) { |
| 2127 | 2259 | return $row; |
| 2128 | - } else return ''; |
|
| 2260 | + } else { |
|
| 2261 | + return ''; |
|
| 2262 | + } |
|
| 2129 | 2263 | } catch (PDOException $e) { |
| 2130 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 2264 | + if (isset($globalDebug) && $globalDebug) { |
|
| 2265 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 2266 | + } |
|
| 2131 | 2267 | return ''; |
| 2132 | 2268 | } |
| 2133 | 2269 | |
@@ -2145,7 +2281,9 @@ discard block |
||
| 2145 | 2281 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 2146 | 2282 | |
| 2147 | 2283 | $Connection = new Connection($this->db); |
| 2148 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 2284 | + if (!$Connection->tableExists('countries')) { |
|
| 2285 | + return ''; |
|
| 2286 | + } |
|
| 2149 | 2287 | |
| 2150 | 2288 | try { |
| 2151 | 2289 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -2157,9 +2295,13 @@ discard block |
||
| 2157 | 2295 | $sth->closeCursor(); |
| 2158 | 2296 | if (count($row) > 0) { |
| 2159 | 2297 | return $row; |
| 2160 | - } else return ''; |
|
| 2298 | + } else { |
|
| 2299 | + return ''; |
|
| 2300 | + } |
|
| 2161 | 2301 | } catch (PDOException $e) { |
| 2162 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 2302 | + if (isset($globalDebug) && $globalDebug) { |
|
| 2303 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 2304 | + } |
|
| 2163 | 2305 | return ''; |
| 2164 | 2306 | } |
| 2165 | 2307 | |
@@ -2177,7 +2319,9 @@ discard block |
||
| 2177 | 2319 | { |
| 2178 | 2320 | global $globalBitlyAccessToken; |
| 2179 | 2321 | |
| 2180 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 2322 | + if ($globalBitlyAccessToken == '') { |
|
| 2323 | + return $url; |
|
| 2324 | + } |
|
| 2181 | 2325 | |
| 2182 | 2326 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 2183 | 2327 | |
@@ -2253,7 +2397,9 @@ discard block |
||
| 2253 | 2397 | } |
| 2254 | 2398 | } |
| 2255 | 2399 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
| 2256 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 2400 | + if ($limit) { |
|
| 2401 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 2402 | + } |
|
| 2257 | 2403 | $sth = $this->db->prepare($query); |
| 2258 | 2404 | $sth->execute($query_values); |
| 2259 | 2405 | $marine_array = array(); |
@@ -2291,9 +2437,15 @@ discard block |
||
| 2291 | 2437 | foreach ($q_array as $q_item){ |
| 2292 | 2438 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
| 2293 | 2439 | $additional_query .= " AND ("; |
| 2294 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
| 2295 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
| 2296 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
| 2440 | + if (is_int($q_item)) { |
|
| 2441 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
| 2442 | + } |
|
| 2443 | + if (is_int($q_item)) { |
|
| 2444 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
| 2445 | + } |
|
| 2446 | + if (is_int($q_item)) { |
|
| 2447 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
| 2448 | + } |
|
| 2297 | 2449 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
| 2298 | 2450 | $additional_query .= ")"; |
| 2299 | 2451 | } |
@@ -2341,7 +2493,9 @@ discard block |
||
| 2341 | 2493 | date_default_timezone_set($globalTimezone); |
| 2342 | 2494 | $datetime = new DateTime(); |
| 2343 | 2495 | $offset = $datetime->format('P'); |
| 2344 | - } else $offset = '+00:00'; |
|
| 2496 | + } else { |
|
| 2497 | + $offset = '+00:00'; |
|
| 2498 | + } |
|
| 2345 | 2499 | if ($date_array[1] != "") |
| 2346 | 2500 | { |
| 2347 | 2501 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -2368,8 +2522,12 @@ discard block |
||
| 2368 | 2522 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 2369 | 2523 | { |
| 2370 | 2524 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 2371 | - } else $limit_query = ""; |
|
| 2372 | - } else $limit_query = ""; |
|
| 2525 | + } else { |
|
| 2526 | + $limit_query = ""; |
|
| 2527 | + } |
|
| 2528 | + } else { |
|
| 2529 | + $limit_query = ""; |
|
| 2530 | + } |
|
| 2373 | 2531 | if ($sort != "") |
| 2374 | 2532 | { |
| 2375 | 2533 | $search_orderby_array = $this->getOrderBy(); |
@@ -2435,8 +2593,11 @@ discard block |
||
| 2435 | 2593 | $sth = $this->db->prepare($query); |
| 2436 | 2594 | $sth->execute(array(':race_name' => $race_name)); |
| 2437 | 2595 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 2438 | - if (isset($result[0])) return $result[0]; |
|
| 2439 | - else return array(); |
|
| 2596 | + if (isset($result[0])) { |
|
| 2597 | + return $result[0]; |
|
| 2598 | + } else { |
|
| 2599 | + return array(); |
|
| 2600 | + } |
|
| 2440 | 2601 | } |
| 2441 | 2602 | |
| 2442 | 2603 | /** |
@@ -2452,8 +2613,11 @@ discard block |
||
| 2452 | 2613 | $sth = $this->db->prepare($query); |
| 2453 | 2614 | $sth->execute(array(':race_id' => $race_id)); |
| 2454 | 2615 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 2455 | - if (isset($result[0])) return $result[0]; |
|
| 2456 | - else return array(); |
|
| 2616 | + if (isset($result[0])) { |
|
| 2617 | + return $result[0]; |
|
| 2618 | + } else { |
|
| 2619 | + return array(); |
|
| 2620 | + } |
|
| 2457 | 2621 | } |
| 2458 | 2622 | |
| 2459 | 2623 | /** |