Completed
Push — master ( e2bc06...df777b )
by Yannick
29:51
created
require/class.Tracker.php 1 patch
Braces   +172 added lines, -61 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
 	public function __construct($dbc = null) {
11 11
 		$Connection = new Connection($dbc);
12 12
 		$this->db = $Connection->db();
13
-		if ($this->db === null) die('Error: No DB connection. (Tracker)');
13
+		if ($this->db === null) {
14
+			die('Error: No DB connection. (Tracker)');
15
+		}
14 16
 	}
15 17
 
16 18
 	/**
@@ -32,7 +34,9 @@  discard block
 block discarded – undo
32 34
 		if (isset($filter[0]['source'])) {
33 35
 			$filters = array_merge($filters,$filter);
34 36
 		}
35
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
37
+		if (is_array($globalFilter)) {
38
+			$filter = array_merge($filter,$globalFilter);
39
+		}
36 40
 		$filter_query_join = '';
37 41
 		$filter_query_where = '';
38 42
 		foreach($filters as $flt) {
@@ -74,8 +78,11 @@  discard block
 block discarded – undo
74 78
 				$filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
75 79
 			}
76 80
 		}
77
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
78
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81
+		if ($filter_query_where == '' && $where) {
82
+			$filter_query_where = ' WHERE';
83
+		} elseif ($filter_query_where != '' && $and) {
84
+			$filter_query_where .= ' AND';
85
+		}
79 86
 		if ($filter_query_where != '') {
80 87
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
81 88
 		}
@@ -129,26 +136,43 @@  discard block
 block discarded – undo
129 136
 				$temp_array['tracker_id'] = $row['tracker_archive_id'];
130 137
 			} elseif (isset($row['tracker_archive_output_id'])) {
131 138
 				$temp_array['tracker_id'] = $row['tracker_archive_output_id'];
132
-			*/} 
133
-			elseif (isset($row['trackerid'])) {
139
+			*/} elseif (isset($row['trackerid'])) {
134 140
 				$temp_array['trackerid'] = $row['trackerid'];
135 141
 			} else {
136 142
 				$temp_array['trackerid'] = '';
137 143
 			}
138
-			if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid'];
139
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
140
-			if (isset($row['comment'])) $temp_array['comment'] = $row['comment'];
144
+			if (isset($row['famtrackid'])) {
145
+				$temp_array['famtrackid'] = $row['famtrackid'];
146
+			}
147
+			if (isset($row['type'])) {
148
+				$temp_array['type'] = $row['type'];
149
+			}
150
+			if (isset($row['comment'])) {
151
+				$temp_array['comment'] = $row['comment'];
152
+			}
141 153
 			$temp_array['ident'] = $row['ident'];
142
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
143
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
144
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
145
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
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
+			}
163
+			if (isset($row['altitude'])) {
164
+				$temp_array['altitude'] = $row['altitude'];
165
+			}
146 166
 			if (isset($row['heading'])) {
147 167
 				$temp_array['heading'] = $row['heading'];
148 168
 				$heading_direction = $this->parseDirection($row['heading']);
149
-				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'];
150 175
 			}
151
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
152 176
 			
153 177
 			if (isset($row['date'])) {
154 178
 				$dateArray = $this->parseDateString($row['date']);
@@ -191,13 +215,21 @@  discard block
 block discarded – undo
191 215
 			}
192 216
 			
193 217
 			$fromsource = NULL;
194
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
195
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
196
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
218
+			if (isset($row['source_name']) && $row['source_name'] != '') {
219
+				$temp_array['source_name'] = $row['source_name'];
220
+			}
221
+			if (isset($row['over_country']) && $row['over_country'] != '') {
222
+				$temp_array['over_country'] = $row['over_country'];
223
+			}
224
+			if (isset($row['distance']) && $row['distance'] != '') {
225
+				$temp_array['distance'] = $row['distance'];
226
+			}
197 227
 			$temp_array['query_number_rows'] = $num_rows;
198 228
 			$tracker_array[] = $temp_array;
199 229
 		}
200
-		if ($num_rows == 0) return array();
230
+		if ($num_rows == 0) {
231
+			return array();
232
+		}
201 233
 		$tracker_array[0]['query_number_rows'] = $num_rows;
202 234
 		return $tracker_array;
203 235
 	}	
@@ -228,8 +260,12 @@  discard block
 block discarded – undo
228 260
 			{
229 261
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
230 262
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
231
-			} else $limit_query = "";
232
-		} else $limit_query = "";
263
+			} else {
264
+				$limit_query = "";
265
+			}
266
+		} else {
267
+			$limit_query = "";
268
+		}
233 269
 		
234 270
 		if ($sort != "")
235 271
 		{
@@ -257,7 +293,9 @@  discard block
 block discarded – undo
257 293
 		global $global_tracker_query;
258 294
 		
259 295
 		date_default_timezone_set('UTC');
260
-		if ($id == '') return array();
296
+		if ($id == '') {
297
+			return array();
298
+		}
261 299
 		$additional_query = "tracker_output.famtrackid = :id";
262 300
 		$query_values = array(':id' => $id);
263 301
 		$query  = $global_tracker_query." WHERE ".$additional_query." ";
@@ -400,8 +438,11 @@  discard block
 block discarded – undo
400 438
 		$query .= " ORDER BY tracker_output.source_name ASC";
401 439
 
402 440
 		$sth = $this->db->prepare($query);
403
-		if (!empty($query_values)) $sth->execute($query_values);
404
-		else $sth->execute();
441
+		if (!empty($query_values)) {
442
+			$sth->execute($query_values);
443
+		} else {
444
+			$sth->execute();
445
+		}
405 446
 
406 447
 		$source_array = array();
407 448
 		$temp_array = array();
@@ -456,7 +497,9 @@  discard block
 block discarded – undo
456 497
 			date_default_timezone_set($globalTimezone);
457 498
 			$datetime = new DateTime();
458 499
 			$offset = $datetime->format('P');
459
-		} else $offset = '+00:00';
500
+		} else {
501
+			$offset = '+00:00';
502
+		}
460 503
 
461 504
 		if ($globalDBdriver == 'mysql') {
462 505
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
@@ -612,7 +655,9 @@  discard block
 block discarded – undo
612 655
 			{
613 656
 				return false;
614 657
 			}
615
-		} else $altitude = 0;
658
+		} else {
659
+			$altitude = 0;
660
+		}
616 661
 		
617 662
 		if ($heading != "")
618 663
 		{
@@ -651,8 +696,12 @@  discard block
 block discarded – undo
651 696
             		$latitude = 0;
652 697
             		$longitude = 0;
653 698
             	}
654
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
655
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
699
+                if ($heading == '' || $Common->isInteger($heading) === false) {
700
+                	$heading = 0;
701
+                }
702
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
703
+                	$groundspeed = 0;
704
+                }
656 705
                 $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
657 706
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
658 707
 
@@ -756,7 +805,9 @@  discard block
 block discarded – undo
756 805
 		global $globalDBdriver, $globalArchive;
757 806
 		//$filter_query = $this->getFilter($filters,true,true);
758 807
 		$Connection= new Connection($this->db);
759
-		if (!$Connection->tableExists('countries')) return array();
808
+		if (!$Connection->tableExists('countries')) {
809
+			return array();
810
+		}
760 811
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
761 812
 			require_once('class.TrackerLive.php');
762 813
 			$TrackerLive = new TrackerLive($this->db);
@@ -799,7 +850,9 @@  discard block
 block discarded – undo
799 850
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country ";
800 851
 		}
801 852
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
802
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
853
+		if ($limit) {
854
+			$query .= " LIMIT 10 OFFSET 0";
855
+		}
803 856
       
804 857
 		
805 858
 		$sth = $this->db->prepare($query);
@@ -832,12 +885,18 @@  discard block
 block discarded – undo
832 885
 		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
833 886
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
834 887
 		 if ($olderthanmonths > 0) {
835
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
836
-			else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
888
+			if ($globalDBdriver == 'mysql') {
889
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
890
+			} else {
891
+				$query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
892
+			}
837 893
 		}
838 894
 		if ($sincedate != '') {
839
-			if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'";
840
-			else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
895
+			if ($globalDBdriver == 'mysql') {
896
+				$query .= " AND tracker_output.date > '".$sincedate."'";
897
+			} else {
898
+				$query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
899
+			}
841 900
 		}
842 901
 		$query_values = array();
843 902
 		if ($year != '') {
@@ -868,7 +927,9 @@  discard block
 block discarded – undo
868 927
 			}
869 928
 		}
870 929
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
871
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
930
+		if ($limit) {
931
+			$query .= " LIMIT 10 OFFSET 0";
932
+		}
872 933
       		
873 934
 		$sth = $this->db->prepare($query);
874 935
 		$sth->execute($query_values);
@@ -903,7 +964,9 @@  discard block
 block discarded – undo
903 964
 			date_default_timezone_set($globalTimezone);
904 965
 			$datetime = new DateTime();
905 966
 			$offset = $datetime->format('P');
906
-		} else $offset = '+00:00';
967
+		} else {
968
+			$offset = '+00:00';
969
+		}
907 970
 
908 971
 		if ($globalDBdriver == 'mysql') {
909 972
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -953,7 +1016,9 @@  discard block
 block discarded – undo
953 1016
 			date_default_timezone_set($globalTimezone);
954 1017
 			$datetime = new DateTime();
955 1018
 			$offset = $datetime->format('P');
956
-		} else $offset = '+00:00';
1019
+		} else {
1020
+			$offset = '+00:00';
1021
+		}
957 1022
 		$filter_query = $this->getFilter($filters,true,true);
958 1023
 		if ($globalDBdriver == 'mysql') {
959 1024
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -999,7 +1064,9 @@  discard block
 block discarded – undo
999 1064
 			date_default_timezone_set($globalTimezone);
1000 1065
 			$datetime = new DateTime();
1001 1066
 			$offset = $datetime->format('P');
1002
-		} else $offset = '+00:00';
1067
+		} else {
1068
+			$offset = '+00:00';
1069
+		}
1003 1070
 		$filter_query = $this->getFilter($filters,true,true);
1004 1071
 		if ($globalDBdriver == 'mysql') {
1005 1072
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1047,7 +1114,9 @@  discard block
 block discarded – undo
1047 1114
 			date_default_timezone_set($globalTimezone);
1048 1115
 			$datetime = new DateTime();
1049 1116
 			$offset = $datetime->format('P');
1050
-		} else $offset = '+00:00';
1117
+		} else {
1118
+			$offset = '+00:00';
1119
+		}
1051 1120
 
1052 1121
 		if ($globalDBdriver == 'mysql') {
1053 1122
 			$query  = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1096,7 +1165,9 @@  discard block
 block discarded – undo
1096 1165
 			date_default_timezone_set($globalTimezone);
1097 1166
 			$datetime = new DateTime();
1098 1167
 			$offset = $datetime->format('P');
1099
-		} else $offset = '+00:00';
1168
+		} else {
1169
+			$offset = '+00:00';
1170
+		}
1100 1171
 		$filter_query = $this->getFilter($filters,true,true);
1101 1172
 		if ($globalDBdriver == 'mysql') {
1102 1173
 			$query  = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1145,7 +1216,9 @@  discard block
 block discarded – undo
1145 1216
 			date_default_timezone_set($globalTimezone);
1146 1217
 			$datetime = new DateTime();
1147 1218
 			$offset = $datetime->format('P');
1148
-		} else $offset = '+00:00';
1219
+		} else {
1220
+			$offset = '+00:00';
1221
+		}
1149 1222
 
1150 1223
 		$orderby_sql = '';
1151 1224
 		if ($orderby == "hour")
@@ -1214,7 +1287,9 @@  discard block
 block discarded – undo
1214 1287
 			date_default_timezone_set($globalTimezone);
1215 1288
 			$datetime = new DateTime($date);
1216 1289
 			$offset = $datetime->format('P');
1217
-		} else $offset = '+00:00';
1290
+		} else {
1291
+			$offset = '+00:00';
1292
+		}
1218 1293
 
1219 1294
 		if ($globalDBdriver == 'mysql') {
1220 1295
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1262,7 +1337,9 @@  discard block
 block discarded – undo
1262 1337
 			date_default_timezone_set($globalTimezone);
1263 1338
 			$datetime = new DateTime();
1264 1339
 			$offset = $datetime->format('P');
1265
-		} else $offset = '+00:00';
1340
+		} else {
1341
+			$offset = '+00:00';
1342
+		}
1266 1343
 
1267 1344
 		if ($globalDBdriver == 'mysql') {
1268 1345
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1327,8 +1404,11 @@  discard block
 block discarded – undo
1327 1404
 				$query_values = array_merge($query_values,array(':month' => $month));
1328 1405
 			}
1329 1406
 		}
1330
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1331
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1407
+		if (empty($query_values)) {
1408
+			$queryi .= $this->getFilter($filters);
1409
+		} else {
1410
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1411
+		}
1332 1412
 		
1333 1413
 		$sth = $this->db->prepare($queryi);
1334 1414
 		$sth->execute($query_values);
@@ -1365,8 +1445,11 @@  discard block
 block discarded – undo
1365 1445
 				$query_values = array_merge($query_values,array(':month' => $month));
1366 1446
 			}
1367 1447
 		}
1368
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1369
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1448
+		if (empty($query_values)) {
1449
+			$queryi .= $this->getFilter($filters);
1450
+		} else {
1451
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1452
+		}
1370 1453
 		
1371 1454
 		$sth = $this->db->prepare($queryi);
1372 1455
 		$sth->execute($query_values);
@@ -1388,7 +1471,9 @@  discard block
 block discarded – undo
1388 1471
 			date_default_timezone_set($globalTimezone);
1389 1472
 			$datetime = new DateTime();
1390 1473
 			$offset = $datetime->format('P');
1391
-		} else $offset = '+00:00';
1474
+		} else {
1475
+			$offset = '+00:00';
1476
+		}
1392 1477
 
1393 1478
 		if ($globalDBdriver == 'mysql') {
1394 1479
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1492,7 +1577,9 @@  discard block
 block discarded – undo
1492 1577
 	*/
1493 1578
 	public function parseDirection($direction = 0)
1494 1579
 	{
1495
-		if ($direction == '') $direction = 0;
1580
+		if ($direction == '') {
1581
+			$direction = 0;
1582
+		}
1496 1583
 		$direction_array = array();
1497 1584
 		$temp_array = array();
1498 1585
 
@@ -1581,7 +1668,9 @@  discard block
 block discarded – undo
1581 1668
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1582 1669
 	
1583 1670
 		$Connection = new Connection($this->db);
1584
-		if (!$Connection->tableExists('countries')) return '';
1671
+		if (!$Connection->tableExists('countries')) {
1672
+			return '';
1673
+		}
1585 1674
 	
1586 1675
 		try {
1587 1676
 			/*
@@ -1601,9 +1690,13 @@  discard block
 block discarded – undo
1601 1690
 			$sth->closeCursor();
1602 1691
 			if (count($row) > 0) {
1603 1692
 				return $row;
1604
-			} else return '';
1693
+			} else {
1694
+				return '';
1695
+			}
1605 1696
 		} catch (PDOException $e) {
1606
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1697
+			if (isset($globalDebug) && $globalDebug) {
1698
+				echo 'Error : '.$e->getMessage()."\n";
1699
+			}
1607 1700
 			return '';
1608 1701
 		}
1609 1702
 	
@@ -1621,7 +1714,9 @@  discard block
 block discarded – undo
1621 1714
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1622 1715
 	
1623 1716
 		$Connection = new Connection($this->db);
1624
-		if (!$Connection->tableExists('countries')) return '';
1717
+		if (!$Connection->tableExists('countries')) {
1718
+			return '';
1719
+		}
1625 1720
 	
1626 1721
 		try {
1627 1722
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1633,9 +1728,13 @@  discard block
 block discarded – undo
1633 1728
 			$sth->closeCursor();
1634 1729
 			if (count($row) > 0) {
1635 1730
 				return $row;
1636
-			} else return '';
1731
+			} else {
1732
+				return '';
1733
+			}
1637 1734
 		} catch (PDOException $e) {
1638
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1735
+			if (isset($globalDebug) && $globalDebug) {
1736
+				echo 'Error : '.$e->getMessage()."\n";
1737
+			}
1639 1738
 			return '';
1640 1739
 		}
1641 1740
 	
@@ -1696,7 +1795,9 @@  discard block
 block discarded – undo
1696 1795
 			}
1697 1796
 		}
1698 1797
 		$query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC";
1699
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1798
+		if ($limit) {
1799
+			$query .= " LIMIT 10 OFFSET 0";
1800
+		}
1700 1801
 		$sth = $this->db->prepare($query);
1701 1802
 		$sth->execute($query_values);
1702 1803
 		$tracker_array = array();
@@ -1733,7 +1834,9 @@  discard block
 block discarded – undo
1733 1834
 				foreach ($q_array as $q_item){
1734 1835
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1735 1836
 					$additional_query .= " AND (";
1736
-					if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR ";
1837
+					if (is_int($q_item)) {
1838
+						$additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR ";
1839
+					}
1737 1840
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%') OR ";
1738 1841
 					$additional_query .= ")";
1739 1842
 				}
@@ -1759,7 +1862,9 @@  discard block
 block discarded – undo
1759 1862
 				date_default_timezone_set($globalTimezone);
1760 1863
 				$datetime = new DateTime();
1761 1864
 				$offset = $datetime->format('P');
1762
-			} else $offset = '+00:00';
1865
+			} else {
1866
+				$offset = '+00:00';
1867
+			}
1763 1868
 			if ($date_array[1] != "")
1764 1869
 			{
1765 1870
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -1786,8 +1891,12 @@  discard block
 block discarded – undo
1786 1891
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1787 1892
 			{
1788 1893
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1789
-			} else $limit_query = "";
1790
-		} else $limit_query = "";
1894
+			} else {
1895
+				$limit_query = "";
1896
+			}
1897
+		} else {
1898
+			$limit_query = "";
1899
+		}
1791 1900
 		if ($sort != "")
1792 1901
 		{
1793 1902
 			$search_orderby_array = $this->getOrderBy();
@@ -1830,7 +1939,9 @@  discard block
 block discarded – undo
1830 1939
 	{
1831 1940
 		global $globalBitlyAccessToken;
1832 1941
 		
1833
-		if ($globalBitlyAccessToken == '') return $url;
1942
+		if ($globalBitlyAccessToken == '') {
1943
+			return $url;
1944
+		}
1834 1945
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1835 1946
 		$ch = curl_init();
1836 1947
 		curl_setopt($ch, CURLOPT_HEADER, 0);
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Braces   +215 added lines, -76 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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) {
@@ -78,8 +82,11 @@  discard block
 block discarded – undo
78 82
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
79 83
 			}
80 84
 		}
81
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
82
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
85
+		if ($filter_query_where == '' && $where) {
86
+			$filter_query_where = ' WHERE';
87
+		} elseif ($filter_query_where != '' && $and) {
88
+			$filter_query_where .= ' AND';
89
+		}
83 90
 		if ($filter_query_where != '') {
84 91
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
85 92
 		}
@@ -133,39 +140,75 @@  discard block
 block discarded – undo
133 140
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
134 141
 			} elseif (isset($row['spotter_archive_output_id'])) {
135 142
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
136
-			*/} 
137
-			elseif (isset($row['marineid'])) {
143
+			*/} elseif (isset($row['marineid'])) {
138 144
 				$temp_array['marine_id'] = $row['marineid'];
139 145
 			} else {
140 146
 				$temp_array['marine_id'] = '';
141 147
 			}
142
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
143
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
144
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
145
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
146
-			if (isset($row['status'])) $temp_array['status'] = $row['status'];
147
-			if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id'];
148
-			if (isset($row['captain_id'])) $temp_array['captain_id'] = $row['captain_id'];
149
-			if (isset($row['captain_name'])) $temp_array['captain_name'] = $row['captain_name'];
150
-			if (isset($row['race_id'])) $temp_array['race_id'] = $row['race_id'];
151
-			if (isset($row['race_name'])) $temp_array['race_name'] = $row['race_name'];
152
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
153
-			if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name'];
154
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
155
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
156
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
148
+			if (isset($row['fammarine_id'])) {
149
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
150
+			}
151
+			if (isset($row['mmsi'])) {
152
+				$temp_array['mmsi'] = $row['mmsi'];
153
+			}
154
+			if (isset($row['type'])) {
155
+				$temp_array['type'] = $row['type'];
156
+			}
157
+			if (isset($row['type_id'])) {
158
+				$temp_array['type_id'] = $row['type_id'];
159
+			}
160
+			if (isset($row['status'])) {
161
+				$temp_array['status'] = $row['status'];
162
+			}
163
+			if (isset($row['status_id'])) {
164
+				$temp_array['status_id'] = $row['status_id'];
165
+			}
166
+			if (isset($row['captain_id'])) {
167
+				$temp_array['captain_id'] = $row['captain_id'];
168
+			}
169
+			if (isset($row['captain_name'])) {
170
+				$temp_array['captain_name'] = $row['captain_name'];
171
+			}
172
+			if (isset($row['race_id'])) {
173
+				$temp_array['race_id'] = $row['race_id'];
174
+			}
175
+			if (isset($row['race_name'])) {
176
+				$temp_array['race_name'] = $row['race_name'];
177
+			}
178
+			if (isset($row['ident'])) {
179
+				$temp_array['ident'] = $row['ident'];
180
+			}
181
+			if (isset($row['arrival_port_name'])) {
182
+				$temp_array['arrival_port_name'] = $row['arrival_port_name'];
183
+			}
184
+			if (isset($row['latitude'])) {
185
+				$temp_array['latitude'] = $row['latitude'];
186
+			}
187
+			if (isset($row['longitude'])) {
188
+				$temp_array['longitude'] = $row['longitude'];
189
+			}
190
+			if (isset($row['format_source'])) {
191
+				$temp_array['format_source'] = $row['format_source'];
192
+			}
157 193
 			if (isset($row['heading'])) {
158 194
 				$temp_array['heading'] = $row['heading'];
159 195
 				$heading_direction = $this->parseDirection($row['heading']);
160
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
196
+				if (isset($heading_direction[0]['direction_fullname'])) {
197
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
198
+				}
199
+			}
200
+			if (isset($row['ground_speed'])) {
201
+				$temp_array['ground_speed'] = $row['ground_speed'];
161 202
 			}
162
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
163 203
 
164 204
 			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
165 205
 			{
166 206
 				$Image = new Image($this->db);
167
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
168
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
207
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
208
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
209
+				} else {
210
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
211
+				}
169 212
 				unset($Image);
170 213
 				if (count($image_array) > 0) {
171 214
 					$temp_array['image'] = $image_array[0]['image'];
@@ -217,13 +260,21 @@  discard block
 block discarded – undo
217 260
 			}
218 261
 			
219 262
 			$fromsource = NULL;
220
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
221
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
222
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
263
+			if (isset($row['source_name']) && $row['source_name'] != '') {
264
+				$temp_array['source_name'] = $row['source_name'];
265
+			}
266
+			if (isset($row['over_country']) && $row['over_country'] != '') {
267
+				$temp_array['over_country'] = $row['over_country'];
268
+			}
269
+			if (isset($row['distance']) && $row['distance'] != '') {
270
+				$temp_array['distance'] = $row['distance'];
271
+			}
223 272
 			$temp_array['query_number_rows'] = $num_rows;
224 273
 			$spotter_array[] = $temp_array;
225 274
 		}
226
-		if ($num_rows == 0) return array();
275
+		if ($num_rows == 0) {
276
+			return array();
277
+		}
227 278
 		$spotter_array[0]['query_number_rows'] = $num_rows;
228 279
 		return $spotter_array;
229 280
 	}	
@@ -249,8 +300,12 @@  discard block
 block discarded – undo
249 300
 			{
250 301
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
251 302
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
252
-			} else $limit_query = "";
253
-		} else $limit_query = "";
303
+			} else {
304
+				$limit_query = "";
305
+			}
306
+		} else {
307
+			$limit_query = "";
308
+		}
254 309
 		if ($sort != "")
255 310
 		{
256 311
 			$search_orderby_array = $this->getOrderBy();
@@ -274,7 +329,9 @@  discard block
 block discarded – undo
274 329
 		global $global_marine_query;
275 330
 		
276 331
 		date_default_timezone_set('UTC');
277
-		if ($id == '') return array();
332
+		if ($id == '') {
333
+			return array();
334
+		}
278 335
 		$additional_query = "marine_output.fammarine_id = :id";
279 336
 		$query_values = array(':id' => $id);
280 337
 		$query  = $global_marine_query." WHERE ".$additional_query." ";
@@ -510,8 +567,11 @@  discard block
 block discarded – undo
510 567
 		$query .= " ORDER BY marine_output.source_name ASC";
511 568
 
512 569
 		$sth = $this->db->prepare($query);
513
-		if (!empty($query_values)) $sth->execute($query_values);
514
-		else $sth->execute();
570
+		if (!empty($query_values)) {
571
+			$sth->execute($query_values);
572
+		} else {
573
+			$sth->execute();
574
+		}
515 575
 
516 576
 		$source_array = array();
517 577
 		$temp_array = array();
@@ -566,8 +626,11 @@  discard block
 block discarded – undo
566 626
 		$sth = $this->db->prepare($query);
567 627
 		$sth->execute(array(':mmsi' => $mmsi));
568 628
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
569
-		if (isset($result[0])) return $result[0];
570
-		else return array();
629
+		if (isset($result[0])) {
630
+			return $result[0];
631
+		} else {
632
+			return array();
633
+		}
571 634
 	}
572 635
 
573 636
 	/**
@@ -608,7 +671,9 @@  discard block
 block discarded – undo
608 671
 			date_default_timezone_set($globalTimezone);
609 672
 			$datetime = new DateTime();
610 673
 			$offset = $datetime->format('P');
611
-		} else $offset = '+00:00';
674
+		} else {
675
+			$offset = '+00:00';
676
+		}
612 677
 
613 678
 		if ($globalDBdriver == 'mysql') {
614 679
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -858,11 +923,19 @@  discard block
 block discarded – undo
858 923
 			$latitude = 0;
859 924
 			$longitude = 0;
860 925
 		}
861
-		if ($type_id == '') $type_id = NULL;
862
-		if ($status_id == '') $status_id = NULL;
863
-		if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
926
+		if ($type_id == '') {
927
+			$type_id = NULL;
928
+		}
929
+		if ($status_id == '') {
930
+			$status_id = NULL;
931
+		}
932
+		if ($heading == '' || $Common->isInteger($heading) === false) {
933
+			$heading = 0;
934
+		}
864 935
 		//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
865
-		if ($arrival_date == '') $arrival_date = NULL;
936
+		if ($arrival_date == '') {
937
+			$arrival_date = NULL;
938
+		}
866 939
 		$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) 
867 940
 		    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)";
868 941
 
@@ -969,7 +1042,9 @@  discard block
 block discarded – undo
969 1042
 		global $globalDBdriver, $globalArchive;
970 1043
 		//$filter_query = $this->getFilter($filters,true,true);
971 1044
 		$Connection= new Connection($this->db);
972
-		if (!$Connection->tableExists('countries')) return array();
1045
+		if (!$Connection->tableExists('countries')) {
1046
+			return array();
1047
+		}
973 1048
 		require_once('class.SpotterLive.php');
974 1049
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
975 1050
 			$MarineLive = new MarineLive($this->db);
@@ -1013,7 +1088,9 @@  discard block
 block discarded – undo
1013 1088
 			$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 ";
1014 1089
 		}
1015 1090
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
1016
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1091
+		if ($limit) {
1092
+			$query .= " LIMIT 10 OFFSET 0";
1093
+		}
1017 1094
 
1018 1095
 		$sth = $this->db->prepare($query);
1019 1096
 		$sth->execute();
@@ -1047,12 +1124,18 @@  discard block
 block discarded – undo
1047 1124
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1048 1125
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
1049 1126
 		 if ($olderthanmonths > 0) {
1050
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
1051
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1127
+			if ($globalDBdriver == 'mysql') {
1128
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
1129
+			} else {
1130
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1131
+			}
1052 1132
 		}
1053 1133
 		if ($sincedate != '') {
1054
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
1055
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1134
+			if ($globalDBdriver == 'mysql') {
1135
+				$query .= " AND marine_output.date > '".$sincedate."'";
1136
+			} else {
1137
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1138
+			}
1056 1139
 		}
1057 1140
 		$query_values = array();
1058 1141
 		if ($year != '') {
@@ -1083,7 +1166,9 @@  discard block
 block discarded – undo
1083 1166
 			}
1084 1167
 		}
1085 1168
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
1086
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1169
+		if ($limit) {
1170
+			$query .= " LIMIT 10 OFFSET 0";
1171
+		}
1087 1172
       		
1088 1173
 		$sth = $this->db->prepare($query);
1089 1174
 		$sth->execute($query_values);
@@ -1118,7 +1203,9 @@  discard block
 block discarded – undo
1118 1203
 			date_default_timezone_set($globalTimezone);
1119 1204
 			$datetime = new DateTime();
1120 1205
 			$offset = $datetime->format('P');
1121
-		} else $offset = '+00:00';
1206
+		} else {
1207
+			$offset = '+00:00';
1208
+		}
1122 1209
 
1123 1210
 		if ($globalDBdriver == 'mysql') {
1124 1211
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1168,7 +1255,9 @@  discard block
 block discarded – undo
1168 1255
 			date_default_timezone_set($globalTimezone);
1169 1256
 			$datetime = new DateTime();
1170 1257
 			$offset = $datetime->format('P');
1171
-		} else $offset = '+00:00';
1258
+		} else {
1259
+			$offset = '+00:00';
1260
+		}
1172 1261
 		$filter_query = $this->getFilter($filters,true,true);
1173 1262
 		if ($globalDBdriver == 'mysql') {
1174 1263
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1214,7 +1303,9 @@  discard block
 block discarded – undo
1214 1303
 			date_default_timezone_set($globalTimezone);
1215 1304
 			$datetime = new DateTime();
1216 1305
 			$offset = $datetime->format('P');
1217
-		} else $offset = '+00:00';
1306
+		} else {
1307
+			$offset = '+00:00';
1308
+		}
1218 1309
 		$filter_query = $this->getFilter($filters,true,true);
1219 1310
 		if ($globalDBdriver == 'mysql') {
1220 1311
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1262,7 +1353,9 @@  discard block
 block discarded – undo
1262 1353
 			date_default_timezone_set($globalTimezone);
1263 1354
 			$datetime = new DateTime();
1264 1355
 			$offset = $datetime->format('P');
1265
-		} else $offset = '+00:00';
1356
+		} else {
1357
+			$offset = '+00:00';
1358
+		}
1266 1359
 
1267 1360
 		if ($globalDBdriver == 'mysql') {
1268 1361
 			$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
@@ -1311,7 +1404,9 @@  discard block
 block discarded – undo
1311 1404
 			date_default_timezone_set($globalTimezone);
1312 1405
 			$datetime = new DateTime();
1313 1406
 			$offset = $datetime->format('P');
1314
-		} else $offset = '+00:00';
1407
+		} else {
1408
+			$offset = '+00:00';
1409
+		}
1315 1410
 		$filter_query = $this->getFilter($filters,true,true);
1316 1411
 		if ($globalDBdriver == 'mysql') {
1317 1412
 			$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
@@ -1360,7 +1455,9 @@  discard block
 block discarded – undo
1360 1455
 			date_default_timezone_set($globalTimezone);
1361 1456
 			$datetime = new DateTime();
1362 1457
 			$offset = $datetime->format('P');
1363
-		} else $offset = '+00:00';
1458
+		} else {
1459
+			$offset = '+00:00';
1460
+		}
1364 1461
 
1365 1462
 		$orderby_sql = '';
1366 1463
 		if ($orderby == "hour")
@@ -1429,7 +1526,9 @@  discard block
 block discarded – undo
1429 1526
 			date_default_timezone_set($globalTimezone);
1430 1527
 			$datetime = new DateTime($date);
1431 1528
 			$offset = $datetime->format('P');
1432
-		} else $offset = '+00:00';
1529
+		} else {
1530
+			$offset = '+00:00';
1531
+		}
1433 1532
 
1434 1533
 		if ($globalDBdriver == 'mysql') {
1435 1534
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1477,7 +1576,9 @@  discard block
 block discarded – undo
1477 1576
 			date_default_timezone_set($globalTimezone);
1478 1577
 			$datetime = new DateTime();
1479 1578
 			$offset = $datetime->format('P');
1480
-		} else $offset = '+00:00';
1579
+		} else {
1580
+			$offset = '+00:00';
1581
+		}
1481 1582
 
1482 1583
 		if ($globalDBdriver == 'mysql') {
1483 1584
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1542,8 +1643,11 @@  discard block
 block discarded – undo
1542 1643
 				$query_values = array_merge($query_values,array(':month' => $month));
1543 1644
 			}
1544 1645
 		}
1545
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1546
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1646
+		if (empty($query_values)) {
1647
+			$queryi .= $this->getFilter($filters);
1648
+		} else {
1649
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1650
+		}
1547 1651
 		
1548 1652
 		$sth = $this->db->prepare($queryi);
1549 1653
 		$sth->execute($query_values);
@@ -1580,8 +1684,11 @@  discard block
 block discarded – undo
1580 1684
 				$query_values = array_merge($query_values,array(':month' => $month));
1581 1685
 			}
1582 1686
 		}
1583
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1584
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1687
+		if (empty($query_values)) {
1688
+			$queryi .= $this->getFilter($filters);
1689
+		} else {
1690
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1691
+		}
1585 1692
 		
1586 1693
 		$sth = $this->db->prepare($queryi);
1587 1694
 		$sth->execute($query_values);
@@ -1603,7 +1710,9 @@  discard block
 block discarded – undo
1603 1710
 			date_default_timezone_set($globalTimezone);
1604 1711
 			$datetime = new DateTime();
1605 1712
 			$offset = $datetime->format('P');
1606
-		} else $offset = '+00:00';
1713
+		} else {
1714
+			$offset = '+00:00';
1715
+		}
1607 1716
 
1608 1717
 		if ($globalDBdriver == 'mysql') {
1609 1718
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1707,7 +1816,9 @@  discard block
 block discarded – undo
1707 1816
 	*/
1708 1817
 	public function parseDirection($direction = 0)
1709 1818
 	{
1710
-		if ($direction == '') $direction = 0;
1819
+		if ($direction == '') {
1820
+			$direction = 0;
1821
+		}
1711 1822
 		$direction_array = array();
1712 1823
 		$temp_array = array();
1713 1824
 
@@ -1796,7 +1907,9 @@  discard block
 block discarded – undo
1796 1907
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1797 1908
 	
1798 1909
 		$Connection = new Connection($this->db);
1799
-		if (!$Connection->tableExists('countries')) return '';
1910
+		if (!$Connection->tableExists('countries')) {
1911
+			return '';
1912
+		}
1800 1913
 	
1801 1914
 		try {
1802 1915
 			/*
@@ -1816,9 +1929,13 @@  discard block
 block discarded – undo
1816 1929
 			$sth->closeCursor();
1817 1930
 			if (count($row) > 0) {
1818 1931
 				return $row;
1819
-			} else return '';
1932
+			} else {
1933
+				return '';
1934
+			}
1820 1935
 		} catch (PDOException $e) {
1821
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1936
+			if (isset($globalDebug) && $globalDebug) {
1937
+				echo 'Error : '.$e->getMessage()."\n";
1938
+			}
1822 1939
 			return '';
1823 1940
 		}
1824 1941
 	
@@ -1836,7 +1953,9 @@  discard block
 block discarded – undo
1836 1953
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1837 1954
 	
1838 1955
 		$Connection = new Connection($this->db);
1839
-		if (!$Connection->tableExists('countries')) return '';
1956
+		if (!$Connection->tableExists('countries')) {
1957
+			return '';
1958
+		}
1840 1959
 	
1841 1960
 		try {
1842 1961
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1848,9 +1967,13 @@  discard block
 block discarded – undo
1848 1967
 			$sth->closeCursor();
1849 1968
 			if (count($row) > 0) {
1850 1969
 				return $row;
1851
-			} else return '';
1970
+			} else {
1971
+				return '';
1972
+			}
1852 1973
 		} catch (PDOException $e) {
1853
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1974
+			if (isset($globalDebug) && $globalDebug) {
1975
+				echo 'Error : '.$e->getMessage()."\n";
1976
+			}
1854 1977
 			return '';
1855 1978
 		}
1856 1979
 	
@@ -1868,7 +1991,9 @@  discard block
 block discarded – undo
1868 1991
 	{
1869 1992
 		global $globalBitlyAccessToken;
1870 1993
 		
1871
-		if ($globalBitlyAccessToken == '') return $url;
1994
+		if ($globalBitlyAccessToken == '') {
1995
+			return $url;
1996
+		}
1872 1997
         
1873 1998
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1874 1999
 		
@@ -1944,7 +2069,9 @@  discard block
 block discarded – undo
1944 2069
 			}
1945 2070
 		}
1946 2071
 		$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC";
1947
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
2072
+		if ($limit) {
2073
+			$query .= " LIMIT 10 OFFSET 0";
2074
+		}
1948 2075
 		$sth = $this->db->prepare($query);
1949 2076
 		$sth->execute($query_values);
1950 2077
 		$marine_array = array();
@@ -1982,9 +2109,15 @@  discard block
 block discarded – undo
1982 2109
 				foreach ($q_array as $q_item){
1983 2110
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1984 2111
 					$additional_query .= " AND (";
1985
-					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
1986
-					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
1987
-					if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2112
+					if (is_int($q_item)) {
2113
+						$additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2114
+					}
2115
+					if (is_int($q_item)) {
2116
+						$additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
2117
+					}
2118
+					if (is_int($q_item)) {
2119
+						$additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2120
+					}
1988 2121
 					$additional_query .= "(marine_output.ident like '%".$q_item."%') OR ";
1989 2122
 					$additional_query .= ")";
1990 2123
 				}
@@ -2032,7 +2165,9 @@  discard block
 block discarded – undo
2032 2165
 				date_default_timezone_set($globalTimezone);
2033 2166
 				$datetime = new DateTime();
2034 2167
 				$offset = $datetime->format('P');
2035
-			} else $offset = '+00:00';
2168
+			} else {
2169
+				$offset = '+00:00';
2170
+			}
2036 2171
 			if ($date_array[1] != "")
2037 2172
 			{
2038 2173
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -2059,8 +2194,12 @@  discard block
 block discarded – undo
2059 2194
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
2060 2195
 			{
2061 2196
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
2062
-			} else $limit_query = "";
2063
-		} else $limit_query = "";
2197
+			} else {
2198
+				$limit_query = "";
2199
+			}
2200
+		} else {
2201
+			$limit_query = "";
2202
+		}
2064 2203
 		if ($sort != "")
2065 2204
 		{
2066 2205
 			$search_orderby_array = $this->getOrderBy();
Please login to merge, or discard this patch.