@@ -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. (Marine)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (Marine)'); |
|
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) { |
@@ -69,8 +73,11 @@ discard block |
||
69 | 73 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
70 | 74 | } |
71 | 75 | } |
72 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
73 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
76 | + if ($filter_query_where == '' && $where) { |
|
77 | + $filter_query_where = ' WHERE'; |
|
78 | + } elseif ($filter_query_where != '' && $and) { |
|
79 | + $filter_query_where .= ' AND'; |
|
80 | + } |
|
74 | 81 | if ($filter_query_where != '') { |
75 | 82 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
76 | 83 | } |
@@ -124,32 +131,54 @@ discard block |
||
124 | 131 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
125 | 132 | } elseif (isset($row['spotter_archive_output_id'])) { |
126 | 133 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
127 | - */} |
|
128 | - elseif (isset($row['marineid'])) { |
|
134 | + */} elseif (isset($row['marineid'])) { |
|
129 | 135 | $temp_array['marine_id'] = $row['marineid']; |
130 | 136 | } else { |
131 | 137 | $temp_array['marine_id'] = ''; |
132 | 138 | } |
133 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
134 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
135 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
136 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
137 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
138 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
139 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
140 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
139 | + if (isset($row['fammarine_id'])) { |
|
140 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
141 | + } |
|
142 | + if (isset($row['mmsi'])) { |
|
143 | + $temp_array['mmsi'] = $row['mmsi']; |
|
144 | + } |
|
145 | + if (isset($row['type'])) { |
|
146 | + $temp_array['type'] = $row['type']; |
|
147 | + } |
|
148 | + if (isset($row['type_id'])) { |
|
149 | + $temp_array['type_id'] = $row['type_id']; |
|
150 | + } |
|
151 | + if (isset($row['ident'])) { |
|
152 | + $temp_array['ident'] = $row['ident']; |
|
153 | + } |
|
154 | + if (isset($row['latitude'])) { |
|
155 | + $temp_array['latitude'] = $row['latitude']; |
|
156 | + } |
|
157 | + if (isset($row['longitude'])) { |
|
158 | + $temp_array['longitude'] = $row['longitude']; |
|
159 | + } |
|
160 | + if (isset($row['format_source'])) { |
|
161 | + $temp_array['format_source'] = $row['format_source']; |
|
162 | + } |
|
141 | 163 | if (isset($row['heading'])) { |
142 | 164 | $temp_array['heading'] = $row['heading']; |
143 | 165 | $heading_direction = $this->parseDirection($row['heading']); |
144 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
166 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
167 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
168 | + } |
|
169 | + } |
|
170 | + if (isset($row['ground_speed'])) { |
|
171 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
145 | 172 | } |
146 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
147 | 173 | |
148 | 174 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
149 | 175 | { |
150 | 176 | $Image = new Image($this->db); |
151 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
152 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
177 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
178 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
179 | + } else { |
|
180 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
181 | + } |
|
153 | 182 | unset($Image); |
154 | 183 | if (count($image_array) > 0) { |
155 | 184 | $temp_array['image'] = $image_array[0]['image']; |
@@ -201,13 +230,21 @@ discard block |
||
201 | 230 | } |
202 | 231 | |
203 | 232 | $fromsource = NULL; |
204 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
205 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
206 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
233 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
234 | + $temp_array['source_name'] = $row['source_name']; |
|
235 | + } |
|
236 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
237 | + $temp_array['over_country'] = $row['over_country']; |
|
238 | + } |
|
239 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
240 | + $temp_array['distance'] = $row['distance']; |
|
241 | + } |
|
207 | 242 | $temp_array['query_number_rows'] = $num_rows; |
208 | 243 | $spotter_array[] = $temp_array; |
209 | 244 | } |
210 | - if ($num_rows == 0) return array(); |
|
245 | + if ($num_rows == 0) { |
|
246 | + return array(); |
|
247 | + } |
|
211 | 248 | $spotter_array[0]['query_number_rows'] = $num_rows; |
212 | 249 | return $spotter_array; |
213 | 250 | } |
@@ -233,8 +270,12 @@ discard block |
||
233 | 270 | { |
234 | 271 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
235 | 272 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
236 | - } else $limit_query = ""; |
|
237 | - } else $limit_query = ""; |
|
273 | + } else { |
|
274 | + $limit_query = ""; |
|
275 | + } |
|
276 | + } else { |
|
277 | + $limit_query = ""; |
|
278 | + } |
|
238 | 279 | if ($sort != "") |
239 | 280 | { |
240 | 281 | $search_orderby_array = $this->getOrderBy(); |
@@ -258,7 +299,9 @@ discard block |
||
258 | 299 | global $global_query; |
259 | 300 | |
260 | 301 | date_default_timezone_set('UTC'); |
261 | - if ($id == '') return array(); |
|
302 | + if ($id == '') { |
|
303 | + return array(); |
|
304 | + } |
|
262 | 305 | $additional_query = "marine_output.fammarine_id = :id"; |
263 | 306 | $query_values = array(':id' => $id); |
264 | 307 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -401,8 +444,11 @@ discard block |
||
401 | 444 | $query .= " ORDER BY marine_output.source_name ASC"; |
402 | 445 | |
403 | 446 | $sth = $this->db->prepare($query); |
404 | - if (!empty($query_values)) $sth->execute($query_values); |
|
405 | - else $sth->execute(); |
|
447 | + if (!empty($query_values)) { |
|
448 | + $sth->execute($query_values); |
|
449 | + } else { |
|
450 | + $sth->execute(); |
|
451 | + } |
|
406 | 452 | |
407 | 453 | $source_array = array(); |
408 | 454 | $temp_array = array(); |
@@ -457,8 +503,11 @@ discard block |
||
457 | 503 | $sth = $this->db->prepare($query); |
458 | 504 | $sth->execute(array(':mmsi' => $mmsi)); |
459 | 505 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
460 | - if (isset($result[0])) return $result[0]; |
|
461 | - else return array(); |
|
506 | + if (isset($result[0])) { |
|
507 | + return $result[0]; |
|
508 | + } else { |
|
509 | + return array(); |
|
510 | + } |
|
462 | 511 | } |
463 | 512 | |
464 | 513 | /* |
@@ -474,7 +523,9 @@ discard block |
||
474 | 523 | date_default_timezone_set($globalTimezone); |
475 | 524 | $datetime = new DateTime(); |
476 | 525 | $offset = $datetime->format('P'); |
477 | - } else $offset = '+00:00'; |
|
526 | + } else { |
|
527 | + $offset = '+00:00'; |
|
528 | + } |
|
478 | 529 | |
479 | 530 | if ($globalDBdriver == 'mysql') { |
480 | 531 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -704,9 +755,15 @@ discard block |
||
704 | 755 | $latitude = 0; |
705 | 756 | $longitude = 0; |
706 | 757 | } |
707 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
708 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
709 | - if ($arrival_date == '') $arrival_date = NULL; |
|
758 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
759 | + $heading = 0; |
|
760 | + } |
|
761 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
762 | + $groundspeed = 0; |
|
763 | + } |
|
764 | + if ($arrival_date == '') { |
|
765 | + $arrival_date = NULL; |
|
766 | + } |
|
710 | 767 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
711 | 768 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
712 | 769 | |
@@ -814,7 +871,9 @@ discard block |
||
814 | 871 | global $globalDBdriver, $globalArchive; |
815 | 872 | //$filter_query = $this->getFilter($filters,true,true); |
816 | 873 | $Connection= new Connection($this->db); |
817 | - if (!$Connection->tableExists('countries')) return array(); |
|
874 | + if (!$Connection->tableExists('countries')) { |
|
875 | + return array(); |
|
876 | + } |
|
818 | 877 | require_once('class.SpotterLive.php'); |
819 | 878 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
820 | 879 | $MarineLive = new MarineLive($this->db); |
@@ -858,7 +917,9 @@ discard block |
||
858 | 917 | $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 "; |
859 | 918 | } |
860 | 919 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
861 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
920 | + if ($limit) { |
|
921 | + $query .= " LIMIT 10 OFFSET 0"; |
|
922 | + } |
|
862 | 923 | |
863 | 924 | $sth = $this->db->prepare($query); |
864 | 925 | $sth->execute(); |
@@ -892,12 +953,18 @@ discard block |
||
892 | 953 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
893 | 954 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
894 | 955 | if ($olderthanmonths > 0) { |
895 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
896 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
956 | + if ($globalDBdriver == 'mysql') { |
|
957 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
958 | + } else { |
|
959 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
960 | + } |
|
897 | 961 | } |
898 | 962 | if ($sincedate != '') { |
899 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
900 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
963 | + if ($globalDBdriver == 'mysql') { |
|
964 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
965 | + } else { |
|
966 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
967 | + } |
|
901 | 968 | } |
902 | 969 | $query_values = array(); |
903 | 970 | if ($year != '') { |
@@ -928,7 +995,9 @@ discard block |
||
928 | 995 | } |
929 | 996 | } |
930 | 997 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
931 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
998 | + if ($limit) { |
|
999 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1000 | + } |
|
932 | 1001 | |
933 | 1002 | $sth = $this->db->prepare($query); |
934 | 1003 | $sth->execute($query_values); |
@@ -963,7 +1032,9 @@ discard block |
||
963 | 1032 | date_default_timezone_set($globalTimezone); |
964 | 1033 | $datetime = new DateTime(); |
965 | 1034 | $offset = $datetime->format('P'); |
966 | - } else $offset = '+00:00'; |
|
1035 | + } else { |
|
1036 | + $offset = '+00:00'; |
|
1037 | + } |
|
967 | 1038 | |
968 | 1039 | if ($globalDBdriver == 'mysql') { |
969 | 1040 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1013,7 +1084,9 @@ discard block |
||
1013 | 1084 | date_default_timezone_set($globalTimezone); |
1014 | 1085 | $datetime = new DateTime(); |
1015 | 1086 | $offset = $datetime->format('P'); |
1016 | - } else $offset = '+00:00'; |
|
1087 | + } else { |
|
1088 | + $offset = '+00:00'; |
|
1089 | + } |
|
1017 | 1090 | $filter_query = $this->getFilter($filters,true,true); |
1018 | 1091 | if ($globalDBdriver == 'mysql') { |
1019 | 1092 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1059,7 +1132,9 @@ discard block |
||
1059 | 1132 | date_default_timezone_set($globalTimezone); |
1060 | 1133 | $datetime = new DateTime(); |
1061 | 1134 | $offset = $datetime->format('P'); |
1062 | - } else $offset = '+00:00'; |
|
1135 | + } else { |
|
1136 | + $offset = '+00:00'; |
|
1137 | + } |
|
1063 | 1138 | $filter_query = $this->getFilter($filters,true,true); |
1064 | 1139 | if ($globalDBdriver == 'mysql') { |
1065 | 1140 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1107,7 +1182,9 @@ discard block |
||
1107 | 1182 | date_default_timezone_set($globalTimezone); |
1108 | 1183 | $datetime = new DateTime(); |
1109 | 1184 | $offset = $datetime->format('P'); |
1110 | - } else $offset = '+00:00'; |
|
1185 | + } else { |
|
1186 | + $offset = '+00:00'; |
|
1187 | + } |
|
1111 | 1188 | |
1112 | 1189 | if ($globalDBdriver == 'mysql') { |
1113 | 1190 | $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 |
@@ -1156,7 +1233,9 @@ discard block |
||
1156 | 1233 | date_default_timezone_set($globalTimezone); |
1157 | 1234 | $datetime = new DateTime(); |
1158 | 1235 | $offset = $datetime->format('P'); |
1159 | - } else $offset = '+00:00'; |
|
1236 | + } else { |
|
1237 | + $offset = '+00:00'; |
|
1238 | + } |
|
1160 | 1239 | $filter_query = $this->getFilter($filters,true,true); |
1161 | 1240 | if ($globalDBdriver == 'mysql') { |
1162 | 1241 | $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 |
@@ -1205,7 +1284,9 @@ discard block |
||
1205 | 1284 | date_default_timezone_set($globalTimezone); |
1206 | 1285 | $datetime = new DateTime(); |
1207 | 1286 | $offset = $datetime->format('P'); |
1208 | - } else $offset = '+00:00'; |
|
1287 | + } else { |
|
1288 | + $offset = '+00:00'; |
|
1289 | + } |
|
1209 | 1290 | |
1210 | 1291 | $orderby_sql = ''; |
1211 | 1292 | if ($orderby == "hour") |
@@ -1274,7 +1355,9 @@ discard block |
||
1274 | 1355 | date_default_timezone_set($globalTimezone); |
1275 | 1356 | $datetime = new DateTime($date); |
1276 | 1357 | $offset = $datetime->format('P'); |
1277 | - } else $offset = '+00:00'; |
|
1358 | + } else { |
|
1359 | + $offset = '+00:00'; |
|
1360 | + } |
|
1278 | 1361 | |
1279 | 1362 | if ($globalDBdriver == 'mysql') { |
1280 | 1363 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1322,7 +1405,9 @@ discard block |
||
1322 | 1405 | date_default_timezone_set($globalTimezone); |
1323 | 1406 | $datetime = new DateTime(); |
1324 | 1407 | $offset = $datetime->format('P'); |
1325 | - } else $offset = '+00:00'; |
|
1408 | + } else { |
|
1409 | + $offset = '+00:00'; |
|
1410 | + } |
|
1326 | 1411 | |
1327 | 1412 | if ($globalDBdriver == 'mysql') { |
1328 | 1413 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1387,8 +1472,11 @@ discard block |
||
1387 | 1472 | $query_values = array_merge($query_values,array(':month' => $month)); |
1388 | 1473 | } |
1389 | 1474 | } |
1390 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1391 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1475 | + if (empty($query_values)) { |
|
1476 | + $queryi .= $this->getFilter($filters); |
|
1477 | + } else { |
|
1478 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1479 | + } |
|
1392 | 1480 | |
1393 | 1481 | $sth = $this->db->prepare($queryi); |
1394 | 1482 | $sth->execute($query_values); |
@@ -1425,8 +1513,11 @@ discard block |
||
1425 | 1513 | $query_values = array_merge($query_values,array(':month' => $month)); |
1426 | 1514 | } |
1427 | 1515 | } |
1428 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1429 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1516 | + if (empty($query_values)) { |
|
1517 | + $queryi .= $this->getFilter($filters); |
|
1518 | + } else { |
|
1519 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1520 | + } |
|
1430 | 1521 | |
1431 | 1522 | $sth = $this->db->prepare($queryi); |
1432 | 1523 | $sth->execute($query_values); |
@@ -1448,7 +1539,9 @@ discard block |
||
1448 | 1539 | date_default_timezone_set($globalTimezone); |
1449 | 1540 | $datetime = new DateTime(); |
1450 | 1541 | $offset = $datetime->format('P'); |
1451 | - } else $offset = '+00:00'; |
|
1542 | + } else { |
|
1543 | + $offset = '+00:00'; |
|
1544 | + } |
|
1452 | 1545 | |
1453 | 1546 | if ($globalDBdriver == 'mysql') { |
1454 | 1547 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1552,7 +1645,9 @@ discard block |
||
1552 | 1645 | */ |
1553 | 1646 | public function parseDirection($direction = 0) |
1554 | 1647 | { |
1555 | - if ($direction == '') $direction = 0; |
|
1648 | + if ($direction == '') { |
|
1649 | + $direction = 0; |
|
1650 | + } |
|
1556 | 1651 | $direction_array = array(); |
1557 | 1652 | $temp_array = array(); |
1558 | 1653 | |
@@ -1641,7 +1736,9 @@ discard block |
||
1641 | 1736 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1642 | 1737 | |
1643 | 1738 | $Connection = new Connection($this->db); |
1644 | - if (!$Connection->tableExists('countries')) return ''; |
|
1739 | + if (!$Connection->tableExists('countries')) { |
|
1740 | + return ''; |
|
1741 | + } |
|
1645 | 1742 | |
1646 | 1743 | try { |
1647 | 1744 | /* |
@@ -1661,9 +1758,13 @@ discard block |
||
1661 | 1758 | $sth->closeCursor(); |
1662 | 1759 | if (count($row) > 0) { |
1663 | 1760 | return $row; |
1664 | - } else return ''; |
|
1761 | + } else { |
|
1762 | + return ''; |
|
1763 | + } |
|
1665 | 1764 | } catch (PDOException $e) { |
1666 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1765 | + if (isset($globalDebug) && $globalDebug) { |
|
1766 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1767 | + } |
|
1667 | 1768 | return ''; |
1668 | 1769 | } |
1669 | 1770 | |
@@ -1681,7 +1782,9 @@ discard block |
||
1681 | 1782 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1682 | 1783 | |
1683 | 1784 | $Connection = new Connection($this->db); |
1684 | - if (!$Connection->tableExists('countries')) return ''; |
|
1785 | + if (!$Connection->tableExists('countries')) { |
|
1786 | + return ''; |
|
1787 | + } |
|
1685 | 1788 | |
1686 | 1789 | try { |
1687 | 1790 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1693,9 +1796,13 @@ discard block |
||
1693 | 1796 | $sth->closeCursor(); |
1694 | 1797 | if (count($row) > 0) { |
1695 | 1798 | return $row; |
1696 | - } else return ''; |
|
1799 | + } else { |
|
1800 | + return ''; |
|
1801 | + } |
|
1697 | 1802 | } catch (PDOException $e) { |
1698 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1803 | + if (isset($globalDebug) && $globalDebug) { |
|
1804 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1805 | + } |
|
1699 | 1806 | return ''; |
1700 | 1807 | } |
1701 | 1808 | |
@@ -1713,7 +1820,9 @@ discard block |
||
1713 | 1820 | { |
1714 | 1821 | global $globalBitlyAccessToken; |
1715 | 1822 | |
1716 | - if ($globalBitlyAccessToken == '') return $url; |
|
1823 | + if ($globalBitlyAccessToken == '') { |
|
1824 | + return $url; |
|
1825 | + } |
|
1717 | 1826 | |
1718 | 1827 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1719 | 1828 | |
@@ -1789,7 +1898,9 @@ discard block |
||
1789 | 1898 | } |
1790 | 1899 | } |
1791 | 1900 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
1792 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1901 | + if ($limit) { |
|
1902 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1903 | + } |
|
1793 | 1904 | $sth = $this->db->prepare($query); |
1794 | 1905 | $sth->execute($query_values); |
1795 | 1906 | $marine_array = array(); |
@@ -1826,9 +1937,15 @@ discard block |
||
1826 | 1937 | foreach ($q_array as $q_item){ |
1827 | 1938 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
1828 | 1939 | $additional_query .= " AND ("; |
1829 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
1830 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
1831 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
1940 | + if (is_int($q_item)) { |
|
1941 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
1942 | + } |
|
1943 | + if (is_int($q_item)) { |
|
1944 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
1945 | + } |
|
1946 | + if (is_int($q_item)) { |
|
1947 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
1948 | + } |
|
1832 | 1949 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
1833 | 1950 | $additional_query .= ")"; |
1834 | 1951 | } |
@@ -1876,7 +1993,9 @@ discard block |
||
1876 | 1993 | date_default_timezone_set($globalTimezone); |
1877 | 1994 | $datetime = new DateTime(); |
1878 | 1995 | $offset = $datetime->format('P'); |
1879 | - } else $offset = '+00:00'; |
|
1996 | + } else { |
|
1997 | + $offset = '+00:00'; |
|
1998 | + } |
|
1880 | 1999 | if ($date_array[1] != "") |
1881 | 2000 | { |
1882 | 2001 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -1903,8 +2022,12 @@ discard block |
||
1903 | 2022 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1904 | 2023 | { |
1905 | 2024 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1906 | - } else $limit_query = ""; |
|
1907 | - } else $limit_query = ""; |
|
2025 | + } else { |
|
2026 | + $limit_query = ""; |
|
2027 | + } |
|
2028 | + } else { |
|
2029 | + $limit_query = ""; |
|
2030 | + } |
|
1908 | 2031 | if ($sort != "") |
1909 | 2032 | { |
1910 | 2033 | $search_orderby_array = $this->getOrderBy(); |