Completed
Push — master ( bb48eb...8e257c )
by Yannick
34:24
created
require/class.Weather.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@  discard block
 block discarded – undo
63 63
 	
64 64
 	public function nomad_wind($hour = '') {
65 65
 		global $globalWindsPath;
66
-		if ($hour == '') $hour = date('G');
66
+		if ($hour == '') {
67
+			$hour = date('G');
68
+		}
67 69
 		if (isset($globalWindsPath) && $globalWindsPath != '') {
68 70
 			$grib2json = $globalWindsPath['grib2json'];
69 71
 			$windpathsrc = $globalWindsPath['source'];
@@ -101,7 +103,9 @@  discard block
 block discarded – undo
101 103
 			system($grib2json.' --data --output '.$windpathdest.' --names --compact '.$windpathsrc);
102 104
 		} else {
103 105
 			// if not try previous run
104
-			if ($hour == date('G')) $this->nomad_wind(date('G')-6);
106
+			if ($hour == date('G')) {
107
+				$this->nomad_wind(date('G')-6);
108
+			}
105 109
 		}
106 110
 	}
107 111
 
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Braces   +225 added lines, -78 removed lines patch added patch discarded remove patch
@@ -61,7 +61,9 @@  discard block
 block discarded – undo
61 61
     public function checkAll() {
62 62
 	global $globalDebug, $globalNoDB, $globalVM;
63 63
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
64
-	    if ($globalDebug) echo "Update last seen tracked data...\n";
64
+	    if ($globalDebug) {
65
+	    	echo "Update last seen tracked data...\n";
66
+	    }
65 67
 	    foreach ($this->all_tracked as $key => $flight) {
66 68
 		if (isset($this->all_tracked[$key]['id'])) {
67 69
 		    //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -71,8 +73,11 @@  discard block
 block discarded – undo
71 73
     			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
72 74
     			} else {
73 75
     			    $timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']);
74
-    			    if ($timerace > time()) $finaldatetime = NULL;
75
-    			    else $finaldatetime = date('Y-m-d H:i:s',$timerace);
76
+    			    if ($timerace > time()) {
77
+    			    	$finaldatetime = NULL;
78
+    			    } else {
79
+    			    	$finaldatetime = date('Y-m-d H:i:s',$timerace);
80
+    			    }
76 81
     			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
77 82
     			}
78 83
     		    } else {
@@ -86,13 +91,17 @@  discard block
 block discarded – undo
86 91
     public function del() {
87 92
 	global $globalDebug, $globalNoDB, $globalNoImport;
88 93
 	// Delete old infos
89
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
94
+	if ($globalDebug) {
95
+		echo 'Delete old values and update latest data...'."\n";
96
+	}
90 97
 	foreach ($this->all_tracked as $key => $flight) {
91 98
     	    if (isset($flight['lastupdate'])) {
92 99
         	if ($flight['lastupdate'] < (time()-3000)) {
93 100
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
94 101
             		if (isset($this->all_tracked[$key]['id'])) {
95
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
102
+            		    if ($globalDebug) {
103
+            		    	echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
104
+            		    }
96 105
 			    /*
97 106
 			    $MarineLive = new MarineLive();
98 107
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -106,14 +115,19 @@  discard block
 block discarded – undo
106 115
 					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
107 116
 				    } else {
108 117
 					$timerace = strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time'];
109
-	        			if ($timerace > time()) $finaldatetime = NULL;
110
-					else $finaldatetime = date('Y-m-d H:i:s',$timerace);
118
+	        			if ($timerace > time()) {
119
+	        				$finaldatetime = NULL;
120
+	        			} else {
121
+						$finaldatetime = date('Y-m-d H:i:s',$timerace);
122
+					}
111 123
 					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
112 124
 				    }
113 125
 				} else {
114 126
 					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
115 127
 				}
116
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
128
+				if ($globalDebug && $result != 'success') {
129
+					echo '!!! ERROR : '.$result."\n";
130
+				}
117 131
 			    }
118 132
 			    // Put in archive
119 133
 //				$Marine->db = null;
@@ -127,7 +141,9 @@  discard block
 block discarded – undo
127 141
 
128 142
     public function add($line) {
129 143
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM;
130
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
144
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
145
+		$globalCoordMinChange = '0.02';
146
+	}
131 147
 	date_default_timezone_set('UTC');
132 148
 	$dataFound = false;
133 149
 	$send = false;
@@ -141,20 +157,30 @@  discard block
 block discarded – undo
141 157
 		// Increment message number
142 158
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
143 159
 		    $current_date = date('Y-m-d');
144
-		    if (isset($line['source_name'])) $source = $line['source_name'];
145
-		    else $source = '';
146
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
160
+		    if (isset($line['source_name'])) {
161
+		    	$source = $line['source_name'];
162
+		    } else {
163
+		    	$source = '';
164
+		    }
165
+		    if ($source == '' || $line['format_source'] == 'aprs') {
166
+		    	$source = $line['format_source'];
167
+		    }
147 168
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
148 169
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
149 170
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
150
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
171
+		    } else {
172
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
173
+		    }
151 174
 		}
152 175
 		
153 176
 		
154 177
 		$Common = new Common();
155 178
 		$AIS = new AIS();
156
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
157
-	        else $id = trim($line['id']);
179
+	        if (!isset($line['id'])) {
180
+	        	$id = trim($line['mmsi']);
181
+	        } else {
182
+	        	$id = trim($line['id']);
183
+	        }
158 184
 		
159 185
 		if (!isset($this->all_tracked[$id])) {
160 186
 		    $this->all_tracked[$id] = array();
@@ -162,10 +188,16 @@  discard block
 block discarded – undo
162 188
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => ''));
163 189
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
164 190
 		    if (!isset($line['id'])) {
165
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
191
+			if (!isset($globalDaemon)) {
192
+				$globalDaemon = TRUE;
193
+			}
166 194
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
167
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
168
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
195
+		     } else {
196
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
197
+		     }
198
+		    if ($globalAllTracked !== FALSE) {
199
+		    	$dataFound = true;
200
+		    }
169 201
 		}
170 202
 		
171 203
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -222,7 +254,9 @@  discard block
 block discarded – undo
222 254
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
223 255
 		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
224 256
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
225
-			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
257
+			if ($globalDebug) {
258
+				echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
259
+			}
226 260
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
227 261
 			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
228 262
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -235,7 +269,9 @@  discard block
 block discarded – undo
235 269
 			}
236 270
 		    } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
237 271
 			$this->all_tracked[$id]['arrival_code'] = $line['arrival_code'];
238
-			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
272
+			if ($globalDebug) {
273
+				echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
274
+			}
239 275
 			if (!isset($line['id'])) {
240 276
 				$this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi');
241 277
 				$this->all_tracked[$id]['forcenew'] = 1;
@@ -244,7 +280,9 @@  discard block
 block discarded – undo
244 280
 		    }
245 281
 		}
246 282
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
247
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
283
+		    if (strtotime($line['arrival_date']) > time()) {
284
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
285
+		    }
248 286
 		}
249 287
 		if (isset($line['captain_id']) && $line['captain_id'] != '') {
250 288
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
@@ -289,34 +327,49 @@  discard block
 block discarded – undo
289 327
 				$Marine = new Marine($this->db);
290 328
 				$fromsource = NULL;
291 329
 				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
292
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
330
+				if ($globalDebug && $result != 'success') {
331
+					echo '!!! ERROR : '.$result."\n";
332
+				}
293 333
 				$Marine->db = null;
294
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
334
+				if ($globalDebugTimeElapsed) {
335
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
336
+				}
295 337
 			    }
296 338
 			}
297 339
 		    }
298
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
340
+		    if (!isset($this->all_tracked[$id]['id'])) {
341
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
342
+		    }
299 343
 		}
300 344
 
301 345
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
302 346
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
303 347
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
304 348
 		    } else {
305
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
306
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
349
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
350
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
351
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
352
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
353
+				}
307 354
 				return '';
308 355
 		    }
309 356
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
310
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
357
+			if ($globalDebug) {
358
+				echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
359
+			}
311 360
 			return '';
312 361
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) {
313
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
362
+			if ($globalDebug) {
363
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
364
+			}
314 365
 			return '';
315 366
 		} elseif (!isset($line['datetime'])) {
316 367
 			date_default_timezone_set('UTC');
317 368
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
318 369
 		} else {
319
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
370
+			if ($globalDebug) {
371
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
372
+			}
320 373
 			return '';
321 374
 		}
322 375
 
@@ -329,14 +382,21 @@  discard block
 block discarded – undo
329 382
 		    if ($distance > 1000 && $distance < 10000) {
330 383
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
331 384
 			$speed = $speed*3.6;
332
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
333
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
385
+			if ($speed < 1000) {
386
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
387
+			}
388
+  			if ($globalDebug) {
389
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
390
+  			}
334 391
 		    }
335 392
 		}
336 393
 
337 394
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
338
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
339
-	    	    else unset($timediff);
395
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
396
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
397
+	    	    } else {
398
+	    	    	unset($timediff);
399
+	    	    }
340 400
 	    	    if ($this->tmd > 5 ||
341 401
 	    		!isset($timediff) ||
342 402
 	    		$timediff > $globalLiveInterval ||
@@ -353,22 +413,32 @@  discard block
 block discarded – undo
353 413
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
354 414
 				$this->all_tracked[$id]['putinarchive'] = true;
355 415
 				
356
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
416
+				if ($globalDebug) {
417
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
418
+				}
357 419
 				$timeelapsed = microtime(true);
358 420
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
359 421
 				    $Marine = new Marine($this->db);
360 422
 				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
361
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
423
+				    if (!empty($all_country)) {
424
+				    	$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
425
+				    }
362 426
 				    $Marine->db = null;
363
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
427
+				    if ($globalDebugTimeElapsed) {
428
+				    	echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
429
+				    }
364 430
 				}
365 431
 				$this->tmd = 0;
366
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
432
+				if ($globalDebug) {
433
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
434
+				}
367 435
 			    }
368 436
 			}
369 437
 
370 438
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
371
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
439
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
440
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
441
+				}
372 442
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
373 443
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
374 444
 				    $dataFound = true;
@@ -377,8 +447,12 @@  discard block
 block discarded – undo
377 447
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
378 448
 			}
379 449
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
380
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
381
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
450
+			    if ($line['longitude'] > 180) {
451
+			    	$line['longitude'] = $line['longitude'] - 360;
452
+			    }
453
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
454
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
455
+				}
382 456
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
383 457
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
384 458
 				    $dataFound = true;
@@ -396,7 +470,9 @@  discard block
 block discarded – undo
396 470
 		    }
397 471
 		}
398 472
 		if (isset($line['last_update']) && $line['last_update'] != '') {
399
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
473
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
474
+		    	$dataFound = true;
475
+		    }
400 476
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
401 477
 		}
402 478
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -410,15 +486,21 @@  discard block
 block discarded – undo
410 486
 		}
411 487
 		
412 488
 		if (isset($line['heading']) && $line['heading'] != '') {
413
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
489
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
490
+		    	$this->all_tracked[$id]['putinarchive'] = true;
491
+		    }
414 492
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
415 493
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
416 494
 		    //$dataFound = true;
417 495
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
418 496
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
419 497
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
420
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
421
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
498
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
499
+		    	$this->all_tracked[$id]['putinarchive'] = true;
500
+		    }
501
+  		    if ($globalDebug) {
502
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
503
+  		    }
422 504
   		}
423 505
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
424 506
 
@@ -430,28 +512,45 @@  discard block
 block discarded – undo
430 512
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
431 513
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
432 514
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
433
-				    if ($globalDebug) echo "Check if vessel is already in DB...";
515
+				    if ($globalDebug) {
516
+				    	echo "Check if vessel is already in DB...";
517
+				    }
434 518
 				    $timeelapsed = microtime(true);
435 519
 				    $MarineLive = new MarineLive($this->db);
436 520
 				    if (isset($line['id']) && isset($globalVM) && $globalVM) {
437 521
 					$Marine = new Marine($this->db);
438 522
 					$recent_ident = $Marine->checkId($line['id']);
439
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
523
+					if ($globalDebugTimeElapsed) {
524
+						echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
525
+					}
440 526
 					$Marine->db=null;
441 527
 				    } elseif (isset($line['id'])) {
442 528
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
443
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
529
+					if ($globalDebugTimeElapsed) {
530
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
531
+					}
444 532
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
445 533
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
446
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
534
+					if ($globalDebugTimeElapsed) {
535
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
536
+					}
447 537
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
448 538
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
449
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
450
-				    } else $recent_ident = '';
539
+					if ($globalDebugTimeElapsed) {
540
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
541
+					}
542
+				    } else {
543
+				    	$recent_ident = '';
544
+				    }
451 545
 				    $MarineLive->db=null;
452
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
453
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
454
-				} else $recent_ident = '';
546
+				    if ($globalDebug && $recent_ident == '') {
547
+				    	echo " Not in DB.\n";
548
+				    } elseif ($globalDebug && $recent_ident != '') {
549
+				    	echo " Already in DB.\n";
550
+				    }
551
+				} else {
552
+					$recent_ident = '';
553
+				}
455 554
 			    } else {
456 555
 				$recent_ident = '';
457 556
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -460,12 +559,17 @@  discard block
 block discarded – undo
460 559
 			    if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
461 560
 			    {
462 561
 				if ($globalDebug) {
463
-					if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
464
-					else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
562
+					if ($this->all_tracked[$id]['mmsi'] == '') {
563
+						echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
564
+					} else {
565
+						echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
566
+					}
465 567
 				}
466 568
 				//adds the spotter data for the archive
467 569
 				    $highlight = '';
468
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
570
+				    if (!isset($this->all_tracked[$id]['id'])) {
571
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
572
+				    }
469 573
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
470 574
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
471 575
 					    $timeelapsed = microtime(true);
@@ -476,20 +580,30 @@  discard block
 block discarded – undo
476 580
 						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
477 581
 					    }
478 582
 					    $Marine->db = null;
479
-					    if ($globalDebug && isset($result)) echo $result."\n";
480
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
583
+					    if ($globalDebug && isset($result)) {
584
+					    	echo $result."\n";
585
+					    }
586
+					    if ($globalDebugTimeElapsed) {
587
+					    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
588
+					    }
481 589
 					}
482 590
 				    }
483 591
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
484 592
 					// Add source stat in DB
485 593
 					$Stats = new Stats($this->db);
486 594
 					if (!empty($this->stats)) {
487
-					    if ($globalDebug) echo 'Add source stats : ';
595
+					    if ($globalDebug) {
596
+					    	echo 'Add source stats : ';
597
+					    }
488 598
 				    	    foreach($this->stats as $date => $data) {
489 599
 						foreach($data as $source => $sourced) {
490 600
 					    	    //print_r($sourced);
491
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
492
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
601
+				    	    	    if (isset($sourced['polar'])) {
602
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
603
+				    	    	    }
604
+				    	    	    if (isset($sourced['hist'])) {
605
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
606
+				    	    	    }
493 607
 				    		    if (isset($sourced['msg'])) {
494 608
 				    			if (time() - $sourced['msg']['date'] > 10) {
495 609
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -502,7 +616,9 @@  discard block
 block discarded – undo
502 616
 			    			    unset($this->stats[$date]);
503 617
 			    			}
504 618
 				    	    }
505
-				    	    if ($globalDebug) echo 'Done'."\n";
619
+				    	    if ($globalDebug) {
620
+				    	    	echo 'Done'."\n";
621
+				    	    }
506 622
 					}
507 623
 					$Stats->db = null;
508 624
 				    }
@@ -512,13 +628,17 @@  discard block
 block discarded – undo
512 628
 				$this->all_tracked[$id]['addedMarine'] = 1;
513 629
 				//print_r($this->all_tracked[$id]);
514 630
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
515
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
631
+				    if ($globalDebug) {
632
+				    	echo "---- Deleting Live Marine data older than 9 hours...";
633
+				    }
516 634
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
517 635
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
518 636
 					$MarineLive = new MarineLive($this->db);
519 637
 					$MarineLive->deleteLiveMarineData();
520 638
 					$MarineLive->db=null;
521
-					if ($globalDebug) echo " Done\n";
639
+					if ($globalDebug) {
640
+						echo " Done\n";
641
+					}
522 642
 				    }
523 643
 				    $this->last_delete = time();
524 644
 				}
@@ -534,8 +654,11 @@  discard block
 block discarded – undo
534 654
 					    } else {
535 655
 						//$finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
536 656
 						$timerace = (strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
537
-						if ($timerace > time()) $finaldatetime = NULL;
538
-						else $finaldatetime = date('Y-m-d H:i:s',$timerace);
657
+						if ($timerace > time()) {
658
+							$finaldatetime = NULL;
659
+						} else {
660
+							$finaldatetime = date('Y-m-d H:i:s',$timerace);
661
+						}
539 662
 
540 663
 						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
541 664
 					    }
@@ -554,18 +677,26 @@  discard block
 block discarded – undo
554 677
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
555 678
 		    }
556 679
 		    $ignoreImport = false;
557
-		    if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true;
680
+		    if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') {
681
+		    	$ignoreImport = true;
682
+		    }
558 683
 		    if (!$ignoreImport) {
559 684
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
560
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
685
+				if ($globalDebug) {
686
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
687
+				}
561 688
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
562 689
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
563 690
 					$timeelapsed = microtime(true);
564 691
 					$MarineLive = new MarineLive($this->db);
565 692
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
566 693
 					$MarineLive->db = null;
567
-					if ($globalDebug) echo $result."\n";
568
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
694
+					if ($globalDebug) {
695
+						echo $result."\n";
696
+					}
697
+					if ($globalDebugTimeElapsed) {
698
+						echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
699
+					}
569 700
 				    }
570 701
 				}
571 702
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
@@ -577,7 +708,9 @@  discard block
 block discarded – undo
577 708
 				
578 709
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
579 710
 					$source = $this->all_tracked[$id]['source_name'];
580
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
711
+					if ($source == '') {
712
+						$source = $this->all_tracked[$id]['format_source'];
713
+					}
581 714
 					if (!isset($this->source_location[$source])) {
582 715
 						$Location = new Source($this->db);
583 716
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -598,7 +731,9 @@  discard block
 block discarded – undo
598 731
 					$stats_heading = round($stats_heading/22.5);
599 732
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
600 733
 					$current_date = date('Y-m-d');
601
-					if ($stats_heading == 16) $stats_heading = 0;
734
+					if ($stats_heading == 16) {
735
+						$stats_heading = 0;
736
+					}
602 737
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
603 738
 						for ($i=0;$i<=15;$i++) {
604 739
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -616,7 +751,9 @@  discard block
 block discarded – undo
616 751
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
617 752
 						    end($this->stats[$current_date][$source]['hist']);
618 753
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
619
-						} else $mini = 0;
754
+						} else {
755
+							$mini = 0;
756
+						}
620 757
 						for ($i=$mini;$i<=$distance;$i+=10) {
621 758
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
622 759
 						}
@@ -628,19 +765,27 @@  discard block
 block discarded – undo
628 765
 				
629 766
 
630 767
 				$this->all_tracked[$id]['lastupdate'] = time();
631
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
632
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
768
+				if ($this->all_tracked[$id]['putinarchive']) {
769
+					$send = true;
770
+				}
771
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
772
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
773
+			}
633 774
 			//$this->del();
634 775
 			
635 776
 			
636 777
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
637 778
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
638
-				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
779
+				if ($globalDebug) {
780
+					echo "---- Deleting Live Marine data Not updated since 2 hour...";
781
+				}
639 782
 				$MarineLive = new MarineLive($this->db);
640 783
 				$MarineLive->deleteLiveMarineDataNotUpdated();
641 784
 				$MarineLive->db = null;
642 785
 				//MarineLive->deleteLiveMarineData();
643
-				if ($globalDebug) echo " Done\n";
786
+				if ($globalDebug) {
787
+					echo " Done\n";
788
+				}
644 789
 			    }
645 790
 			    $this->last_delete_hourly = time();
646 791
 			}
@@ -649,7 +794,9 @@  discard block
 block discarded – undo
649 794
 		    //$ignoreImport = false;
650 795
 		}
651 796
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
652
-		if ($send) return $this->all_tracked[$id];
797
+		if ($send) {
798
+			return $this->all_tracked[$id];
799
+		}
653 800
 	    }
654 801
 	}
655 802
     }
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Braces   +282 added lines, -100 removed lines patch added patch discarded remove patch
@@ -15,7 +15,9 @@  discard block
 block discarded – undo
15 15
 	public function __construct($dbc = null) {
16 16
 		$Connection = new Connection($dbc);
17 17
 		$this->db = $Connection->db();
18
-		if ($this->db === null) die('Error: No DB connection. (Marine)');
18
+		if ($this->db === null) {
19
+			die('Error: No DB connection. (Marine)');
20
+		}
19 21
 	}
20 22
 
21 23
 	/**
@@ -37,7 +39,9 @@  discard block
 block discarded – undo
37 39
 		if (isset($filter[0]['source'])) {
38 40
 			$filters = array_merge($filters,$filter);
39 41
 		}
40
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
42
+		if (is_array($globalFilter)) {
43
+			$filter = array_merge($filter,$globalFilter);
44
+		}
41 45
 		$filter_query_join = '';
42 46
 		$filter_query_where = '';
43 47
 		foreach($filters as $flt) {
@@ -85,8 +89,11 @@  discard block
 block discarded – undo
85 89
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
86 90
 			}
87 91
 		}
88
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
89
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
92
+		if ($filter_query_where == '' && $where) {
93
+			$filter_query_where = ' WHERE';
94
+		} elseif ($filter_query_where != '' && $and) {
95
+			$filter_query_where .= ' AND';
96
+		}
90 97
 		if ($filter_query_where != '') {
91 98
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
92 99
 		}
@@ -141,42 +148,84 @@  discard block
 block discarded – undo
141 148
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
142 149
 			} elseif (isset($row['spotter_archive_output_id'])) {
143 150
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
144
-			*/} 
145
-			elseif (isset($row['marineid'])) {
151
+			*/} elseif (isset($row['marineid'])) {
146 152
 				$temp_array['marine_id'] = $row['marineid'];
147 153
 			} else {
148 154
 				$temp_array['marine_id'] = '';
149 155
 			}
150
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
151
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
152
-			if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES);
153
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
154
-			if (isset($row['status'])) $temp_array['status'] = $row['status'];
155
-			if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id'];
156
-			if (isset($row['captain_id'])) $temp_array['captain_id'] = $row['captain_id'];
157
-			if (isset($row['captain_name'])) $temp_array['captain_name'] = $row['captain_name'];
158
-			if (isset($row['race_id'])) $temp_array['race_id'] = $row['race_id'];
159
-			if (isset($row['race_name'])) $temp_array['race_name'] = $row['race_name'];
160
-			if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) $temp_array['race_time'] = $row['race_time'];
161
-			if (isset($row['race_rank'])) $temp_array['race_rank'] = $row['race_rank'];
162
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
163
-			if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name'];
164
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
165
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
166
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
167
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
156
+			if (isset($row['fammarine_id'])) {
157
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
158
+			}
159
+			if (isset($row['mmsi'])) {
160
+				$temp_array['mmsi'] = $row['mmsi'];
161
+			}
162
+			if (isset($row['type'])) {
163
+				$temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES);
164
+			}
165
+			if (isset($row['type_id'])) {
166
+				$temp_array['type_id'] = $row['type_id'];
167
+			}
168
+			if (isset($row['status'])) {
169
+				$temp_array['status'] = $row['status'];
170
+			}
171
+			if (isset($row['status_id'])) {
172
+				$temp_array['status_id'] = $row['status_id'];
173
+			}
174
+			if (isset($row['captain_id'])) {
175
+				$temp_array['captain_id'] = $row['captain_id'];
176
+			}
177
+			if (isset($row['captain_name'])) {
178
+				$temp_array['captain_name'] = $row['captain_name'];
179
+			}
180
+			if (isset($row['race_id'])) {
181
+				$temp_array['race_id'] = $row['race_id'];
182
+			}
183
+			if (isset($row['race_name'])) {
184
+				$temp_array['race_name'] = $row['race_name'];
185
+			}
186
+			if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) {
187
+				$temp_array['race_time'] = $row['race_time'];
188
+			}
189
+			if (isset($row['race_rank'])) {
190
+				$temp_array['race_rank'] = $row['race_rank'];
191
+			}
192
+			if (isset($row['ident'])) {
193
+				$temp_array['ident'] = $row['ident'];
194
+			}
195
+			if (isset($row['arrival_port_name'])) {
196
+				$temp_array['arrival_port_name'] = $row['arrival_port_name'];
197
+			}
198
+			if (isset($row['latitude'])) {
199
+				$temp_array['latitude'] = $row['latitude'];
200
+			}
201
+			if (isset($row['longitude'])) {
202
+				$temp_array['longitude'] = $row['longitude'];
203
+			}
204
+			if (isset($row['distance']) && $row['distance'] != '') {
205
+				$temp_array['distance'] = $row['distance'];
206
+			}
207
+			if (isset($row['format_source'])) {
208
+				$temp_array['format_source'] = $row['format_source'];
209
+			}
168 210
 			if (isset($row['heading'])) {
169 211
 				$temp_array['heading'] = $row['heading'];
170 212
 				$heading_direction = $this->parseDirection($row['heading']);
171
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
213
+				if (isset($heading_direction[0]['direction_fullname'])) {
214
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
215
+				}
216
+			}
217
+			if (isset($row['ground_speed'])) {
218
+				$temp_array['ground_speed'] = $row['ground_speed'];
172 219
 			}
173
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
174 220
 
175 221
 			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
176 222
 			{
177 223
 				$Image = new Image($this->db);
178
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
179
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
224
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
225
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
226
+				} else {
227
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
228
+				}
180 229
 				unset($Image);
181 230
 				if (count($image_array) > 0) {
182 231
 					$temp_array['image'] = $image_array[0]['image'];
@@ -240,13 +289,21 @@  discard block
 block discarded – undo
240 289
 			}
241 290
 			
242 291
 			$fromsource = NULL;
243
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
244
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
245
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
292
+			if (isset($row['source_name']) && $row['source_name'] != '') {
293
+				$temp_array['source_name'] = $row['source_name'];
294
+			}
295
+			if (isset($row['over_country']) && $row['over_country'] != '') {
296
+				$temp_array['over_country'] = $row['over_country'];
297
+			}
298
+			if (isset($row['distance']) && $row['distance'] != '') {
299
+				$temp_array['distance'] = $row['distance'];
300
+			}
246 301
 			$temp_array['query_number_rows'] = $num_rows;
247 302
 			$spotter_array[] = $temp_array;
248 303
 		}
249
-		if ($num_rows == 0) return array();
304
+		if ($num_rows == 0) {
305
+			return array();
306
+		}
250 307
 		$spotter_array[0]['query_number_rows'] = $num_rows;
251 308
 		return $spotter_array;
252 309
 	}	
@@ -272,8 +329,12 @@  discard block
 block discarded – undo
272 329
 			{
273 330
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
274 331
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
275
-			} else $limit_query = "";
276
-		} else $limit_query = "";
332
+			} else {
333
+				$limit_query = "";
334
+			}
335
+		} else {
336
+			$limit_query = "";
337
+		}
277 338
 		if ($sort != "")
278 339
 		{
279 340
 			$search_orderby_array = $this->getOrderBy();
@@ -297,7 +358,9 @@  discard block
 block discarded – undo
297 358
 		global $global_marine_query;
298 359
 		
299 360
 		date_default_timezone_set('UTC');
300
-		if ($id == '') return array();
361
+		if ($id == '') {
362
+			return array();
363
+		}
301 364
 		$additional_query = "marine_output.fammarine_id = :id";
302 365
 		$query_values = array(':id' => $id);
303 366
 		$query  = $global_marine_query." WHERE ".$additional_query." ";
@@ -745,8 +808,11 @@  discard block
 block discarded – undo
745 808
 		$sth = $this->db->prepare($query);
746 809
 		$sth->execute($query_values);
747 810
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
748
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
749
-		else return $result[0]['duration'];
811
+		if (is_int($result[0]['duration'])) {
812
+			return gmdate('H:i:s',$result[0]['duration']);
813
+		} else {
814
+			return $result[0]['duration'];
815
+		}
750 816
 	}
751 817
 
752 818
 	/**
@@ -790,7 +856,9 @@  discard block
 block discarded – undo
790 856
 			}
791 857
 		}
792 858
 		$query .= " GROUP BY marine_output.captain_id,marine_output.captain_name ORDER BY duration DESC";
793
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
859
+		if ($limit) {
860
+			$query .= " LIMIT 10 OFFSET 0";
861
+		}
794 862
 		$sth = $this->db->prepare($query);
795 863
 		$sth->execute($query_values);
796 864
 		//if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
@@ -869,8 +937,11 @@  discard block
 block discarded – undo
869 937
 		$query .= " ORDER BY marine_output.source_name ASC";
870 938
 
871 939
 		$sth = $this->db->prepare($query);
872
-		if (!empty($query_values)) $sth->execute($query_values);
873
-		else $sth->execute();
940
+		if (!empty($query_values)) {
941
+			$sth->execute($query_values);
942
+		} else {
943
+			$sth->execute();
944
+		}
874 945
 
875 946
 		$source_array = array();
876 947
 		$temp_array = array();
@@ -925,8 +996,11 @@  discard block
 block discarded – undo
925 996
 		$sth = $this->db->prepare($query);
926 997
 		$sth->execute(array(':mmsi' => $mmsi));
927 998
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
928
-		if (isset($result[0])) return $result[0];
929
-		else return array();
999
+		if (isset($result[0])) {
1000
+			return $result[0];
1001
+		} else {
1002
+			return array();
1003
+		}
930 1004
 	}
931 1005
 
932 1006
 	/**
@@ -967,7 +1041,9 @@  discard block
 block discarded – undo
967 1041
 			date_default_timezone_set($globalTimezone);
968 1042
 			$datetime = new DateTime();
969 1043
 			$offset = $datetime->format('P');
970
-		} else $offset = '+00:00';
1044
+		} else {
1045
+			$offset = '+00:00';
1046
+		}
971 1047
 
972 1048
 		if ($globalDBdriver == 'mysql') {
973 1049
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -1074,8 +1150,12 @@  discard block
 block discarded – undo
1074 1150
 	*/	
1075 1151
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1076 1152
 	{
1077
-		if ($latitude == '') $latitude = NULL;
1078
-		if ($longitude == '') $longitude = NULL;
1153
+		if ($latitude == '') {
1154
+			$latitude = NULL;
1155
+		}
1156
+		if ($longitude == '') {
1157
+			$longitude = NULL;
1158
+		}
1079 1159
 		$groundspeed = round($groundspeed);
1080 1160
 		if ($race_begin != '') {
1081 1161
 			$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status, date = :race_begin WHERE fammarine_id = :fammarine_id';
@@ -1228,14 +1308,28 @@  discard block
 block discarded – undo
1228 1308
 			$latitude = 0;
1229 1309
 			$longitude = 0;
1230 1310
 		}
1231
-		if ($type_id == '') $type_id = NULL;
1232
-		if ($status_id == '') $status_id = NULL;
1233
-		if ($distance == '') $distance = NULL;
1234
-		if ($race_rank == '') $race_rank = NULL;
1235
-		if ($race_time == '') $race_time = NULL;
1236
-		if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1311
+		if ($type_id == '') {
1312
+			$type_id = NULL;
1313
+		}
1314
+		if ($status_id == '') {
1315
+			$status_id = NULL;
1316
+		}
1317
+		if ($distance == '') {
1318
+			$distance = NULL;
1319
+		}
1320
+		if ($race_rank == '') {
1321
+			$race_rank = NULL;
1322
+		}
1323
+		if ($race_time == '') {
1324
+			$race_time = NULL;
1325
+		}
1326
+		if ($heading == '' || $Common->isInteger($heading) === false) {
1327
+			$heading = 0;
1328
+		}
1237 1329
 		//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1238
-		if ($arrival_date == '') $arrival_date = NULL;
1330
+		if ($arrival_date == '') {
1331
+			$arrival_date = NULL;
1332
+		}
1239 1333
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) 
1240 1334
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)";
1241 1335
 
@@ -1342,7 +1436,9 @@  discard block
 block discarded – undo
1342 1436
 		global $globalDBdriver, $globalArchive;
1343 1437
 		//$filter_query = $this->getFilter($filters,true,true);
1344 1438
 		$Connection= new Connection($this->db);
1345
-		if (!$Connection->tableExists('countries')) return array();
1439
+		if (!$Connection->tableExists('countries')) {
1440
+			return array();
1441
+		}
1346 1442
 		require_once('class.SpotterLive.php');
1347 1443
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
1348 1444
 			$MarineLive = new MarineLive($this->db);
@@ -1386,7 +1482,9 @@  discard block
 block discarded – undo
1386 1482
 			$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 ";
1387 1483
 		}
1388 1484
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
1389
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1485
+		if ($limit) {
1486
+			$query .= " LIMIT 10 OFFSET 0";
1487
+		}
1390 1488
 
1391 1489
 		$sth = $this->db->prepare($query);
1392 1490
 		$sth->execute();
@@ -1420,12 +1518,18 @@  discard block
 block discarded – undo
1420 1518
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1421 1519
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
1422 1520
 		 if ($olderthanmonths > 0) {
1423
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
1424
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1521
+			if ($globalDBdriver == 'mysql') {
1522
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
1523
+			} else {
1524
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1525
+			}
1425 1526
 		}
1426 1527
 		if ($sincedate != '') {
1427
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
1428
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1528
+			if ($globalDBdriver == 'mysql') {
1529
+				$query .= " AND marine_output.date > '".$sincedate."'";
1530
+			} else {
1531
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1532
+			}
1429 1533
 		}
1430 1534
 		$query_values = array();
1431 1535
 		if ($year != '') {
@@ -1456,7 +1560,9 @@  discard block
 block discarded – undo
1456 1560
 			}
1457 1561
 		}
1458 1562
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
1459
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1563
+		if ($limit) {
1564
+			$query .= " LIMIT 10 OFFSET 0";
1565
+		}
1460 1566
       		
1461 1567
 		$sth = $this->db->prepare($query);
1462 1568
 		$sth->execute($query_values);
@@ -1491,7 +1597,9 @@  discard block
 block discarded – undo
1491 1597
 			date_default_timezone_set($globalTimezone);
1492 1598
 			$datetime = new DateTime();
1493 1599
 			$offset = $datetime->format('P');
1494
-		} else $offset = '+00:00';
1600
+		} else {
1601
+			$offset = '+00:00';
1602
+		}
1495 1603
 
1496 1604
 		if ($globalDBdriver == 'mysql') {
1497 1605
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1541,7 +1649,9 @@  discard block
 block discarded – undo
1541 1649
 			date_default_timezone_set($globalTimezone);
1542 1650
 			$datetime = new DateTime();
1543 1651
 			$offset = $datetime->format('P');
1544
-		} else $offset = '+00:00';
1652
+		} else {
1653
+			$offset = '+00:00';
1654
+		}
1545 1655
 		$filter_query = $this->getFilter($filters,true,true);
1546 1656
 		if ($globalDBdriver == 'mysql') {
1547 1657
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1587,7 +1697,9 @@  discard block
 block discarded – undo
1587 1697
 			date_default_timezone_set($globalTimezone);
1588 1698
 			$datetime = new DateTime();
1589 1699
 			$offset = $datetime->format('P');
1590
-		} else $offset = '+00:00';
1700
+		} else {
1701
+			$offset = '+00:00';
1702
+		}
1591 1703
 		$filter_query = $this->getFilter($filters,true,true);
1592 1704
 		if ($globalDBdriver == 'mysql') {
1593 1705
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1635,7 +1747,9 @@  discard block
 block discarded – undo
1635 1747
 			date_default_timezone_set($globalTimezone);
1636 1748
 			$datetime = new DateTime();
1637 1749
 			$offset = $datetime->format('P');
1638
-		} else $offset = '+00:00';
1750
+		} else {
1751
+			$offset = '+00:00';
1752
+		}
1639 1753
 
1640 1754
 		if ($globalDBdriver == 'mysql') {
1641 1755
 			$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
@@ -1684,7 +1798,9 @@  discard block
 block discarded – undo
1684 1798
 			date_default_timezone_set($globalTimezone);
1685 1799
 			$datetime = new DateTime();
1686 1800
 			$offset = $datetime->format('P');
1687
-		} else $offset = '+00:00';
1801
+		} else {
1802
+			$offset = '+00:00';
1803
+		}
1688 1804
 		$filter_query = $this->getFilter($filters,true,true);
1689 1805
 		if ($globalDBdriver == 'mysql') {
1690 1806
 			$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
@@ -1733,7 +1849,9 @@  discard block
 block discarded – undo
1733 1849
 			date_default_timezone_set($globalTimezone);
1734 1850
 			$datetime = new DateTime();
1735 1851
 			$offset = $datetime->format('P');
1736
-		} else $offset = '+00:00';
1852
+		} else {
1853
+			$offset = '+00:00';
1854
+		}
1737 1855
 
1738 1856
 		$orderby_sql = '';
1739 1857
 		if ($orderby == "hour")
@@ -1802,7 +1920,9 @@  discard block
 block discarded – undo
1802 1920
 			date_default_timezone_set($globalTimezone);
1803 1921
 			$datetime = new DateTime($date);
1804 1922
 			$offset = $datetime->format('P');
1805
-		} else $offset = '+00:00';
1923
+		} else {
1924
+			$offset = '+00:00';
1925
+		}
1806 1926
 
1807 1927
 		if ($globalDBdriver == 'mysql') {
1808 1928
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1850,7 +1970,9 @@  discard block
 block discarded – undo
1850 1970
 			date_default_timezone_set($globalTimezone);
1851 1971
 			$datetime = new DateTime();
1852 1972
 			$offset = $datetime->format('P');
1853
-		} else $offset = '+00:00';
1973
+		} else {
1974
+			$offset = '+00:00';
1975
+		}
1854 1976
 
1855 1977
 		if ($globalDBdriver == 'mysql') {
1856 1978
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1909,7 +2031,9 @@  discard block
 block discarded – undo
1909 2031
 			}
1910 2032
 		}
1911 2033
 		$query .= " GROUP BY marine_output.race_id,marine_output.race_name ORDER BY captain_count DESC";
1912
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
2034
+		if ($limit) {
2035
+			$query .= " LIMIT 10 OFFSET 0";
2036
+		}
1913 2037
 		$sth = $this->db->prepare($query);
1914 2038
 		$sth->execute();
1915 2039
 		$marine_array = array();
@@ -1956,8 +2080,11 @@  discard block
 block discarded – undo
1956 2080
 				$query_values = array_merge($query_values,array(':month' => $month));
1957 2081
 			}
1958 2082
 		}
1959
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1960
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2083
+		if (empty($query_values)) {
2084
+			$queryi .= $this->getFilter($filters);
2085
+		} else {
2086
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
2087
+		}
1961 2088
 		
1962 2089
 		$sth = $this->db->prepare($queryi);
1963 2090
 		$sth->execute($query_values);
@@ -1994,8 +2121,11 @@  discard block
 block discarded – undo
1994 2121
 				$query_values = array_merge($query_values,array(':month' => $month));
1995 2122
 			}
1996 2123
 		}
1997
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1998
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2124
+		if (empty($query_values)) {
2125
+			$queryi .= $this->getFilter($filters);
2126
+		} else {
2127
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
2128
+		}
1999 2129
 		
2000 2130
 		$sth = $this->db->prepare($queryi);
2001 2131
 		$sth->execute($query_values);
@@ -2032,8 +2162,11 @@  discard block
 block discarded – undo
2032 2162
 				$query_values = array_merge($query_values,array(':month' => $month));
2033 2163
 			}
2034 2164
 		}
2035
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2036
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2165
+		if (empty($query_values)) {
2166
+			$queryi .= $this->getFilter($filters);
2167
+		} else {
2168
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
2169
+		}
2037 2170
 		
2038 2171
 		$sth = $this->db->prepare($queryi);
2039 2172
 		$sth->execute($query_values);
@@ -2070,8 +2203,11 @@  discard block
 block discarded – undo
2070 2203
 				$query_values = array_merge($query_values,array(':month' => $month));
2071 2204
 			}
2072 2205
 		}
2073
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2074
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2206
+		if (empty($query_values)) {
2207
+			$queryi .= $this->getFilter($filters);
2208
+		} else {
2209
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
2210
+		}
2075 2211
 		
2076 2212
 		$sth = $this->db->prepare($queryi);
2077 2213
 		$sth->execute($query_values);
@@ -2092,7 +2228,9 @@  discard block
 block discarded – undo
2092 2228
 			date_default_timezone_set($globalTimezone);
2093 2229
 			$datetime = new DateTime();
2094 2230
 			$offset = $datetime->format('P');
2095
-		} else $offset = '+00:00';
2231
+		} else {
2232
+			$offset = '+00:00';
2233
+		}
2096 2234
 
2097 2235
 		if ($globalDBdriver == 'mysql') {
2098 2236
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -2196,7 +2334,9 @@  discard block
 block discarded – undo
2196 2334
 	*/
2197 2335
 	public function parseDirection($direction = 0)
2198 2336
 	{
2199
-		if ($direction == '') $direction = 0;
2337
+		if ($direction == '') {
2338
+			$direction = 0;
2339
+		}
2200 2340
 		$direction_array = array();
2201 2341
 		$temp_array = array();
2202 2342
 
@@ -2285,7 +2425,9 @@  discard block
 block discarded – undo
2285 2425
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2286 2426
 	
2287 2427
 		$Connection = new Connection($this->db);
2288
-		if (!$Connection->tableExists('countries')) return '';
2428
+		if (!$Connection->tableExists('countries')) {
2429
+			return '';
2430
+		}
2289 2431
 	
2290 2432
 		try {
2291 2433
 			/*
@@ -2305,9 +2447,13 @@  discard block
 block discarded – undo
2305 2447
 			$sth->closeCursor();
2306 2448
 			if (count($row) > 0) {
2307 2449
 				return $row;
2308
-			} else return '';
2450
+			} else {
2451
+				return '';
2452
+			}
2309 2453
 		} catch (PDOException $e) {
2310
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
2454
+			if (isset($globalDebug) && $globalDebug) {
2455
+				echo 'Error : '.$e->getMessage()."\n";
2456
+			}
2311 2457
 			return '';
2312 2458
 		}
2313 2459
 	
@@ -2325,7 +2471,9 @@  discard block
 block discarded – undo
2325 2471
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
2326 2472
 	
2327 2473
 		$Connection = new Connection($this->db);
2328
-		if (!$Connection->tableExists('countries')) return '';
2474
+		if (!$Connection->tableExists('countries')) {
2475
+			return '';
2476
+		}
2329 2477
 	
2330 2478
 		try {
2331 2479
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -2337,9 +2485,13 @@  discard block
 block discarded – undo
2337 2485
 			$sth->closeCursor();
2338 2486
 			if (count($row) > 0) {
2339 2487
 				return $row;
2340
-			} else return '';
2488
+			} else {
2489
+				return '';
2490
+			}
2341 2491
 		} catch (PDOException $e) {
2342
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
2492
+			if (isset($globalDebug) && $globalDebug) {
2493
+				echo 'Error : '.$e->getMessage()."\n";
2494
+			}
2343 2495
 			return '';
2344 2496
 		}
2345 2497
 	
@@ -2357,7 +2509,9 @@  discard block
 block discarded – undo
2357 2509
 	{
2358 2510
 		global $globalBitlyAccessToken;
2359 2511
 		
2360
-		if ($globalBitlyAccessToken == '') return $url;
2512
+		if ($globalBitlyAccessToken == '') {
2513
+			return $url;
2514
+		}
2361 2515
         
2362 2516
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
2363 2517
 		
@@ -2433,7 +2587,9 @@  discard block
 block discarded – undo
2433 2587
 			}
2434 2588
 		}
2435 2589
 		$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC";
2436
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
2590
+		if ($limit) {
2591
+			$query .= " LIMIT 10 OFFSET 0";
2592
+		}
2437 2593
 		$sth = $this->db->prepare($query);
2438 2594
 		$sth->execute($query_values);
2439 2595
 		$marine_array = array();
@@ -2471,13 +2627,27 @@  discard block
 block discarded – undo
2471 2627
 				foreach ($q_array as $q_item){
2472 2628
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
2473 2629
 					$additional_query .= " AND (";
2474
-					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2475
-					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
2476
-					if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2477
-					if (is_int($q_item)) $additional_query .= "(marine_output.captain_id = '".$q_item."') OR ";
2478
-					if (is_int($q_item)) $additional_query .= "(marine_output.race_id = '".$q_item."') OR ";
2479
-					if (!is_int($q_item)) $additional_query .= "(marine_output.captain_name = '".$q_item."') OR ";
2480
-					if (!is_int($q_item)) $additional_query .= "(marine_output.race_name = '".$q_item."') OR ";
2630
+					if (is_int($q_item)) {
2631
+						$additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2632
+					}
2633
+					if (is_int($q_item)) {
2634
+						$additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
2635
+					}
2636
+					if (is_int($q_item)) {
2637
+						$additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2638
+					}
2639
+					if (is_int($q_item)) {
2640
+						$additional_query .= "(marine_output.captain_id = '".$q_item."') OR ";
2641
+					}
2642
+					if (is_int($q_item)) {
2643
+						$additional_query .= "(marine_output.race_id = '".$q_item."') OR ";
2644
+					}
2645
+					if (!is_int($q_item)) {
2646
+						$additional_query .= "(marine_output.captain_name = '".$q_item."') OR ";
2647
+					}
2648
+					if (!is_int($q_item)) {
2649
+						$additional_query .= "(marine_output.race_name = '".$q_item."') OR ";
2650
+					}
2481 2651
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
2482 2652
 					$additional_query .= ")";
2483 2653
 				}
@@ -2569,7 +2739,9 @@  discard block
 block discarded – undo
2569 2739
 				date_default_timezone_set($globalTimezone);
2570 2740
 				$datetime = new DateTime();
2571 2741
 				$offset = $datetime->format('P');
2572
-			} else $offset = '+00:00';
2742
+			} else {
2743
+				$offset = '+00:00';
2744
+			}
2573 2745
 			if ($date_array[1] != "")
2574 2746
 			{
2575 2747
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -2596,8 +2768,12 @@  discard block
 block discarded – undo
2596 2768
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
2597 2769
 			{
2598 2770
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
2599
-			} else $limit_query = "";
2600
-		} else $limit_query = "";
2771
+			} else {
2772
+				$limit_query = "";
2773
+			}
2774
+		} else {
2775
+			$limit_query = "";
2776
+		}
2601 2777
 		if ($sort != "")
2602 2778
 		{
2603 2779
 			$search_orderby_array = $this->getOrderBy();
@@ -2663,8 +2839,11 @@  discard block
 block discarded – undo
2663 2839
 		$sth = $this->db->prepare($query);
2664 2840
 		$sth->execute(array(':race_name' => $race_name));
2665 2841
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2666
-		if (isset($result[0])) return $result[0];
2667
-		else return array();
2842
+		if (isset($result[0])) {
2843
+			return $result[0];
2844
+		} else {
2845
+			return array();
2846
+		}
2668 2847
 	}
2669 2848
 
2670 2849
 	/**
@@ -2680,8 +2859,11 @@  discard block
 block discarded – undo
2680 2859
 		$sth = $this->db->prepare($query);
2681 2860
 		$sth->execute(array(':race_id' => $race_id));
2682 2861
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2683
-		if (isset($result[0])) return $result[0];
2684
-		else return array();
2862
+		if (isset($result[0])) {
2863
+			return $result[0];
2864
+		} else {
2865
+			return array();
2866
+		}
2685 2867
 	}
2686 2868
 
2687 2869
 	/**
Please login to merge, or discard this patch.
search.php 1 patch
Braces   +158 added lines, -43 removed lines patch added patch discarded remove patch
@@ -46,8 +46,10 @@  discard block
 block discarded – undo
46 46
 			$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
47 47
 			$sql_date = $end_date;
48 48
 		}
49
-	} else $sql_date = '';
50
-}
49
+	} else {
50
+		$sql_date = '';
51
+	}
52
+	}
51 53
 
52 54
 if (isset($_GET['highest_altitude'])) {
53 55
 	//for altitude manipulation
@@ -61,8 +63,12 @@  discard block
 block discarded – undo
61 63
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
62 64
 		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
63 65
 		$sql_altitude = $start_altitude;
64
-	} else $sql_altitude = '';
65
-} else $sql_altitude = '';
66
+	} else {
67
+		$sql_altitude = '';
68
+	}
69
+	} else {
70
+	$sql_altitude = '';
71
+}
66 72
 
67 73
 //calculuation for the pagination
68 74
 if(!isset($_GET['limit']))
@@ -80,7 +86,7 @@  discard block
 block discarded – undo
80 86
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
81 87
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
82 88
 	}
83
-}  else {
89
+} else {
84 90
 	$limit_explode = explode(",", $_GET['limit']);
85 91
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
86 92
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -146,10 +152,15 @@  discard block
 block discarded – undo
146 152
 	$dist = filter_input(INPUT_GET,'dist',FILTER_SANITIZE_NUMBER_INT);
147 153
 	$number_results = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
148 154
 	if ($dist != '') {
149
-		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') $dist = $dist*1.60934;
150
-		elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') $dist = $dist*1.852;
155
+		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') {
156
+			$dist = $dist*1.60934;
157
+		} elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') {
158
+			$dist = $dist*1.852;
159
+		}
160
+	}
161
+	if (!isset($sql_date)) {
162
+		$sql_date = '';
151 163
 	}
152
-	if (!isset($sql_date)) $sql_date = '';
153 164
 	if ($archive == 1) {
154 165
 		if ($type == 'aircraft') {
155 166
 			$SpotterArchive = new SpotterArchive();
@@ -227,7 +238,10 @@  discard block
 block discarded – undo
227 238
 		if (isset($_GET['aircraft']) && $_GET['aircraft'] != ""){ print _("Aircraft:").' <span>'.$aircraft.'</span> '; }
228 239
 		if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != ""){ print _("Manufacturer:").' <span>'.$manufacturer.'</span> '; }
229 240
 		if (isset($_GET['registration']) && $_GET['registration'] != ""){ print _("Registration:").' <span>'.$registration.'</span> '; }
230
-		if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> '; }
241
+		if (isset($_GET['highlights'])) {
242
+			if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> ';
243
+		}
244
+		}
231 245
 		if (isset($_GET['airline']) && $_GET['airline'] != ""){ print _("Airline:").' <span>'.$airline.'</span> '; }
232 246
 		if (isset($_GET['airline_country']) && $_GET['airline_country'] != ""){ print _("Airline country:").' <span>'.$airline_country.'</span> '; }
233 247
 		if (isset($_GET['airline_type']) && $_GET['airline_type'] != ""){ print _("Airline type:").' <span>'.$airline_type.'</span> '; }
@@ -367,7 +381,10 @@  discard block
 block discarded – undo
367 381
 			<div class="form-group">
368 382
 				<label class="control-label col-sm-2"><?php echo _("Keywords"); ?></label>
369 383
 				<div class="col-sm-10">
370
-					<input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) print $q; ?>" size="10" placeholder="<?php echo _("Keywords"); ?>" />
384
+					<input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) {
385
+	print $q;
386
+}
387
+?>" size="10" placeholder="<?php echo _("Keywords"); ?>" />
371 388
 				</div>
372 389
 			</div>
373 390
 		</fieldset>
@@ -386,7 +403,10 @@  discard block
 block discarded – undo
386 403
 					    </select>
387 404
 					</div>
388 405
 				</div>
389
-				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) print $manufacturer; ?>')</script>
406
+				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) {
407
+	print $manufacturer;
408
+}
409
+?>')</script>
390 410
 				<div class="form-group">
391 411
 					<label class="control-label col-sm-2"><?php echo _("Type"); ?></label>
392 412
 						<div class="col-sm-10">
@@ -395,11 +415,17 @@  discard block
 block discarded – undo
395 415
 							</select>
396 416
 						</div>
397 417
 				</div>
398
-				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) print $aircraft_icao; ?>');</script>
418
+				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) {
419
+	print $aircraft_icao;
420
+}
421
+?>');</script>
399 422
 				<div class="form-group">
400 423
 					<label class="control-label col-sm-2"><?php echo _("Registration"); ?></label> 
401 424
 					<div class="col-sm-10">
402
-						<input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) print $registration; ?>" size="8" placeholder="<?php echo _("Registration"); ?>" />
425
+						<input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) {
426
+	print $registration;
427
+}
428
+?>" size="8" placeholder="<?php echo _("Registration"); ?>" />
403 429
 					</div>
404 430
 				</div>
405 431
 <?php
@@ -408,22 +434,31 @@  discard block
 block discarded – undo
408 434
 				<div class="form-group">
409 435
 					<label class="control-label col-sm-2"><?php echo _("Pilot id"); ?></label> 
410 436
 					<div class="col-sm-10">
411
-						<input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) print $pilot_id; ?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" />
437
+						<input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) {
438
+	print $pilot_id;
439
+}
440
+?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" />
412 441
 					</div>
413 442
 				</div>
414 443
 				<div class="form-group">
415 444
 					<label class="control-label col-sm-2"><?php echo _("Pilot name"); ?></label> 
416 445
 					<div class="col-sm-10">
417
-						<input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) print $pilot_name; ?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" />
446
+						<input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) {
447
+	print $pilot_name;
448
+}
449
+?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" />
418 450
 					</div>
419 451
 				</div>
420 452
 <?php
421
-	}else {
453
+	} else {
422 454
 ?>
423 455
 				<div class="form-group">
424 456
 					<label class="control-label col-sm-2"><?php echo _("Owner name"); ?></label> 
425 457
 					<div class="col-sm-10">
426
-						<input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) print $owner; ?>" size="15" placeholder="<?php echo _("Owner name"); ?>" />
458
+						<input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) {
459
+	print $owner;
460
+}
461
+?>" size="15" placeholder="<?php echo _("Owner name"); ?>" />
427 462
 					</div>
428 463
 				</div>
429 464
 <?php
@@ -431,8 +466,14 @@  discard block
 block discarded – undo
431 466
 ?>
432 467
 				<div class="form-group">
433 468
 					<div class="col-sm-offset-2 col-sm-10">
434
-					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
435
-					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label>
469
+					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) {
470
+	if ($_GET['highlights'] == "true"){ print 'checked="checked"';
471
+}
472
+} ?>> <label for="highlights"><?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
473
+					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) {
474
+	if ($_GET['highlights'] == "true"){ print 'checked="checked"';
475
+}
476
+} ?>> <?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label>
436 477
 					</div>
437 478
 				</div>
438 479
 			</fieldset>
@@ -446,7 +487,10 @@  discard block
 block discarded – undo
446 487
 						</select>
447 488
 					</div>
448 489
 				</div>
449
-				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) print $airline; ?>');</script>
490
+				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) {
491
+	print $airline;
492
+}
493
+?>');</script>
450 494
 				<div class="form-group">
451 495
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
452 496
 					<div class="col-sm-10">
@@ -455,19 +499,34 @@  discard block
 block discarded – undo
455 499
 						</select>
456 500
 					</div>
457 501
 				</div>
458
-				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) print $airline_country; ?>');</script>
502
+				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) {
503
+	print $airline_country;
504
+}
505
+?>');</script>
459 506
 				<div class="form-group">
460 507
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
461 508
 					<div class="col-sm-10">
462
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
509
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
510
+	print $callsign;
511
+}
512
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
463 513
 					</div>
464 514
 				</div>
465 515
 				<div class="form-group">
466 516
 					<div class="col-sm-offset-2 col-sm-10">
467 517
 						<label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all"){ print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label>
468
-						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label>
469
-						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label>
470
-						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label>
518
+						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) {
519
+	if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"';
520
+}
521
+} ?>> <?php echo _("Only Passenger airlines"); ?></label>
522
+						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) {
523
+	if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"';
524
+}
525
+} ?>> <?php echo _("Only Cargo airlines"); ?></label>
526
+						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) {
527
+	if ( $_GET['airline_type'] == "military"){ print 'checked="checked"';
528
+}
529
+} ?>> <?php echo _("Only Military airlines"); ?></label>
471 530
 					</div>
472 531
 				</div>
473 532
 			</fieldset>
@@ -481,7 +540,10 @@  discard block
 block discarded – undo
481 540
 						</select>
482 541
 					</div>
483 542
 				</div>
484
-				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) print $airport_icao; ?>');</script>
543
+				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) {
544
+	print $airport_icao;
545
+}
546
+?>');</script>
485 547
 				<div class="form-group">
486 548
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
487 549
 					<div class="col-sm-10">
@@ -490,7 +552,10 @@  discard block
 block discarded – undo
490 552
 						</select>
491 553
 					</div>
492 554
 				</div>
493
-				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) print $airport_country; ?>');</script>
555
+				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) {
556
+	print $airport_country;
557
+}
558
+?>');</script>
494 559
 			</fieldset>
495 560
 			<fieldset>
496 561
 				<legend><?php echo _("Route"); ?></legend>
@@ -502,7 +567,10 @@  discard block
 block discarded – undo
502 567
 						</select>
503 568
 					</div>
504 569
 				</div>
505
-				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) print $departure_airport_route; ?>');</script>
570
+				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) {
571
+	print $departure_airport_route;
572
+}
573
+?>');</script>
506 574
 				<div class="form-group">
507 575
 					<label class="control-label col-sm-2"><?php echo _("Arrival Airport"); ?></label> 
508 576
 					<div class="col-sm-10">
@@ -511,7 +579,10 @@  discard block
 block discarded – undo
511 579
 						</select>
512 580
 					</div>
513 581
 				</div>
514
-				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) print $arrival_airport_route; ?>');</script>
582
+				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) {
583
+	print $arrival_airport_route;
584
+}
585
+?>');</script>
515 586
 			</fieldset>
516 587
 			<fieldset>
517 588
 				<legend>Altitude</legend>
@@ -561,19 +632,33 @@  discard block
 block discarded – undo
561 632
 				<div class="form-group">
562 633
 					<label class="control-label col-sm-2"><?php echo _("Latitude"); ?></label>
563 634
 					<div class="col-sm-10">
564
-						<input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) print $origlat; ?>" />
635
+						<input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) {
636
+	print $origlat;
637
+}
638
+?>" />
565 639
 					</div>
566 640
 				</div>
567 641
 				<div class="form-group">
568 642
 					<label class="control-label col-sm-2"><?php echo _("Longitude"); ?></label>
569 643
 					<div class="col-sm-10">
570
-						<input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) print $origlon; ?>" />
644
+						<input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) {
645
+	print $origlon;
646
+}
647
+?>" />
571 648
 					</div>
572 649
 				</div>
573 650
 				<div class="form-group">
574
-					<label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) print $globalDistanceUnit; else print 'km'; print ')'; ?></label>
651
+					<label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) {
652
+	print $globalDistanceUnit;
653
+} else {
654
+	print 'km';
655
+}
656
+print ')'; ?></label>
575 657
 					<div class="col-sm-10">
576
-						<input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) print $distance; ?>" />
658
+						<input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) {
659
+	print $distance;
660
+}
661
+?>" />
577 662
 					</div>
578 663
 				</div>
579 664
 			</fieldset>
@@ -584,7 +669,10 @@  discard block
 block discarded – undo
584 669
 				<div class="form-group">
585 670
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
586 671
 					<div class="col-sm-10">
587
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
672
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
673
+	print $callsign;
674
+}
675
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
588 676
 					</div>
589 677
 				</div>
590 678
 			</fieldset>
@@ -595,7 +683,10 @@  discard block
 block discarded – undo
595 683
 				<div class="form-group">
596 684
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
597 685
 					<div class="col-sm-10">
598
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
686
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
687
+	print $callsign;
688
+}
689
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
599 690
 					</div>
600 691
 				</div>
601 692
 			</fieldset>
@@ -606,7 +697,10 @@  discard block
 block discarded – undo
606 697
 				<div class="form-group">
607 698
 					<label class="control-label col-sm-2"><?php echo _("Captain id"); ?></label> 
608 699
 					<div class="col-sm-10">
609
-						<input type="text" name="captain_id" class="form-control" value="<?php if (isset($_GET['captain_id'])) print $captain_id; ?>" size="8" placeholder="<?php echo _("Captain id"); ?>" />
700
+						<input type="text" name="captain_id" class="form-control" value="<?php if (isset($_GET['captain_id'])) {
701
+	print $captain_id;
702
+}
703
+?>" size="8" placeholder="<?php echo _("Captain id"); ?>" />
610 704
 					</div>
611 705
 				</div>
612 706
 			</fieldset>
@@ -614,7 +708,10 @@  discard block
 block discarded – undo
614 708
 				<div class="form-group">
615 709
 					<label class="control-label col-sm-2"><?php echo _("Captain name"); ?></label> 
616 710
 					<div class="col-sm-10">
617
-						<input type="text" name="captain_name" class="form-control" value="<?php if (isset($_GET['captain_name'])) print $captain_name; ?>" size="8" placeholder="<?php echo _("Captain name"); ?>" />
711
+						<input type="text" name="captain_name" class="form-control" value="<?php if (isset($_GET['captain_name'])) {
712
+	print $captain_name;
713
+}
714
+?>" size="8" placeholder="<?php echo _("Captain name"); ?>" />
618 715
 					</div>
619 716
 				</div>
620 717
 			</fieldset>
@@ -622,7 +719,10 @@  discard block
 block discarded – undo
622 719
 				<div class="form-group">
623 720
 					<label class="control-label col-sm-2"><?php echo _("Race id"); ?></label> 
624 721
 					<div class="col-sm-10">
625
-						<input type="text" name="race_id" class="form-control" value="<?php if (isset($_GET['race_id'])) print $race_id; ?>" size="8" placeholder="<?php echo _("Race id"); ?>" />
722
+						<input type="text" name="race_id" class="form-control" value="<?php if (isset($_GET['race_id'])) {
723
+	print $race_id;
724
+}
725
+?>" size="8" placeholder="<?php echo _("Race id"); ?>" />
626 726
 					</div>
627 727
 				</div>
628 728
 			</fieldset>
@@ -630,7 +730,10 @@  discard block
 block discarded – undo
630 730
 				<div class="form-group">
631 731
 					<label class="control-label col-sm-2"><?php echo _("Race name"); ?></label> 
632 732
 					<div class="col-sm-10">
633
-						<input type="text" name="race_name" class="form-control" value="<?php if (isset($_GET['race_name'])) print $race_name; ?>" size="8" placeholder="<?php echo _("Race name"); ?>" />
733
+						<input type="text" name="race_name" class="form-control" value="<?php if (isset($_GET['race_name'])) {
734
+	print $race_name;
735
+}
736
+?>" size="8" placeholder="<?php echo _("Race name"); ?>" />
634 737
 					</div>
635 738
 				</div>
636 739
 			</fieldset>
@@ -641,7 +744,10 @@  discard block
 block discarded – undo
641 744
 				<div class="form-group">
642 745
 					<label class="control-label col-sm-2"><?php echo _("MMSI"); ?></label> 
643 746
 					<div class="col-sm-10">
644
-						<input type="text" name="mmsi" class="form-control" value="<?php if (isset($_GET['mmsi'])) print $mmsi; ?>" size="8" placeholder="<?php echo _("MMSI"); ?>" />
747
+						<input type="text" name="mmsi" class="form-control" value="<?php if (isset($_GET['mmsi'])) {
748
+	print $mmsi;
749
+}
750
+?>" size="8" placeholder="<?php echo _("MMSI"); ?>" />
645 751
 					</div>
646 752
 				</div>
647 753
 			</fieldset>
@@ -649,7 +755,10 @@  discard block
 block discarded – undo
649 755
 				<div class="form-group">
650 756
 					<label class="control-label col-sm-2"><?php echo _("IMO"); ?></label> 
651 757
 					<div class="col-sm-10">
652
-						<input type="text" name="imo" class="form-control" value="<?php if (isset($_GET['imo'])) print $imo; ?>" size="8" placeholder="<?php echo _("IMO"); ?>" />
758
+						<input type="text" name="imo" class="form-control" value="<?php if (isset($_GET['imo'])) {
759
+	print $imo;
760
+}
761
+?>" size="8" placeholder="<?php echo _("IMO"); ?>" />
653 762
 					</div>
654 763
 				</div>
655 764
 			</fieldset>
@@ -663,7 +772,10 @@  discard block
 block discarded – undo
663 772
 					<label class="control-label col-sm-2"><?php echo _("Start Date"); ?></label>
664 773
 					<div class="col-sm-10">
665 774
 						<div class='input-group date' id='datetimepicker1'>
666
-							<input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date']) && $_GET['start_date'] != '') print $start_date; ?>" placeholder="<?php echo _("Start Date/Time"); ?>" />
775
+							<input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date']) && $_GET['start_date'] != '') {
776
+	print $start_date;
777
+}
778
+?>" placeholder="<?php echo _("Start Date/Time"); ?>" />
667 779
 							<span class="input-group-addon">
668 780
 								<span class="glyphicon glyphicon-calendar"></span>
669 781
 							</span>
@@ -674,7 +786,10 @@  discard block
 block discarded – undo
674 786
 					<label class="control-label col-sm-2"><?php echo _("End Date"); ?></label>
675 787
 					<div class="col-sm-10">
676 788
 						<div class='input-group date' id='datetimepicker2'>
677
-						<input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date']) && $_GET['end_date'] != '') print $end_date; ?>" placeholder="<?php echo _("End Date/Time"); ?>" />
789
+						<input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date']) && $_GET['end_date'] != '') {
790
+	print $end_date;
791
+}
792
+?>" placeholder="<?php echo _("End Date/Time"); ?>" />
678 793
 						<span class="input-group-addon">
679 794
 							<span class="glyphicon glyphicon-calendar"></span>
680 795
 						</span>
Please login to merge, or discard this patch.
live-geojson.php 1 patch
Braces   +361 added lines, -146 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 $tracker = false;
13 13
 $marine = false;
14 14
 $usecoord = false;
15
-if (isset($_GET['test'])) exit();
15
+if (isset($_GET['test'])) {
16
+	exit();
17
+}
16 18
 if (isset($_GET['tracker'])) {
17 19
     $tracker = true;
18 20
 }
@@ -57,29 +59,58 @@  discard block
 block discarded – undo
57 59
 }
58 60
 header('Content-Type: text/javascript');
59 61
 
60
-if (!isset($globalJsonCompress)) $compress = true;
61
-else $compress = $globalJsonCompress;
62
+if (!isset($globalJsonCompress)) {
63
+	$compress = true;
64
+} else {
65
+	$compress = $globalJsonCompress;
66
+}
62 67
 
63 68
 $from_archive = false;
64 69
 $min = true;
65 70
 $allhistory = false;
66 71
 $filter['source'] = array();
67
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
70
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
72
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
73
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
78
-if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT);
72
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
73
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
74
+}
75
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
76
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
77
+}
78
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
79
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
80
+}
81
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
82
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
83
+}
84
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
85
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
86
+}
87
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
88
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
89
+}
90
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') {
91
+	$filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
92
+}
93
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
94
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
95
+}
96
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
97
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
98
+}
99
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
100
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
101
+}
102
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
103
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
104
+}
105
+if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') {
106
+	$filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT);
107
+}
79 108
 
80 109
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
81 110
 	$min = true;
82
-} else $min = false;
111
+} else {
112
+	$min = false;
113
+}
83 114
 
84 115
 $spotter_array = array();
85 116
 
@@ -190,24 +221,38 @@  discard block
 block discarded – undo
190 221
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
191 222
 		}
192 223
 	}
193
-	if ($flightcnt == '') $flightcnt = 0;
194
-} else $flightcnt = 0;
224
+	if ($flightcnt == '') {
225
+		$flightcnt = 0;
226
+	}
227
+	} else {
228
+	$flightcnt = 0;
229
+}
195 230
 
196 231
 $sqltime = round(microtime(true)-$begintime,2);
197 232
 
198 233
 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
199
-if ($currenttime != '') $currenttime = round($currenttime/1000);
234
+if ($currenttime != '') {
235
+	$currenttime = round($currenttime/1000);
236
+}
200 237
 
201
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
202
-else $usenextlatlon = true;
203
-if ($usenextlatlon === false) $currenttime = '';
238
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
239
+	$usenextlatlon = false;
240
+} else {
241
+	$usenextlatlon = true;
242
+}
243
+if ($usenextlatlon === false) {
244
+	$currenttime = '';
245
+}
204 246
 $j = 0;
205 247
 $prev_flightaware_id = '';
206 248
 $aircrafts_shadow = array();
207 249
 $output = '{';
208 250
 	$output .= '"type": "FeatureCollection",';
209
-		if ($min) $output .= '"minimal": "true",';
210
-		else $output .= '"minimal": "false",';
251
+		if ($min) {
252
+			$output .= '"minimal": "true",';
253
+		} else {
254
+			$output .= '"minimal": "false",';
255
+		}
211 256
 		//$output .= '"fc": "'.$flightcnt.'",';
212 257
 		$output .= '"sqt": "'.$sqltime.'",';
213 258
 
@@ -252,18 +297,29 @@  discard block
 block discarded – undo
252 297
 						}
253 298
 						$output .= '"properties": {';
254 299
 						if (isset($spotter_item['flightaware_id'])) {
255
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
256
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
300
+							if ($compress) {
301
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
302
+							} else {
303
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
304
+							}
257 305
 						} elseif (isset($spotter_item['famtrackid'])) {
258
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
259
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
306
+							if ($compress) {
307
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
308
+							} else {
309
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
310
+							}
260 311
 						} elseif (isset($spotter_item['fammarine_id'])) {
261
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
262
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
312
+							if ($compress) {
313
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
314
+							} else {
315
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
316
+							}
263 317
 						}
264 318
 						$output .= '"fc": "'.$flightcnt.'",';
265 319
 						$output .= '"sqt": "'.$sqltime.'",';
266
-						if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
320
+						if (isset($begindate)) {
321
+							$output .= '"archive_date": "'.$begindate.'",';
322
+						}
267 323
 
268 324
 /*
269 325
 							if ($min) $output .= '"minimal": "true",';
@@ -271,16 +327,25 @@  discard block
 block discarded – undo
271 327
 */
272 328
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
273 329
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
274
-							if ($compress) $output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
275
-							else $output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
330
+							if ($compress) {
331
+								$output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
332
+							} else {
333
+								$output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
334
+							}
276 335
 							//'
277 336
 						} else {
278
-							if ($compress) $output .= '"c": "NA",';
279
-							else $output .= '"callsign": "NA",';
337
+							if ($compress) {
338
+								$output .= '"c": "NA",';
339
+							} else {
340
+								$output .= '"callsign": "NA",';
341
+							}
280 342
 						}
281 343
 						if (isset($spotter_item['registration'])) {
282
-							if ($compress) $output .= '"reg": '.json_encode($spotter_item['registration']).',';
283
-							else $output .= '"registration": '.json_encode($spotter_item['registration']).',';
344
+							if ($compress) {
345
+								$output .= '"reg": '.json_encode($spotter_item['registration']).',';
346
+							} else {
347
+								$output .= '"registration": '.json_encode($spotter_item['registration']).',';
348
+							}
284 349
 						}
285 350
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
286 351
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
@@ -291,20 +356,30 @@  discard block
 block discarded – undo
291 356
 							$output .= '"aircraft_name": "NA",';
292 357
 						}
293 358
 						if (isset($spotter_item['aircraft_icao'])) {
294
-							if ($compress) $output .= '"ai": "'.$spotter_item['aircraft_icao'].'",';
295
-							else $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
359
+							if ($compress) {
360
+								$output .= '"ai": "'.$spotter_item['aircraft_icao'].'",';
361
+							} else {
362
+								$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
363
+							}
296 364
 						}
297 365
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker && !$marine) {
298
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
299
-							else {
366
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
367
+								$spotter_item['aircraft_shadow'] = '';
368
+							} else {
300 369
 								$aircraft_icao = $spotter_item['aircraft_icao'];
301
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
302
-								else {
370
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
371
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
372
+								} else {
303 373
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
304
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
305
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
306
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
307
-									else $spotter_item['aircraft_shadow'] = '';
374
+									if (count($aircraft_info) > 0) {
375
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
376
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
377
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
378
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
379
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
380
+									} else {
381
+										$spotter_item['aircraft_shadow'] = '';
382
+									}
308 383
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
309 384
 								}
310 385
 							}
@@ -312,90 +387,171 @@  discard block
 block discarded – undo
312 387
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
313 388
 							if ($tracker) {
314 389
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
315
-									if ($compress) $output .= '"as": "ambulance.png",';
316
-									else $output .= '"aircraft_shadow": "ambulance.png",';
390
+									if ($compress) {
391
+										$output .= '"as": "ambulance.png",';
392
+									} else {
393
+										$output .= '"aircraft_shadow": "ambulance.png",';
394
+									}
317 395
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
318
-									if ($compress) $output .= '"as": "police.png",';
319
-									else $output .= '"aircraft_shadow": "police.png",';
396
+									if ($compress) {
397
+										$output .= '"as": "police.png",';
398
+									} else {
399
+										$output .= '"aircraft_shadow": "police.png",';
400
+									}
320 401
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
321
-									if ($compress) $output .= '"as": "ship.png",';
322
-									else $output .= '"aircraft_shadow": "ship.png",';
402
+									if ($compress) {
403
+										$output .= '"as": "ship.png",';
404
+									} else {
405
+										$output .= '"aircraft_shadow": "ship.png",';
406
+									}
323 407
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
324
-									if ($compress) $output .= '"as": "ship.png",';
325
-									else $output .= '"aircraft_shadow": "ship.png",';
408
+									if ($compress) {
409
+										$output .= '"as": "ship.png",';
410
+									} else {
411
+										$output .= '"aircraft_shadow": "ship.png",';
412
+									}
326 413
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
327
-									if ($compress) $output .= '"as": "ship.png",';
328
-									else $output .= '"aircraft_shadow": "ship.png",';
414
+									if ($compress) {
415
+										$output .= '"as": "ship.png",';
416
+									} else {
417
+										$output .= '"aircraft_shadow": "ship.png",';
418
+									}
329 419
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
330
-									if ($compress) $output .= '"as": "truck.png",';
331
-									else $output .= '"aircraft_shadow": "truck.png",';
420
+									if ($compress) {
421
+										$output .= '"as": "truck.png",';
422
+									} else {
423
+										$output .= '"aircraft_shadow": "truck.png",';
424
+									}
332 425
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
333
-									if ($compress) $output .= '"as": "truck.png",';
334
-									else $output .= '"aircraft_shadow": "truck.png",';
426
+									if ($compress) {
427
+										$output .= '"as": "truck.png",';
428
+									} else {
429
+										$output .= '"aircraft_shadow": "truck.png",';
430
+									}
335 431
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
336
-									if ($compress) $output .= '"as": "aircraft.png",';
337
-									else $output .= '"aircraft_shadow": "aircraft.png",';
432
+									if ($compress) {
433
+										$output .= '"as": "aircraft.png",';
434
+									} else {
435
+										$output .= '"aircraft_shadow": "aircraft.png",';
436
+									}
338 437
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
339
-									if ($compress) $output .= '"as": "aircraft.png",';
340
-									else $output .= '"aircraft_shadow": "aircraft.png",';
438
+									if ($compress) {
439
+										$output .= '"as": "aircraft.png",';
440
+									} else {
441
+										$output .= '"aircraft_shadow": "aircraft.png",';
442
+									}
341 443
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
342
-									if ($compress) $output .= '"as": "helico.png",';
343
-									else $output .= '"aircraft_shadow": "helico.png",';
444
+									if ($compress) {
445
+										$output .= '"as": "helico.png",';
446
+									} else {
447
+										$output .= '"aircraft_shadow": "helico.png",';
448
+									}
344 449
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
345
-									if ($compress) $output .= '"as": "rail.png",';
346
-									else $output .= '"aircraft_shadow": "rail.png",';
450
+									if ($compress) {
451
+										$output .= '"as": "rail.png",';
452
+									} else {
453
+										$output .= '"aircraft_shadow": "rail.png",';
454
+									}
347 455
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
348
-									if ($compress) $output .= '"as": "firetruck.png",';
349
-									else $output .= '"aircraft_shadow": "firetruck.png",';
456
+									if ($compress) {
457
+										$output .= '"as": "firetruck.png",';
458
+									} else {
459
+										$output .= '"aircraft_shadow": "firetruck.png",';
460
+									}
350 461
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
351
-									if ($compress) $output .= '"as": "bus.png",';
352
-									else $output .= '"aircraft_shadow": "bus.png",';
462
+									if ($compress) {
463
+										$output .= '"as": "bus.png",';
464
+									} else {
465
+										$output .= '"aircraft_shadow": "bus.png",';
466
+									}
353 467
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
354
-									if ($compress) $output .= '"as": "phone.png",';
355
-									else $output .= '"aircraft_shadow": "phone.png",';
468
+									if ($compress) {
469
+										$output .= '"as": "phone.png",';
470
+									} else {
471
+										$output .= '"aircraft_shadow": "phone.png",';
472
+									}
356 473
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
357
-									if ($compress) $output .= '"as": "jogger.png",';
358
-									else $output .= '"aircraft_shadow": "jogger.png",';
474
+									if ($compress) {
475
+										$output .= '"as": "jogger.png",';
476
+									} else {
477
+										$output .= '"aircraft_shadow": "jogger.png",';
478
+									}
359 479
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
360
-									if ($compress) $output .= '"as": "bike.png",';
361
-									else $output .= '"aircraft_shadow": "bike.png",';
480
+									if ($compress) {
481
+										$output .= '"as": "bike.png",';
482
+									} else {
483
+										$output .= '"aircraft_shadow": "bike.png",';
484
+									}
362 485
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
363
-									if ($compress) $output .= '"as": "motorcycle.png",';
364
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
486
+									if ($compress) {
487
+										$output .= '"as": "motorcycle.png",';
488
+									} else {
489
+										$output .= '"aircraft_shadow": "motorcycle.png",';
490
+									}
365 491
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
366
-									if ($compress) $output .= '"as": "balloon.png",';
367
-									else $output .= '"aircraft_shadow": "balloon.png",';
492
+									if ($compress) {
493
+										$output .= '"as": "balloon.png",';
494
+									} else {
495
+										$output .= '"aircraft_shadow": "balloon.png",';
496
+									}
368 497
 								} else {
369
-									if ($compress) $output .= '"as": "car.png",';
370
-									else $output .= '"aircraft_shadow": "car.png",';
498
+									if ($compress) {
499
+										$output .= '"as": "car.png",';
500
+									} else {
501
+										$output .= '"aircraft_shadow": "car.png",';
502
+									}
371 503
 								}
372 504
 							} elseif ($marine) {
373 505
 								if (isset($spotter_item['type']) && ($spotter_item['type']  == '50&#39; Performance Cruiser' || $spotter_item['type']  == '50\' Performance Cruiser' || $spotter_item['type'] == 'Sail')) {
374
-									if ($compress) $output .= '"as": "50perfcruiser.png",';
375
-									else $output .= '"aircraft_shadow": "50perfcruiser.png",';
506
+									if ($compress) {
507
+										$output .= '"as": "50perfcruiser.png",';
508
+									} else {
509
+										$output .= '"aircraft_shadow": "50perfcruiser.png",';
510
+									}
376 511
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Sailaway Cruiser 38') {
377
-									if ($compress) $output .= '"as": "cruiser38.png",';
378
-									else $output .= '"aircraft_shadow": "cruiser38.png",';
512
+									if ($compress) {
513
+										$output .= '"as": "cruiser38.png",';
514
+									} else {
515
+										$output .= '"aircraft_shadow": "cruiser38.png",';
516
+									}
379 517
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Mini Transat') {
380
-									if ($compress) $output .= '"as": "transat.png",';
381
-									else $output .= '"aircraft_shadow": "transat.png",';
518
+									if ($compress) {
519
+										$output .= '"as": "transat.png",';
520
+									} else {
521
+										$output .= '"aircraft_shadow": "transat.png",';
522
+									}
382 523
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == '52&#39; Cruising Cat') {
383
-									if ($compress) $output .= '"as": "catamaran.png",';
384
-									else $output .= '"aircraft_shadow": "catamaran.png",';
524
+									if ($compress) {
525
+										$output .= '"as": "catamaran.png",';
526
+									} else {
527
+										$output .= '"aircraft_shadow": "catamaran.png",';
528
+									}
385 529
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Caribbean Rose') {
386
-									if ($compress) $output .= '"as": "carib.png",';
387
-									else $output .= '"aircraft_shadow": "carib.png",';
530
+									if ($compress) {
531
+										$output .= '"as": "carib.png",';
532
+									} else {
533
+										$output .= '"aircraft_shadow": "carib.png",';
534
+									}
388 535
 								} else {
389
-									if ($compress) $output .= '"as": "ship.png",';
390
-									else $output .= '"aircraft_shadow": "ship.png",';
536
+									if ($compress) {
537
+										$output .= '"as": "ship.png",';
538
+									} else {
539
+										$output .= '"aircraft_shadow": "ship.png",';
540
+									}
391 541
 								}
392 542
 							} else {
393
-								if ($compress) $output .= '"as": "default.png",';
394
-								else $output .= '"aircraft_shadow": "default.png",';
543
+								if ($compress) {
544
+									$output .= '"as": "default.png",';
545
+								} else {
546
+									$output .= '"aircraft_shadow": "default.png",';
547
+								}
395 548
 							}
396 549
 						} else {
397
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
398
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
550
+							if ($compress) {
551
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
552
+							} else {
553
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
554
+							}
399 555
 						}
400 556
 						if (isset($spotter_item['airline_name'])) {
401 557
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -403,8 +559,11 @@  discard block
 block discarded – undo
403 559
 							$output .= '"airline_name": "NA",';
404 560
 						}
405 561
 						if (isset($spotter_item['departure_airport'])) {
406
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
407
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
562
+							if ($compress) {
563
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
564
+							} else {
565
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
566
+							}
408 567
 						}
409 568
 						if (isset($spotter_item['departure_airport_city'])) {
410 569
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -416,8 +575,11 @@  discard block
 block discarded – undo
416 575
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
417 576
 						}
418 577
 						if (isset($spotter_item['arrival_airport'])) {
419
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
420
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
578
+							if ($compress) {
579
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
580
+							} else {
581
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
582
+							}
421 583
 						}
422 584
 						if (isset($spotter_item['arrival_airport_city'])) {
423 585
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -436,11 +598,17 @@  discard block
 block discarded – undo
436 598
 						}
437 599
 						
438 600
 						if (isset($spotter_item['real_altitude'])) {
439
-							if ($compress) $output .= '"a": "'.($spotter_item['real_altitude']/100).'",';
440
-							else $output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",';
601
+							if ($compress) {
602
+								$output .= '"a": "'.($spotter_item['real_altitude']/100).'",';
603
+							} else {
604
+								$output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",';
605
+							}
441 606
 						} elseif (isset($spotter_item['altitude'])) {
442
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
443
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
607
+							if ($compress) {
608
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
609
+							} else {
610
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
611
+							}
444 612
 						}
445 613
 						
446 614
 						$heading = $spotter_item['heading'];
@@ -464,19 +632,24 @@  discard block
 block discarded – undo
464 632
 							}
465 633
 						}
466 634
 						
467
-						if ($compress)$output .= '"h": "'.$heading.'",';
468
-						else $output .= '"heading": "'.$heading.'",';
635
+						if ($compress) {
636
+							$output .= '"h": "'.$heading.'",';
637
+						} else {
638
+							$output .= '"heading": "'.$heading.'",';
639
+						}
469 640
 						if ($currenttime != '') {
470 641
 							if (strtotime($spotter_item['date']) < $currenttime) {
471 642
 								if (isset($archivespeed)) {
472 643
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
473 644
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
474
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
475
-									else {
645
+									if (!isset($idistance) || $fdistance < $idistance) {
646
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
647
+									} else {
476 648
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
477 649
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
478
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
479
-										else {
650
+										if (!isset($idistance) || $fdistance < $idistance) {
651
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
652
+										} else {
480 653
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
481 654
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
482 655
 										}
@@ -484,12 +657,14 @@  discard block
 block discarded – undo
484 657
 								} elseif ($usenextlatlon) {
485 658
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
486 659
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
487
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
488
-									else {
660
+									if (!isset($idistance) || $fdistance < $idistance) {
661
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
662
+									} else {
489 663
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
490 664
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
491
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
492
-										else {
665
+										if (!isset($idistance) || $fdistance < $idistance) {
666
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
667
+										} else {
493 668
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
494 669
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
495 670
 										}
@@ -528,7 +703,9 @@  discard block
 block discarded – undo
528 703
 							}
529 704
 						}
530 705
 
531
-						if (!$min) $output .= '"image": "'.$image.'",';
706
+						if (!$min) {
707
+							$output .= '"image": "'.$image.'",';
708
+						}
532 709
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
533 710
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
534 711
 						}
@@ -536,8 +713,11 @@  discard block
 block discarded – undo
536 713
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
537 714
 						}
538 715
 						if (isset($spotter_item['squawk'])) {
539
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
540
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
716
+							if ($compress) {
717
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
718
+							} else {
719
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
720
+							}
541 721
 						}
542 722
 						if (isset($spotter_item['squawk_usage'])) {
543 723
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -568,14 +748,23 @@  discard block
 block discarded – undo
568 748
 						}
569 749
 						// type when not aircraft ?
570 750
 						if (isset($spotter_item['type'])) {
571
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
572
-							else $output .= '"type": "'.$spotter_item['type'].'"';
751
+							if ($compress) {
752
+								$output .= '"t": "'.$spotter_item['type'].'"';
753
+							} else {
754
+								$output .= '"type": "'.$spotter_item['type'].'"';
755
+							}
573 756
 						} elseif ($marine) {
574
-							if ($compress) $output .= '"t": "ship"';
575
-							else $output .= '"type": "ship"';
757
+							if ($compress) {
758
+								$output .= '"t": "ship"';
759
+							} else {
760
+								$output .= '"type": "ship"';
761
+							}
576 762
 						} else {
577
-							if ($compress) $output .= '"t": "aircraft"';
578
-							else $output .= '"type": "aircraft"';
763
+							if ($compress) {
764
+								$output .= '"t": "aircraft"';
765
+							} else {
766
+								$output .= '"type": "aircraft"';
767
+							}
579 768
 						}
580 769
 						$output .= '},';
581 770
 						$output .= '"geometry": {';
@@ -583,15 +772,19 @@  discard block
 block discarded – undo
583 772
 								$output .= '"coordinates": [';
584 773
 								if ($currenttime != '') {
585 774
 									if (strtotime($spotter_item['date']) < $currenttime) {
586
-										if (!isset($archivespeed)) $archivespeed = 1;
775
+										if (!isset($archivespeed)) {
776
+											$archivespeed = 1;
777
+										}
587 778
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
588 779
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
589
-										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
590
-										else {
780
+										if (!isset($idistance) || $fdistance < $idistance) {
781
+											$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
782
+										} else {
591 783
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
592 784
 											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
593
-											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
594
-											else {
785
+											if (!isset($idistance) || $fdistance < $idistance) {
786
+												$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
787
+											} else {
595 788
 												$output .= $spotter_item['longitude'].', ';
596 789
 												$output .= $spotter_item['latitude'];
597 790
 											}
@@ -669,7 +862,9 @@  discard block
 block discarded – undo
669 862
 			}
670 863
 */
671 864
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
672
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
865
+				if ($history == '' && isset($_COOKIE['history'])) {
866
+					$history = $_COOKIE['history'];
867
+				}
673 868
 				
674 869
 				if (
675 870
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -739,8 +934,11 @@  discard block
 block discarded – undo
739 934
 									$output_history .= ']}},';
740 935
 									$output .= $output_history;
741 936
 								}
742
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
743
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
937
+								if ($compress) {
938
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
939
+								} else {
940
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
941
+								}
744 942
 							}
745 943
 							$output_history .= '[';
746 944
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -761,10 +959,15 @@  discard block
 block discarded – undo
761 959
 							if ($d == false) {
762 960
 								if ($compress) {
763 961
 									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",';
764
-									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
765
-									elseif (isset($spotter_history_array[0]['mapmatching_engine'])) $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
962
+									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') {
963
+										$output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
964
+									} elseif (isset($spotter_history_array[0]['mapmatching_engine'])) {
965
+										$output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
966
+									}
766 967
 									$output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": [';
767
-								} else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
968
+								} else {
969
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
970
+								}
768 971
 								$d = true;
769 972
 							}
770 973
 							$output_history .= '[';
@@ -787,7 +990,9 @@  discard block
 block discarded – undo
787 990
 							$output_historyd = '[';
788 991
 							$output_historyd .=  $spotter_item['longitude'].', ';
789 992
 							$output_historyd .=  $spotter_item['latitude'];
790
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
993
+							if (isset($spotter_history['altitude'])) {
994
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
995
+							}
791 996
 							$output_historyd .= '],';
792 997
 							//$output_history = $output_historyd.$output_history;
793 998
 							$output_history = $output_history.$output_historyd;
@@ -815,8 +1020,11 @@  discard block
 block discarded – undo
815 1020
 				        && $spotter_item['arrival_airport'] != 'NA' 
816 1021
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
817 1022
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
818
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
819
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
1023
+				    if ($compress) {
1024
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
1025
+				    } else {
1026
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
1027
+				    }
820 1028
 				    if (isset($spotter_item['departure_airport_latitude'])) {
821 1029
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
822 1030
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -849,8 +1057,11 @@  discard block
 block discarded – undo
849 1057
 				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
850 1058
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
851 1059
 				    $havedata = false;
852
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
853
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1060
+				    if ($compress) {
1061
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1062
+				    } else {
1063
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1064
+				    }
854 1065
 				    
855 1066
 				    //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
856 1067
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -875,7 +1086,9 @@  discard block
 block discarded – undo
875 1086
 					$output_dest  = substr($output_dest, 0, -1);
876 1087
 				    }
877 1088
 				    $output_dest .= ']}},';
878
-				    if ($havedata) $output .= $output_dest;
1089
+				    if ($havedata) {
1090
+				    	$output .= $output_dest;
1091
+				    }
879 1092
 				    unset($output_dest);
880 1093
 				}
881 1094
 			}
@@ -883,7 +1096,9 @@  discard block
 block discarded – undo
883 1096
 			$output .= ']';
884 1097
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
885 1098
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
886
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
1099
+			if (isset($begindate)) {
1100
+				$output .= '"archive_date": "'.$begindate.'",';
1101
+			}
887 1102
 			$output .= '"fc": "'.$j.'"';
888 1103
 		} else {
889 1104
 			$output .= '"features": ';
Please login to merge, or discard this patch.