@@ -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) { |
@@ -72,8 +76,11 @@ discard block |
||
72 | 76 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
73 | 77 | } |
74 | 78 | } |
75 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
76 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
79 | + if ($filter_query_where == '' && $where) { |
|
80 | + $filter_query_where = ' WHERE'; |
|
81 | + } elseif ($filter_query_where != '' && $and) { |
|
82 | + $filter_query_where .= ' AND'; |
|
83 | + } |
|
77 | 84 | if ($filter_query_where != '') { |
78 | 85 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
79 | 86 | } |
@@ -127,32 +134,54 @@ discard block |
||
127 | 134 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
128 | 135 | } elseif (isset($row['spotter_archive_output_id'])) { |
129 | 136 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
130 | - */} |
|
131 | - elseif (isset($row['marineid'])) { |
|
137 | + */} elseif (isset($row['marineid'])) { |
|
132 | 138 | $temp_array['marine_id'] = $row['marineid']; |
133 | 139 | } else { |
134 | 140 | $temp_array['marine_id'] = ''; |
135 | 141 | } |
136 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
137 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
138 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
139 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
140 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
141 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
142 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
143 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
142 | + if (isset($row['fammarine_id'])) { |
|
143 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
144 | + } |
|
145 | + if (isset($row['mmsi'])) { |
|
146 | + $temp_array['mmsi'] = $row['mmsi']; |
|
147 | + } |
|
148 | + if (isset($row['type'])) { |
|
149 | + $temp_array['type'] = $row['type']; |
|
150 | + } |
|
151 | + if (isset($row['type_id'])) { |
|
152 | + $temp_array['type_id'] = $row['type_id']; |
|
153 | + } |
|
154 | + if (isset($row['ident'])) { |
|
155 | + $temp_array['ident'] = $row['ident']; |
|
156 | + } |
|
157 | + if (isset($row['latitude'])) { |
|
158 | + $temp_array['latitude'] = $row['latitude']; |
|
159 | + } |
|
160 | + if (isset($row['longitude'])) { |
|
161 | + $temp_array['longitude'] = $row['longitude']; |
|
162 | + } |
|
163 | + if (isset($row['format_source'])) { |
|
164 | + $temp_array['format_source'] = $row['format_source']; |
|
165 | + } |
|
144 | 166 | if (isset($row['heading'])) { |
145 | 167 | $temp_array['heading'] = $row['heading']; |
146 | 168 | $heading_direction = $this->parseDirection($row['heading']); |
147 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
169 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
170 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
171 | + } |
|
172 | + } |
|
173 | + if (isset($row['ground_speed'])) { |
|
174 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
148 | 175 | } |
149 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
150 | 176 | |
151 | 177 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
152 | 178 | { |
153 | 179 | $Image = new Image($this->db); |
154 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
155 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
180 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
181 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
182 | + } else { |
|
183 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
184 | + } |
|
156 | 185 | unset($Image); |
157 | 186 | if (count($image_array) > 0) { |
158 | 187 | $temp_array['image'] = $image_array[0]['image']; |
@@ -204,13 +233,21 @@ discard block |
||
204 | 233 | } |
205 | 234 | |
206 | 235 | $fromsource = NULL; |
207 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
208 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
209 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
236 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
237 | + $temp_array['source_name'] = $row['source_name']; |
|
238 | + } |
|
239 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
240 | + $temp_array['over_country'] = $row['over_country']; |
|
241 | + } |
|
242 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
243 | + $temp_array['distance'] = $row['distance']; |
|
244 | + } |
|
210 | 245 | $temp_array['query_number_rows'] = $num_rows; |
211 | 246 | $spotter_array[] = $temp_array; |
212 | 247 | } |
213 | - if ($num_rows == 0) return array(); |
|
248 | + if ($num_rows == 0) { |
|
249 | + return array(); |
|
250 | + } |
|
214 | 251 | $spotter_array[0]['query_number_rows'] = $num_rows; |
215 | 252 | return $spotter_array; |
216 | 253 | } |
@@ -236,8 +273,12 @@ discard block |
||
236 | 273 | { |
237 | 274 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
238 | 275 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
239 | - } else $limit_query = ""; |
|
240 | - } else $limit_query = ""; |
|
276 | + } else { |
|
277 | + $limit_query = ""; |
|
278 | + } |
|
279 | + } else { |
|
280 | + $limit_query = ""; |
|
281 | + } |
|
241 | 282 | if ($sort != "") |
242 | 283 | { |
243 | 284 | $search_orderby_array = $this->getOrderBy(); |
@@ -261,7 +302,9 @@ discard block |
||
261 | 302 | global $global_query; |
262 | 303 | |
263 | 304 | date_default_timezone_set('UTC'); |
264 | - if ($id == '') return array(); |
|
305 | + if ($id == '') { |
|
306 | + return array(); |
|
307 | + } |
|
265 | 308 | $additional_query = "marine_output.fammarine_id = :id"; |
266 | 309 | $query_values = array(':id' => $id); |
267 | 310 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -404,8 +447,11 @@ discard block |
||
404 | 447 | $query .= " ORDER BY marine_output.source_name ASC"; |
405 | 448 | |
406 | 449 | $sth = $this->db->prepare($query); |
407 | - if (!empty($query_values)) $sth->execute($query_values); |
|
408 | - else $sth->execute(); |
|
450 | + if (!empty($query_values)) { |
|
451 | + $sth->execute($query_values); |
|
452 | + } else { |
|
453 | + $sth->execute(); |
|
454 | + } |
|
409 | 455 | |
410 | 456 | $source_array = array(); |
411 | 457 | $temp_array = array(); |
@@ -460,8 +506,11 @@ discard block |
||
460 | 506 | $sth = $this->db->prepare($query); |
461 | 507 | $sth->execute(array(':mmsi' => $mmsi)); |
462 | 508 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
463 | - if (isset($result[0])) return $result[0]; |
|
464 | - else return ''; |
|
509 | + if (isset($result[0])) { |
|
510 | + return $result[0]; |
|
511 | + } else { |
|
512 | + return ''; |
|
513 | + } |
|
465 | 514 | } |
466 | 515 | |
467 | 516 | /** |
@@ -502,7 +551,9 @@ discard block |
||
502 | 551 | date_default_timezone_set($globalTimezone); |
503 | 552 | $datetime = new DateTime(); |
504 | 553 | $offset = $datetime->format('P'); |
505 | - } else $offset = '+00:00'; |
|
554 | + } else { |
|
555 | + $offset = '+00:00'; |
|
556 | + } |
|
506 | 557 | |
507 | 558 | if ($globalDBdriver == 'mysql') { |
508 | 559 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -727,9 +778,15 @@ discard block |
||
727 | 778 | $latitude = 0; |
728 | 779 | $longitude = 0; |
729 | 780 | } |
730 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
731 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
732 | - if ($arrival_date == '') $arrival_date = NULL; |
|
781 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
782 | + $heading = 0; |
|
783 | + } |
|
784 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
785 | + $groundspeed = 0; |
|
786 | + } |
|
787 | + if ($arrival_date == '') { |
|
788 | + $arrival_date = NULL; |
|
789 | + } |
|
733 | 790 | $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) |
734 | 791 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
735 | 792 | |
@@ -837,7 +894,9 @@ discard block |
||
837 | 894 | global $globalDBdriver, $globalArchive; |
838 | 895 | //$filter_query = $this->getFilter($filters,true,true); |
839 | 896 | $Connection= new Connection($this->db); |
840 | - if (!$Connection->tableExists('countries')) return array(); |
|
897 | + if (!$Connection->tableExists('countries')) { |
|
898 | + return array(); |
|
899 | + } |
|
841 | 900 | require_once('class.SpotterLive.php'); |
842 | 901 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
843 | 902 | $MarineLive = new MarineLive($this->db); |
@@ -881,7 +940,9 @@ discard block |
||
881 | 940 | $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 "; |
882 | 941 | } |
883 | 942 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
884 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
943 | + if ($limit) { |
|
944 | + $query .= " LIMIT 10 OFFSET 0"; |
|
945 | + } |
|
885 | 946 | |
886 | 947 | $sth = $this->db->prepare($query); |
887 | 948 | $sth->execute(); |
@@ -915,12 +976,18 @@ discard block |
||
915 | 976 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
916 | 977 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
917 | 978 | if ($olderthanmonths > 0) { |
918 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
919 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
979 | + if ($globalDBdriver == 'mysql') { |
|
980 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
981 | + } else { |
|
982 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
983 | + } |
|
920 | 984 | } |
921 | 985 | if ($sincedate != '') { |
922 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
923 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
986 | + if ($globalDBdriver == 'mysql') { |
|
987 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
988 | + } else { |
|
989 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
990 | + } |
|
924 | 991 | } |
925 | 992 | $query_values = array(); |
926 | 993 | if ($year != '') { |
@@ -951,7 +1018,9 @@ discard block |
||
951 | 1018 | } |
952 | 1019 | } |
953 | 1020 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
954 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1021 | + if ($limit) { |
|
1022 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1023 | + } |
|
955 | 1024 | |
956 | 1025 | $sth = $this->db->prepare($query); |
957 | 1026 | $sth->execute($query_values); |
@@ -986,7 +1055,9 @@ discard block |
||
986 | 1055 | date_default_timezone_set($globalTimezone); |
987 | 1056 | $datetime = new DateTime(); |
988 | 1057 | $offset = $datetime->format('P'); |
989 | - } else $offset = '+00:00'; |
|
1058 | + } else { |
|
1059 | + $offset = '+00:00'; |
|
1060 | + } |
|
990 | 1061 | |
991 | 1062 | if ($globalDBdriver == 'mysql') { |
992 | 1063 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1036,7 +1107,9 @@ discard block |
||
1036 | 1107 | date_default_timezone_set($globalTimezone); |
1037 | 1108 | $datetime = new DateTime(); |
1038 | 1109 | $offset = $datetime->format('P'); |
1039 | - } else $offset = '+00:00'; |
|
1110 | + } else { |
|
1111 | + $offset = '+00:00'; |
|
1112 | + } |
|
1040 | 1113 | $filter_query = $this->getFilter($filters,true,true); |
1041 | 1114 | if ($globalDBdriver == 'mysql') { |
1042 | 1115 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1082,7 +1155,9 @@ discard block |
||
1082 | 1155 | date_default_timezone_set($globalTimezone); |
1083 | 1156 | $datetime = new DateTime(); |
1084 | 1157 | $offset = $datetime->format('P'); |
1085 | - } else $offset = '+00:00'; |
|
1158 | + } else { |
|
1159 | + $offset = '+00:00'; |
|
1160 | + } |
|
1086 | 1161 | $filter_query = $this->getFilter($filters,true,true); |
1087 | 1162 | if ($globalDBdriver == 'mysql') { |
1088 | 1163 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1130,7 +1205,9 @@ discard block |
||
1130 | 1205 | date_default_timezone_set($globalTimezone); |
1131 | 1206 | $datetime = new DateTime(); |
1132 | 1207 | $offset = $datetime->format('P'); |
1133 | - } else $offset = '+00:00'; |
|
1208 | + } else { |
|
1209 | + $offset = '+00:00'; |
|
1210 | + } |
|
1134 | 1211 | |
1135 | 1212 | if ($globalDBdriver == 'mysql') { |
1136 | 1213 | $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 |
@@ -1179,7 +1256,9 @@ discard block |
||
1179 | 1256 | date_default_timezone_set($globalTimezone); |
1180 | 1257 | $datetime = new DateTime(); |
1181 | 1258 | $offset = $datetime->format('P'); |
1182 | - } else $offset = '+00:00'; |
|
1259 | + } else { |
|
1260 | + $offset = '+00:00'; |
|
1261 | + } |
|
1183 | 1262 | $filter_query = $this->getFilter($filters,true,true); |
1184 | 1263 | if ($globalDBdriver == 'mysql') { |
1185 | 1264 | $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 |
@@ -1228,7 +1307,9 @@ discard block |
||
1228 | 1307 | date_default_timezone_set($globalTimezone); |
1229 | 1308 | $datetime = new DateTime(); |
1230 | 1309 | $offset = $datetime->format('P'); |
1231 | - } else $offset = '+00:00'; |
|
1310 | + } else { |
|
1311 | + $offset = '+00:00'; |
|
1312 | + } |
|
1232 | 1313 | |
1233 | 1314 | $orderby_sql = ''; |
1234 | 1315 | if ($orderby == "hour") |
@@ -1297,7 +1378,9 @@ discard block |
||
1297 | 1378 | date_default_timezone_set($globalTimezone); |
1298 | 1379 | $datetime = new DateTime($date); |
1299 | 1380 | $offset = $datetime->format('P'); |
1300 | - } else $offset = '+00:00'; |
|
1381 | + } else { |
|
1382 | + $offset = '+00:00'; |
|
1383 | + } |
|
1301 | 1384 | |
1302 | 1385 | if ($globalDBdriver == 'mysql') { |
1303 | 1386 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1345,7 +1428,9 @@ discard block |
||
1345 | 1428 | date_default_timezone_set($globalTimezone); |
1346 | 1429 | $datetime = new DateTime(); |
1347 | 1430 | $offset = $datetime->format('P'); |
1348 | - } else $offset = '+00:00'; |
|
1431 | + } else { |
|
1432 | + $offset = '+00:00'; |
|
1433 | + } |
|
1349 | 1434 | |
1350 | 1435 | if ($globalDBdriver == 'mysql') { |
1351 | 1436 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1410,8 +1495,11 @@ discard block |
||
1410 | 1495 | $query_values = array_merge($query_values,array(':month' => $month)); |
1411 | 1496 | } |
1412 | 1497 | } |
1413 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1414 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1498 | + if (empty($query_values)) { |
|
1499 | + $queryi .= $this->getFilter($filters); |
|
1500 | + } else { |
|
1501 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1502 | + } |
|
1415 | 1503 | |
1416 | 1504 | $sth = $this->db->prepare($queryi); |
1417 | 1505 | $sth->execute($query_values); |
@@ -1448,8 +1536,11 @@ discard block |
||
1448 | 1536 | $query_values = array_merge($query_values,array(':month' => $month)); |
1449 | 1537 | } |
1450 | 1538 | } |
1451 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1452 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1539 | + if (empty($query_values)) { |
|
1540 | + $queryi .= $this->getFilter($filters); |
|
1541 | + } else { |
|
1542 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1543 | + } |
|
1453 | 1544 | |
1454 | 1545 | $sth = $this->db->prepare($queryi); |
1455 | 1546 | $sth->execute($query_values); |
@@ -1471,7 +1562,9 @@ discard block |
||
1471 | 1562 | date_default_timezone_set($globalTimezone); |
1472 | 1563 | $datetime = new DateTime(); |
1473 | 1564 | $offset = $datetime->format('P'); |
1474 | - } else $offset = '+00:00'; |
|
1565 | + } else { |
|
1566 | + $offset = '+00:00'; |
|
1567 | + } |
|
1475 | 1568 | |
1476 | 1569 | if ($globalDBdriver == 'mysql') { |
1477 | 1570 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1575,7 +1668,9 @@ discard block |
||
1575 | 1668 | */ |
1576 | 1669 | public function parseDirection($direction = 0) |
1577 | 1670 | { |
1578 | - if ($direction == '') $direction = 0; |
|
1671 | + if ($direction == '') { |
|
1672 | + $direction = 0; |
|
1673 | + } |
|
1579 | 1674 | $direction_array = array(); |
1580 | 1675 | $temp_array = array(); |
1581 | 1676 | |
@@ -1664,7 +1759,9 @@ discard block |
||
1664 | 1759 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1665 | 1760 | |
1666 | 1761 | $Connection = new Connection($this->db); |
1667 | - if (!$Connection->tableExists('countries')) return ''; |
|
1762 | + if (!$Connection->tableExists('countries')) { |
|
1763 | + return ''; |
|
1764 | + } |
|
1668 | 1765 | |
1669 | 1766 | try { |
1670 | 1767 | /* |
@@ -1684,9 +1781,13 @@ discard block |
||
1684 | 1781 | $sth->closeCursor(); |
1685 | 1782 | if (count($row) > 0) { |
1686 | 1783 | return $row; |
1687 | - } else return ''; |
|
1784 | + } else { |
|
1785 | + return ''; |
|
1786 | + } |
|
1688 | 1787 | } catch (PDOException $e) { |
1689 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1788 | + if (isset($globalDebug) && $globalDebug) { |
|
1789 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1790 | + } |
|
1690 | 1791 | return ''; |
1691 | 1792 | } |
1692 | 1793 | |
@@ -1704,7 +1805,9 @@ discard block |
||
1704 | 1805 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1705 | 1806 | |
1706 | 1807 | $Connection = new Connection($this->db); |
1707 | - if (!$Connection->tableExists('countries')) return ''; |
|
1808 | + if (!$Connection->tableExists('countries')) { |
|
1809 | + return ''; |
|
1810 | + } |
|
1708 | 1811 | |
1709 | 1812 | try { |
1710 | 1813 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1716,9 +1819,13 @@ discard block |
||
1716 | 1819 | $sth->closeCursor(); |
1717 | 1820 | if (count($row) > 0) { |
1718 | 1821 | return $row; |
1719 | - } else return ''; |
|
1822 | + } else { |
|
1823 | + return ''; |
|
1824 | + } |
|
1720 | 1825 | } catch (PDOException $e) { |
1721 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1826 | + if (isset($globalDebug) && $globalDebug) { |
|
1827 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1828 | + } |
|
1722 | 1829 | return ''; |
1723 | 1830 | } |
1724 | 1831 | |
@@ -1736,7 +1843,9 @@ discard block |
||
1736 | 1843 | { |
1737 | 1844 | global $globalBitlyAccessToken; |
1738 | 1845 | |
1739 | - if ($globalBitlyAccessToken == '') return $url; |
|
1846 | + if ($globalBitlyAccessToken == '') { |
|
1847 | + return $url; |
|
1848 | + } |
|
1740 | 1849 | |
1741 | 1850 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1742 | 1851 | |
@@ -1812,7 +1921,9 @@ discard block |
||
1812 | 1921 | } |
1813 | 1922 | } |
1814 | 1923 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
1815 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1924 | + if ($limit) { |
|
1925 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1926 | + } |
|
1816 | 1927 | $sth = $this->db->prepare($query); |
1817 | 1928 | $sth->execute($query_values); |
1818 | 1929 | $marine_array = array(); |
@@ -1849,9 +1960,15 @@ discard block |
||
1849 | 1960 | foreach ($q_array as $q_item){ |
1850 | 1961 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
1851 | 1962 | $additional_query .= " AND ("; |
1852 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
1853 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
1854 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
1963 | + if (is_int($q_item)) { |
|
1964 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
1965 | + } |
|
1966 | + if (is_int($q_item)) { |
|
1967 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
1968 | + } |
|
1969 | + if (is_int($q_item)) { |
|
1970 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
1971 | + } |
|
1855 | 1972 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
1856 | 1973 | $additional_query .= ")"; |
1857 | 1974 | } |
@@ -1899,7 +2016,9 @@ discard block |
||
1899 | 2016 | date_default_timezone_set($globalTimezone); |
1900 | 2017 | $datetime = new DateTime(); |
1901 | 2018 | $offset = $datetime->format('P'); |
1902 | - } else $offset = '+00:00'; |
|
2019 | + } else { |
|
2020 | + $offset = '+00:00'; |
|
2021 | + } |
|
1903 | 2022 | if ($date_array[1] != "") |
1904 | 2023 | { |
1905 | 2024 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -1926,8 +2045,12 @@ discard block |
||
1926 | 2045 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1927 | 2046 | { |
1928 | 2047 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1929 | - } else $limit_query = ""; |
|
1930 | - } else $limit_query = ""; |
|
2048 | + } else { |
|
2049 | + $limit_query = ""; |
|
2050 | + } |
|
2051 | + } else { |
|
2052 | + $limit_query = ""; |
|
2053 | + } |
|
1931 | 2054 | if ($sort != "") |
1932 | 2055 | { |
1933 | 2056 | $search_orderby_array = $this->getOrderBy(); |