Completed
Push — master ( c0278b...990a68 )
by Yannick
09:48
created
require/class.SpotterImport.php 1 patch
Braces   +398 added lines, -142 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@  discard block
 block discarded – undo
63 63
 	$dbc = $this->db;
64 64
 	$this->all_flights[$id]['schedule_check'] = true;
65 65
 	if ($globalSchedulesFetch) {
66
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
66
+	if ($globalDebug) {
67
+		echo 'Getting schedule info...'."\n";
68
+	}
67 69
 	$Spotter = new Spotter($dbc);
68 70
 	$Schedule = new Schedule($dbc);
69 71
 	$Translation = new Translation($dbc);
@@ -74,7 +76,9 @@  discard block
 block discarded – undo
74 76
 	    if ($Schedule->checkSchedule($operator) == 0) {
75 77
 		$schedule = $Schedule->fetchSchedule($operator);
76 78
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
79
+		    if ($globalDebug) {
80
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
81
+		    }
78 82
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79 83
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80 84
 		    // Should also check if route schedule = route from DB
@@ -83,7 +87,9 @@  discard block
 block discarded – undo
83 87
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84 88
 			    if (trim($airport_icao) != '') {
85 89
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
86
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
90
+				if ($globalDebug) {
91
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
92
+				}
87 93
 			    }
88 94
 			}
89 95
 		    }
@@ -92,17 +98,25 @@  discard block
 block discarded – undo
92 98
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93 99
 			    if (trim($airport_icao) != '') {
94 100
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
95
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
101
+				if ($globalDebug) {
102
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
103
+				}
96 104
 			    }
97 105
 			}
98 106
 		    }
99 107
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
100 108
 		}
101
-	    } else $scheduleexist = true;
102
-	} else $scheduleexist = true;
109
+	    } else {
110
+	    	$scheduleexist = true;
111
+	    }
112
+	} else {
113
+		$scheduleexist = true;
114
+	}
103 115
 	// close connection, at least one way will work ?
104 116
        if ($scheduleexist) {
105
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
117
+		if ($globalDebug) {
118
+			echo "-> get arrival/departure airport info for ".$ident."\n";
119
+		}
106 120
     		$sch = $Schedule->getSchedule($operator);
107 121
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
108 122
        }
@@ -124,14 +138,18 @@  discard block
 block discarded – undo
124 138
 
125 139
     public function checkAll() {
126 140
 	global $globalDebug, $globalNoImport;
127
-	if ($globalDebug) echo "Update last seen flights data...\n";
141
+	if ($globalDebug) {
142
+		echo "Update last seen flights data...\n";
143
+	}
128 144
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
129 145
 	    foreach ($this->all_flights as $key => $flight) {
130 146
 		if (isset($this->all_flights[$key]['id'])) {
131 147
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 148
     		    $Spotter = new Spotter($this->db);
133 149
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
150
+        	    if (isset($this->all_flights[$key]['altitude'])) {
151
+        	    	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
152
+        	    }
135 153
         	}
136 154
 	    }
137 155
 	}
@@ -139,24 +157,32 @@  discard block
 block discarded – undo
139 157
 
140 158
     public function arrival($key) {
141 159
 	global $globalClosestMinDist, $globalDebug;
142
-	if ($globalDebug) echo 'Update arrival...'."\n";
160
+	if ($globalDebug) {
161
+		echo 'Update arrival...'."\n";
162
+	}
143 163
 	$Spotter = new Spotter($this->db);
144 164
         $airport_icao = '';
145 165
         $airport_time = '';
146
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
166
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
167
+        	$globalClosestMinDist = 50;
168
+        }
147 169
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148 170
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149 171
     	    if (isset($closestAirports[0])) {
150 172
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 173
         	    $airport_icao = $closestAirports[0]['icao'];
152 174
         	    $airport_time = $this->all_flights[$key]['datetime'];
153
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
175
+        	    if ($globalDebug) {
176
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
177
+        	    }
154 178
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155 179
         	    foreach ($closestAirports as $airport) {
156 180
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157 181
         		    $airport_icao = $airport['icao'];
158 182
         		    $airport_time = $this->all_flights[$key]['datetime'];
159
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
183
+        		    if ($globalDebug) {
184
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
185
+        		    }
160 186
         		    break;
161 187
         		}
162 188
         	    }
@@ -164,14 +190,20 @@  discard block
 block discarded – undo
164 190
         		$airport_icao = $closestAirports[0]['icao'];
165 191
         		$airport_time = $this->all_flights[$key]['datetime'];
166 192
         	} else {
167
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
193
+        		if ($globalDebug) {
194
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
195
+        		}
168 196
         	}
169 197
     	    } else {
170
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
198
+    		    if ($globalDebug) {
199
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
200
+    		    }
171 201
     	    }
172 202
 
173 203
         } else {
174
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
204
+        	if ($globalDebug) {
205
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
206
+        	}
175 207
         }
176 208
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177 209
     }
@@ -181,7 +213,9 @@  discard block
 block discarded – undo
181 213
     public function del() {
182 214
 	global $globalDebug, $globalNoImport, $globalNoDB;
183 215
 	// Delete old infos
184
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
216
+	if ($globalDebug) {
217
+		echo 'Delete old values and update latest data...'."\n";
218
+	}
185 219
 	foreach ($this->all_flights as $key => $flight) {
186 220
 	    if (isset($flight['lastupdate'])) {
187 221
 		if ($flight['lastupdate'] < (time()-5900)) {
@@ -195,13 +229,17 @@  discard block
 block discarded – undo
195 229
 	global $globalDebug, $globalNoImport, $globalNoDB;
196 230
 	// Delete old infos
197 231
 	if (isset($this->all_flights[$key]['id'])) {
198
-		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
232
+		if ($globalDebug) {
233
+			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
234
+		}
199 235
 		if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
200 236
 			$real_arrival = $this->arrival($key);
201 237
 			$Spotter = new Spotter($this->db);
202 238
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
203 239
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
204
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
240
+				if ($globalDebug && $result != 'success') {
241
+					echo '!!! ERROR : '.$result."\n";
242
+				}
205 243
 			}
206 244
 		}
207 245
 	}
@@ -211,9 +249,13 @@  discard block
 block discarded – undo
211 249
     public function add($line) {
212 250
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval;
213 251
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
214
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
215
-	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000;
216
-/*
252
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
253
+		$globalCoordMinChange = '0.02';
254
+	}
255
+	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') {
256
+		$globalAircraftMaxUpdate = 3000;
257
+	}
258
+	/*
217 259
 	$Spotter = new Spotter();
218 260
 	$dbc = $Spotter->db;
219 261
 	$SpotterLive = new SpotterLive($dbc);
@@ -235,19 +277,28 @@  discard block
 block discarded – undo
235 277
 	// SBS format is CSV format
236 278
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
237 279
 	    //print_r($line);
238
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
280
+	    if (isset($line['hex'])) {
281
+	    	$line['hex'] = strtoupper($line['hex']);
282
+	    }
239 283
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
240 284
 
241 285
 		// Increment message number
242 286
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
243 287
 		    $current_date = date('Y-m-d');
244
-		    if (isset($line['source_name'])) $source = $line['source_name'];
245
-		    else $source = '';
246
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
288
+		    if (isset($line['source_name'])) {
289
+		    	$source = $line['source_name'];
290
+		    } else {
291
+		    	$source = '';
292
+		    }
293
+		    if ($source == '' || $line['format_source'] == 'aprs') {
294
+		    	$source = $line['format_source'];
295
+		    }
247 296
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
248 297
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
249 298
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
250
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
299
+		    } else {
300
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
301
+		    }
251 302
 		}
252 303
 		
253 304
 		/*
@@ -263,23 +314,38 @@  discard block
 block discarded – undo
263 314
 		//$this->db = $dbc;
264 315
 
265 316
 		//$hex = trim($line['hex']);
266
-	        if (!isset($line['id'])) $id = trim($line['hex']);
267
-	        else $id = trim($line['id']);
317
+	        if (!isset($line['id'])) {
318
+	        	$id = trim($line['hex']);
319
+	        } else {
320
+	        	$id = trim($line['id']);
321
+	        }
268 322
 		
269 323
 		if (!isset($this->all_flights[$id])) {
270
-		    if ($globalDebug) echo 'New flight...'."\n";
324
+		    if ($globalDebug) {
325
+		    	echo 'New flight...'."\n";
326
+		    }
271 327
 		    $this->all_flights[$id] = array();
272 328
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
273 329
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
274
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
330
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
331
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
332
+		    }
275 333
 		    if (!isset($line['id'])) {
276
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
277
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
334
+			if (!isset($globalDaemon)) {
335
+				$globalDaemon = TRUE;
336
+			}
337
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
278 338
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
279
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
339
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
340
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
341
+			}
280 342
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
281
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
282
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
343
+		     } else {
344
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
345
+		     }
346
+		    if ($globalAllFlights !== FALSE) {
347
+		    	$dataFound = true;
348
+		    }
283 349
 		}
284 350
 		if (isset($line['source_type']) && $line['source_type'] != '') {
285 351
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -301,12 +367,20 @@  discard block
 block discarded – undo
301 367
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
302 368
 			    }
303 369
 			    $Spotter->db = null;
304
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
305
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
370
+			    if ($globalDebugTimeElapsed) {
371
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
372
+			    }
373
+			    if ($aircraft_icao != '') {
374
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
375
+			    }
306 376
 			}
307 377
 		    }
308
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
309
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
378
+		    if ($globalAllFlights !== FALSE) {
379
+		    	$dataFound = true;
380
+		    }
381
+		    if ($globalDebug) {
382
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
383
+		    }
310 384
 		}
311 385
 	        if (isset($line['id']) && !isset($line['hex'])) {
312 386
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
@@ -314,7 +388,9 @@  discard block
 block discarded – undo
314 388
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
315 389
 			$icao = $line['aircraft_icao'];
316 390
 			$Spotter = new Spotter($this->db);
317
-			if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
391
+			if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
392
+				$icao = $Spotter->aircraft_correct_icaotype[$icao];
393
+			}
318 394
 			$Spotter->db = null;
319 395
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
320 396
 		}
@@ -324,15 +400,24 @@  discard block
 block discarded – undo
324 400
 				$Spotter = new Spotter($this->db);
325 401
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
326 402
 				$Spotter->db = null;
327
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
403
+				if ($aircraft_icao != '') {
404
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
405
+				}
328 406
 			}
329 407
 		}
330 408
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
331
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
332
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
333
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
334
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
335
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
409
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
410
+				$aircraft_icao = 'GLID';
411
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
412
+				$aircraft_icao = 'UHEL';
413
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
414
+				$aircraft_icao = 'TOWPLANE';
415
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
416
+				$aircraft_icao = 'POWAIRC';
417
+			}
418
+			if (isset($aircraft_icao)) {
419
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
420
+			}
336 421
 		}
337 422
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
338 423
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -342,8 +427,11 @@  discard block
 block discarded – undo
342 427
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
343 428
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
344 429
 		    } else {
345
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
346
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
430
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
431
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
432
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
433
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
434
+				}
347 435
 				/*
348 436
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
349 437
 				print_r($this->all_flights[$id]);
@@ -352,17 +440,23 @@  discard block
 block discarded – undo
352 440
 				return '';
353 441
 		    }
354 442
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
355
-			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
443
+			if ($globalDebug) {
444
+				echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
445
+			}
356 446
 			return '';
357 447
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
358
-			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n
448
+			if ($globalDebug) {
449
+				echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n
359 450
 			";
451
+			}
360 452
 			return '';
361 453
 		} elseif (!isset($line['datetime'])) {
362 454
 			date_default_timezone_set('UTC');
363 455
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
364 456
 		} else {
365
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
457
+			if ($globalDebug) {
458
+				echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
459
+			}
366 460
 			return '';
367 461
 		}
368 462
 
@@ -383,30 +477,48 @@  discard block
 block discarded – undo
383 477
 
384 478
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
385 479
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
386
-				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
480
+				if ($globalDebug) {
481
+					echo '---!!!! New ident, reset aircraft data...'."\n";
482
+				}
387 483
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
388 484
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
389
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
390
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
391
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
485
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
486
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
487
+				} elseif (isset($line['id'])) {
488
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
489
+				} elseif (isset($this->all_flights[$id]['ident'])) {
490
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
491
+				}
392 492
 			} else {
393 493
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
394 494
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
395 495
 				$timeelapsed = microtime(true);
396 496
             			$Spotter = new Spotter($this->db);
397 497
             			$fromsource = NULL;
398
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
399
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
400
-				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
401
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
402
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
498
+            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
499
+            				$fromsource = $globalAirlinesSource;
500
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
501
+            				$fromsource = 'vatsim';
502
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
503
+					$fromsource = 'ivao';
504
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
505
+					$fromsource = 'vatsim';
506
+				} elseif (isset($globalIVAO) && $globalIVAO) {
507
+					$fromsource = 'ivao';
508
+				}
403 509
             			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
404
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
510
+				if ($globalDebug && $result != 'success') {
511
+					echo '!!! ERROR : '.$result."\n";
512
+				}
405 513
 				$Spotter->db = null;
406
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
514
+				if ($globalDebugTimeElapsed) {
515
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
516
+				}
407 517
 			    }
408 518
 			}
409
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
519
+		    } else {
520
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
521
+		    }
410 522
 		    
411 523
 /*
412 524
 		    if (!isset($line['id'])) {
@@ -416,7 +528,9 @@  discard block
 block discarded – undo
416 528
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
417 529
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
418 530
   */
419
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
531
+		    if (!isset($this->all_flights[$id]['id'])) {
532
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
533
+		    }
420 534
 
421 535
 		    //$putinarchive = true;
422 536
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -434,7 +548,9 @@  discard block
 block discarded – undo
434 548
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
435 549
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
436 550
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
437
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
551
+				if ($globalDebugTimeElapsed) {
552
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
553
+				}
438 554
                         }
439 555
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
440 556
 			$timeelapsed = microtime(true);
@@ -448,7 +564,9 @@  discard block
 block discarded – undo
448 564
 				$Translation->db = null;
449 565
 			    }
450 566
 			    $Spotter->db = null;
451
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
567
+			    if ($globalDebugTimeElapsed) {
568
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
569
+			    }
452 570
                     	}
453 571
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
454 572
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -457,9 +575,13 @@  discard block
 block discarded – undo
457 575
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
458 576
 		    	    }
459 577
 			}
460
-			if (!isset($globalFork)) $globalFork = TRUE;
578
+			if (!isset($globalFork)) {
579
+				$globalFork = TRUE;
580
+			}
461 581
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
462
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
582
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
583
+					$this->get_Schedule($id,trim($line['ident']));
584
+				}
463 585
 			}
464 586
 		    }
465 587
 		}
@@ -477,9 +599,13 @@  discard block
 block discarded – undo
477 599
 			$speed = $speed*3.6;
478 600
 			if ($speed < 1000) {
479 601
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
480
-	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
602
+	  			if ($globalDebug) {
603
+	  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
604
+	  			}
481 605
 	  		} else {
482
-	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
606
+	  			if ($globalDebug) {
607
+	  				echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
608
+	  			}
483 609
 	  		}
484 610
 		    }
485 611
 		}
@@ -488,13 +614,21 @@  discard block
 block discarded – undo
488 614
 
489 615
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
490 616
 	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
491
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
617
+	    	    	if ($globalDebug) {
618
+	    	    		echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
619
+	    	    	}
492 620
 	    	    	return false;
493 621
 	    	    }
494
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
495
-	    	    else unset($timediff);
496
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
497
-	    	    else unset($timediff_archive);
622
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
623
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
624
+	    	    } else {
625
+	    	    	unset($timediff);
626
+	    	    }
627
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) {
628
+	    	    	$timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
629
+	    	    } else {
630
+	    	    	unset($timediff_archive);
631
+	    	    }
498 632
 	    	    if ($this->tmd > 5
499 633
 	    	        || (isset($line['format_source']) 
500 634
 	    	    	    && $line['format_source'] == 'airwhere' 
@@ -530,16 +664,25 @@  discard block
 block discarded – undo
530 664
 				$this->all_flights[$id]['putinarchive'] = true;
531 665
 				$this->tmd = 0;
532 666
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
533
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
667
+				    if ($globalDebug) {
668
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
669
+				    }
534 670
 				    $timeelapsed = microtime(true);
535 671
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
536 672
 					$Spotter = new Spotter($this->db);
537 673
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
538
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
539
-					else $this->all_flights[$id]['over_country'] = '';
674
+					if (!empty($all_country)) {
675
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
676
+					} else {
677
+						$this->all_flights[$id]['over_country'] = '';
678
+					}
540 679
 					$Spotter->db = null;
541
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
542
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
680
+					if ($globalDebugTimeElapsed) {
681
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
682
+					}
683
+					if ($globalDebug) {
684
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
685
+					}
543 686
 				    }
544 687
 				}
545 688
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
@@ -585,7 +728,9 @@  discard block
 block discarded – undo
585 728
 			    */
586 729
 			}
587 730
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
588
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
731
+			    if ($line['longitude'] > 180) {
732
+			    	$line['longitude'] = $line['longitude'] - 360;
733
+			    }
589 734
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
590 735
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
591 736
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -622,7 +767,9 @@  discard block
 block discarded – undo
622 767
 		    }
623 768
 		}
624 769
 		if (isset($line['last_update']) && $line['last_update'] != '') {
625
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
770
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
771
+		    	$dataFound = true;
772
+		    }
626 773
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
627 774
 		}
628 775
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -644,53 +791,79 @@  discard block
 block discarded – undo
644 791
 			// Here we force archive of flight because after ground it's a new one (or should be)
645 792
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
646 793
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
647
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
648
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
649
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
794
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
795
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
796
+			} elseif (isset($line['id'])) {
797
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
798
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
799
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
800
+			}
801
+		    }
802
+		    if ($line['ground'] != 1) {
803
+		    	$line['ground'] = 0;
650 804
 		    }
651
-		    if ($line['ground'] != 1) $line['ground'] = 0;
652 805
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
653 806
 		    //$dataFound = true;
654 807
 		}
655 808
 		if (isset($line['squawk']) && $line['squawk'] != '') {
656 809
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
657
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
810
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
811
+			    	$this->all_flights[$id]['putinarchive'] = true;
812
+			    }
658 813
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
659 814
 			    $highlight = '';
660
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
661
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
662
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
815
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
816
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
817
+			    }
818
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
819
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
820
+			    }
821
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
822
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
823
+			    }
663 824
 			    if ($highlight != '') {
664 825
 				$timeelapsed = microtime(true);
665 826
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
666 827
 				    $Spotter = new Spotter($this->db);
667 828
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
668 829
 				    $Spotter->db = null;
669
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
830
+				    if ($globalDebugTimeElapsed) {
831
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
832
+				    }
670 833
 				}
671 834
 				//$putinarchive = true;
672 835
 				//$highlight = '';
673 836
 			    }
674 837
 			    
675
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
838
+		    } else {
839
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
840
+		    }
676 841
 		    //$dataFound = true;
677 842
 		}
678 843
 
679 844
 		if (isset($line['altitude']) && $line['altitude'] != '') {
680 845
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
681
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
846
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
847
+				$this->all_flights[$id]['putinarchive'] = true;
848
+			}
682 849
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
683 850
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
684 851
 			//$dataFound = true;
685 852
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
686 853
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
687 854
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
688
-				if ($globalDebug) echo '--- Reset because of altitude'."\n";
855
+				if ($globalDebug) {
856
+					echo '--- Reset because of altitude'."\n";
857
+				}
689 858
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
690 859
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
691
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
692
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
693
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
860
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
861
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
862
+				} elseif (isset($line['id'])) {
863
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
864
+				} elseif (isset($this->all_flights[$id]['ident'])) {
865
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
866
+				}
694 867
 			}
695 868
 		    }
696 869
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
@@ -701,22 +874,32 @@  discard block
 block discarded – undo
701 874
 		}
702 875
 		
703 876
 		if (isset($line['heading']) && $line['heading'] != '') {
704
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
877
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
878
+		    	$this->all_flights[$id]['putinarchive'] = true;
879
+		    }
705 880
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
706 881
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
707 882
 		    //$dataFound = true;
708 883
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
709 884
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
710 885
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
711
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
712
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
886
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
887
+		    	$this->all_flights[$id]['putinarchive'] = true;
888
+		    }
889
+  		    if ($globalDebug) {
890
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
891
+  		    }
713 892
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
714 893
   		    // If not enough messages and ACARS set heading to 0
715 894
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
716 895
   		}
717
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
718
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
719
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false;
896
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
897
+			$dataFound = false;
898
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
899
+			$dataFound = false;
900
+		} elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) {
901
+			$dataFound = false;
902
+		}
720 903
 
721 904
 //		print_r($this->all_flights[$id]);
722 905
 		//gets the callsign from the last hour
@@ -733,23 +916,38 @@  discard block
 block discarded – undo
733 916
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
734 917
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
735 918
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
736
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
919
+				    if ($globalDebug) {
920
+				    	echo "Check if aircraft is already in DB...";
921
+				    }
737 922
 				    $timeelapsed = microtime(true);
738 923
 				    $SpotterLive = new SpotterLive($this->db);
739 924
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
740 925
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
741
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
926
+					if ($globalDebugTimeElapsed) {
927
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
928
+					}
742 929
 				    } elseif (isset($line['id'])) {
743 930
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
744
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
931
+					if ($globalDebugTimeElapsed) {
932
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
933
+					}
745 934
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
746 935
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
747
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
748
-				    } else $recent_ident = '';
936
+					if ($globalDebugTimeElapsed) {
937
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
938
+					}
939
+				    } else {
940
+				    	$recent_ident = '';
941
+				    }
749 942
 				    $SpotterLive->db=null;
750
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
751
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
752
-				} else $recent_ident = '';
943
+				    if ($globalDebug && $recent_ident == '') {
944
+				    	echo " Not in DB.\n";
945
+				    } elseif ($globalDebug && $recent_ident != '') {
946
+				    	echo " Already in DB.\n";
947
+				    }
948
+				} else {
949
+					$recent_ident = '';
950
+				}
753 951
 			    } else {
754 952
 				$recent_ident = '';
755 953
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -757,7 +955,9 @@  discard block
 block discarded – undo
757 955
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
758 956
 			    if($recent_ident == "")
759 957
 			    {
760
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
958
+				if ($globalDebug) {
959
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
960
+				}
761 961
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
762 962
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
763 963
 				//adds the spotter data for the archive
@@ -801,31 +1001,49 @@  discard block
 block discarded – undo
801 1001
 				
802 1002
 				if (!$ignoreImport) {
803 1003
 				    $highlight = '';
804
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
805
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
806
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
807
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1004
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
1005
+				    	$highlight = 'Squawk 7500 : Hijack';
1006
+				    }
1007
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
1008
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
1009
+				    }
1010
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
1011
+				    	$highlight = 'Squawk 7700 : Emergency';
1012
+				    }
1013
+				    if (!isset($this->all_flights[$id]['id'])) {
1014
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1015
+				    }
808 1016
 				    $timeelapsed = microtime(true);
809 1017
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
810 1018
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
811 1019
 					    $Spotter = new Spotter($this->db);
812 1020
 					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
813 1021
 					    $Spotter->db = null;
814
-					    if ($globalDebug && isset($result)) echo $result."\n";
1022
+					    if ($globalDebug && isset($result)) {
1023
+					    	echo $result."\n";
1024
+					    }
815 1025
 					}
816 1026
 				    }
817
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1027
+				    if ($globalDebugTimeElapsed) {
1028
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1029
+				    }
818 1030
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
819 1031
 
820 1032
 				    // Add source stat in DB
821 1033
 				    $Stats = new Stats($this->db);
822 1034
 				    if (!empty($this->stats)) {
823
-					if ($globalDebug) echo 'Add source stats : ';
1035
+					if ($globalDebug) {
1036
+						echo 'Add source stats : ';
1037
+					}
824 1038
 				        foreach($this->stats as $date => $data) {
825 1039
 					    foreach($data as $source => $sourced) {
826 1040
 					        //print_r($sourced);
827
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
828
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1041
+				    	        if (isset($sourced['polar'])) {
1042
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
1043
+				    	        }
1044
+				    	        if (isset($sourced['hist'])) {
1045
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1046
+				    	        }
829 1047
 				    		if (isset($sourced['msg'])) {
830 1048
 				    		    if (time() - $sourced['msg']['date'] > 10) {
831 1049
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -838,13 +1056,17 @@  discard block
 block discarded – undo
838 1056
 			    			unset($this->stats[$date]);
839 1057
 			    		    }
840 1058
 				    	}
841
-				    	if ($globalDebug) echo 'Done'."\n";
1059
+				    	if ($globalDebug) {
1060
+				    		echo 'Done'."\n";
1061
+				    	}
842 1062
 
843 1063
 				    }
844 1064
 				    $Stats->db = null;
845 1065
 				    }
846 1066
 				    $this->del();
847
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
1067
+				} elseif ($globalDebug) {
1068
+					echo 'Ignore data'."\n";
1069
+				}
848 1070
 				//$ignoreImport = false;
849 1071
 				$this->all_flights[$id]['addedSpotter'] = 1;
850 1072
 				//print_r($this->all_flights[$id]);
@@ -861,7 +1083,9 @@  discard block
 block discarded – undo
861 1083
 			*/
862 1084
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
863 1085
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
864
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
1086
+				    if ($globalDebug) {
1087
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
1088
+				    }
865 1089
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
866 1090
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
867 1091
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -870,7 +1094,9 @@  discard block
 block discarded – undo
870 1094
 					    $SpotterLive->db=null;
871 1095
 					}
872 1096
 				    }
873
-				    if ($globalDebug) echo " Done\n";
1097
+				    if ($globalDebug) {
1098
+				    	echo " Done\n";
1099
+				    }
874 1100
 				    $this->last_delete = time();
875 1101
 				}
876 1102
 			    } else {
@@ -897,11 +1123,17 @@  discard block
 block discarded – undo
897 1123
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
898 1124
 		    if ($globalDebug) {
899 1125
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
900
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
901
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1126
+				if (isset($this->all_flights[$id]['source_name'])) {
1127
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
1128
+				} else {
1129
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1130
+				}
902 1131
 			} else {
903
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
904
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1132
+				if (isset($this->all_flights[$id]['source_name'])) {
1133
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
1134
+				} else {
1135
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1136
+				}
905 1137
 			}
906 1138
 		    }
907 1139
 		    $ignoreImport = false;
@@ -947,22 +1179,30 @@  discard block
 block discarded – undo
947 1179
 
948 1180
 		    if (!$ignoreImport) {
949 1181
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
950
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1182
+				if (!isset($this->all_flights[$id]['id'])) {
1183
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1184
+				}
951 1185
 				$timeelapsed = microtime(true);
952 1186
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
953 1187
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
954
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1188
+					if ($globalDebug) {
1189
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1190
+					}
955 1191
 					$SpotterLive = new SpotterLive($this->db);
956 1192
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
957 1193
 					$SpotterLive->db = null;
958
-					if ($globalDebug) echo $result."\n";
1194
+					if ($globalDebug) {
1195
+						echo $result."\n";
1196
+					}
959 1197
 				    }
960 1198
 				}
961 1199
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
962 1200
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
963 1201
 				}
964 1202
 				$this->all_flights[$id]['putinarchive'] = false;
965
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1203
+				if ($globalDebugTimeElapsed) {
1204
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1205
+				}
966 1206
 
967 1207
 				// Put statistics in $this->stats variable
968 1208
 				//if ($line['format_source'] != 'aprs') {
@@ -970,7 +1210,9 @@  discard block
 block discarded – undo
970 1210
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
971 1211
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
972 1212
 					$source = $this->all_flights[$id]['source_name'];
973
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1213
+					if ($source == '') {
1214
+						$source = $this->all_flights[$id]['format_source'];
1215
+					}
974 1216
 					if (!isset($this->source_location[$source])) {
975 1217
 						$Location = new Source();
976 1218
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -991,7 +1233,9 @@  discard block
 block discarded – undo
991 1233
 					$stats_heading = round($stats_heading/22.5);
992 1234
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
993 1235
 					$current_date = date('Y-m-d');
994
-					if ($stats_heading == 16) $stats_heading = 0;
1236
+					if ($stats_heading == 16) {
1237
+						$stats_heading = 0;
1238
+					}
995 1239
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
996 1240
 						for ($i=0;$i<=15;$i++) {
997 1241
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -1009,7 +1253,9 @@  discard block
 block discarded – undo
1009 1253
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1010 1254
 						    end($this->stats[$current_date][$source]['hist']);
1011 1255
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1012
-						} else $mini = 0;
1256
+						} else {
1257
+							$mini = 0;
1258
+						}
1013 1259
 						for ($i=$mini;$i<=$distance;$i+=10) {
1014 1260
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1015 1261
 						}
@@ -1021,19 +1267,27 @@  discard block
 block discarded – undo
1021 1267
 				}
1022 1268
 
1023 1269
 				$this->all_flights[$id]['lastupdate'] = time();
1024
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1270
+				if ($this->all_flights[$id]['putinarchive']) {
1271
+					$send = true;
1272
+				}
1025 1273
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1026
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1274
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1275
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1276
+			}
1027 1277
 			//$this->del();
1028 1278
 			
1029 1279
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1030 1280
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1031
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1281
+				if ($globalDebug) {
1282
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1283
+				}
1032 1284
 				$SpotterLive = new SpotterLive($this->db);
1033 1285
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
1034 1286
 				$SpotterLive->db = null;
1035 1287
 				//SpotterLive->deleteLiveSpotterData();
1036
-				if ($globalDebug) echo " Done\n";
1288
+				if ($globalDebug) {
1289
+					echo " Done\n";
1290
+				}
1037 1291
 				$this->last_delete_hourly = time();
1038 1292
 			    } else {
1039 1293
 				$this->del();
@@ -1045,7 +1299,9 @@  discard block
 block discarded – undo
1045 1299
 		    //$ignoreImport = false;
1046 1300
 		}
1047 1301
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1048
-		if ($send) return $this->all_flights[$id];
1302
+		if ($send) {
1303
+			return $this->all_flights[$id];
1304
+		}
1049 1305
 	    }
1050 1306
 	}
1051 1307
     }
Please login to merge, or discard this patch.
live-czml.php 1 patch
Braces   +108 added lines, -38 removed lines patch added patch discarded remove patch
@@ -8,8 +8,12 @@  discard block
 block discarded – undo
8 8
 }
9 9
 $tracker = false;
10 10
 $marine = false;
11
-if (isset($_GET['tracker'])) $tracker = true;
12
-if (isset($_GET['marine'])) $marine = true;
11
+if (isset($_GET['tracker'])) {
12
+	$tracker = true;
13
+}
14
+if (isset($_GET['marine'])) {
15
+	$marine = true;
16
+}
13 17
 if ($tracker) {
14 18
 	require_once('require/class.Tracker.php');
15 19
 	require_once('require/class.TrackerLive.php');
@@ -66,23 +70,46 @@  discard block
 block discarded – undo
66 70
 }
67 71
 header('Content-Type: text/javascript');
68 72
 
69
-if (!isset($globalJsonCompress)) $compress = true;
70
-else $compress = $globalJsonCompress;
73
+if (!isset($globalJsonCompress)) {
74
+	$compress = true;
75
+} else {
76
+	$compress = $globalJsonCompress;
77
+}
71 78
 
72 79
 $from_archive = false;
73 80
 $min = false;
74 81
 $allhistory = false;
75 82
 $filter['source'] = array();
76
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
77
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
78
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
79
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
80
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
81
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
82
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
83
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
84
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
85
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
83
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
84
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
85
+}
86
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
87
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
88
+}
89
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
90
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
91
+}
92
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
93
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
94
+}
95
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
96
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
97
+}
98
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
99
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
100
+}
101
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
102
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
103
+}
104
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
105
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
106
+}
107
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
108
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
109
+}
110
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
111
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
112
+}
86 113
 /*
87 114
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
88 115
 	$min = true;
@@ -167,8 +194,12 @@  discard block
 block discarded – undo
167 194
 	} else {
168 195
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
169 196
 	}
170
-	if ($flightcnt == '') $flightcnt = 0;
171
-} else $flightcnt = 0;
197
+	if ($flightcnt == '') {
198
+		$flightcnt = 0;
199
+	}
200
+	} else {
201
+	$flightcnt = 0;
202
+}
172 203
 
173 204
 $sqltime = round(microtime(true)-$begintime,2);
174 205
 $minitime = time();
@@ -192,7 +223,9 @@  discard block
 block discarded – undo
192 223
 $j = 0;
193 224
 $prev_flightaware_id = '';
194 225
 $speed = 1;
195
-if (isset($archivespeed)) $speed = $archivespeed;
226
+if (isset($archivespeed)) {
227
+	$speed = $archivespeed;
228
+}
196 229
 $output = '[';
197 230
 if ($tracker) {
198 231
 	$output .= '{"id" : "document", "name" : "tracker","version" : "1.0"';
@@ -227,9 +260,13 @@  discard block
 block discarded – undo
227 260
 			$image = "images/placeholder_thumb.png";
228 261
 		}
229 262
 
230
-                if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
231
-                elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
232
-                elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
263
+                if (isset($spotter_item['flightaware_id'])) {
264
+                	$id = $spotter_item['flightaware_id'];
265
+                } elseif (isset($spotter_item['famtrackid'])) {
266
+                	$id = $spotter_item['famtrackid'];
267
+                } elseif (isset($spotter_item['fammarine_id'])) {
268
+                	$id = $spotter_item['fammarine_id'];
269
+                }
233 270
                 if ($prev_flightaware_id != $id) {
234 271
 			if ($prev_flightaware_id != '') {
235 272
 				$output .= ']';
@@ -271,7 +308,9 @@  discard block
 block discarded – undo
271 308
 							$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
272 309
 							$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
273 310
 							$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
274
-						} else $aircraft_shadow = '';
311
+						} else {
312
+							$aircraft_shadow = '';
313
+						}
275 314
 	    					$output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5';
276 315
 						if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] && isset($_COOKIE['IconColor'])) {
277 316
 							$rgb = $Common->hex2rgb($_COOKIE['IconColor']);
@@ -279,7 +318,9 @@  discard block
 block discarded – undo
279 318
 						}
280 319
 						$output .= '},';
281 320
 					}
282
-				} else $output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/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y+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},';
321
+				} else {
322
+					$output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJM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97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},';
323
+				}
283 324
 			} elseif ($one3dmodel) {
284 325
 				if (isset($globalMap3DForceModel) && $globalMap3DForceModel != '') {
285 326
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$globalMap3DForceModel.'","scale" : 1.0,"minimumPixelSize": 20';
@@ -310,7 +351,9 @@  discard block
 block discarded – undo
310 351
 							$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
311 352
 							$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
312 353
 							$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
313
-						} else $aircraft_shadow = '';
354
+						} else {
355
+							$aircraft_shadow = '';
356
+						}
314 357
 						if ($aircraft_shadow != '') {
315 358
 							if (isset($modelsdb[$aircraft_shadow])) {
316 359
 								$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20';
@@ -447,7 +490,9 @@  discard block
 block discarded – undo
447 490
 								}
448 491
 								$output .= '},';
449 492
 								//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
450
-								if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
493
+								if ($spotter_item['aircraft_icao'] != '') {
494
+									$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
495
+								}
451 496
 								$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
452 497
 							}
453 498
 						} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
@@ -469,7 +514,9 @@  discard block
 block discarded – undo
469 514
 							}
470 515
 							$output .= '},';
471 516
 							//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
472
-							if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
517
+							if ($spotter_item['aircraft_icao'] != '') {
518
+								$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
519
+							}
473 520
 							$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
474 521
 						}
475 522
 					} else {
@@ -482,7 +529,9 @@  discard block
 block discarded – undo
482 529
 						}
483 530
 						$output .= '},';
484 531
 						//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
485
-						if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
532
+						if ($spotter_item['aircraft_icao'] != '') {
533
+							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
534
+						}
486 535
 						$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
487 536
 					}
488 537
 				} elseif ($tracker && isset($spotter_item['type'])) {
@@ -538,8 +587,12 @@  discard block
 block discarded – undo
538 587
 	//		$output .= '"interpolationDegree" : 5,';
539 588
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
540 589
 			$output .= '"cartographicDegrees": [';
541
-			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
542
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
590
+			if ($minitime > strtotime($spotter_item['date'])) {
591
+				$minitime = strtotime($spotter_item['date']);
592
+			}
593
+			if ($maxitime < strtotime($spotter_item['date'])) {
594
+				$maxitime = strtotime($spotter_item['date']);
595
+			}
543 596
 			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
544 597
 			$output .= $spotter_item['longitude'].', ';
545 598
 			$output .= $spotter_item['latitude'];
@@ -553,19 +606,26 @@  discard block
 block discarded – undo
553 606
 					$output .= ', '.round($spotter_item['altitude']*30.48);
554 607
 					$prevalt = round($spotter_item['altitude']*30.48);
555 608
 				}
556
-			} else $output .= ', 0';
609
+			} else {
610
+				$output .= ', 0';
611
+			}
557 612
 			//$orientation = '"orientation" : { ';
558 613
 			//$orientation .= '"unitQuaternion": [';
559 614
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
560 615
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
561 616
 		} else {
562 617
 			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
563
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
618
+			if ($maxitime < strtotime($spotter_item['date'])) {
619
+				$maxitime = strtotime($spotter_item['date']);
620
+			}
564 621
 			if ($spotter_item['ground_speed'] == 0) {
565 622
 				$output .= $prevlong.', ';
566 623
 				$output .= $prevlat;
567
-				if (!$tracker && !$marine) $output .= ', '.$prevalt;
568
-				else $output .= ', 0';
624
+				if (!$tracker && !$marine) {
625
+					$output .= ', '.$prevalt;
626
+				} else {
627
+					$output .= ', 0';
628
+				}
569 629
 			} else {
570 630
 				$output .= $spotter_item['longitude'].', ';
571 631
 				$output .= $spotter_item['latitude'];
@@ -577,10 +637,15 @@  discard block
 block discarded – undo
577 637
 							$output .= ', 0';
578 638
 						}
579 639
 					} else {
580
-						if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') $output .= ', '.round($spotter_item['real_altitude']*0.3048);
581
-						else $output .= ', '.round($spotter_item['altitude']*30.48);
640
+						if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') {
641
+							$output .= ', '.round($spotter_item['real_altitude']*0.3048);
642
+						} else {
643
+							$output .= ', '.round($spotter_item['altitude']*30.48);
644
+						}
582 645
 					}
583
-				} else $output .= ', 0';
646
+				} else {
647
+					$output .= ', 0';
648
+				}
584 649
 			}
585 650
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
586 651
 			//$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
@@ -593,9 +658,14 @@  discard block
 block discarded – undo
593 658
 }
594 659
 $output .= ']';
595 660
 if (isset($globalArchive) && $globalArchive === TRUE) {
596
-	if ((time()-$globalLiveInterval) > $minitime) $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output);
597
-	else $output = str_replace('%minitime%',date("c",$minitime),$output);
598
-} else $output = str_replace('%minitime%',date("c",$minitime),$output);
661
+	if ((time()-$globalLiveInterval) > $minitime) {
662
+		$output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output);
663
+	} else {
664
+		$output = str_replace('%minitime%',date("c",$minitime),$output);
665
+	}
666
+	} else {
667
+	$output = str_replace('%minitime%',date("c",$minitime),$output);
668
+}
599 669
 $output = str_replace('%maxitime%',date("c",$maxitime),$output);
600 670
 print $output;
601 671
 ?>
Please login to merge, or discard this patch.