Completed
Push — master ( b1de3e...465722 )
by Yannick
28:21
created
require/class.TrackerLive.php 1 patch
Braces   +110 added lines, -37 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. (TrackerLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (TrackerLive)');
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) {
@@ -77,8 +81,11 @@  discard block
 block discarded – undo
77 81
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
78 82
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
79 83
 		}
80
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
84
+		if ($filter_query_where == '' && $where) {
85
+			$filter_query_where = ' WHERE';
86
+		} elseif ($filter_query_where != '' && $and) {
87
+			$filter_query_where .= ' AND';
88
+		}
82 89
 		if ($filter_query_where != '') {
83 90
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
84 91
 		}
@@ -120,7 +127,9 @@  discard block
 block discarded – undo
120 127
 			}
121 128
 		}
122 129
 
123
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
130
+		if (!isset($globalLiveInterval)) {
131
+			$globalLiveInterval = '200';
132
+		}
124 133
 		if ($globalDBdriver == 'mysql') {
125 134
 			//$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";
126 135
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -145,7 +154,9 @@  discard block
 block discarded – undo
145 154
 
146 155
 		$filter_query = $this->getFilter($filter,true,true);
147 156
 
148
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
157
+		if (!isset($globalLiveInterval)) {
158
+			$globalLiveInterval = '200';
159
+		}
149 160
 		if ($globalDBdriver == 'mysql') {
150 161
 			$query  = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
151 162
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";
@@ -190,50 +201,74 @@  discard block
 block discarded – undo
190 201
 		}
191 202
 		$filter_query = $this->getFilter($filter,true,true);
192 203
 
193
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194
-		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300';
204
+		if (!isset($globalLiveInterval)) {
205
+			$globalLiveInterval = '200';
206
+		}
207
+		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') {
208
+			$globalMap3DTrackersLimit = '300';
209
+		}
195 210
 		if ($globalDBdriver == 'mysql') {
196 211
 			if (isset($globalArchive) && $globalArchive) {
197 212
 				$query  = "SELECT * FROM (
198 213
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
199 214
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
200
-				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
215
+				if ($usecoord) {
216
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
217
+				}
201 218
 				$query .= "UNION
202 219
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
203 220
 					FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
204
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
221
+				if ($usecoord) {
222
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
223
+				}
205 224
 				$query .= ") AS tracker
206 225
 				    WHERE latitude <> '0' AND longitude <> '0' 
207 226
 				    ORDER BY famtrackid, date";
208
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
227
+				if ($limit) {
228
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
229
+				}
209 230
 			} else {
210 231
 				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
211 232
 				    FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
212
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
233
+				if ($usecoord) {
234
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
235
+				}
213 236
 				$query .= "AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
214 237
 				    ORDER BY tracker_live.famtrackid, tracker_live.date";
215
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
238
+				if ($limit) {
239
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
240
+				}
216 241
 			}
217 242
 		} else {
218 243
 			if (isset($globalArchive) && $globalArchive) {
219 244
 				$query  = "SELECT * FROM (
220 245
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
221 246
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
222
-				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
247
+				if ($usecoord) {
248
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
249
+				}
223 250
 				$query .= "UNION
224 251
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
225 252
 					FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date";
226
-				if ($usecoord) $query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
253
+				if ($usecoord) {
254
+					$query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
255
+				}
227 256
 				$query .= ") AS tracker
228 257
 				    WHERE latitude <> '0' AND longitude <> '0' 
229 258
 				    ORDER BY famtrackid, date";
230
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
259
+				if ($limit) {
260
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
261
+				}
231 262
 			} else {
232 263
 				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
233 264
 				    FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' ";
234
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
265
+				if ($usecoord) {
266
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
267
+				}
235 268
 				$query .= "ORDER BY tracker_live.famtrackid, tracker_live.date";
236
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
269
+				if ($limit) {
270
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
271
+				}
237 272
 			}
238 273
 		}
239 274
 
@@ -259,7 +294,9 @@  discard block
 block discarded – undo
259 294
 		global $globalDBdriver, $globalLiveInterval;
260 295
 		$filter_query = $this->getFilter($filter,true,true);
261 296
 
262
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
297
+		if (!isset($globalLiveInterval)) {
298
+			$globalLiveInterval = '200';
299
+		}
263 300
 		if ($globalDBdriver == 'mysql') {
264 301
 			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
265 302
 		} else {
@@ -287,7 +324,9 @@  discard block
 block discarded – undo
287 324
 	{
288 325
 		global $globalDBdriver, $globalLiveInterval;
289 326
 		$Tracker = new Tracker($this->db);
290
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
327
+		if (!isset($globalLiveInterval)) {
328
+			$globalLiveInterval = '200';
329
+		}
291 330
 		$filter_query = $this->getFilter($filter);
292 331
 
293 332
 		if (is_array($coord)) {
@@ -295,7 +334,9 @@  discard block
 block discarded – undo
295 334
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
296 335
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
297 336
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
298
-		} else return array();
337
+		} else {
338
+			return array();
339
+		}
299 340
 		if ($globalDBdriver == 'mysql') {
300 341
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
301 342
 		} else {
@@ -315,7 +356,9 @@  discard block
 block discarded – undo
315 356
 	{
316 357
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
317 358
 		$Tracker = new Tracker($this->db);
318
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
359
+		if (!isset($globalLiveInterval)) {
360
+			$globalLiveInterval = '200';
361
+		}
319 362
 		$filter_query = $this->getFilter($filter,true,true);
320 363
 
321 364
 		if (is_array($coord)) {
@@ -323,7 +366,9 @@  discard block
 block discarded – undo
323 366
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
324 367
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
325 368
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
326
-		} else return array();
369
+		} else {
370
+			return array();
371
+		}
327 372
 		/*
328 373
 		if ($globalDBdriver == 'mysql') {
329 374
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
@@ -557,11 +602,15 @@  discard block
 block discarded – undo
557 602
 		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
558 603
 		if ($globalDBdriver == 'mysql') {
559 604
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
560
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
605
+			if ($liveinterval) {
606
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
607
+			}
561 608
 			$query .= ' ORDER BY date';
562 609
 		} else {
563 610
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
564
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
611
+			if ($liveinterval) {
612
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
613
+			}
565 614
 			$query .= ' ORDER BY date';
566 615
 		}
567 616
 
@@ -656,7 +705,9 @@  discard block
 block discarded – undo
656 705
 				$i++;
657 706
 				$j++;
658 707
 				if ($j == 30) {
659
-					if ($globalDebug) echo ".";
708
+					if ($globalDebug) {
709
+						echo ".";
710
+					}
660 711
 				    	try {
661 712
 						
662 713
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -903,7 +954,9 @@  discard block
 block discarded – undo
903 954
 			{
904 955
 				return false;
905 956
 			}
906
-		} else return '';
957
+		} else {
958
+			return '';
959
+		}
907 960
 
908 961
 		if ($longitude != '')
909 962
 		{
@@ -911,7 +964,9 @@  discard block
 block discarded – undo
911 964
 			{
912 965
 				return false;
913 966
 			}
914
-		} else return '';
967
+		} else {
968
+			return '';
969
+		}
915 970
 
916 971
 		if ($altitude != '')
917 972
 		{
@@ -919,7 +974,9 @@  discard block
 block discarded – undo
919 974
 			{
920 975
 				return false;
921 976
 			}
922
-		} else $altitude = 0;
977
+		} else {
978
+			$altitude = 0;
979
+		}
923 980
 
924 981
 		if ($heading != '')
925 982
 		{
@@ -927,7 +984,9 @@  discard block
 block discarded – undo
927 984
 			{
928 985
 				return false;
929 986
 			}
930
-		} else $heading = 0;
987
+		} else {
988
+			$heading = 0;
989
+		}
931 990
 
932 991
 		if ($groundspeed != '')
933 992
 		{
@@ -935,9 +994,13 @@  discard block
 block discarded – undo
935 994
 			{
936 995
 				return false;
937 996
 			}
938
-		} else $groundspeed = 0;
997
+		} else {
998
+			$groundspeed = 0;
999
+		}
939 1000
 		date_default_timezone_set('UTC');
940
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1001
+		if ($date == '') {
1002
+			$date = date("Y-m-d H:i:s", time());
1003
+		}
941 1004
 
942 1005
         
943 1006
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -953,12 +1016,18 @@  discard block
 block discarded – undo
953 1016
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
954 1017
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
955 1018
 
956
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
957
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1019
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1020
+            		$groundspeed = 0;
1021
+            	}
1022
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1023
+            		$heading = 0;
1024
+            	}
958 1025
             	
959 1026
 		$query = '';
960 1027
 		if ($globalArchive) {
961
-			if ($globalDebug) echo '-- Delete previous data -- ';
1028
+			if ($globalDebug) {
1029
+				echo '-- Delete previous data -- ';
1030
+			}
962 1031
 			$query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;';
963 1032
 		}
964 1033
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
@@ -977,10 +1046,14 @@  discard block
 block discarded – undo
977 1046
                 echo 'noarchive : '.$noarchive."\n";
978 1047
                 */
979 1048
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
980
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
1049
+		    if ($globalDebug) {
1050
+		    	echo '(Add to Tracker archive '.$famtrackid.' : ';
1051
+		    }
981 1052
 		    $TrackerArchive = new TrackerArchive($this->db);
982 1053
 		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
983
-		    if ($globalDebug) echo $result.')';
1054
+		    if ($globalDebug) {
1055
+		    	echo $result.')';
1056
+		    }
984 1057
 		}
985 1058
 
986 1059
 		return "success";
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Braces   +122 added lines, -41 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. (SpotterLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (SpotterLive)');
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) {
@@ -123,8 +127,11 @@  discard block
 block discarded – undo
123 127
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
124 128
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
125 129
 		}
126
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
127
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
130
+		if ($filter_query_where == '' && $where) {
131
+			$filter_query_where = ' WHERE';
132
+		} elseif ($filter_query_where != '' && $and) {
133
+			$filter_query_where .= ' AND';
134
+		}
128 135
 		if ($filter_query_where != '') {
129 136
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
130 137
 		}
@@ -165,9 +172,13 @@  discard block
 block discarded – undo
165 172
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
166 173
 			}
167 174
 		}
168
-		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
175
+		if ($orderby_query == '') {
176
+			$orderby_query = ' ORDER BY date DESC';
177
+		}
169 178
 
170
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
179
+		if (!isset($globalLiveInterval)) {
180
+			$globalLiveInterval = '200';
181
+		}
171 182
 		if ($globalDBdriver == 'mysql') {
172 183
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
173 184
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -190,7 +201,9 @@  discard block
 block discarded – undo
190 201
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
191 202
 		date_default_timezone_set('UTC');
192 203
 		$filter_query = $this->getFilter($filter,true,true);
193
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
204
+		if (!isset($globalLiveInterval)) {
205
+			$globalLiveInterval = '200';
206
+		}
194 207
 		if ($globalDBdriver == 'mysql') {
195 208
 			if (isset($globalArchive) && $globalArchive === TRUE) {
196 209
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -240,8 +253,12 @@  discard block
 block discarded – undo
240 253
 		}
241 254
 		$filter_query = $this->getFilter($filter,true,true);
242 255
 
243
-		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
244
-		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
256
+		if (!isset($globalLiveInterval) || $globalLiveInterval == '') {
257
+			$globalLiveInterval = '200';
258
+		}
259
+		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') {
260
+			$globalMap3DAircraftsLimit = '300';
261
+		}
245 262
 		if ($globalDBdriver == 'mysql') {
246 263
 			if (isset($globalArchive) && $globalArchive === TRUE) {
247 264
 				/*
@@ -252,22 +269,32 @@  discard block
 block discarded – undo
252 269
 				*/
253 270
 				$query  = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
254 271
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id ";
255
-				if ($usecoord) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
272
+				if ($usecoord) {
273
+					$query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
274
+				}
256 275
 				$query .= "UNION
257 276
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
258 277
 				FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date";
259
-				if ($usecoord) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
278
+				if ($usecoord) {
279
+					$query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
280
+				}
260 281
 				$query .= ") AS spotter 
261 282
 				WHERE latitude <> '0' AND longitude <> '0' 
262 283
 				ORDER BY flightaware_id, date";
263
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
284
+				if ($limit) {
285
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
286
+				}
264 287
 			} else {
265 288
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
266 289
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date ";
267
-				if ($usecoord) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
290
+				if ($usecoord) {
291
+					$query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
292
+				}
268 293
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
269 294
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
270
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
295
+				if ($limit) {
296
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
297
+				}
271 298
 			}
272 299
 		} else {
273 300
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -279,21 +306,31 @@  discard block
 block discarded – undo
279 306
                                */
280 307
 				$query  = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
281 308
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id ";
282
-				if ($usecoord) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
309
+				if ($usecoord) {
310
+					$query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
311
+				}
283 312
 				$query .= "UNION
284 313
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
285 314
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date";
286
-				if ($usecoord) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
315
+				if ($usecoord) {
316
+					$query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
317
+				}
287 318
 				$query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' ";
288 319
 				$query .= "ORDER BY flightaware_id, date";
289
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
320
+				if ($limit) {
321
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
322
+				}
290 323
 			} else {
291 324
 				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
292 325
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date ";
293
-				if ($usecoord) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
326
+				if ($usecoord) {
327
+					$query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
328
+				}
294 329
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
295 330
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
296
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
331
+				if ($limit) {
332
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
333
+				}
297 334
 			}
298 335
 		}
299 336
 		try {
@@ -318,7 +355,9 @@  discard block
 block discarded – undo
318 355
 		global $globalDBdriver, $globalLiveInterval;
319 356
 		$filter_query = $this->getFilter($filter,true,true);
320 357
 
321
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
358
+		if (!isset($globalLiveInterval)) {
359
+			$globalLiveInterval = '200';
360
+		}
322 361
 		if ($globalDBdriver == 'mysql') {
323 362
 			//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
324 363
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -348,7 +387,9 @@  discard block
 block discarded – undo
348 387
 	{
349 388
 		global $globalDBdriver, $globalLiveInterval;
350 389
 		$Spotter = new Spotter($this->db);
351
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
390
+		if (!isset($globalLiveInterval)) {
391
+			$globalLiveInterval = '200';
392
+		}
352 393
 		$filter_query = $this->getFilter($filter);
353 394
 
354 395
 		if (is_array($coord)) {
@@ -356,7 +397,9 @@  discard block
 block discarded – undo
356 397
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
357 398
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
358 399
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
359
-		} else return array();
400
+		} else {
401
+			return array();
402
+		}
360 403
 		if ($globalDBdriver == 'mysql') {
361 404
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
362 405
 		} else {
@@ -377,7 +420,9 @@  discard block
 block discarded – undo
377 420
 	{
378 421
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
379 422
 		$Spotter = new Spotter($this->db);
380
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
423
+		if (!isset($globalLiveInterval)) {
424
+			$globalLiveInterval = '200';
425
+		}
381 426
 		$filter_query = $this->getFilter($filter,true,true);
382 427
 
383 428
 		if (is_array($coord)) {
@@ -385,7 +430,9 @@  discard block
 block discarded – undo
385 430
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
386 431
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
387 432
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
388
-		} else return array();
433
+		} else {
434
+			return array();
435
+		}
389 436
 		if ($globalDBdriver == 'mysql') {
390 437
 			if (isset($globalArchive) && $globalArchive === TRUE) {
391 438
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -612,11 +659,15 @@  discard block
 block discarded – undo
612 659
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
613 660
 		if ($globalDBdriver == 'mysql') {
614 661
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
615
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
662
+			if ($liveinterval) {
663
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
664
+			}
616 665
 			$query .= ' ORDER BY date';
617 666
 		} else {
618 667
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
619
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
668
+			if ($liveinterval) {
669
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
670
+			}
620 671
 			$query .= ' ORDER BY date';
621 672
 		}
622 673
 
@@ -711,7 +762,9 @@  discard block
 block discarded – undo
711 762
 				$i++;
712 763
 				$j++;
713 764
 				if ($j == 30) {
714
-					if ($globalDebug) echo ".";
765
+					if ($globalDebug) {
766
+						echo ".";
767
+					}
715 768
 				    	try {
716 769
 						
717 770
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -1018,7 +1071,9 @@  discard block
 block discarded – undo
1018 1071
 			{
1019 1072
 				return false;
1020 1073
 			}
1021
-		} else return '';
1074
+		} else {
1075
+			return '';
1076
+		}
1022 1077
 
1023 1078
 		if ($longitude != '')
1024 1079
 		{
@@ -1026,7 +1081,9 @@  discard block
 block discarded – undo
1026 1081
 			{
1027 1082
 				return false;
1028 1083
 			}
1029
-		} else return '';
1084
+		} else {
1085
+			return '';
1086
+		}
1030 1087
 
1031 1088
 		if ($waypoints != '')
1032 1089
 		{
@@ -1042,14 +1099,18 @@  discard block
 block discarded – undo
1042 1099
 			{
1043 1100
 				return false;
1044 1101
 			}
1045
-		} else $altitude = 0;
1102
+		} else {
1103
+			$altitude = 0;
1104
+		}
1046 1105
 		if ($altitude_real != '')
1047 1106
 		{
1048 1107
 			if (!is_numeric($altitude_real))
1049 1108
 			{
1050 1109
 				return false;
1051 1110
 			}
1052
-		} else $altitude_real = 0;
1111
+		} else {
1112
+			$altitude_real = 0;
1113
+		}
1053 1114
 
1054 1115
 		if ($heading != '')
1055 1116
 		{
@@ -1057,7 +1118,9 @@  discard block
 block discarded – undo
1057 1118
 			{
1058 1119
 				return false;
1059 1120
 			}
1060
-		} else $heading = 0;
1121
+		} else {
1122
+			$heading = 0;
1123
+		}
1061 1124
 
1062 1125
 		if ($groundspeed != '')
1063 1126
 		{
@@ -1065,9 +1128,13 @@  discard block
 block discarded – undo
1065 1128
 			{
1066 1129
 				return false;
1067 1130
 			}
1068
-		} else $groundspeed = 0;
1131
+		} else {
1132
+			$groundspeed = 0;
1133
+		}
1069 1134
 		date_default_timezone_set('UTC');
1070
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1135
+		if ($date == '') {
1136
+			$date = date("Y-m-d H:i:s", time());
1137
+		}
1071 1138
 
1072 1139
         
1073 1140
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1112,14 +1179,24 @@  discard block
 block discarded – undo
1112 1179
 		$arrival_airport_country = '';
1113 1180
 		
1114 1181
             	
1115
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1116
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1117
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1118
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1182
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1183
+            		$squawk = NULL;
1184
+            	}
1185
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1186
+            		$verticalrate = NULL;
1187
+            	}
1188
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1189
+            		$groundspeed = 0;
1190
+            	}
1191
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1192
+            		$heading = 0;
1193
+            	}
1119 1194
 		
1120 1195
 		$query = '';
1121 1196
 		if ($globalArchive) {
1122
-			if ($globalDebug) echo '-- Delete previous data -- ';
1197
+			if ($globalDebug) {
1198
+				echo '-- Delete previous data -- ';
1199
+			}
1123 1200
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1124 1201
 		}
1125 1202
 
@@ -1136,10 +1213,14 @@  discard block
 block discarded – undo
1136 1213
 			return "error : ".$e->getMessage();
1137 1214
 		}
1138 1215
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1139
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1216
+		    if ($globalDebug) {
1217
+		    	echo '(Add to SBS archive : ';
1218
+		    }
1140 1219
 		    $SpotterArchive = new SpotterArchive($this->db);
1141 1220
 		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1142
-		    if ($globalDebug) echo $result.')';
1221
+		    if ($globalDebug) {
1222
+		    	echo $result.')';
1223
+		    }
1143 1224
 		} elseif ($globalDebug && $putinarchive !== true) {
1144 1225
 			echo '(Not adding to archive)';
1145 1226
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Braces   +173 added lines, -62 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) {
@@ -69,8 +73,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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($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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
require/class.Tracker.php 1 patch
Braces   +160 added lines, -57 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) {
@@ -71,8 +75,11 @@  discard block
 block discarded – undo
71 75
 				$filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
72 76
 			}
73 77
 		}
74
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
75
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
78
+		if ($filter_query_where == '' && $where) {
79
+			$filter_query_where = ' WHERE';
80
+		} elseif ($filter_query_where != '' && $and) {
81
+			$filter_query_where .= ' AND';
82
+		}
76 83
 		if ($filter_query_where != '') {
77 84
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
78 85
 		}
@@ -126,26 +133,43 @@  discard block
 block discarded – undo
126 133
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
127 134
 			} elseif (isset($row['spotter_archive_output_id'])) {
128 135
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
129
-			*/} 
130
-			elseif (isset($row['trackerid'])) {
136
+			*/} elseif (isset($row['trackerid'])) {
131 137
 				$temp_array['trackerid'] = $row['trackerid'];
132 138
 			} else {
133 139
 				$temp_array['trackerid'] = '';
134 140
 			}
135
-			if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid'];
136
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
137
-			if (isset($row['comment'])) $temp_array['comment'] = $row['comment'];
141
+			if (isset($row['famtrackid'])) {
142
+				$temp_array['famtrackid'] = $row['famtrackid'];
143
+			}
144
+			if (isset($row['type'])) {
145
+				$temp_array['type'] = $row['type'];
146
+			}
147
+			if (isset($row['comment'])) {
148
+				$temp_array['comment'] = $row['comment'];
149
+			}
138 150
 			$temp_array['ident'] = $row['ident'];
139
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
140
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
141
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
142
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
151
+			if (isset($row['latitude'])) {
152
+				$temp_array['latitude'] = $row['latitude'];
153
+			}
154
+			if (isset($row['longitude'])) {
155
+				$temp_array['longitude'] = $row['longitude'];
156
+			}
157
+			if (isset($row['format_source'])) {
158
+				$temp_array['format_source'] = $row['format_source'];
159
+			}
160
+			if (isset($row['altitude'])) {
161
+				$temp_array['altitude'] = $row['altitude'];
162
+			}
143 163
 			if (isset($row['heading'])) {
144 164
 				$temp_array['heading'] = $row['heading'];
145 165
 				$heading_direction = $this->parseDirection($row['heading']);
146
-				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'];
147 172
 			}
148
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
149 173
 			
150 174
 			if (isset($row['date'])) {
151 175
 				$dateArray = $this->parseDateString($row['date']);
@@ -188,13 +212,21 @@  discard block
 block discarded – undo
188 212
 			}
189 213
 			
190 214
 			$fromsource = NULL;
191
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
192
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
193
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
215
+			if (isset($row['source_name']) && $row['source_name'] != '') {
216
+				$temp_array['source_name'] = $row['source_name'];
217
+			}
218
+			if (isset($row['over_country']) && $row['over_country'] != '') {
219
+				$temp_array['over_country'] = $row['over_country'];
220
+			}
221
+			if (isset($row['distance']) && $row['distance'] != '') {
222
+				$temp_array['distance'] = $row['distance'];
223
+			}
194 224
 			$temp_array['query_number_rows'] = $num_rows;
195 225
 			$spotter_array[] = $temp_array;
196 226
 		}
197
-		if ($num_rows == 0) return array();
227
+		if ($num_rows == 0) {
228
+			return array();
229
+		}
198 230
 		$spotter_array[0]['query_number_rows'] = $num_rows;
199 231
 		return $spotter_array;
200 232
 	}	
@@ -225,8 +257,12 @@  discard block
 block discarded – undo
225 257
 			{
226 258
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
227 259
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
228
-			} else $limit_query = "";
229
-		} else $limit_query = "";
260
+			} else {
261
+				$limit_query = "";
262
+			}
263
+		} else {
264
+			$limit_query = "";
265
+		}
230 266
 		
231 267
 		if ($sort != "")
232 268
 		{
@@ -254,7 +290,9 @@  discard block
 block discarded – undo
254 290
 		global $global_query;
255 291
 		
256 292
 		date_default_timezone_set('UTC');
257
-		if ($id == '') return array();
293
+		if ($id == '') {
294
+			return array();
295
+		}
258 296
 		$additional_query = "tracker_output.famtrackid = :id";
259 297
 		$query_values = array(':id' => $id);
260 298
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -397,8 +435,11 @@  discard block
 block discarded – undo
397 435
 		$query .= " ORDER BY tracker_output.source_name ASC";
398 436
 
399 437
 		$sth = $this->db->prepare($query);
400
-		if (!empty($query_values)) $sth->execute($query_values);
401
-		else $sth->execute();
438
+		if (!empty($query_values)) {
439
+			$sth->execute($query_values);
440
+		} else {
441
+			$sth->execute();
442
+		}
402 443
 
403 444
 		$source_array = array();
404 445
 		$temp_array = array();
@@ -453,7 +494,9 @@  discard block
 block discarded – undo
453 494
 			date_default_timezone_set($globalTimezone);
454 495
 			$datetime = new DateTime();
455 496
 			$offset = $datetime->format('P');
456
-		} else $offset = '+00:00';
497
+		} else {
498
+			$offset = '+00:00';
499
+		}
457 500
 
458 501
 		if ($globalDBdriver == 'mysql') {
459 502
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
@@ -609,7 +652,9 @@  discard block
 block discarded – undo
609 652
 			{
610 653
 				return false;
611 654
 			}
612
-		} else $altitude = 0;
655
+		} else {
656
+			$altitude = 0;
657
+		}
613 658
 		
614 659
 		if ($heading != "")
615 660
 		{
@@ -648,8 +693,12 @@  discard block
 block discarded – undo
648 693
             		$latitude = 0;
649 694
             		$longitude = 0;
650 695
             	}
651
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
652
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
696
+                if ($heading == '' || $Common->isInteger($heading) === false) {
697
+                	$heading = 0;
698
+                }
699
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
700
+                	$groundspeed = 0;
701
+                }
653 702
                 $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
654 703
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
655 704
 
@@ -758,7 +807,9 @@  discard block
 block discarded – undo
758 807
 		global $globalDBdriver, $globalArchive;
759 808
 		//$filter_query = $this->getFilter($filters,true,true);
760 809
 		$Connection= new Connection($this->db);
761
-		if (!$Connection->tableExists('countries')) return array();
810
+		if (!$Connection->tableExists('countries')) {
811
+			return array();
812
+		}
762 813
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
763 814
 			require_once('class.TrackerLive.php');
764 815
 			$TrackerLive = new TrackerLive($this->db);
@@ -801,7 +852,9 @@  discard block
 block discarded – undo
801 852
 			$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 ";
802 853
 		}
803 854
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
804
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
855
+		if ($limit) {
856
+			$query .= " LIMIT 10 OFFSET 0";
857
+		}
805 858
       
806 859
 		
807 860
 		$sth = $this->db->prepare($query);
@@ -834,12 +887,18 @@  discard block
 block discarded – undo
834 887
 		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
835 888
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
836 889
 		 if ($olderthanmonths > 0) {
837
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
838
-			else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
890
+			if ($globalDBdriver == 'mysql') {
891
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
892
+			} else {
893
+				$query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
894
+			}
839 895
 		}
840 896
 		if ($sincedate != '') {
841
-			if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'";
842
-			else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
897
+			if ($globalDBdriver == 'mysql') {
898
+				$query .= " AND tracker_output.date > '".$sincedate."'";
899
+			} else {
900
+				$query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
901
+			}
843 902
 		}
844 903
 		$query_values = array();
845 904
 		if ($year != '') {
@@ -870,7 +929,9 @@  discard block
 block discarded – undo
870 929
 			}
871 930
 		}
872 931
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
873
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
932
+		if ($limit) {
933
+			$query .= " LIMIT 10 OFFSET 0";
934
+		}
874 935
       		
875 936
 		$sth = $this->db->prepare($query);
876 937
 		$sth->execute($query_values);
@@ -905,7 +966,9 @@  discard block
 block discarded – undo
905 966
 			date_default_timezone_set($globalTimezone);
906 967
 			$datetime = new DateTime();
907 968
 			$offset = $datetime->format('P');
908
-		} else $offset = '+00:00';
969
+		} else {
970
+			$offset = '+00:00';
971
+		}
909 972
 
910 973
 		if ($globalDBdriver == 'mysql') {
911 974
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -955,7 +1018,9 @@  discard block
 block discarded – undo
955 1018
 			date_default_timezone_set($globalTimezone);
956 1019
 			$datetime = new DateTime();
957 1020
 			$offset = $datetime->format('P');
958
-		} else $offset = '+00:00';
1021
+		} else {
1022
+			$offset = '+00:00';
1023
+		}
959 1024
 		$filter_query = $this->getFilter($filters,true,true);
960 1025
 		if ($globalDBdriver == 'mysql') {
961 1026
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1001,7 +1066,9 @@  discard block
 block discarded – undo
1001 1066
 			date_default_timezone_set($globalTimezone);
1002 1067
 			$datetime = new DateTime();
1003 1068
 			$offset = $datetime->format('P');
1004
-		} else $offset = '+00:00';
1069
+		} else {
1070
+			$offset = '+00:00';
1071
+		}
1005 1072
 		$filter_query = $this->getFilter($filters,true,true);
1006 1073
 		if ($globalDBdriver == 'mysql') {
1007 1074
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1049,7 +1116,9 @@  discard block
 block discarded – undo
1049 1116
 			date_default_timezone_set($globalTimezone);
1050 1117
 			$datetime = new DateTime();
1051 1118
 			$offset = $datetime->format('P');
1052
-		} else $offset = '+00:00';
1119
+		} else {
1120
+			$offset = '+00:00';
1121
+		}
1053 1122
 
1054 1123
 		if ($globalDBdriver == 'mysql') {
1055 1124
 			$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
@@ -1098,7 +1167,9 @@  discard block
 block discarded – undo
1098 1167
 			date_default_timezone_set($globalTimezone);
1099 1168
 			$datetime = new DateTime();
1100 1169
 			$offset = $datetime->format('P');
1101
-		} else $offset = '+00:00';
1170
+		} else {
1171
+			$offset = '+00:00';
1172
+		}
1102 1173
 		$filter_query = $this->getFilter($filters,true,true);
1103 1174
 		if ($globalDBdriver == 'mysql') {
1104 1175
 			$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
@@ -1147,7 +1218,9 @@  discard block
 block discarded – undo
1147 1218
 			date_default_timezone_set($globalTimezone);
1148 1219
 			$datetime = new DateTime();
1149 1220
 			$offset = $datetime->format('P');
1150
-		} else $offset = '+00:00';
1221
+		} else {
1222
+			$offset = '+00:00';
1223
+		}
1151 1224
 
1152 1225
 		$orderby_sql = '';
1153 1226
 		if ($orderby == "hour")
@@ -1216,7 +1289,9 @@  discard block
 block discarded – undo
1216 1289
 			date_default_timezone_set($globalTimezone);
1217 1290
 			$datetime = new DateTime($date);
1218 1291
 			$offset = $datetime->format('P');
1219
-		} else $offset = '+00:00';
1292
+		} else {
1293
+			$offset = '+00:00';
1294
+		}
1220 1295
 
1221 1296
 		if ($globalDBdriver == 'mysql') {
1222 1297
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1264,7 +1339,9 @@  discard block
 block discarded – undo
1264 1339
 			date_default_timezone_set($globalTimezone);
1265 1340
 			$datetime = new DateTime();
1266 1341
 			$offset = $datetime->format('P');
1267
-		} else $offset = '+00:00';
1342
+		} else {
1343
+			$offset = '+00:00';
1344
+		}
1268 1345
 
1269 1346
 		if ($globalDBdriver == 'mysql') {
1270 1347
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1329,8 +1406,11 @@  discard block
 block discarded – undo
1329 1406
 				$query_values = array_merge($query_values,array(':month' => $month));
1330 1407
 			}
1331 1408
 		}
1332
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1333
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1409
+		if (empty($query_values)) {
1410
+			$queryi .= $this->getFilter($filters);
1411
+		} else {
1412
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1413
+		}
1334 1414
 		
1335 1415
 		$sth = $this->db->prepare($queryi);
1336 1416
 		$sth->execute($query_values);
@@ -1367,8 +1447,11 @@  discard block
 block discarded – undo
1367 1447
 				$query_values = array_merge($query_values,array(':month' => $month));
1368 1448
 			}
1369 1449
 		}
1370
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1371
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1450
+		if (empty($query_values)) {
1451
+			$queryi .= $this->getFilter($filters);
1452
+		} else {
1453
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1454
+		}
1372 1455
 		
1373 1456
 		$sth = $this->db->prepare($queryi);
1374 1457
 		$sth->execute($query_values);
@@ -1390,7 +1473,9 @@  discard block
 block discarded – undo
1390 1473
 			date_default_timezone_set($globalTimezone);
1391 1474
 			$datetime = new DateTime();
1392 1475
 			$offset = $datetime->format('P');
1393
-		} else $offset = '+00:00';
1476
+		} else {
1477
+			$offset = '+00:00';
1478
+		}
1394 1479
 
1395 1480
 		if ($globalDBdriver == 'mysql') {
1396 1481
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1494,7 +1579,9 @@  discard block
 block discarded – undo
1494 1579
 	*/
1495 1580
 	public function parseDirection($direction = 0)
1496 1581
 	{
1497
-		if ($direction == '') $direction = 0;
1582
+		if ($direction == '') {
1583
+			$direction = 0;
1584
+		}
1498 1585
 		$direction_array = array();
1499 1586
 		$temp_array = array();
1500 1587
 
@@ -1583,7 +1670,9 @@  discard block
 block discarded – undo
1583 1670
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1584 1671
 	
1585 1672
 		$Connection = new Connection($this->db);
1586
-		if (!$Connection->tableExists('countries')) return '';
1673
+		if (!$Connection->tableExists('countries')) {
1674
+			return '';
1675
+		}
1587 1676
 	
1588 1677
 		try {
1589 1678
 			/*
@@ -1603,9 +1692,13 @@  discard block
 block discarded – undo
1603 1692
 			$sth->closeCursor();
1604 1693
 			if (count($row) > 0) {
1605 1694
 				return $row;
1606
-			} else return '';
1695
+			} else {
1696
+				return '';
1697
+			}
1607 1698
 		} catch (PDOException $e) {
1608
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1699
+			if (isset($globalDebug) && $globalDebug) {
1700
+				echo 'Error : '.$e->getMessage()."\n";
1701
+			}
1609 1702
 			return '';
1610 1703
 		}
1611 1704
 	
@@ -1623,7 +1716,9 @@  discard block
 block discarded – undo
1623 1716
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1624 1717
 	
1625 1718
 		$Connection = new Connection($this->db);
1626
-		if (!$Connection->tableExists('countries')) return '';
1719
+		if (!$Connection->tableExists('countries')) {
1720
+			return '';
1721
+		}
1627 1722
 	
1628 1723
 		try {
1629 1724
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1635,9 +1730,13 @@  discard block
 block discarded – undo
1635 1730
 			$sth->closeCursor();
1636 1731
 			if (count($row) > 0) {
1637 1732
 				return $row;
1638
-			} else return '';
1733
+			} else {
1734
+				return '';
1735
+			}
1639 1736
 		} catch (PDOException $e) {
1640
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1737
+			if (isset($globalDebug) && $globalDebug) {
1738
+				echo 'Error : '.$e->getMessage()."\n";
1739
+			}
1641 1740
 			return '';
1642 1741
 		}
1643 1742
 	
@@ -1698,7 +1797,9 @@  discard block
 block discarded – undo
1698 1797
 			}
1699 1798
 		}
1700 1799
 		$query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC";
1701
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1800
+		if ($limit) {
1801
+			$query .= " LIMIT 10 OFFSET 0";
1802
+		}
1702 1803
 		$sth = $this->db->prepare($query);
1703 1804
 		$sth->execute($query_values);
1704 1805
 		$tracker_array = array();
@@ -1725,7 +1826,9 @@  discard block
 block discarded – undo
1725 1826
 	{
1726 1827
 		global $globalBitlyAccessToken;
1727 1828
 		
1728
-		if ($globalBitlyAccessToken == '') return $url;
1829
+		if ($globalBitlyAccessToken == '') {
1830
+			return $url;
1831
+		}
1729 1832
         
1730 1833
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1731 1834
 		
Please login to merge, or discard this patch.
require/class.Image.php 1 patch
Braces   +220 added lines, -81 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  discard block
 block discarded – undo
9 9
 	public function __construct($dbc = null) {
10 10
 		$Connection = new Connection($dbc);
11 11
 		$this->db = $Connection->db();
12
-		if ($this->db === null) die('Error: No DB connection. (Image)');
12
+		if ($this->db === null) {
13
+			die('Error: No DB connection. (Image)');
14
+		}
13 15
 	}
14 16
 
15 17
 	/**
@@ -24,7 +26,9 @@  discard block
 block discarded – undo
24 26
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
25 27
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
26 28
 		$reg = $registration;
27
-		if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
29
+		if ($reg == '' && $aircraft_icao != '') {
30
+			$reg = $aircraft_icao.$airline_icao;
31
+		}
28 32
 		$reg = trim($reg);
29 33
 		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
30 34
 			FROM spotter_image 
@@ -32,9 +36,13 @@  discard block
 block discarded – undo
32 36
 		$sth = $this->db->prepare($query);
33 37
 		$sth->execute(array(':registration' => $reg));
34 38
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
35
-		if (!empty($result)) return $result;
36
-		elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
37
-		else return array();
39
+		if (!empty($result)) {
40
+			return $result;
41
+		} elseif ($registration != '') {
42
+			return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
43
+		} else {
44
+			return array();
45
+		}
38 46
 	}
39 47
 
40 48
 	/**
@@ -77,8 +85,11 @@  discard block
 block discarded – undo
77 85
 	public function getExifCopyright($url) {
78 86
 		$exif = exif_read_data($url);
79 87
 		$copyright = '';
80
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
81
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
88
+		if (isset($exif['COMPUTED']['copyright'])) {
89
+			$copyright = $exif['COMPUTED']['copyright'];
90
+		} elseif (isset($exif['copyright'])) {
91
+			$copyright = $exif['copyright'];
92
+		}
82 93
 		if ($copyright != '') {
83 94
 			$copyright = str_replace('Copyright ','',$copyright);
84 95
 			$copyright = str_replace('© ','',$copyright);
@@ -96,17 +107,27 @@  discard block
 block discarded – undo
96 107
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
97 108
 	{
98 109
 		global $globalDebug,$globalAircraftImageFetch;
99
-		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
110
+		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) {
111
+			return '';
112
+		}
100 113
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
101 114
 		$registration = trim($registration);
102 115
 		//getting the aircraft image
103
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
104
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
105
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
116
+		if ($globalDebug && $registration != '') {
117
+			echo 'Try to find an aircraft image for '.$registration.'...';
118
+		} elseif ($globalDebug && $aircraft_icao != '') {
119
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
120
+		} elseif ($globalDebug && $airline_icao != '') {
121
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
122
+		}
106 123
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
107
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
124
+		if ($registration == '' && $aircraft_icao != '') {
125
+			$registration = $aircraft_icao.$airline_icao;
126
+		}
108 127
 		if ($image_url['original'] != '') {
109
-			if ($globalDebug) echo 'Found !'."\n";
128
+			if ($globalDebug) {
129
+				echo 'Found !'."\n";
130
+			}
110 131
 			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
111 132
 			try {
112 133
 				$sth = $this->db->prepare($query);
@@ -115,7 +136,9 @@  discard block
 block discarded – undo
115 136
 				echo $e->getMessage()."\n";
116 137
 				return "error";
117 138
 			}
118
-		} elseif ($globalDebug) echo "Not found :'(\n";
139
+		} elseif ($globalDebug) {
140
+			echo "Not found :'(\n";
141
+		}
119 142
 		return "success";
120 143
 	}
121 144
 
@@ -128,7 +151,9 @@  discard block
 block discarded – undo
128 151
 	public function addMarineImage($mmsi,$imo = '',$name = '')
129 152
 	{
130 153
 		global $globalDebug,$globalMarineImageFetch;
131
-		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return '';
154
+		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) {
155
+			return '';
156
+		}
132 157
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
133 158
 		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
134 159
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
@@ -138,16 +163,22 @@  discard block
 block discarded – undo
138 163
 			$identity = $Marine->getIdentity($mmsi);
139 164
 			if (isset($identity[0]['mmsi'])) {
140 165
 				$imo = $identity[0]['imo'];
141
-				if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name'];
166
+				if ($identity[0]['ship_name'] != '') {
167
+					$name = $identity[0]['ship_name'];
168
+				}
142 169
 			}
143 170
 		}
144 171
 		unset($Marine);
145 172
 
146 173
 		//getting the aircraft image
147
-		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
174
+		if ($globalDebug && $name != '') {
175
+			echo 'Try to find an vessel image for '.$name.'...';
176
+		}
148 177
 		$image_url = $this->findMarineImage($mmsi,$imo,$name);
149 178
 		if ($image_url['original'] != '') {
150
-			if ($globalDebug) echo 'Found !'."\n";
179
+			if ($globalDebug) {
180
+				echo 'Found !'."\n";
181
+			}
151 182
 			$query  = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
152 183
 			try {
153 184
 				$sth = $this->db->prepare($query);
@@ -156,7 +187,9 @@  discard block
 block discarded – undo
156 187
 				echo $e->getMessage()."\n";
157 188
 				return "error";
158 189
 			}
159
-		} elseif ($globalDebug) echo "Not found :'(\n";
190
+		} elseif ($globalDebug) {
191
+			echo "Not found :'(\n";
192
+		}
160 193
 		return "success";
161 194
 	}
162 195
 
@@ -171,41 +204,85 @@  discard block
 block discarded – undo
171 204
 	{
172 205
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
173 206
 		$Spotter = new Spotter($this->db);
174
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
207
+		if (!isset($globalIVAO)) {
208
+			$globalIVAO = FALSE;
209
+		}
175 210
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
176 211
 		if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) {
177
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
212
+			if (strpos($aircraft_registration,'/') !== false) {
213
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
214
+			}
178 215
 			$aircraft_registration = urlencode(trim($aircraft_registration));
179 216
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
180
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
181
-			else $aircraft_name = '';
182
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
183
-			else $aircraft_icao = '';
184
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
185
-			else $airline_icao = '';
217
+			if (isset($aircraft_info[0]['aircraft_name'])) {
218
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
219
+			} else {
220
+				$aircraft_name = '';
221
+			}
222
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
223
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
224
+			} else {
225
+				$aircraft_icao = '';
226
+			}
227
+			if (isset($aircraft_info[0]['airline_icao'])) {
228
+				$airline_icao = $aircraft_info[0]['airline_icao'];
229
+			} else {
230
+				$airline_icao = '';
231
+			}
186 232
 		} elseif ($aircraft_icao != '') {
187 233
 			$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
188
-			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
189
-			else $aircraft_name = '';
234
+			if (isset($aircraft_info[0]['type'])) {
235
+				$aircraft_name = $aircraft_info[0]['type'];
236
+			} else {
237
+				$aircraft_name = '';
238
+			}
190 239
 			$aircraft_registration = $aircraft_icao;
191
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
240
+		} else {
241
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
242
+		}
192 243
 		unset($Spotter);
193
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
244
+		if (!isset($globalAircraftImageSources)) {
245
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
246
+		}
194 247
 		foreach ($globalAircraftImageSources as $source) {
195 248
 			$source = strtolower($source);
196
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
197
-			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
198
-			if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
199
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
200
-			if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
201
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
202
-			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
203
-			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
204
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
205
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
206
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
207
-		}
208
-		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
249
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
250
+				$images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
251
+			}
252
+			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) {
253
+				$images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
254
+			}
255
+			if ($source == 'flickr' && extension_loaded('simplexml')) {
256
+				$images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
257
+			}
258
+			if ($source == 'bing') {
259
+				$images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
260
+			}
261
+			if ($source == 'deviantart' && extension_loaded('simplexml')) {
262
+				$images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
263
+			}
264
+			if ($source == 'wikimedia') {
265
+				$images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
266
+			}
267
+			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) {
268
+				$images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
269
+			}
270
+			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) {
271
+				$images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
272
+			}
273
+			if ($source == 'airportdata' && !$globalIVAO) {
274
+				$images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
275
+			}
276
+			if ($source == 'customsources') {
277
+				$images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
278
+			}
279
+			if (isset($images_array) && $images_array['original'] != '') {
280
+				return $images_array;
281
+			}
282
+		}
283
+		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) {
284
+			return $this->findAircraftImage($aircraft_icao);
285
+		}
209 286
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
210 287
 	}
211 288
 
@@ -225,7 +302,9 @@  discard block
 block discarded – undo
225 302
 		//$imo = filter_var($imo,FILTER_SANITIZE_STRING);
226 303
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
227 304
 		$name = trim($name);
228
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
305
+		if (strlen($name) < 4) {
306
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
307
+		}
229 308
 		/*
230 309
 		$Marine = new Marine($this->db);
231 310
 		if ($imo == '' || $name == '') {
@@ -237,15 +316,29 @@  discard block
 block discarded – undo
237 316
 		}
238 317
 		unset($Marine);
239 318
 		*/
240
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
319
+		if (!isset($globalMarineImageSources)) {
320
+			$globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
321
+		}
241 322
 		foreach ($globalMarineImageSources as $source) {
242 323
 			$source = strtolower($source);
243
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
244
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
245
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
246
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
247
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
248
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
324
+			if ($source == 'flickr') {
325
+				$images_array = $this->fromFlickr('marine',$mmsi,$name);
326
+			}
327
+			if ($source == 'bing') {
328
+				$images_array = $this->fromBing('marine',$mmsi,$name);
329
+			}
330
+			if ($source == 'deviantart') {
331
+				$images_array = $this->fromDeviantart('marine',$mmsi,$name);
332
+			}
333
+			if ($source == 'wikimedia') {
334
+				$images_array = $this->fromWikimedia('marine',$mmsi,$name);
335
+			}
336
+			if ($source == 'customsources') {
337
+				$images_array = $this->fromCustomSource('marine',$mmsi,$name);
338
+			}
339
+			if (isset($images_array) && $images_array['original'] != '') {
340
+				return $images_array;
341
+			}
249 342
 		}
250 343
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
251 344
 	}
@@ -268,7 +361,9 @@  discard block
 block discarded – undo
268 361
 			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
269 362
 		}
270 363
 		$data = $Common->getData($url);
271
-		if (substr($data, 0, 5) != "<?xml") return false;
364
+		if (substr($data, 0, 5) != "<?xml") {
365
+			return false;
366
+		}
272 367
 		if ($xml = simplexml_load_string($data)) {
273 368
 			if (isset($xml->channel->item)) {
274 369
 				$image_url = array();
@@ -307,7 +402,9 @@  discard block
 block discarded – undo
307 402
 			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"';
308 403
 		}
309 404
 		$data = $Common->getData($url);
310
-		if (substr($data, 0, 5) != "<?xml") return false;
405
+		if (substr($data, 0, 5) != "<?xml") {
406
+			return false;
407
+		}
311 408
 		if ($xml = simplexml_load_string($data)) {
312 409
 			if (isset($xml->channel->item->link)) {
313 410
 				$image_url = array();
@@ -411,14 +508,22 @@  discard block
 block discarded – undo
411 508
 	public function fromFlickr($type,$registration,$name='') {
412 509
 		$Common = new Common();
413 510
 		if ($type == 'aircraft') {
414
-			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
415
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
511
+			if ($name != '') {
512
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
513
+			} else {
514
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
515
+			}
416 516
 		} elseif ($type == 'marine') {
417
-			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name);
418
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship';
517
+			if ($name != '') {
518
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name);
519
+			} else {
520
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship';
521
+			}
419 522
 		}
420 523
 		$data = $Common->getData($url);
421
-		if (substr($data, 0, 5) != "<?xml") return false;
524
+		if (substr($data, 0, 5) != "<?xml") {
525
+			return false;
526
+		}
422 527
 		if ($xml = simplexml_load_string($data)) {
423 528
 			if (isset($xml->channel->item)) {
424 529
 				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
@@ -461,13 +566,21 @@  discard block
 block discarded – undo
461 566
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
462 567
 		global $globalImageBingKey;
463 568
 		$Common = new Common();
464
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
569
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
570
+			return false;
571
+		}
465 572
 		if ($type == 'aircraft') {
466
-			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
467
-			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
573
+			if ($aircraft_name != '') {
574
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
575
+			} else {
576
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
577
+			}
468 578
 		} elseif ($type == 'marine') {
469
-			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
470
-			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
579
+			if ($aircraft_name != '') {
580
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
581
+			} else {
582
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
583
+			}
471 584
 		}
472 585
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
473 586
 		$data = $Common->getData($url,'get','',$headers);
@@ -523,17 +636,25 @@  discard block
 block discarded – undo
523 636
 	public function fromWikimedia($type,$registration,$name='') {
524 637
 		$Common = new Common();
525 638
 		if ($type == 'aircraft') {
526
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
527
-			else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
639
+			if ($name != '') {
640
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
641
+			} else {
642
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
643
+			}
528 644
 		} elseif ($type == 'marine') {
529
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
530
-			else return false;
645
+			if ($name != '') {
646
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
647
+			} else {
648
+				return false;
649
+			}
531 650
 		}
532 651
 		$data = $Common->getData($url);
533 652
 		$result = json_decode($data);
534 653
 		if (isset($result->query->search[0]->title)) {
535 654
 			$fileo = $result->query->search[0]->title;
536
-			if (substr($fileo,-3) == 'pdf') return false;
655
+			if (substr($fileo,-3) == 'pdf') {
656
+				return false;
657
+			}
537 658
 			$file = urlencode($fileo);
538 659
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
539 660
 			$data2 = $Common->getData($url2);
@@ -604,18 +725,27 @@  discard block
 block discarded – undo
604 725
 					$image_url = array();
605 726
 					$image_url['thumbnail'] = $url_thumbnail;
606 727
 					$image_url['original'] = $url;
607
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
608
-					else $exifCopyright = '';
609
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
610
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
611
-					else $image_url['copyright'] = $source['source_website'];
728
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
729
+						$exifCopyright = $this->getExifCopyright($url);
730
+					} else {
731
+						$exifCopyright = '';
732
+					}
733
+					if ($exifCopyright  != '') {
734
+						$image_url['copyright'] = $exifCopyright;
735
+					} elseif (isset($source['copyright'])) {
736
+						$image_url['copyright'] = $source['copyright'];
737
+					} else {
738
+						$image_url['copyright'] = $source['source_website'];
739
+					}
612 740
 					$image_url['source_website'] = $source['source_website'];
613 741
 					$image_url['source'] = $source['source'];
614 742
 					return $image_url;
615 743
 				}
616 744
 			}
617 745
 			return false;
618
-		} else return false;
746
+		} else {
747
+			return false;
748
+		}
619 749
 		if (!empty($globalMarineImageCustomSources) && $type == 'marine') {
620 750
 			$customsources = array();
621 751
 			if (!isset($globalMarineImageCustomSources[0])) {
@@ -640,18 +770,27 @@  discard block
 block discarded – undo
640 770
 					$image_url = array();
641 771
 					$image_url['thumbnail'] = $url_thumbnail;
642 772
 					$image_url['original'] = $url;
643
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
644
-					else $exifCopyright = '';
645
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
646
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
647
-					else $image_url['copyright'] = $source['source_website'];
773
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
774
+						$exifCopyright = $this->getExifCopyright($url);
775
+					} else {
776
+						$exifCopyright = '';
777
+					}
778
+					if ($exifCopyright  != '') {
779
+						$image_url['copyright'] = $exifCopyright;
780
+					} elseif (isset($source['copyright'])) {
781
+						$image_url['copyright'] = $source['copyright'];
782
+					} else {
783
+						$image_url['copyright'] = $source['source_website'];
784
+					}
648 785
 					$image_url['source_website'] = $source['source_website'];
649 786
 					$image_url['source'] = $source['source'];
650 787
 					return $image_url;
651 788
 				}
652 789
 			}
653 790
 			return false;
654
-		} else return false;
791
+		} else {
792
+			return false;
793
+		}
655 794
 	}
656 795
 }
657 796
 
Please login to merge, or discard this patch.