Completed
Push — master ( 87b9d1...9e0f72 )
by Yannick
31:32
created
polar-geojson.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 header('Content-Type: text/javascript');
18 18
 
19 19
 
20
-$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
20
+$polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
21 21
 $output = '{"type": "FeatureCollection","features": [';
22 22
 if (!empty($polar)) {
23
-	foreach($polar as $eachpolar) {
23
+	foreach ($polar as $eachpolar) {
24 24
 		$data = json_decode($eachpolar['source_data']);
25 25
 		$name = $eachpolar['source_name'];
26 26
 		$coord = $Location->getLocationInfobySourceName($name);
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 			$initial_longitude = $globalCenterLongitude;
34 34
 		}
35 35
 		$first = '';
36
-		foreach($data as $value => $key) {
37
-			$final_coord = $Common->getCoordfromDistanceBearing($initial_latitude,$initial_longitude,$value*22.5,$key);
38
-			if ($first == '') $first = '['.round($final_coord['longitude'],5).','.round($final_coord['latitude'],5).']';
36
+		foreach ($data as $value => $key) {
37
+			$final_coord = $Common->getCoordfromDistanceBearing($initial_latitude, $initial_longitude, $value*22.5, $key);
38
+			if ($first == '') $first = '['.round($final_coord['longitude'], 5).','.round($final_coord['latitude'], 5).']';
39 39
 			$output .= '['.$final_coord['longitude'].','.$final_coord['latitude'].'],';
40 40
 		}
41 41
 		$output .= $first;
42 42
 		$output .= ']]}},';
43 43
 	}
44
-	$output  = substr($output, 0, -1);
44
+	$output = substr($output, 0, -1);
45 45
 }
46 46
 $output .= ']}';
47 47
 print $output;
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Spacing   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
 	    die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
53
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
54 54
     }
55 55
 }
56 56
 
57
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
57
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65 65
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
66
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
67 67
     else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106 106
     if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
107
+    $SI = new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
111 111
     $SI->connect();
112 112
 */
113
-} else $SI=new SpotterImport($Connection->db);
113
+} else $SI = new SpotterImport($Connection->db);
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
     $MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127
-$SBS=new SBS();
127
+$SBS = new SBS();
128 128
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
129
-	$ACARS=new ACARS($Connection->db,true);
130
-	$Source=new Source($Connection->db);
129
+	$ACARS = new ACARS($Connection->db, true);
130
+	$Source = new Source($Connection->db);
131 131
 }
132
-$Common=new Common();
132
+$Common = new Common();
133 133
 date_default_timezone_set('UTC');
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
137
+    pcntl_signal(SIGINT, function() {
138 138
         global $sockets;
139 139
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140 140
         die("Bye!\n");
@@ -150,35 +150,35 @@  discard block
 block discarded – undo
150 150
 
151 151
 function connect_all($hosts) {
152 152
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
153
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
154 154
     $reset++;
155 155
     if ($globalDebug) echo 'Connect to all...'."\n";
156 156
     foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
160
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
+            if (preg_match('/deltadb.txt$/i', $host)) {
162 162
         	//$formats[$id] = 'deltadbtxt';
163 163
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 164
         	//$last_exec['deltadbtxt'] = 0;
165 165
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
166
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
167 167
         	//$formats[$id] = 'vatsimtxt';
168 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 169
         	//$last_exec['vatsimtxt'] = 0;
170 170
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
171
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
172 172
         	//$formats[$id] = 'aircraftlistjson';
173 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 174
         	//$last_exec['aircraftlistjson'] = 0;
175 175
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
176
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
177 177
         	//$formats[$id] = 'aircraftjson';
178 178
         	$globalSources[$id]['format'] = 'aircraftjson';
179 179
         	//$last_exec['aircraftlistjson'] = 0;
180 180
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
181
-    	    } else if (preg_match('/opensky/i',$host)) {
181
+    	    } else if (preg_match('/opensky/i', $host)) {
182 182
         	//$formats[$id] = 'aircraftlistjson';
183 183
         	$globalSources[$id]['format'] = 'opensky';
184 184
         	//$last_exec['aircraftlistjson'] = 0;
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         	    exit(0);
196 196
         	}
197 197
     	    */
198
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
198
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
199 199
         	//$formats[$id] = 'planeupdatefaa';
200 200
         	$globalSources[$id]['format'] = 'planeupdatefaa';
201 201
         	//$last_exec['planeupdatefaa'] = 0;
@@ -204,37 +204,37 @@  discard block
 block discarded – undo
204 204
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
205 205
         	    exit(0);
206 206
         	}
207
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
207
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
208 208
         	//$formats[$id] = 'phpvmacars';
209 209
         	$globalSources[$id]['format'] = 'phpvmacars';
210 210
         	//$last_exec['phpvmacars'] = 0;
211 211
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
212
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
212
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
213 213
         	//$formats[$id] = 'phpvmacars';
214 214
         	$globalSources[$id]['format'] = 'vaos';
215 215
         	//$last_exec['phpvmacars'] = 0;
216 216
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
217
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
217
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
218 218
         	//$formats[$id] = 'phpvmacars';
219 219
         	$globalSources[$id]['format'] = 'vam';
220 220
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
221
-            } else if (preg_match('/whazzup/i',$host)) {
221
+            } else if (preg_match('/whazzup/i', $host)) {
222 222
         	//$formats[$id] = 'whazzup';
223 223
         	$globalSources[$id]['format'] = 'whazzup';
224 224
         	//$last_exec['whazzup'] = 0;
225 225
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
226
-            } else if (preg_match('/blitzortung/i',$host)) {
226
+            } else if (preg_match('/blitzortung/i', $host)) {
227 227
         	$globalSources[$id]['format'] = 'blitzortung';
228 228
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
229
-            } else if (preg_match('/airwhere/i',$host)) {
229
+            } else if (preg_match('/airwhere/i', $host)) {
230 230
         	$globalSources[$id]['format'] = 'airwhere';
231 231
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
232
-            } else if (preg_match('/recentpireps/i',$host)) {
232
+            } else if (preg_match('/recentpireps/i', $host)) {
233 233
         	//$formats[$id] = 'pirepsjson';
234 234
         	$globalSources[$id]['format'] = 'pirepsjson';
235 235
         	//$last_exec['pirepsjson'] = 0;
236 236
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
237
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
237
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
238 238
         	//$formats[$id] = 'fr24json';
239 239
         	$globalSources[$id]['format'] = 'fr24json';
240 240
         	//$last_exec['fr24json'] = 0;
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
244 244
         	    exit(0);
245 245
         	}
246
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
246
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
247 247
         	//$formats[$id] = 'fr24json';
248 248
         	$globalSources[$id]['format'] = 'myshiptracking';
249 249
         	//$last_exec['fr24json'] = 0;
@@ -253,21 +253,21 @@  discard block
 block discarded – undo
253 253
         	    exit(0);
254 254
         	}
255 255
             //} else if (preg_match('/10001/',$host)) {
256
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
256
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
257 257
         	//$formats[$id] = 'tsv';
258 258
         	$globalSources[$id]['format'] = 'tsv';
259 259
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
260 260
             }
261
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
261
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
262 262
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
263
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
263
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
264 264
     		    if ($idf !== false) {
265 265
     			$httpfeeds[$id] = $idf;
266 266
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
267 267
     		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
268 268
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
269
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
270
-	    $hostport = explode(':',$host);
269
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
270
+	    $hostport = explode(':', $host);
271 271
 	    if (isset($hostport[1])) {
272 272
 		$port = $hostport[1];
273 273
 		$hostn = $hostport[0];
@@ -277,19 +277,19 @@  discard block
 block discarded – undo
277 277
 	    }
278 278
 	    $Common = new Common();
279 279
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
280
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
280
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
281 281
     	    } else {
282
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
282
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
283 283
 	    }
284 284
 	    if ($s) {
285 285
     	        $sockets[$id] = $s;
286 286
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
287
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
287
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
288 288
 			//$formats[$id] = 'aprs';
289 289
 			$globalSources[$id]['format'] = 'aprs';
290 290
 			//$aprs_connect = 0;
291 291
 			//$use_aprs = true;
292
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
292
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
293 293
 			$globalSources[$id]['format'] = 'vrstcp';
294 294
     		    } elseif ($port == '10001') {
295 295
         		//$formats[$id] = 'tsv';
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
329 329
 else $timeout = 20;
330 330
 $errno = '';
331
-$errstr='';
331
+$errstr = '';
332 332
 
333 333
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
334 334
 /* Initiate connections to all the hosts simultaneously */
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 //connect_all($globalSources);
337 337
 
338 338
 if (isset($globalProxy) && $globalProxy) {
339
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
339
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
340 340
 } else {
341 341
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
342 342
 }
@@ -366,16 +366,16 @@  discard block
 block discarded – undo
366 366
 
367 367
 if ($use_aprs) {
368 368
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
369
-	$APRS=new APRS();
369
+	$APRS = new APRS();
370 370
 	$aprs_connect = 0;
371 371
 	$aprs_keep = 120;
372 372
 	$aprs_last_tx = time();
373 373
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
374
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
374
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
375 375
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
376
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
376
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
377 377
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
378
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
378
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
379 379
 	if ($aprs_full) $aprs_filter = '';
380 380
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
381 381
 	else $aprs_pass = '-1';
@@ -389,12 +389,12 @@  discard block
 block discarded – undo
389 389
 sleep(1);
390 390
 if ($globalDebug) echo "SCAN MODE \n\n";
391 391
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
392
-$endtime = time()+$globalCronEnd;
392
+$endtime = time() + $globalCronEnd;
393 393
 $i = 1;
394 394
 $tt = array();
395 395
 // Delete all ATC
396 396
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
397
-	$ATC=new ATC($Connection->db);
397
+	$ATC = new ATC($Connection->db);
398 398
 }
399 399
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
400 400
 	$ATC->deleteAll();
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 while ($i > 0) {
405 405
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
406 406
 
407
-    if (!$globalDaemon) $i = $endtime-time();
407
+    if (!$globalDaemon) $i = $endtime - time();
408 408
     // Delete old ATC
409 409
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
410 410
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	}
419 419
 	if ($max < $globalMinFetch) {
420 420
 	    if ($globalDebug) echo 'Sleeping...'."\n";
421
-	    sleep($globalMinFetch-$max+2);
421
+	    sleep($globalMinFetch - $max + 2);
422 422
 	}
423 423
     }
424 424
 
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 	    //$buffer = $Common->getData($hosts[$id]);
438 438
 	    $buffer = $Common->getData($value['host']);
439 439
 	    if ($buffer != '') $reset = 0;
440
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
441
-	    $buffer = explode('\n',$buffer);
440
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
441
+	    $buffer = explode('\n', $buffer);
442 442
 	    foreach ($buffer as $line) {
443 443
     		if ($line != '' && count($line) > 7) {
444 444
     		    $line = explode(',', $line);
@@ -471,11 +471,11 @@  discard block
 block discarded – undo
471 471
 	    )
472 472
 	) {
473 473
 	    date_default_timezone_set('CET');
474
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
474
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
475 475
 	    date_default_timezone_set('UTC');
476 476
 	    if ($buffer != '') $reset = 0;
477
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
478
-	    $buffer = explode('\n',$buffer);
477
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
478
+	    $buffer = explode('\n', $buffer);
479 479
 	    foreach ($buffer as $line) {
480 480
 		if ($line != '') {
481 481
 		    //echo "'".$line."'\n";
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 		    $ais_data = $AIS->parse_line(trim($line));
484 484
 		    $data = array();
485 485
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
486
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
486
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
487 487
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
488 488
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
489 489
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
496 496
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
497 497
 		    if (isset($ais_data['timestamp'])) {
498
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
498
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
499 499
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
500 500
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
501 501
 			    $add = true;
@@ -518,21 +518,21 @@  discard block
 block discarded – undo
518 518
 	    $w = $e = null;
519 519
 	    
520 520
 	    if (isset($arr[$id])) {
521
-		$nn = stream_select($arr,$w,$e,$timeout);
521
+		$nn = stream_select($arr, $w, $e, $timeout);
522 522
 		if ($nn > 0) {
523 523
 		    foreach ($httpfeeds as $feed) {
524
-			$buffer = stream_get_line($feed,2000,"\n");
524
+			$buffer = stream_get_line($feed, 2000, "\n");
525 525
 			if ($buffer === FALSE) {
526 526
 			    connect_all($globalSources);
527 527
 			}
528
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
529
-			$buffer = explode('\n',$buffer);
528
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
529
+			$buffer = explode('\n', $buffer);
530 530
 			foreach ($buffer as $line) {
531 531
 			    if ($line != '') {
532 532
 				$ais_data = $AIS->parse_line(trim($line));
533 533
 				$data = array();
534 534
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
535
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
535
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
536 536
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
537 537
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
538 538
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -544,9 +544,9 @@  discard block
 block discarded – undo
544 544
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
545 545
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
546 546
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
547
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
547
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
548 548
 				if (isset($ais_data['timestamp'])) {
549
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
549
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
550 550
 				} else {
551 551
 				    $data['datetime'] = date('Y-m-d H:i:s');
552 552
 				}
@@ -578,10 +578,10 @@  discard block
 block discarded – undo
578 578
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
579 579
 	    )
580 580
 	) {
581
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
581
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
582 582
 	    if ($buffer != '') {
583 583
 		//echo $buffer;
584
-		$all_data = json_decode($buffer,true);
584
+		$all_data = json_decode($buffer, true);
585 585
 		//print_r($all_data);
586 586
 		if (isset($all_data[0]['DATA'])) {
587 587
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 			    $data['ident'] = $line['NAME'];
591 591
 			    $data['mmsi'] = $line['MMSI'];
592 592
 			    if (strlen($data['mmsi']) > 9) {
593
-				$data['mmsi'] = substr($data['mmsi'],-9);
593
+				$data['mmsi'] = substr($data['mmsi'], -9);
594 594
 			    }
595 595
 			    $data['speed'] = $line['SOG'];
596 596
 			    $data['heading'] = $line['COG'];
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
 			    //$data['type_id'] = $line['TYPE'];
601 601
 			    $data['imo'] = $line['IMO'];
602 602
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
603
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
604
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
603
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
604
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
605 605
 			    $data['format_source'] = 'myshiptracking';
606 606
 			    $data['id_source'] = $id_source;
607 607
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -618,16 +618,16 @@  discard block
 block discarded – undo
618 618
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
619 619
 	    )
620 620
 	) {
621
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
621
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
622 622
 	    if ($buffer != '') {
623
-		$all_data = json_decode($buffer,true);
623
+		$all_data = json_decode($buffer, true);
624 624
 		if (isset($all_data[0]['mmsi'])) {
625 625
 		    foreach ($all_data as $line) {
626 626
 			if ($line != '') {
627 627
 			    $data = array();
628 628
 			    $data['ident'] = $line['shipname'];
629 629
 			    $data['callsign'] = $line['callsign'];
630
-			    $data['mmsi'] = substr($line['mmsi'],-9);
630
+			    $data['mmsi'] = substr($line['mmsi'], -9);
631 631
 			    $data['speed'] = $line['sog'];
632 632
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
633 633
 			    $data['latitude'] = $line['latitude'];
@@ -654,14 +654,14 @@  discard block
 block discarded – undo
654 654
 	) {
655 655
 	    $buffer = $Common->getData($value['host']);
656 656
 	    if ($buffer != '') {
657
-		$all_data = json_decode($buffer,true);
657
+		$all_data = json_decode($buffer, true);
658 658
 		if (isset($all_data['features'][0]['id'])) {
659 659
 		    foreach ($all_data['features'] as $line) {
660 660
 			print_r($line);
661 661
 			$data = array();
662 662
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
663 663
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
664
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
664
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
665 665
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
666 666
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
667 667
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -688,31 +688,31 @@  discard block
 block discarded – undo
688 688
 	    )
689 689
 	) {
690 690
 	    echo 'download...';
691
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
691
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
692 692
 	    echo 'done !'."\n";
693 693
 	    // FIXME: Need more work
694 694
 	    if ($buffer != '') $reset = 0;
695
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
696
-	    $buffer = explode('\n',$buffer);
695
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
696
+	    $buffer = explode('\n', $buffer);
697 697
 	    foreach ($buffer as $line) {
698 698
 		if ($line != '') {
699 699
 		    $data = array();
700 700
 		    echo $line."\n";
701
-		    $data['mmsi'] = (int)substr($line,0,9);
702
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
703
-		    $data['status_id'] = substr($line,21,2);
704
-		    $data['type_id'] = substr($line,24,3);
705
-		    $data['latitude'] = substr($line,29,9);
706
-		    $data['longitude'] = substr($line,41,9);
707
-		    $data['speed'] = round(substr($line,51,5));
701
+		    $data['mmsi'] = (int) substr($line, 0, 9);
702
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
703
+		    $data['status_id'] = substr($line, 21, 2);
704
+		    $data['type_id'] = substr($line, 24, 3);
705
+		    $data['latitude'] = substr($line, 29, 9);
706
+		    $data['longitude'] = substr($line, 41, 9);
707
+		    $data['speed'] = round(substr($line, 51, 5));
708 708
 		    //$data['course'] = substr($line,57,5);
709
-		    $data['heading'] = round(substr($line,63,3));
709
+		    $data['heading'] = round(substr($line, 63, 3));
710 710
 		    //$data['draft'] = substr($line,67,4);
711 711
 		    //$data['length'] = substr($line,72,3);
712 712
 		    //$data['beam'] = substr($line,76,2);
713
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
713
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
714 714
 		    //$data['callsign'] = trim(substr($line,100,7);
715
-		    $data['arrival_code'] = substr($line,108,20);
715
+		    $data['arrival_code'] = substr($line, 108, 20);
716 716
 		    //$data['etaDate'] = substr($line,129,5);
717 717
 		    //$data['etaTime'] = substr($line,135,5);
718 718
 		    $data['format_source'] = 'shipplotter';
@@ -743,8 +743,8 @@  discard block
 block discarded – undo
743 743
 	) {
744 744
 	    //$buffer = $Common->getData($hosts[$id]);
745 745
 	    $buffer = $Common->getData($value['host']);
746
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
747
-	    $buffer = explode('\n',$buffer);
746
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
747
+	    $buffer = explode('\n', $buffer);
748 748
 	    $reset = 0;
749 749
 	    foreach ($buffer as $line) {
750 750
     		if ($line != '') {
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
756 756
 			$data['pilot_id'] = $line[1];
757 757
 			$data['pilot_name'] = $line[2];
758
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
758
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
759 759
 			$data['ident'] = $line[0]; // ident
760 760
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
761 761
 			$data['speed'] = $line[8]; // speed
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
772 772
 			//if (isset($line[37])) $data['last_update'] = $line[37];
773 773
 		        $data['departure_airport_icao'] = $line[11];
774
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
774
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
775 775
 		        $data['arrival_airport_icao'] = $line[13];
776 776
 			$data['frequency'] = $line[4];
777 777
 			$data['type'] = $line[18];
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
     			$data['id_source'] = $id_source;
781 781
 	    		//$data['arrival_airport_time'] = ;
782 782
 	    		if ($line[9] != '') {
783
-	    		    $aircraft_data = explode('/',$line[9]);
783
+	    		    $aircraft_data = explode('/', $line[9]);
784 784
 	    		    if (isset($aircraft_data[1])) {
785 785
 	    			$data['aircraft_icao'] = $aircraft_data[1];
786 786
 	    		    }
@@ -795,9 +795,9 @@  discard block
 block discarded – undo
795 795
     			if ($line[3] === 'PILOT') $SI->add($data);
796 796
 			elseif ($line[3] === 'ATC') {
797 797
 				//print_r($data);
798
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
799
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
800
-				$typec = substr($data['ident'],-3);
798
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
799
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
800
+				$typec = substr($data['ident'], -3);
801 801
 				if ($typec === 'APP') $data['type'] = 'Approach';
802 802
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
803 803
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
810 810
 				if (!isset($data['source_name'])) $data['source_name'] = '';
811 811
 				if (isset($ATC)) {
812
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
813
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
812
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
813
+					else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
814 814
 				}
815 815
 			}
816 816
     			unset($data);
@@ -826,24 +826,24 @@  discard block
 block discarded – undo
826 826
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
827 827
     	    )
828 828
     	) {
829
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
829
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
830 830
 	    if ($buffer != '') {
831 831
 		$all_data = simplexml_load_string($buffer);
832
-		foreach($all_data->children() as $childdata) {
832
+		foreach ($all_data->children() as $childdata) {
833 833
 			$data = array();
834 834
 			$line = $childdata;
835 835
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
836
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
837
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
838
-			$data['latitude'] = (float)$line['pktLatitude'];
839
-			$data['longitude'] = (float)$line['pktLongitude'];
840
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
841
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
842
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
836
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
837
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
838
+			$data['latitude'] = (float) $line['pktLatitude'];
839
+			$data['longitude'] = (float) $line['pktLongitude'];
840
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
841
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
842
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
843 843
 			$data['altitude_relative'] = 'AMSL';
844
-			$data['pilot_id'] = (int)$line['pktPilotID'];
844
+			$data['pilot_id'] = (int) $line['pktPilotID'];
845 845
 			$data['aircraft_icao'] = 'PARAGLIDER';
846
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
846
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
847 847
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
848 848
 			$data['format_source'] = $value['format'];
849 849
 			$SI->add($data);
@@ -851,22 +851,22 @@  discard block
 block discarded – undo
851 851
 		}
852 852
 	    }
853 853
 	    $Source->deleteOldLocationByType('gs');
854
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
854
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
855 855
 	    if ($buffer != '') {
856 856
 		$all_data = simplexml_load_string($buffer);
857
-		foreach($all_data->children() as $childdata) {
857
+		foreach ($all_data->children() as $childdata) {
858 858
 			$data = array();
859 859
 			$line = $childdata;
860
-			$data['id'] = (int)$line['gsID'];
861
-			$data['latitude'] = (float)$line['gsLatitude'];
862
-			$data['longitude'] = (float)$line['gsLongitude'];
863
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
860
+			$data['id'] = (int) $line['gsID'];
861
+			$data['latitude'] = (float) $line['gsLatitude'];
862
+			$data['longitude'] = (float) $line['gsLongitude'];
863
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
864 864
 			$data['altitude_relative'] = 'AMSL';
865
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
865
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
866 866
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
867
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
867
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
868 868
 			} else {
869
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
869
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
870 870
 			}
871 871
 			unset($data);
872 872
 		}
@@ -884,9 +884,9 @@  discard block
 block discarded – undo
884 884
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
885 885
 	    )
886 886
 	) {
887
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
887
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
888 888
 	    if ($buffer != '') {
889
-	        $all_data = json_decode($buffer,true);
889
+	        $all_data = json_decode($buffer, true);
890 890
 		if (isset($all_data['acList'])) {
891 891
 		    $reset = 0;
892 892
 		    foreach ($all_data['acList'] as $line) {
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
903 903
 			$data['emergency'] = ''; // emergency
904 904
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
905
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
905
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
906 906
 			else $data['datetime'] = date('Y-m-d H:i:s');
907 907
 			//$data['datetime'] = date('Y-m-d H:i:s');
908 908
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 			$data['verticalrate'] = $line['vrt']; // verticale rate
928 928
 			$data['squawk'] = $line['squawk']; // squawk
929 929
 			$data['emergency'] = ''; // emergency
930
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
930
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
931 931
 			else $data['datetime'] = date('Y-m-d H:i:s');
932 932
 			$data['format_source'] = 'aircraftlistjson';
933 933
 			$data['id_source'] = $id_source;
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
     	    )
949 949
     	) {
950 950
 	    $buffer = $Common->getData($value['host']);
951
-	    $all_data = json_decode($buffer,true);
951
+	    $all_data = json_decode($buffer, true);
952 952
 	    if (isset($all_data['planes'])) {
953 953
 		$reset = 0;
954 954
 		foreach ($all_data['planes'] as $key => $line) {
@@ -965,12 +965,12 @@  discard block
 block discarded – undo
965 965
 		    $data['emergency'] = ''; // emergency
966 966
 		    $data['registration'] = $line[2];
967 967
 		    $data['aircraft_icao'] = $line[0];
968
-		    $deparr = explode('-',$line[1]);
968
+		    $deparr = explode('-', $line[1]);
969 969
 		    if (count($deparr) === 2) {
970 970
 			$data['departure_airport_icao'] = $deparr[0];
971 971
 			$data['arrival_airport_icao'] = $deparr[1];
972 972
 		    }
973
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
973
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
974 974
 	    	    $data['format_source'] = 'planeupdatefaa';
975 975
     		    $data['id_source'] = $id_source;
976 976
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 	    )
989 989
 	) {
990 990
 	    $buffer = $Common->getData($value['host']);
991
-	    $all_data = json_decode($buffer,true);
991
+	    $all_data = json_decode($buffer, true);
992 992
 	    if (isset($all_data['states'])) {
993 993
 		$reset = 0;
994 994
 		foreach ($all_data['states'] as $key => $line) {
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 		    //$data['emergency'] = ''; // emergency
1006 1006
 		    //$data['registration'] = $line[2];
1007 1007
 		    //$data['aircraft_icao'] = $line[0];
1008
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1008
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1009 1009
 		    $data['format_source'] = 'opensky';
1010 1010
 		    $data['id_source'] = $id_source;
1011 1011
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
 	    )
1023 1023
 	) {
1024 1024
 	    $buffer = $Common->getData($value['host']);
1025
-	    $all_data = json_decode($buffer,true);
1025
+	    $all_data = json_decode($buffer, true);
1026 1026
 	    if (isset($all_data['aircraft'])) {
1027 1027
 		$reset = 0;
1028 1028
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
 	) {
1059 1059
 	    //$buffer = $Common->getData($hosts[$id]);
1060 1060
 	    $buffer = $Common->getData($value['host']);
1061
-	    $all_data = json_decode($buffer,true);
1061
+	    $all_data = json_decode($buffer, true);
1062 1062
 	    if (!empty($all_data)) $reset = 0;
1063 1063
 	    foreach ($all_data as $key => $line) {
1064 1064
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1096,11 +1096,11 @@  discard block
 block discarded – undo
1096 1096
 	    )
1097 1097
 	) {
1098 1098
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1099
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1099
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1100 1100
 	    //echo $buffer;
1101
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1102
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1103
-	    $all_data = json_decode($buffer,true);
1101
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1102
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1103
+	    $all_data = json_decode($buffer, true);
1104 1104
 	    if (json_last_error() != JSON_ERROR_NONE) {
1105 1105
 		die(json_last_error_msg());
1106 1106
 	    }
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 			//$data['departure_airport_iata'] = $line[11];
1124 1124
 			//$data['arrival_airport_iata'] = $line[12];
1125 1125
 	    		//$data['emergency'] = ''; // emergency
1126
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1126
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1127 1127
 	    		$data['format_source'] = 'radarvirtueljson';
1128 1128
     			$data['id_source'] = $id_source;
1129 1129
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1144,14 +1144,14 @@  discard block
 block discarded – undo
1144 1144
 	) {
1145 1145
 	    //$buffer = $Common->getData($hosts[$id]);
1146 1146
 	    $buffer = $Common->getData($value['host'].'?'.time());
1147
-	    $all_data = json_decode(utf8_encode($buffer),true);
1147
+	    $all_data = json_decode(utf8_encode($buffer), true);
1148 1148
 	    
1149 1149
 	    if (isset($all_data['pireps'])) {
1150 1150
 		$reset = 0;
1151 1151
 	        foreach ($all_data['pireps'] as $line) {
1152 1152
 		    $data = array();
1153 1153
 		    $data['id'] = $line['id'];
1154
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1154
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1155 1155
 		    $data['ident'] = $line['callsign']; // ident
1156 1156
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1157 1157
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1181,9 +1181,9 @@  discard block
 block discarded – undo
1181 1181
 			$SI->add($data);
1182 1182
 		    //    print_r($data);
1183 1183
     		    } elseif ($line['icon'] === 'ct') {
1184
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1185
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1186
-			$typec = substr($data['ident'],-3);
1184
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1185
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1186
+			$typec = substr($data['ident'], -3);
1187 1187
 			$data['type'] = '';
1188 1188
 			if ($typec === 'APP') $data['type'] = 'Approach';
1189 1189
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1195 1195
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1196 1196
 			else $data['type'] = 'Observer';
1197
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1197
+			if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
1198 1198
 		    }
1199 1199
 		    unset($data);
1200 1200
 		}
@@ -1211,14 +1211,14 @@  discard block
 block discarded – undo
1211 1211
 	    //$buffer = $Common->getData($hosts[$id]);
1212 1212
 	    if ($globalDebug) echo 'Get Data...'."\n";
1213 1213
 	    $buffer = $Common->getData($value['host']);
1214
-	    $all_data = json_decode($buffer,true);
1214
+	    $all_data = json_decode($buffer, true);
1215 1215
 	    if ($buffer != '' && is_array($all_data)) {
1216 1216
 		$reset = 0;
1217 1217
 		foreach ($all_data as $line) {
1218 1218
 	    	    $data = array();
1219 1219
 	    	    //$data['id'] = $line['id']; // id not usable
1220 1220
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1221
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1221
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1222 1222
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1223 1223
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1224 1224
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 	    	    //$data['datetime'] = $line['lastupdate'];
1234 1234
 	    	    //$data['last_update'] = $line['lastupdate'];
1235 1235
 	    	    if (isset($value['timezone'])) {
1236
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1236
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1237 1237
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1238 1238
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1239 1239
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1249,14 +1249,14 @@  discard block
 block discarded – undo
1249 1249
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1250 1250
 		    if (isset($line['aircraftname'])) {
1251 1251
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1252
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1253
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1252
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1253
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1254 1254
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1255 1255
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1256 1256
 	    		else {
1257
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1258
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1259
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1257
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1258
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1259
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1260 1260
 	    		}
1261 1261
 	    	    }
1262 1262
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1281,7 +1281,7 @@  discard block
 block discarded – undo
1281 1281
 	    //$buffer = $Common->getData($hosts[$id]);
1282 1282
 	    if ($globalDebug) echo 'Get Data...'."\n";
1283 1283
 	    $buffer = $Common->getData($value['host']);
1284
-	    $all_data = json_decode($buffer,true);
1284
+	    $all_data = json_decode($buffer, true);
1285 1285
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1286 1286
 		$reset = 0;
1287 1287
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1292,7 +1292,7 @@  discard block
 block discarded – undo
1292 1292
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1293 1293
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1294 1294
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1295
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1295
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1296 1296
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1297 1297
 	    	    $data['altitude'] = $line['altitude']; // altitude
1298 1298
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
 	    	    //$data['squawk'] = ''; // squawk
1304 1304
 	    	    //$data['emergency'] = ''; // emergency
1305 1305
 	    	    if (isset($value['timezone'])) {
1306
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1306
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1307 1307
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1308 1308
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1309 1309
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1339,14 +1339,14 @@  discard block
 block discarded – undo
1339 1339
 	    //$buffer = $Common->getData($hosts[$id]);
1340 1340
 	    if ($globalDebug) echo 'Get Data...'."\n";
1341 1341
 	    $buffer = $Common->getData($value['host']);
1342
-	    $all_data = json_decode($buffer,true);
1342
+	    $all_data = json_decode($buffer, true);
1343 1343
 	    if ($buffer != '' && is_array($all_data)) {
1344 1344
 		$reset = 0;
1345 1345
 		foreach ($all_data as $line) {
1346 1346
 	    	    $data = array();
1347 1347
 	    	    //$data['id'] = $line['id']; // id not usable
1348 1348
 	    	    $data['id'] = trim($line['flight_id']);
1349
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1349
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1350 1350
 	    	    $data['pilot_name'] = $line['pilot_name'];
1351 1351
 	    	    $data['pilot_id'] = $line['pilot_id'];
1352 1352
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1390,24 +1390,24 @@  discard block
 block discarded – undo
1390 1390
 	    //$buffer = $Common->getData($hosts[$id]);
1391 1391
 	    if ($globalDebug) echo 'Get Data...'."\n";
1392 1392
 	    $buffer = $Common->getData($value['host']);
1393
-	    $all_data = json_decode($buffer,true);
1393
+	    $all_data = json_decode($buffer, true);
1394 1394
 	    if ($buffer != '') {
1395 1395
 		$Source->deleteLocationBySource('blitzortung');
1396
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1397
-		$buffer = explode('\n',$buffer);
1396
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1397
+		$buffer = explode('\n', $buffer);
1398 1398
 		foreach ($buffer as $buffer_line) {
1399
-		    $line = json_decode($buffer_line,true);
1399
+		    $line = json_decode($buffer_line, true);
1400 1400
 		    if (isset($line['time'])) {
1401 1401
 			$data = array();
1402 1402
 			$data['altitude'] = $line['alt']; // altitude
1403 1403
 			$data['latitude'] = $line['lat']; // lat
1404 1404
 			$data['longitude'] = $line['lon']; // long
1405
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1405
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1406 1406
 			$data['id_source'] = $id_source;
1407 1407
 			$data['format_source'] = 'blitzortung';
1408 1408
 			$SI->add($data);
1409 1409
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1410
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1410
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1411 1411
 			unset($data);
1412 1412
 		    }
1413 1413
 		}
@@ -1430,11 +1430,11 @@  discard block
 block discarded – undo
1430 1430
 		    //$value = $formats[$nb];
1431 1431
 		    $format = $globalSources[$nb]['format'];
1432 1432
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1433
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1433
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1434 1434
 		    } elseif ($format === 'vrstcp') {
1435 1435
 			$buffer = @socket_read($r, 6000);
1436 1436
 		    } else {
1437
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1437
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1438 1438
 		    }
1439 1439
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1440 1440
 		    //echo $buffer."\n";
@@ -1444,8 +1444,8 @@  discard block
 block discarded – undo
1444 1444
 		    //$SI::del();
1445 1445
 		    if ($buffer !== FALSE) {
1446 1446
 			if ($format === 'vrstcp') {
1447
-			    $buffer = explode('},{',$buffer);
1448
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1447
+			    $buffer = explode('},{', $buffer);
1448
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1449 1449
 		    }
1450 1450
 		    // SBS format is CSV format
1451 1451
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
 			    $ais_data = $AIS->parse_line(trim($buffer));
1470 1470
 			    $data = array();
1471 1471
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1472
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1472
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1473 1473
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1474 1474
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1475 1475
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1480,13 +1480,13 @@  discard block
 block discarded – undo
1480 1480
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1481 1481
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1482 1482
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1483
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1483
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1484 1484
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1485 1485
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1486 1486
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1487 1487
 
1488 1488
 			    if (isset($ais_data['timestamp'])) {
1489
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1489
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1490 1490
 			    } else {
1491 1491
 				$data['datetime'] = date('Y-m-d H:i:s');
1492 1492
 			    }
@@ -1497,10 +1497,10 @@  discard block
 block discarded – undo
1497 1497
                         } elseif ($format === 'flightgearsp') {
1498 1498
                     	    //echo $buffer."\n";
1499 1499
                     	    if (strlen($buffer) > 5) {
1500
-				$line = explode(',',$buffer);
1500
+				$line = explode(',', $buffer);
1501 1501
 				$data = array();
1502 1502
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1503
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1503
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1504 1504
 				$data['ident'] = $line[6];
1505 1505
 				$data['aircraft_name'] = $line[7];
1506 1506
 				$data['longitude'] = $line[1];
@@ -1517,16 +1517,16 @@  discard block
 block discarded – undo
1517 1517
                         } elseif ($format === 'acars') {
1518 1518
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1519 1519
 			    $ACARS->add(trim($buffer));
1520
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1520
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1521 1521
 			    $ACARS->deleteLiveAcarsData();
1522 1522
 			} elseif ($format === 'flightgearmp') {
1523
-			    if (substr($buffer,0,1) != '#') {
1523
+			    if (substr($buffer, 0, 1) != '#') {
1524 1524
 				$data = array();
1525 1525
 				//echo $buffer."\n";
1526
-				$line = explode(' ',$buffer);
1526
+				$line = explode(' ', $buffer);
1527 1527
 				if (count($line) === 11) {
1528
-				    $userserver = explode('@',$line[0]);
1529
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1528
+				    $userserver = explode('@', $line[0]);
1529
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1530 1530
 				    $data['ident'] = $userserver[0];
1531 1531
 				    $data['registration'] = $userserver[0];
1532 1532
 				    $data['latitude'] = $line[4];
@@ -1534,8 +1534,8 @@  discard block
 block discarded – undo
1534 1534
 				    $data['altitude'] = $line[6];
1535 1535
 				    $data['datetime'] = date('Y-m-d H:i:s');
1536 1536
 				    $aircraft_type = $line[10];
1537
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1538
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1537
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1538
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1539 1539
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1540 1540
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1541 1541
 				}
@@ -1544,8 +1544,8 @@  discard block
 block discarded – undo
1544 1544
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1545 1545
 			    die;
1546 1546
 			} elseif ($format === 'vrstcp') {
1547
-			    foreach($buffer as $all_data) {
1548
-				$line = json_decode('{'.$all_data.'}',true);
1547
+			    foreach ($buffer as $all_data) {
1548
+				$line = json_decode('{'.$all_data.'}', true);
1549 1549
 				$data = array();
1550 1550
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1551 1551
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1571,16 +1571,16 @@  discard block
 block discarded – undo
1571 1571
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1572 1572
 				unset($data);
1573 1573
 			    }
1574
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1574
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1575 1575
 			    $line = explode("\t", $buffer);
1576
-			    for($k = 0; $k < count($line); $k=$k+2) {
1576
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1577 1577
 				$key = $line[$k];
1578
-			        $lined[$key] = $line[$k+1];
1578
+			        $lined[$key] = $line[$k + 1];
1579 1579
 			    }
1580 1580
     			    if (count($lined) > 3) {
1581 1581
     				$data['hex'] = $lined['hexid'];
1582 1582
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1583
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1583
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1584 1584
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1585 1585
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1586 1586
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1599,23 +1599,23 @@  discard block
 block discarded – undo
1599 1599
     			    } else $error = true;
1600 1600
 			} elseif ($format === 'aprs' && $use_aprs) {
1601 1601
 			    if ($aprs_connect === 0) {
1602
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1602
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1603 1603
 				$aprs_connect = 1;
1604 1604
 			    }
1605 1605
 			    
1606
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1606
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1607 1607
 				$aprs_last_tx = time();
1608 1608
 				$data_aprs = "# Keep alive";
1609
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1609
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1610 1610
 			    }
1611 1611
 			    
1612 1612
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1613 1613
 			    //echo 'APRS data : '.$buffer."\n";
1614
-			    $buffer = str_replace('APRS <- ','',$buffer);
1615
-			    $buffer = str_replace('APRS -> ','',$buffer);
1614
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1615
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1616 1616
 			    //echo $buffer."\n";
1617 1617
 			    date_default_timezone_set('UTC');
1618
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1618
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1619 1619
 				$line = $APRS->parse($buffer);
1620 1620
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1621 1621
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1630,7 +1630,7 @@  discard block
 block discarded – undo
1630 1630
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1631 1631
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1632 1632
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1633
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1633
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1634 1634
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1635 1635
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1636 1636
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1713,29 +1713,29 @@  discard block
 block discarded – undo
1713 1713
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1714 1714
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1715 1715
 					$Source->deleteOldLocationByType('gs');
1716
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1717
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1716
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1717
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1718 1718
 					} else {
1719
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1719
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1720 1720
 					}
1721 1721
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1722 1722
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1723 1723
 					if ($globalDebug) echo '# Weather Station added'."\n";
1724 1724
 					$Source->deleteOldLocationByType('wx');
1725 1725
 					$weather_data = json_encode($line);
1726
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1727
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1726
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1727
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1728 1728
 					} else {
1729
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1729
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1730 1730
 					}
1731 1731
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1732 1732
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1733 1733
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1734 1734
 					$Source->deleteOldLocationByType('lightning');
1735
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1736
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1735
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1736
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1737 1737
 					} else {
1738
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1738
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1739 1739
 					}
1740 1740
 				    } elseif ($globalDebug) {
1741 1741
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1744,7 +1744,7 @@  discard block
 block discarded – undo
1744 1744
 				    unset($data);
1745 1745
 				}
1746 1746
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1747
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1747
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1748 1748
 				}
1749 1749
 				/*
1750 1750
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) {
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
 				*/
1754 1754
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1755 1755
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1756
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1756
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1757 1757
 					$Source->deleteOldLocationByType('lightning');
1758 1758
 					$Source->deleteOldLocationByType('wx');
1759 1759
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1838,7 +1838,7 @@  discard block
 block discarded – undo
1838 1838
 				connect_all($sourceee);
1839 1839
 				$sourceee = array();
1840 1840
 				//connect_all($globalSources);
1841
-				$tt[$format]=0;
1841
+				$tt[$format] = 0;
1842 1842
 				break;
1843 1843
 			    } 
1844 1844
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -1848,14 +1848,14 @@  discard block
 block discarded – undo
1848 1848
 	    } else {
1849 1849
 		$error = socket_strerror(socket_last_error());
1850 1850
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1851
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1851
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1852 1852
 			if (isset($globalDebug)) echo "Restarting...\n";
1853 1853
 			// Restart the script if possible
1854 1854
 			if (is_array($sockets)) {
1855 1855
 			    if ($globalDebug) echo "Shutdown all sockets...";
1856 1856
 			    
1857 1857
 			    foreach ($sockets as $sock) {
1858
-				@socket_shutdown($sock,2);
1858
+				@socket_shutdown($sock, 2);
1859 1859
 				@socket_close($sock);
1860 1860
 			    }
1861 1861
 			    
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 		$currentdate = date('Y-m-d');
35 35
 		$sourcestat = $Stats->getStatsSource($currentdate);
36 36
 		if (!empty($sourcestat)) {
37
-		    foreach($sourcestat as $srcst) {
37
+		    foreach ($sourcestat as $srcst) {
38 38
 		    	$type = $srcst['stats_type'];
39 39
 			if ($type == 'polar' || $type == 'hist') {
40 40
 			    $source = $srcst['source_name'];
41 41
 			    $data = $srcst['source_data'];
42
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
42
+			    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
43 43
 	    		}
44 44
 		    }
45 45
 		}
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 	if (isset($globalGeoid) && $globalGeoid) {
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54
-		} catch(Exception $e) {
54
+		} catch (Exception $e) {
55 55
 			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
56 56
 			$GeoidClass = FALSE;
57 57
 		}
58 58
 	}
59 59
     }
60 60
 
61
-    public function get_Schedule($id,$ident) {
61
+    public function get_Schedule($id, $ident) {
62 62
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
63 63
 	// Get schedule here, so it's done only one time
64 64
 	
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 		$schedule = $Schedule->fetchSchedule($operator);
84 84
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85 85
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
86
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
87
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
88 88
 		    // Should also check if route schedule = route from DB
89 89
 		    if ($schedule['DepartureAirportIATA'] != '') {
90 90
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			    }
105 105
 			}
106 106
 		    }
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']);
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']);
108 108
 		}
109 109
 	    } else $scheduleexist = true;
110 110
 	} else $scheduleexist = true;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
        if ($scheduleexist) {
113 113
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
114 114
     		$sch = $Schedule->getSchedule($operator);
115
-		$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']));
115
+		$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']));
116 116
        }
117 117
 	$Spotter->db = null;
118 118
 	$Schedule->db = null;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
140 140
     		    $Spotter = new Spotter($this->db);
141 141
         	    $real_arrival = $this->arrival($key);
142
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $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']);
142
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $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']);
143 143
         	}
144 144
 	    }
145 145
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         $airport_time = '';
154 154
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
155 155
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
156
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
156
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
157 157
     	    if (isset($closestAirports[0])) {
158 158
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
159 159
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         		    break;
169 169
         		}
170 170
         	    }
171
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
171
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
172 172
         		$airport_icao = $closestAirports[0]['icao'];
173 173
         		$airport_time = $this->all_flights[$key]['datetime'];
174 174
         	} else {
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         } else {
182 182
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
183 183
         }
184
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
184
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
185 185
     }
186 186
 
187 187
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
193 193
 	foreach ($this->all_flights as $key => $flight) {
194 194
 	    if (isset($flight['lastupdate'])) {
195
-		if ($flight['lastupdate'] < (time()-1800)) {
195
+		if ($flight['lastupdate'] < (time() - 1800)) {
196 196
 		    $this->delKey($key);
197 197
 		}
198 198
 	    }
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$real_arrival = $this->arrival($key);
209 209
 			$Spotter = new Spotter($this->db);
210 210
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
211
-				$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']);
211
+				$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']);
212 212
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
213 213
 			}
214 214
 		}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	$send = false;
242 242
 	
243 243
 	// SBS format is CSV format
244
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
244
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
245 245
 	    //print_r($line);
246 246
 	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
247 247
   	    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)) {
@@ -277,25 +277,25 @@  discard block
 block discarded – undo
277 277
 		if (!isset($this->all_flights[$id])) {
278 278
 		    if ($globalDebug) echo 'New flight...'."\n";
279 279
 		    $this->all_flights[$id] = array();
280
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
281
-		    $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' => ''));
282
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
280
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
281
+		    $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' => ''));
282
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
283 283
 		    if (!isset($line['id'])) {
284 284
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
285 285
 //			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')));
286 286
 //			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')));
287
-			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')));
287
+			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')));
288 288
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
289
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
289
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
290 290
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
291 291
 		}
292 292
 		if (isset($line['source_type']) && $line['source_type'] != '') {
293
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
293
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
294 294
 		}
295 295
 		
296 296
 		//print_r($this->all_flights);
297 297
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
298
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
298
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
299 299
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
300 300
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
301 301
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -304,20 +304,20 @@  discard block
 block discarded – undo
304 304
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
305 305
 			    $Spotter = new Spotter($this->db);
306 306
 			    if (isset($this->all_flights[$id]['source_type'])) {
307
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
307
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
308 308
 			    } else {
309 309
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
310 310
 			    }
311 311
 			    $Spotter->db = null;
312
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
312
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
313
+			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
314 314
 			}
315 315
 		    }
316 316
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
317 317
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
318 318
 		}
319 319
 	        if (isset($line['id']) && !isset($line['hex'])) {
320
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
320
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => ''));
321 321
 	        }
322 322
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
323 323
 			$icao = $line['aircraft_icao'];
@@ -326,14 +326,14 @@  discard block
 block discarded – undo
326 326
 				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
327 327
 				$Spotter->db = null;
328 328
 			}
329
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
329
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao));
330 330
 		} elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
331 331
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
332 332
 				// Get aircraft ICAO from aircraft name
333 333
 				$Spotter = new Spotter($this->db);
334 334
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
335 335
 				$Spotter->db = null;
336
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
336
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
337 337
 			}
338 338
 		}
339 339
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -341,15 +341,15 @@  discard block
 block discarded – undo
341 341
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
342 342
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
343 343
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
344
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
344
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
345 345
 		}
346 346
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
347
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
347
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
348 348
 		}
349 349
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
350
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
350
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
351 351
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
352
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
352
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
353 353
 		    } else {
354 354
 				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";
355 355
 				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";
@@ -360,31 +360,31 @@  discard block
 block discarded – undo
360 360
 				*/
361 361
 				return '';
362 362
 		    }
363
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
363
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
364 364
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
365 365
 			return '';
366
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
366
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
367 367
 			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
368 368
 			return '';
369 369
 		} elseif (!isset($line['datetime'])) {
370 370
 			date_default_timezone_set('UTC');
371
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
371
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
372 372
 		} else {
373 373
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
374 374
 			return '';
375 375
 		}
376 376
 
377 377
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') {
378
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
378
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
379 379
 		}
380 380
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
381
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
381
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
382 382
 		}
383 383
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
384
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
384
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id'])));
385 385
 		}
386 386
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
387
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
387
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name'])));
388 388
 		}
389 389
  
390 390
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
@@ -392,13 +392,13 @@  discard block
 block discarded – undo
392 392
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
393 393
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
394 394
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
395
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
396
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
397
-				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')));
398
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
399
-				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']));
395
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
396
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
397
+				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')));
398
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
399
+				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']));
400 400
 			} else {
401
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
401
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
402 402
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
403 403
 				$timeelapsed = microtime(true);
404 404
             			$Spotter = new Spotter($this->db);
@@ -408,13 +408,13 @@  discard block
 block discarded – undo
408 408
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
409 409
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
410 410
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
411
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
411
+            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
412 412
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
413 413
 				$Spotter->db = null;
414
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
414
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
415 415
 			    }
416 416
 			}
417
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
417
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
418 418
 		    
419 419
 /*
420 420
 		    if (!isset($line['id'])) {
@@ -424,25 +424,25 @@  discard block
 block discarded – undo
424 424
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
425 425
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
426 426
   */
427
-		    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']));
427
+		    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']));
428 428
 
429 429
 		    //$putinarchive = true;
430 430
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
431
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
431
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
432 432
 		    }
433 433
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
434
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
434
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
435 435
 		    }
436 436
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
437
-		    		$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
+		    		$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' => ''));
438 438
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
439 439
 			$timeelapsed = microtime(true);
440 440
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
441 441
 				$Spotter = new Spotter($this->db);
442 442
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
443 443
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
444
-		    		$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' => ''));
445
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
444
+		    		$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' => ''));
445
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
446 446
                         }
447 447
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
448 448
 			$timeelapsed = microtime(true);
@@ -456,35 +456,35 @@  discard block
 block discarded – undo
456 456
 				$Translation->db = null;
457 457
 			    }
458 458
 			    $Spotter->db = null;
459
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
459
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
460 460
                     	}
461 461
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
462 462
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
463 463
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
464 464
 				//    $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']));
465
-		    		$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']));
465
+		    		$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']));
466 466
 		    	    }
467 467
 			}
468 468
 			if (!isset($globalFork)) $globalFork = TRUE;
469 469
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
470
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
470
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
471 471
 			}
472 472
 		    }
473 473
 		}
474 474
 
475 475
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
476 476
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
477
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
478
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
477
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
478
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
479 479
 		    //$dataFound = true;
480 480
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
481
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
481
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
482 482
 		    if ($distance > 1000 && $distance < 10000) {
483 483
 		    // use datetime
484 484
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
485 485
 			$speed = $speed*3.6;
486 486
 			if ($speed < 1000) {
487
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
487
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
488 488
 	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
489 489
 	  		} else {
490 490
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
@@ -499,9 +499,9 @@  discard block
 block discarded – undo
499 499
 	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
500 500
 	    	    	return false;
501 501
 	    	    }
502
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
502
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
503 503
 	    	    else unset($timediff);
504
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
504
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']);
505 505
 	    	    else unset($timediff_archive);
506 506
 	    	    if ($this->tmd > 5
507 507
 	    	        || (isset($line['format_source']) 
@@ -526,14 +526,14 @@  discard block
 block discarded – undo
526 526
 	    	    	|| ($timediff > 30 
527 527
 	    	    	    && isset($this->all_flights[$id]['latitude']) 
528 528
 	    	    	    && isset($this->all_flights[$id]['longitude']) 
529
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
529
+	    	    	    && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'))
530 530
 	    	    	    )
531 531
 	    	    	) {
532 532
 
533 533
 			if ((isset($timediff) && !isset($timediff_archive)) || (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']))) {
534 534
 			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
535 535
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
536
-				|| !$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'])) {
536
+				|| !$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'])) {
537 537
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
538 538
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
539 539
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -543,11 +543,11 @@  discard block
 block discarded – undo
543 543
 				    $timeelapsed = microtime(true);
544 544
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
545 545
 					$Spotter = new Spotter($this->db);
546
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
546
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
547 547
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
548 548
 					else $this->all_flights[$id]['over_country'] = '';
549 549
 					$Spotter->db = null;
550
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
550
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
551 551
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
552 552
 				    }
553 553
 				}
@@ -573,13 +573,13 @@  discard block
 block discarded – undo
573 573
 					$this->all_flights[$id]['time_last_coord'] = time();
574 574
 				}
575 575
 				//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' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
576
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
576
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) {
577 577
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
578 578
 				    $dataFound = true;
579 579
 				    $this->all_flights[$id]['time_last_coord'] = time();
580 580
 				}
581 581
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
582
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
582
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
583 583
 				/*
584 584
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
585 585
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -601,13 +601,13 @@  discard block
 block discarded – undo
601 601
 					$this->all_flights[$id]['time_last_coord'] = time();
602 602
 				}
603 603
 				//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' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
604
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
604
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) {
605 605
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
606 606
 				    $dataFound = true;
607 607
 				    $this->all_flights[$id]['time_last_coord'] = time();
608 608
 				}
609 609
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
610
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
610
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
611 611
 				/*
612 612
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
613 613
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -625,46 +625,46 @@  discard block
 block discarded – undo
625 625
 		    } else if ($globalDebug && $timediff > 30) {
626 626
 			$this->tmd = $this->tmd + 1;
627 627
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
628
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
629
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
628
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
629
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
630 630
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
631 631
 		    }
632 632
 		}
633 633
 		if (isset($line['last_update']) && $line['last_update'] != '') {
634 634
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
635
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
635
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
636 636
 		}
637 637
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
638
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
638
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
639 639
 		    //$dataFound = true;
640 640
 		}
641 641
 		if (isset($line['format_source']) && $line['format_source'] != '') {
642
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
642
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
643 643
 		}
644 644
 		if (isset($line['source_name']) && $line['source_name'] != '') {
645
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
645
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
646 646
 		}
647 647
 		if (isset($line['emergency']) && $line['emergency'] != '') {
648
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
648
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
649 649
 		    //$dataFound = true;
650 650
 		}
651 651
 		if (isset($line['ground']) && $line['ground'] != '') {
652 652
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
653 653
 			// Here we force archive of flight because after ground it's a new one (or should be)
654
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
655
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
656
-			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')));
657
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
658
-			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']));
654
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
655
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
656
+			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')));
657
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
658
+			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']));
659 659
 		    }
660 660
 		    if ($line['ground'] != 1) $line['ground'] = 0;
661
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
661
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
662 662
 		    //$dataFound = true;
663 663
 		}
664 664
 		if (isset($line['squawk']) && $line['squawk'] != '') {
665 665
 		    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'])) {
666 666
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
667
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
667
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
668 668
 			    $highlight = '';
669 669
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
670 670
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -673,66 +673,66 @@  discard block
 block discarded – undo
673 673
 				$timeelapsed = microtime(true);
674 674
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
675 675
 				    $Spotter = new Spotter($this->db);
676
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
676
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
677 677
 				    $Spotter->db = null;
678
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
678
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
679 679
 				}
680 680
 				//$putinarchive = true;
681 681
 				//$highlight = '';
682 682
 			    }
683 683
 			    
684
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
684
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
685 685
 		    //$dataFound = true;
686 686
 		}
687 687
 
688 688
 		if (isset($line['altitude']) && $line['altitude'] != '') {
689 689
 			if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) {
690 690
 				if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') {
691
-					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2);
691
+					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2);
692 692
 					//if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n";
693 693
 					$line['altitude'] = $line['altitude'] - $geoid;
694 694
 				}
695 695
 			}
696 696
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
697
-			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;
698
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
699
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
697
+			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;
698
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
699
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
700 700
 			//$dataFound = true;
701 701
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
702 702
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
703 703
 			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) {
704 704
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
705
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
706
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
707
-				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')));
708
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
709
-				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']));
705
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
706
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
707
+				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')));
708
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
709
+				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']));
710 710
 			}
711 711
 		    }
712
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
712
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude']));
713 713
 		}
714 714
 
715 715
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
716
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
716
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
717 717
 		}
718 718
 		
719 719
 		if (isset($line['heading']) && $line['heading'] != '') {
720
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
721
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
722
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
720
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
721
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
722
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
723 723
 		    //$dataFound = true;
724 724
   		} 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']) {
725
-  		    $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']);
726
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
727
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
725
+  		    $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']);
726
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
727
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
728 728
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
729 729
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
730 730
   		    // If not enough messages and ACARS set heading to 0
731
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
731
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
732 732
   		}
733
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
734
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
735
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
733
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
734
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
735
+		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
736 736
 
737 737
 //		print_r($this->all_flights[$id]);
738 738
 		//gets the callsign from the last hour
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
744 744
 		    $this->all_flights[$id]['lastupdate'] = time();
745 745
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
746
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
746
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
747 747
 			    //print_r($this->all_flights);
748 748
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
749 749
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -754,61 +754,61 @@  discard block
 block discarded – undo
754 754
 				    $SpotterLive = new SpotterLive($this->db);
755 755
 				    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')) {
756 756
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
757
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
757
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
758 758
 				    } elseif (isset($line['id'])) {
759 759
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
760
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
760
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
761 761
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
762 762
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
763
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
763
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
764 764
 				    } else $recent_ident = '';
765
-				    $SpotterLive->db=null;
765
+				    $SpotterLive->db = null;
766 766
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
767 767
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
768 768
 				} else $recent_ident = '';
769 769
 			    } else {
770 770
 				$recent_ident = '';
771
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
771
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
772 772
 			    }
773 773
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
774
-			    if($recent_ident == "")
774
+			    if ($recent_ident == "")
775 775
 			    {
776 776
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
777 777
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
778 778
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
779 779
 				//adds the spotter data for the archive
780 780
 				$ignoreImport = false;
781
-				foreach($globalAirportIgnore as $airportIgnore) {
781
+				foreach ($globalAirportIgnore as $airportIgnore) {
782 782
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
783 783
 					$ignoreImport = true;
784 784
 				    }
785 785
 				}
786 786
 				if (count($globalAirportAccept) > 0) {
787 787
 				    $ignoreImport = true;
788
-				    foreach($globalAirportIgnore as $airportIgnore) {
788
+				    foreach ($globalAirportIgnore as $airportIgnore) {
789 789
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
790 790
 					    $ignoreImport = false;
791 791
 					}
792 792
 				    }
793 793
 				}
794 794
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
795
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
796
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
795
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
796
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
797 797
 					    $ignoreImport = true;
798 798
 					}
799 799
 				    }
800 800
 				}
801 801
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
802 802
 				    $ignoreImport = true;
803
-				    foreach($globalAirlineAccept as $airlineAccept) {
804
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
803
+				    foreach ($globalAirlineAccept as $airlineAccept) {
804
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
805 805
 					    $ignoreImport = false;
806 806
 					}
807 807
 				    }
808 808
 				}
809 809
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
810 810
 				    $ignoreImport = true;
811
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
811
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
812 812
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
813 813
 					    $ignoreImport = false;
814 814
 					}
@@ -820,32 +820,32 @@  discard block
 block discarded – undo
820 820
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
821 821
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
822 822
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
823
-				    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')));
823
+				    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')));
824 824
 				    $timeelapsed = microtime(true);
825 825
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
826 826
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
827 827
 					    $Spotter = new Spotter($this->db);
828
-					    $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']);
828
+					    $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']);
829 829
 					    $Spotter->db = null;
830 830
 					    if ($globalDebug && isset($result)) echo $result."\n";
831 831
 					}
832 832
 				    }
833
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
833
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
834 834
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
835 835
 
836 836
 				    // Add source stat in DB
837 837
 				    $Stats = new Stats($this->db);
838 838
 				    if (!empty($this->stats)) {
839 839
 					if ($globalDebug) echo 'Add source stats : ';
840
-				        foreach($this->stats as $date => $data) {
841
-					    foreach($data as $source => $sourced) {
840
+				        foreach ($this->stats as $date => $data) {
841
+					    foreach ($data as $source => $sourced) {
842 842
 					        //print_r($sourced);
843
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
844
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
843
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
844
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
845 845
 				    		if (isset($sourced['msg'])) {
846 846
 				    		    if (time() - $sourced['msg']['date'] > 10) {
847 847
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
848
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
848
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
849 849
 			    			        unset($this->stats[$date][$source]['msg']);
850 850
 			    			    }
851 851
 			    			}
@@ -883,14 +883,14 @@  discard block
 block discarded – undo
883 883
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
884 884
 					    $SpotterLive = new SpotterLive($this->db);
885 885
 					    $SpotterLive->deleteLiveSpotterData();
886
-					    $SpotterLive->db=null;
886
+					    $SpotterLive->db = null;
887 887
 					}
888 888
 				    }
889 889
 				    if ($globalDebug) echo " Done\n";
890 890
 				    $this->last_delete = time();
891 891
 				}
892 892
 			    } else {
893
-				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'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
893
+				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'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
894 894
 				    $this->all_flights[$id]['id'] = $recent_ident;
895 895
 				    $this->all_flights[$id]['addedSpotter'] = 1;
896 896
 				}
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
899 899
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
900 900
 					    $Spotter = new Spotter($this->db);
901
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
901
+					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
902 902
 					    $Spotter->db = null;
903 903
 					}
904 904
 				    }
@@ -924,37 +924,37 @@  discard block
 block discarded – undo
924 924
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
925 925
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
926 926
 
927
-		    foreach($globalAirportIgnore as $airportIgnore) {
927
+		    foreach ($globalAirportIgnore as $airportIgnore) {
928 928
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
929 929
 			    $ignoreImport = true;
930 930
 			}
931 931
 		    }
932 932
 		    if (count($globalAirportAccept) > 0) {
933 933
 		        $ignoreImport = true;
934
-		        foreach($globalAirportIgnore as $airportIgnore) {
934
+		        foreach ($globalAirportIgnore as $airportIgnore) {
935 935
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
936 936
 				$ignoreImport = false;
937 937
 			    }
938 938
 			}
939 939
 		    }
940 940
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
941
-			foreach($globalAirlineIgnore as $airlineIgnore) {
942
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
941
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
942
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
943 943
 				$ignoreImport = true;
944 944
 			    }
945 945
 			}
946 946
 		    }
947 947
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
948 948
 			$ignoreImport = true;
949
-			foreach($globalAirlineAccept as $airlineAccept) {
950
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
949
+			foreach ($globalAirlineAccept as $airlineAccept) {
950
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
951 951
 				$ignoreImport = false;
952 952
 			    }
953 953
 			}
954 954
 		    }
955 955
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
956 956
 			$ignoreImport = true;
957
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
957
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
958 958
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
959 959
 			        $ignoreImport = false;
960 960
 			    }
@@ -962,23 +962,23 @@  discard block
 block discarded – undo
962 962
 		    }
963 963
 
964 964
 		    if (!$ignoreImport) {
965
-			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'])) {
966
-				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')));
965
+			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'])) {
966
+				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')));
967 967
 				$timeelapsed = microtime(true);
968 968
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
969 969
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
970 970
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
971 971
 					$SpotterLive = new SpotterLive($this->db);
972
-					$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']);
972
+					$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']);
973 973
 					$SpotterLive->db = null;
974 974
 					if ($globalDebug) echo $result."\n";
975 975
 				    }
976 976
 				}
977 977
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
978
-					$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']);
978
+					$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']);
979 979
 				}
980 980
 				$this->all_flights[$id]['putinarchive'] = false;
981
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
981
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
982 982
 
983 983
 				// Put statistics in $this->stats variable
984 984
 				//if ($line['format_source'] != 'aprs') {
@@ -997,19 +997,19 @@  discard block
 block discarded – undo
997 997
 							$latitude = $globalCenterLatitude;
998 998
 							$longitude = $globalCenterLongitude;
999 999
 						}
1000
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
1000
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
1001 1001
 					} else {
1002 1002
 						$latitude = $this->source_location[$source]['latitude'];
1003 1003
 						$longitude = $this->source_location[$source]['longitude'];
1004 1004
 					}
1005
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1005
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1006 1006
 					//$stats_heading = $stats_heading%22.5;
1007 1007
 					$stats_heading = round($stats_heading/22.5);
1008
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1008
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1009 1009
 					$current_date = date('Y-m-d');
1010 1010
 					if ($stats_heading == 16) $stats_heading = 0;
1011 1011
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1012
-						for ($i=0;$i<=15;$i++) {
1012
+						for ($i = 0; $i <= 15; $i++) {
1013 1013
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1014 1014
 						}
1015 1015
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -1024,9 +1024,9 @@  discard block
 block discarded – undo
1024 1024
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1025 1025
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1026 1026
 						    end($this->stats[$current_date][$source]['hist']);
1027
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1027
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
1028 1028
 						} else $mini = 0;
1029
-						for ($i=$mini;$i<=$distance;$i+=10) {
1029
+						for ($i = $mini; $i <= $distance; $i += 10) {
1030 1030
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1031 1031
 						}
1032 1032
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 				$this->all_flights[$id]['lastupdate'] = time();
1040 1040
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
1041 1041
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1042
-			} 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";
1042
+			} 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";
1043 1043
 			//$this->del();
1044 1044
 			
1045 1045
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.