Completed
Push — master ( 179cf7...3d8cb5 )
by Yannick
06:45
created
require/class.SpotterImport.php 1 patch
Braces   +337 added lines, -119 removed lines patch added patch discarded remove patch
@@ -61,7 +61,9 @@  discard block
 block discarded – undo
61 61
 	$dbc = $this->db;
62 62
 	$this->all_flights[$id]['schedule_check'] = true;
63 63
 	if ($globalSchedulesFetch) {
64
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
64
+	if ($globalDebug) {
65
+		echo 'Getting schedule info...'."\n";
66
+	}
65 67
 	$Spotter = new Spotter($dbc);
66 68
 	$Schedule = new Schedule($dbc);
67 69
 	$Translation = new Translation($dbc);
@@ -72,7 +74,9 @@  discard block
 block discarded – undo
72 74
 	    if ($Schedule->checkSchedule($operator) == 0) {
73 75
 		$schedule = $Schedule->fetchSchedule($operator);
74 76
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
75
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
77
+		    if ($globalDebug) {
78
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
79
+		    }
76 80
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
77 81
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
78 82
 		    // Should also check if route schedule = route from DB
@@ -81,7 +85,9 @@  discard block
 block discarded – undo
81 85
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
82 86
 			    if (trim($airport_icao) != '') {
83 87
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
84
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
88
+				if ($globalDebug) {
89
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
90
+				}
85 91
 			    }
86 92
 			}
87 93
 		    }
@@ -90,17 +96,25 @@  discard block
 block discarded – undo
90 96
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
91 97
 			    if (trim($airport_icao) != '') {
92 98
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
93
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
99
+				if ($globalDebug) {
100
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
101
+				}
94 102
 			    }
95 103
 			}
96 104
 		    }
97 105
 		    $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']);
98 106
 		}
99
-	    } else $scheduleexist = true;
100
-	} else $scheduleexist = true;
107
+	    } else {
108
+	    	$scheduleexist = true;
109
+	    }
110
+	} else {
111
+		$scheduleexist = true;
112
+	}
101 113
 	// close connection, at least one way will work ?
102 114
        if ($scheduleexist) {
103
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
115
+		if ($globalDebug) {
116
+			echo "-> get arrival/departure airport info for ".$ident."\n";
117
+		}
104 118
     		$sch = $Schedule->getSchedule($operator);
105 119
 		$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']));
106 120
        }
@@ -122,7 +136,9 @@  discard block
 block discarded – undo
122 136
 
123 137
     public function checkAll() {
124 138
 	global $globalDebug, $globalNoImport;
125
-	if ($globalDebug) echo "Update last seen flights data...\n";
139
+	if ($globalDebug) {
140
+		echo "Update last seen flights data...\n";
141
+	}
126 142
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
127 143
 	    foreach ($this->all_flights as $key => $flight) {
128 144
 		if (isset($this->all_flights[$key]['id'])) {
@@ -137,24 +153,32 @@  discard block
 block discarded – undo
137 153
 
138 154
     public function arrival($key) {
139 155
 	global $globalClosestMinDist, $globalDebug;
140
-	if ($globalDebug) echo 'Update arrival...'."\n";
156
+	if ($globalDebug) {
157
+		echo 'Update arrival...'."\n";
158
+	}
141 159
 	$Spotter = new Spotter($this->db);
142 160
         $airport_icao = '';
143 161
         $airport_time = '';
144
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
162
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
163
+        	$globalClosestMinDist = 50;
164
+        }
145 165
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
146 166
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
147 167
     	    if (isset($closestAirports[0])) {
148 168
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
149 169
         	    $airport_icao = $closestAirports[0]['icao'];
150 170
         	    $airport_time = $this->all_flights[$key]['datetime'];
151
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
171
+        	    if ($globalDebug) {
172
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
173
+        	    }
152 174
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
153 175
         	    foreach ($closestAirports as $airport) {
154 176
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
155 177
         		    $airport_icao = $airport['icao'];
156 178
         		    $airport_time = $this->all_flights[$key]['datetime'];
157
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
179
+        		    if ($globalDebug) {
180
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
181
+        		    }
158 182
         		    break;
159 183
         		}
160 184
         	    }
@@ -162,14 +186,20 @@  discard block
 block discarded – undo
162 186
         		$airport_icao = $closestAirports[0]['icao'];
163 187
         		$airport_time = $this->all_flights[$key]['datetime'];
164 188
         	} else {
165
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
189
+        		if ($globalDebug) {
190
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
191
+        		}
166 192
         	}
167 193
     	    } else {
168
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
194
+    		    if ($globalDebug) {
195
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
196
+    		    }
169 197
     	    }
170 198
 
171 199
         } else {
172
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
200
+        	if ($globalDebug) {
201
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
202
+        	}
173 203
         }
174 204
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
175 205
     }
@@ -179,12 +209,16 @@  discard block
 block discarded – undo
179 209
     public function del() {
180 210
 	global $globalDebug, $globalNoImport, $globalNoDB;
181 211
 	// Delete old infos
182
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
212
+	if ($globalDebug) {
213
+		echo 'Delete old values and update latest data...'."\n";
214
+	}
183 215
 	foreach ($this->all_flights as $key => $flight) {
184 216
     	    if (isset($flight['lastupdate'])) {
185 217
         	if ($flight['lastupdate'] < (time()-3000)) {
186 218
             	    if (isset($this->all_flights[$key]['id'])) {
187
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
219
+            		if ($globalDebug) {
220
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
221
+            		}
188 222
 			/*
189 223
 			$SpotterLive = new SpotterLive();
190 224
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -195,7 +229,9 @@  discard block
 block discarded – undo
195 229
             		    $Spotter = new Spotter($this->db);
196 230
             	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
197 231
 				$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']);
198
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
232
+				if ($globalDebug && $result != 'success') {
233
+					echo '!!! ERROR : '.$result."\n";
234
+				}
199 235
 			    }
200 236
 			// Put in archive
201 237
 //				$Spotter->db = null;
@@ -210,8 +246,10 @@  discard block
 block discarded – undo
210 246
     public function add($line) {
211 247
 	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;
212 248
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
213
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
214
-/*
249
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
250
+		$globalCoordMinChange = '0.02';
251
+	}
252
+	/*
215 253
 	$Spotter = new Spotter();
216 254
 	$dbc = $Spotter->db;
217 255
 	$SpotterLive = new SpotterLive($dbc);
@@ -239,11 +277,15 @@  discard block
 block discarded – undo
239 277
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
240 278
 		    $current_date = date('Y-m-d');
241 279
 		    $source = $line['source_name'];
242
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
280
+		    if ($source == '' || $line['format_source'] == 'aprs') {
281
+		    	$source = $line['format_source'];
282
+		    }
243 283
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
244 284
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
245 285
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
246
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
286
+		    } else {
287
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
288
+		    }
247 289
 		}
248 290
 		
249 291
 		/*
@@ -259,8 +301,11 @@  discard block
 block discarded – undo
259 301
 		//$this->db = $dbc;
260 302
 
261 303
 		//$hex = trim($line['hex']);
262
-	        if (!isset($line['id'])) $id = trim($line['hex']);
263
-	        else $id = trim($line['id']);
304
+	        if (!isset($line['id'])) {
305
+	        	$id = trim($line['hex']);
306
+	        } else {
307
+	        	$id = trim($line['id']);
308
+	        }
264 309
 		
265 310
 		if (!isset($this->all_flights[$id])) {
266 311
 		    $this->all_flights[$id] = array();
@@ -268,13 +313,21 @@  discard block
 block discarded – undo
268 313
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', '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' => ''));
269 314
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
270 315
 		    if (!isset($line['id'])) {
271
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
272
-//			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')));
316
+			if (!isset($globalDaemon)) {
317
+				$globalDaemon = TRUE;
318
+			}
319
+			//			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')));
273 320
 //			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')));
274
-			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')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
321
+			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')) {
322
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
323
+			}
275 324
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
276
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
277
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
325
+		     } else {
326
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
327
+		     }
328
+		    if ($globalAllFlights !== FALSE) {
329
+		    	$dataFound = true;
330
+		    }
278 331
 		}
279 332
 		if (isset($line['source_type']) && $line['source_type'] != '') {
280 333
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -296,12 +349,20 @@  discard block
 block discarded – undo
296 349
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
297 350
 			    }
298 351
 			    $Spotter->db = null;
299
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
300
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
352
+			    if ($globalDebugTimeElapsed) {
353
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
354
+			    }
355
+			    if ($aircraft_icao != '') {
356
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
357
+			    }
301 358
 			}
302 359
 		    }
303
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
304
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
360
+		    if ($globalAllFlights !== FALSE) {
361
+		    	$dataFound = true;
362
+		    }
363
+		    if ($globalDebug) {
364
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
365
+		    }
305 366
 		}
306 367
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
307 368
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
@@ -312,15 +373,24 @@  discard block
 block discarded – undo
312 373
 				$Spotter = new Spotter($this->db);
313 374
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
314 375
 				$Spotter->db = null;
315
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
376
+				if ($aircraft_icao != '') {
377
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
378
+				}
316 379
 			}
317 380
 		}
318 381
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
319
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
320
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
321
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
322
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
323
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
382
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
383
+				$aircraft_icao = 'GLID';
384
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
385
+				$aircraft_icao = 'UHEL';
386
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
387
+				$aircraft_icao = 'TOWPLANE';
388
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
389
+				$aircraft_icao = 'POWAIRC';
390
+			}
391
+			if (isset($aircraft_icao)) {
392
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
393
+			}
324 394
 		}
325 395
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
326 396
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -330,8 +400,11 @@  discard block
 block discarded – undo
330 400
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
331 401
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
332 402
 		    } else {
333
-				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";
334
-				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";
403
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
404
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
405
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
406
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
407
+				}
335 408
 				/*
336 409
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
337 410
 				print_r($this->all_flights[$id]);
@@ -364,15 +437,25 @@  discard block
 block discarded – undo
364 437
 			    $timeelapsed = microtime(true);
365 438
             		    $Spotter = new Spotter($this->db);
366 439
             		    $fromsource = NULL;
367
-            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
368
-            		    elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
369
-			    elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
370
-			    elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
371
-			    elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
440
+            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
441
+            		    	$fromsource = $globalAirlinesSource;
442
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
443
+            		    	$fromsource = 'vatsim';
444
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
445
+			    	$fromsource = 'ivao';
446
+			    } elseif (isset($globalVATSIM) && $globalVATSIM) {
447
+			    	$fromsource = 'vatsim';
448
+			    } elseif (isset($globalIVAO) && $globalIVAO) {
449
+			    	$fromsource = 'ivao';
450
+			    }
372 451
             		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
373
-			    if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
452
+			    if ($globalDebug && $result != 'success') {
453
+			    	echo '!!! ERROR : '.$result."\n";
454
+			    }
374 455
 			    $Spotter->db = null;
375
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
456
+			    if ($globalDebugTimeElapsed) {
457
+			    	echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
458
+			    }
376 459
 			}
377 460
 		    }
378 461
 
@@ -384,7 +467,9 @@  discard block
 block discarded – undo
384 467
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
385 468
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
386 469
   */
387
-		    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']));
470
+		    if (!isset($this->all_flights[$id]['id'])) {
471
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
472
+		    }
388 473
 
389 474
 		    //$putinarchive = true;
390 475
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -402,7 +487,9 @@  discard block
 block discarded – undo
402 487
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
403 488
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
404 489
 		    		$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' => ''));
405
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
490
+				if ($globalDebugTimeElapsed) {
491
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
492
+				}
406 493
                         }
407 494
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
408 495
 			$timeelapsed = microtime(true);
@@ -416,7 +503,9 @@  discard block
 block discarded – undo
416 503
 				$Translation->db = null;
417 504
 			    }
418 505
 			    $Spotter->db = null;
419
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
506
+			    if ($globalDebugTimeElapsed) {
507
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
508
+			    }
420 509
                     	}
421 510
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
422 511
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -425,9 +514,13 @@  discard block
 block discarded – undo
425 514
 		    		$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']));
426 515
 		    	    }
427 516
 			}
428
-			if (!isset($globalFork)) $globalFork = TRUE;
517
+			if (!isset($globalFork)) {
518
+				$globalFork = TRUE;
519
+			}
429 520
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
430
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
521
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
522
+					$this->get_Schedule($id,trim($line['ident']));
523
+				}
431 524
 			}
432 525
 		    }
433 526
 		}
@@ -443,16 +536,23 @@  discard block
 block discarded – undo
443 536
 		    // use datetime
444 537
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
445 538
 			$speed = $speed*3.6;
446
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
447
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
539
+			if ($speed < 1000) {
540
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
541
+			}
542
+  			if ($globalDebug) {
543
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
544
+  			}
448 545
 		    }
449 546
 		}
450 547
 
451 548
 
452 549
 
453 550
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
454
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
455
-	    	    else unset($timediff);
551
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
552
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
553
+	    	    } else {
554
+	    	    	unset($timediff);
555
+	    	    }
456 556
 	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
457 557
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
458 558
 			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -461,15 +561,23 @@  discard block
 block discarded – undo
461 561
 				$this->all_flights[$id]['putinarchive'] = true;
462 562
 				$this->tmd = 0;
463 563
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
464
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
564
+				    if ($globalDebug) {
565
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
566
+				    }
465 567
 				    $timeelapsed = microtime(true);
466 568
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
467 569
 					$Spotter = new Spotter($this->db);
468 570
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
469
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
571
+					if (!empty($all_country)) {
572
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
573
+					}
470 574
 					$Spotter->db = null;
471
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
472
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
575
+					if ($globalDebugTimeElapsed) {
576
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
577
+					}
578
+					if ($globalDebug) {
579
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
580
+					}
473 581
 				    }
474 582
 				}
475 583
 			    }
@@ -477,7 +585,9 @@  discard block
 block discarded – undo
477 585
 
478 586
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
479 587
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
480
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
588
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
589
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
590
+				}
481 591
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
482 592
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
483 593
 				    $dataFound = true;
@@ -499,9 +609,13 @@  discard block
 block discarded – undo
499 609
 			    */
500 610
 			}
501 611
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
502
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
612
+			    if ($line['longitude'] > 180) {
613
+			    	$line['longitude'] = $line['longitude'] - 360;
614
+			    }
503 615
 			    //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) {
504
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
616
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
617
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
618
+				}
505 619
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
506 620
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
507 621
 				    $dataFound = true;
@@ -532,7 +646,9 @@  discard block
 block discarded – undo
532 646
 		    }
533 647
 		}
534 648
 		if (isset($line['last_update']) && $line['last_update'] != '') {
535
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
649
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
650
+		    	$dataFound = true;
651
+		    }
536 652
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
537 653
 		}
538 654
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -554,41 +670,61 @@  discard block
 block discarded – undo
554 670
 			// Here we force archive of flight because after ground it's a new one (or should be)
555 671
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
556 672
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
557
-			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'].'-'.date('YmdGi')));
558
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
559
-			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']));
673
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
674
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
675
+			} elseif (isset($line['id'])) {
676
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
677
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
678
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
679
+			}
680
+		    }
681
+		    if ($line['ground'] != 1) {
682
+		    	$line['ground'] = 0;
560 683
 		    }
561
-		    if ($line['ground'] != 1) $line['ground'] = 0;
562 684
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
563 685
 		    //$dataFound = true;
564 686
 		}
565 687
 		if (isset($line['squawk']) && $line['squawk'] != '') {
566 688
 		    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'])) {
567
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
689
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
690
+			    	$this->all_flights[$id]['putinarchive'] = true;
691
+			    }
568 692
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
569 693
 			    $highlight = '';
570
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
571
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
572
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
694
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
695
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
696
+			    }
697
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
698
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
699
+			    }
700
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
701
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
702
+			    }
573 703
 			    if ($highlight != '') {
574 704
 				$timeelapsed = microtime(true);
575 705
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
576 706
 				    $Spotter = new Spotter($this->db);
577 707
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
578 708
 				    $Spotter->db = null;
579
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
709
+				    if ($globalDebugTimeElapsed) {
710
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
711
+				    }
580 712
 				}
581 713
 				//$putinarchive = true;
582 714
 				//$highlight = '';
583 715
 			    }
584 716
 			    
585
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
717
+		    } else {
718
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
719
+		    }
586 720
 		    //$dataFound = true;
587 721
 		}
588 722
 
589 723
 		if (isset($line['altitude']) && $line['altitude'] != '') {
590 724
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
591
-			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;
725
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
726
+				$this->all_flights[$id]['putinarchive'] = true;
727
+			}
592 728
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
593 729
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
594 730
 			//$dataFound = true;
@@ -600,21 +736,30 @@  discard block
 block discarded – undo
600 736
 		}
601 737
 		
602 738
 		if (isset($line['heading']) && $line['heading'] != '') {
603
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
739
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
740
+		    	$this->all_flights[$id]['putinarchive'] = true;
741
+		    }
604 742
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
605 743
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
606 744
 		    //$dataFound = true;
607 745
   		} 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']) {
608 746
   		    $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']);
609 747
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
610
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
611
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
748
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
749
+		    	$this->all_flights[$id]['putinarchive'] = true;
750
+		    }
751
+  		    if ($globalDebug) {
752
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
753
+  		    }
612 754
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
613 755
   		    // If not enough messages and ACARS set heading to 0
614 756
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
615 757
   		}
616
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
617
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
758
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
759
+			$dataFound = false;
760
+		} elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
761
+			$dataFound = false;
762
+		}
618 763
 
619 764
 //		print_r($this->all_flights[$id]);
620 765
 		//gets the callsign from the last hour
@@ -630,23 +775,38 @@  discard block
 block discarded – undo
630 775
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
631 776
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
632 777
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
633
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
778
+				    if ($globalDebug) {
779
+				    	echo "Check if aircraft is already in DB...";
780
+				    }
634 781
 				    $timeelapsed = microtime(true);
635 782
 				    $SpotterLive = new SpotterLive($this->db);
636 783
 				    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')) {
637 784
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
638
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
785
+					if ($globalDebugTimeElapsed) {
786
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
787
+					}
639 788
 				    } elseif (isset($line['id'])) {
640 789
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
641
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
790
+					if ($globalDebugTimeElapsed) {
791
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
792
+					}
642 793
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
643 794
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
644
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
645
-				    } else $recent_ident = '';
795
+					if ($globalDebugTimeElapsed) {
796
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
797
+					}
798
+				    } else {
799
+				    	$recent_ident = '';
800
+				    }
646 801
 				    $SpotterLive->db=null;
647
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
648
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
649
-				} else $recent_ident = '';
802
+				    if ($globalDebug && $recent_ident == '') {
803
+				    	echo " Not in DB.\n";
804
+				    } elseif ($globalDebug && $recent_ident != '') {
805
+				    	echo " Already in DB.\n";
806
+				    }
807
+				} else {
808
+					$recent_ident = '';
809
+				}
650 810
 			    } else {
651 811
 				$recent_ident = '';
652 812
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -654,7 +814,9 @@  discard block
 block discarded – undo
654 814
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
655 815
 			    if($recent_ident == "")
656 816
 			    {
657
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
817
+				if ($globalDebug) {
818
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
819
+				}
658 820
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
659 821
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
660 822
 				//adds the spotter data for the archive
@@ -698,31 +860,49 @@  discard block
 block discarded – undo
698 860
 				
699 861
 				if (!$ignoreImport) {
700 862
 				    $highlight = '';
701
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
702
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
703
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
704
-				    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')));
863
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
864
+				    	$highlight = 'Squawk 7500 : Hijack';
865
+				    }
866
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
867
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
868
+				    }
869
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
870
+				    	$highlight = 'Squawk 7700 : Emergency';
871
+				    }
872
+				    if (!isset($this->all_flights[$id]['id'])) {
873
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
874
+				    }
705 875
 				    $timeelapsed = microtime(true);
706 876
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
707 877
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
708 878
 					    $Spotter = new Spotter($this->db);
709 879
 					    $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']);
710 880
 					    $Spotter->db = null;
711
-					    if ($globalDebug && isset($result)) echo $result."\n";
881
+					    if ($globalDebug && isset($result)) {
882
+					    	echo $result."\n";
883
+					    }
712 884
 					}
713 885
 				    }
714
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
886
+				    if ($globalDebugTimeElapsed) {
887
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
888
+				    }
715 889
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
716 890
 
717 891
 				    // Add source stat in DB
718 892
 				    $Stats = new Stats($this->db);
719 893
 				    if (!empty($this->stats)) {
720
-					if ($globalDebug) echo 'Add source stats : ';
894
+					if ($globalDebug) {
895
+						echo 'Add source stats : ';
896
+					}
721 897
 				        foreach($this->stats as $date => $data) {
722 898
 					    foreach($data as $source => $sourced) {
723 899
 					        //print_r($sourced);
724
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
725
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
900
+				    	        if (isset($sourced['polar'])) {
901
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
902
+				    	        }
903
+				    	        if (isset($sourced['hist'])) {
904
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
905
+				    	        }
726 906
 				    		if (isset($sourced['msg'])) {
727 907
 				    		    if (time() - $sourced['msg']['date'] > 10) {
728 908
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -735,13 +915,17 @@  discard block
 block discarded – undo
735 915
 			    			unset($this->stats[$date]);
736 916
 			    		    }
737 917
 				    	}
738
-				    	if ($globalDebug) echo 'Done'."\n";
918
+				    	if ($globalDebug) {
919
+				    		echo 'Done'."\n";
920
+				    	}
739 921
 
740 922
 				    }
741 923
 				    $Stats->db = null;
742 924
 				    }
743 925
 				    $this->del();
744
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
926
+				} elseif ($globalDebug) {
927
+					echo 'Ignore data'."\n";
928
+				}
745 929
 				//$ignoreImport = false;
746 930
 				$this->all_flights[$id]['addedSpotter'] = 1;
747 931
 				//print_r($this->all_flights[$id]);
@@ -758,7 +942,9 @@  discard block
 block discarded – undo
758 942
 			*/
759 943
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
760 944
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
761
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
945
+				    if ($globalDebug) {
946
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
947
+				    }
762 948
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
763 949
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
764 950
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -767,7 +953,9 @@  discard block
 block discarded – undo
767 953
 					    $SpotterLive->db=null;
768 954
 					}
769 955
 				    }
770
-				    if ($globalDebug) echo " Done\n";
956
+				    if ($globalDebug) {
957
+				    	echo " Done\n";
958
+				    }
771 959
 				    $this->last_delete = time();
772 960
 				}
773 961
 			    } else {
@@ -794,11 +982,17 @@  discard block
 block discarded – undo
794 982
 		    //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";
795 983
 		    if ($globalDebug) {
796 984
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
797
-				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";
798
-				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";
985
+				if (isset($this->all_flights[$id]['source_name'])) {
986
+					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";
987
+				} else {
988
+					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";
989
+				}
799 990
 			} else {
800
-				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";
801
-				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";
991
+				if (isset($this->all_flights[$id]['source_name'])) {
992
+					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";
993
+				} else {
994
+					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";
995
+				}
802 996
 			}
803 997
 		    }
804 998
 		    $ignoreImport = false;
@@ -844,22 +1038,30 @@  discard block
 block discarded – undo
844 1038
 
845 1039
 		    if (!$ignoreImport) {
846 1040
 			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'])) {
847
-				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')));
1041
+				if (!isset($this->all_flights[$id]['id'])) {
1042
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1043
+				}
848 1044
 				$timeelapsed = microtime(true);
849 1045
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
850 1046
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
851
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1047
+					if ($globalDebug) {
1048
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1049
+					}
852 1050
 					$SpotterLive = new SpotterLive($this->db);
853 1051
 					$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']);
854 1052
 					$SpotterLive->db = null;
855
-					if ($globalDebug) echo $result."\n";
1053
+					if ($globalDebug) {
1054
+						echo $result."\n";
1055
+					}
856 1056
 				    }
857 1057
 				}
858 1058
 				if (isset($globalServerAPRS) && $globalServerAPRS) {
859 1059
 					$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']);
860 1060
 				}
861 1061
 				$this->all_flights[$id]['putinarchive'] = false;
862
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1062
+				if ($globalDebugTimeElapsed) {
1063
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1064
+				}
863 1065
 
864 1066
 				// Put statistics in $this->stats variable
865 1067
 				//if ($line['format_source'] != 'aprs') {
@@ -867,7 +1069,9 @@  discard block
 block discarded – undo
867 1069
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
868 1070
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
869 1071
 					$source = $this->all_flights[$id]['source_name'];
870
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1072
+					if ($source == '') {
1073
+						$source = $this->all_flights[$id]['format_source'];
1074
+					}
871 1075
 					if (!isset($this->source_location[$source])) {
872 1076
 						$Location = new Source();
873 1077
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -888,7 +1092,9 @@  discard block
 block discarded – undo
888 1092
 					$stats_heading = round($stats_heading/22.5);
889 1093
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
890 1094
 					$current_date = date('Y-m-d');
891
-					if ($stats_heading == 16) $stats_heading = 0;
1095
+					if ($stats_heading == 16) {
1096
+						$stats_heading = 0;
1097
+					}
892 1098
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
893 1099
 						for ($i=0;$i<=15;$i++) {
894 1100
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -906,7 +1112,9 @@  discard block
 block discarded – undo
906 1112
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
907 1113
 						    end($this->stats[$current_date][$source]['hist']);
908 1114
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
909
-						} else $mini = 0;
1115
+						} else {
1116
+							$mini = 0;
1117
+						}
910 1118
 						for ($i=$mini;$i<=$distance;$i+=10) {
911 1119
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
912 1120
 						}
@@ -918,19 +1126,27 @@  discard block
 block discarded – undo
918 1126
 				}
919 1127
 
920 1128
 				$this->all_flights[$id]['lastupdate'] = time();
921
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1129
+				if ($this->all_flights[$id]['putinarchive']) {
1130
+					$send = true;
1131
+				}
922 1132
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
923
-			} 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";
1133
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1134
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1135
+			}
924 1136
 			//$this->del();
925 1137
 			
926 1138
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
927 1139
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
928
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1140
+				if ($globalDebug) {
1141
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1142
+				}
929 1143
 				$SpotterLive = new SpotterLive($this->db);
930 1144
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
931 1145
 				$SpotterLive->db = null;
932 1146
 				//SpotterLive->deleteLiveSpotterData();
933
-				if ($globalDebug) echo " Done\n";
1147
+				if ($globalDebug) {
1148
+					echo " Done\n";
1149
+				}
934 1150
 				$this->last_delete_hourly = time();
935 1151
 			    } else {
936 1152
 				$this->del();
@@ -942,7 +1158,9 @@  discard block
 block discarded – undo
942 1158
 		    //$ignoreImport = false;
943 1159
 		}
944 1160
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
945
-		if ($send) return $this->all_flights[$id];
1161
+		if ($send) {
1162
+			return $this->all_flights[$id];
1163
+		}
946 1164
 	    }
947 1165
 	}
948 1166
     }
Please login to merge, or discard this patch.