Completed
Push — master ( 3b96e3...9ee9e2 )
by Yannick
84:45 queued 56:09
created
require/class.APRS.php 1 patch
Spacing   +157 added lines, -158 removed lines patch added patch discarded remove patch
@@ -167,8 +167,7 @@  discard block
 block discarded – undo
167 167
 	
168 168
 
169 169
     private function urshift($n, $s) {
170
-	return ($n >= 0) ? ($n >> $s) :
171
-	    (($n & 0x7fffffff) >> $s) | 
170
+	return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
172 171
 		(0x40000000 >> ($s - 1));
173 172
     }
174 173
 
@@ -180,7 +179,7 @@  discard block
 block discarded – undo
180 179
 	//$split_input = str_split($input);
181 180
 
182 181
 	/* Find the end of header checking for NULL bytes while doing it. */
183
-	$splitpos = strpos($input,':');
182
+	$splitpos = strpos($input, ':');
184 183
 	
185 184
 	/* Check that end was found and body has at least one byte. */
186 185
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -190,15 +189,15 @@  discard block
 block discarded – undo
190 189
 	
191 190
 	if ($debug) echo 'input : '.$input."\n";
192 191
 	/* Save header and body. */
193
-	$body = substr($input,$splitpos+1,$input_len);
192
+	$body = substr($input, $splitpos + 1, $input_len);
194 193
 	$body_len = strlen($body);
195
-	$header = substr($input,0,$splitpos);
194
+	$header = substr($input, 0, $splitpos);
196 195
 	//$header_len = strlen($header);
197 196
 	if ($debug) echo 'header : '.$header."\n";
198 197
 	
199 198
 	/* Parse source, target and path. */
200 199
 	//FLRDF0A52>APRS,qAS,LSTB
201
-	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
200
+	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
202 201
 	    $ident = $matches[1];
203 202
 	    $all_elements = $matches[2];
204 203
 	    if ($ident == 'AIRCRAFT') {
@@ -215,14 +214,14 @@  discard block
 block discarded – undo
215 214
 	    if ($debug) 'No ident'."\n";
216 215
 	    return false;
217 216
 	}
218
-	$elements = explode(',',$all_elements);
217
+	$elements = explode(',', $all_elements);
219 218
 	$source = end($elements);
220 219
 	$result['source'] = $source;
221 220
 	foreach ($elements as $element) {
222
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
221
+	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
223 222
 	        //echo "ok";
224 223
 	        //if ($element == 'TCPIP*') return false;
225
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
224
+	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
226 225
 		if ($debug) echo 'element : '.$element."\n";
227 226
 		return false;
228 227
 	    }
@@ -235,14 +234,14 @@  discard block
 block discarded – undo
235 234
 	    */
236 235
 	}
237 236
 	
238
-	$type = substr($body,0,1);
237
+	$type = substr($body, 0, 1);
239 238
 	if ($debug) echo 'type : '.$type."\n";
240 239
 	if ($type == ';') {
241 240
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
242
-			$result['address'] = trim(substr($body,1,9));
241
+			$result['address'] = trim(substr($body, 1, 9));
243 242
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
244
-			$result['mmsi'] = trim(substr($body,1,9));
245
-		} else $result['ident'] = trim(substr($body,1,9));
243
+			$result['mmsi'] = trim(substr($body, 1, 9));
244
+		} else $result['ident'] = trim(substr($body, 1, 9));
246 245
 	} elseif ($type == ',') {
247 246
 		// Invalid data or test data
248 247
 		return false;
@@ -250,24 +249,24 @@  discard block
 block discarded – undo
250 249
 	
251 250
 	// Check for Timestamp
252 251
 	$find = false;
253
-	$body_parse = substr($body,1);
252
+	$body_parse = substr($body, 1);
254 253
 	//echo 'Body : '.$body."\n";
255
-	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
256
-	    $body_parse = substr($body_parse,10);
254
+	if (preg_match('/^;(.){9}\*/', $body, $matches)) {
255
+	    $body_parse = substr($body_parse, 10);
257 256
 	    $find = true;
258 257
 	    //echo $body_parse."\n";
259 258
 	}
260
-	if (preg_match('/^`(.*)\//',$body,$matches)) {
261
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
259
+	if (preg_match('/^`(.*)\//', $body, $matches)) {
260
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
262 261
 	    $find = true;
263 262
 	    //echo $body_parse."\n";
264 263
 	}
265
-	if (preg_match("/^'(.*)\//",$body,$matches)) {
266
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
264
+	if (preg_match("/^'(.*)\//", $body, $matches)) {
265
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
267 266
 	    $find = true;
268 267
 	    //echo $body_parse."\n";
269 268
 	}
270
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
269
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
271 270
 	    $find = true;
272 271
 	    //print_r($matches);
273 272
 	    $timestamp = $matches[0];
@@ -282,19 +281,19 @@  discard block
 block discarded – undo
282 281
 		// This work or not ?
283 282
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
284 283
 	    }
285
-	    $body_parse = substr($body_parse,7);
284
+	    $body_parse = substr($body_parse, 7);
286 285
 	    $result['timestamp'] = $timestamp;
287 286
 	    //echo date('Ymd H:i:s',$timestamp);
288 287
 	}
289
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
288
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
290 289
 	    $find = true;
291 290
 	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
292
-	    $body_parse = substr($body_parse,8);
291
+	    $body_parse = substr($body_parse, 8);
293 292
 	    $result['timestamp'] = $timestamp;
294 293
 	    //echo date('Ymd H:i:s',$timestamp);
295 294
 	}
296 295
 	//if (strlen($body_parse) > 19) {
297
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
296
+	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
298 297
 		$find = true;
299 298
 		// 4658.70N/00707.78Ez
300 299
 		//print_r(str_split($body_parse));
@@ -321,11 +320,11 @@  discard block
 block discarded – undo
321 320
 	    */
322 321
 		$latitude = $lat + floatval($lat_min)/60;
323 322
 		$longitude = $lon + floatval($lon_min)/60;
324
-		if ($sind == 'S') $latitude = 0-$latitude;
325
-		if ($wind == 'W') $longitude = 0-$longitude;
323
+		if ($sind == 'S') $latitude = 0 - $latitude;
324
+		if ($wind == 'W') $longitude = 0 - $longitude;
326 325
 		$result['latitude'] = $latitude;
327 326
 		$result['longitude'] = $longitude;
328
-		$body_parse = substr($body_parse,18);
327
+		$body_parse = substr($body_parse, 18);
329 328
 		$body_parse_len = strlen($body_parse);
330 329
 	    }
331 330
 	    $body_parse_len = strlen($body_parse);
@@ -357,7 +356,7 @@  discard block
 block discarded – undo
357 356
 		//echo $body_parse;
358 357
 			//if ($type != ';' && $type != '>') {
359 358
 			if ($type != '') {
360
-			$body_parse = substr($body_parse,1);
359
+			$body_parse = substr($body_parse, 1);
361 360
 			$body_parse_len = strlen($body_parse);
362 361
 			$result['symbol_code'] = $symbol_code;
363 362
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
@@ -368,16 +367,16 @@  discard block
 block discarded – undo
368 367
 		    //$body_parse_len = strlen($body_parse);
369 368
 		    if ($body_parse_len >= 7) {
370 369
 			
371
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
372
-		    	    $course = substr($body_parse,0,3);
370
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
371
+		    	    $course = substr($body_parse, 0, 3);
373 372
 		    	    $tmp_s = intval($course);
374 373
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
375
-		    	    $speed = substr($body_parse,4,3);
374
+		    	    $speed = substr($body_parse, 4, 3);
376 375
 		    	    if ($speed != '...') {
377 376
 		    		//$result['speed'] = round($speed*1.852);
378 377
 		    		$result['speed'] = intval($speed);
379 378
 		    	    }
380
-		    	    $body_parse = substr($body_parse,7);
379
+		    	    $body_parse = substr($body_parse, 7);
381 380
 		        }
382 381
 		        // Check PHGR, PHG, RNG
383 382
 		    } 
@@ -387,12 +386,12 @@  discard block
 block discarded – undo
387 386
 		    }
388 387
 		    */
389 388
 		    if (strlen($body_parse) > 0) {
390
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
389
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
391 390
 		            $altitude = intval($matches[1]);
392 391
 		            //$result['altitude'] = round($altitude*0.3048);
393 392
 		            $result['altitude'] = $altitude;
394 393
 		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
395
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
394
+		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse));
396 395
 		        }
397 396
 		    }
398 397
 		    
@@ -404,13 +403,13 @@  discard block
 block discarded – undo
404 403
 		    */
405 404
 		    // DAO
406 405
 		    
407
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
406
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
408 407
 			    
409 408
 			    $dao = $matches[1];
410
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
409
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
411 410
 				$dao_split = str_split($dao);
412
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
413
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
411
+			        $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
412
+			        $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
414 413
 			    
415 414
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
416 415
 				else $result['latitude'] += $lat_off;
@@ -418,50 +417,50 @@  discard block
 block discarded – undo
418 417
 				else $result['longitude'] += $lon_off;
419 418
 			    }
420 419
 			    
421
-		            $body_parse = substr($body_parse,6);
420
+		            $body_parse = substr($body_parse, 6);
422 421
 		    }
423 422
 		    
424
-		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
425
-			$result['ident'] = str_replace('_',' ',$matches[1]);
423
+		    if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) {
424
+			$result['ident'] = str_replace('_', ' ', $matches[1]);
426 425
 		    }
427
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
426
+		    if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) {
428 427
 			$result['squawk'] = $matches[1];
429 428
 		    }
430
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
429
+		    if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) {
431 430
 			$result['aircraft_icao'] = $matches[1];
432 431
 		    }
433
-		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
432
+		    if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) {
434 433
 			$result['verticalrate'] = $matches[1];
435 434
 		    }
436
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
435
+		    if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) {
437 436
 			$result['typeid'] = $matches[1];
438 437
 		    }
439
-		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
438
+		    if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) {
440 439
 			$result['statusid'] = $matches[1];
441 440
 		    }
442
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
441
+		    if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) {
443 442
 			$result['imo'] = $matches[1];
444 443
 		    }
445
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
444
+		    if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) {
446 445
 			$result['arrival_date'] = $matches[1];
447 446
 		    }
448
-		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
449
-			$result['arrival_code'] = str_replace('_',' ',$matches[1]);
447
+		    if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) {
448
+			$result['arrival_code'] = str_replace('_', ' ', $matches[1]);
450 449
 		    }
451 450
 		    // OGN comment
452 451
 		   // echo "Before OGN : ".$body_parse."\n";
453 452
 		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
454
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
453
+		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
455 454
 			$id = $matches[1];
456 455
 			//$mode = substr($id,0,2);
457
-			$address = substr($id,2);
456
+			$address = substr($id, 2);
458 457
 			//print_r($matches);
459
-			$addressType = (intval(substr($id,0,2),16))&3;
458
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
460 459
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
461 460
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
462 461
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
463 462
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
464
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
463
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
465 464
 			$result['aircrafttype_code'] = $aircraftType;
466 465
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
467 466
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -478,7 +477,7 @@  discard block
 block discarded – undo
478 477
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
479 478
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
480 479
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
481
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
480
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
482 481
 			$result['stealth'] = $stealth;
483 482
 			$result['address'] = $address;
484 483
 		    }
@@ -490,96 +489,96 @@  discard block
 block discarded – undo
490 489
 		    //$body_parse = substr($body_parse,1);
491 490
 		    //$body_parse_len = strlen($body_parse);
492 491
 		    //echo 'weather'."\n";
493
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
492
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
494 493
 			    $result['wind_dir'] = intval($matches[1]);
495
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
496
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
497
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
498
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
499
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
494
+			    $result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
495
+			    $result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
496
+			    $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1);
497
+		    	    $body_parse = substr($body_parse, strlen($matches[0]) + 1);
498
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
500 499
 			$result['wind_dir'] = intval($matches[1]);
501
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
502
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
503
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
504
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
505
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
500
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
501
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
502
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
503
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
504
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
506 505
 			$result['wind_dir'] = intval($matches[1]);
507
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
508
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
509
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
510
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
506
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
507
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
508
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
509
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
511 510
 			$result['wind_dir'] = intval($matches[1]);
512
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
513
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
514
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
511
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
512
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
513
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
515 514
 		    }
516 515
 		    //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
517 516
 		    //g012t088r000p000P000h38b10110
518 517
 		    //g011t086r000p000P000h29b10198
519
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
520
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
521
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
522
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
523
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
524
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
518
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
519
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
520
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
521
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
522
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
523
+			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
525 524
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
526
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
527
-		        $body_parse = substr($body_parse,strlen($matches[0]));
528
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
529
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
530
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
531
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
532
-			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
533
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
525
+			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
526
+		        $body_parse = substr($body_parse, strlen($matches[0]));
527
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
528
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
529
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
530
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
531
+			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1);
532
+			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
534 533
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
535
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
536
-		        $body_parse = substr($body_parse,strlen($matches[0]));
537
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
538
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
539
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
540
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
541
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
542
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
534
+			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
535
+		        $body_parse = substr($body_parse, strlen($matches[0]));
536
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
537
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
538
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
539
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
540
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
541
+			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
543 542
 			if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
544
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
545
-		        $body_parse = substr($body_parse,strlen($matches[0]));
546
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
547
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
548
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
549
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
550
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
543
+			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
544
+		        $body_parse = substr($body_parse, strlen($matches[0]));
545
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
546
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
547
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
548
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
549
+			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
551 550
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
552
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
553
-		        $body_parse = substr($body_parse,strlen($matches[0]));
554
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
555
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
556
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
557
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
558
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
551
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
552
+		        $body_parse = substr($body_parse, strlen($matches[0]));
553
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
554
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
555
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
556
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
557
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
559 558
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
560
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
561
-		        $body_parse = substr($body_parse,strlen($matches[0]));
562
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
563
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
564
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
565
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
566
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
559
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
560
+		        $body_parse = substr($body_parse, strlen($matches[0]));
561
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
562
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
563
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
564
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
565
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
567 566
 			if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
568
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
569
-		        $body_parse = substr($body_parse,strlen($matches[0]));
570
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
571
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
572
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
567
+			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
568
+		        $body_parse = substr($body_parse, strlen($matches[0]));
569
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
570
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
571
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
573 572
 			if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
574
-			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
575
-		        $body_parse = substr($body_parse,strlen($matches[0]));
576
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
577
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
578
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
579
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
573
+			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1);
574
+		        $body_parse = substr($body_parse, strlen($matches[0]));
575
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
576
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
577
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
578
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
580 579
 			if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
581
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
582
-		        $body_parse = substr($body_parse,strlen($matches[0]));
580
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
581
+		        $body_parse = substr($body_parse, strlen($matches[0]));
583 582
 		    }
584 583
 		    $result['comment'] = trim($body_parse);
585 584
 		}
@@ -587,42 +586,42 @@  discard block
 block discarded – undo
587 586
 
588 587
 	    }
589 588
 	//}
590
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
591
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
589
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
590
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
592 591
 	if ($debug) print_r($result);
593 592
 	return $result;
594 593
     }
595 594
     
596 595
     public function connect() {
597
-	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
596
+	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport;
598 597
 	$aprs_connect = 0;
599 598
 	$aprs_keep = 120;
600 599
 	$aprs_last_tx = time();
601 600
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
602
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
601
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
603 602
 	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
604
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
603
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
605 604
 	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
606 605
 	else $aprs_pass = '-1';
607 606
 	
608
-	$aprs_filter  = '';
607
+	$aprs_filter = '';
609 608
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
610 609
 	$Common = new Common();
611
-	$s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr);
610
+	$s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr);
612 611
 	if ($s !== false) {
613 612
 		echo 'Connected to APRS server! '."\n";
614 613
 		$authstart = time();
615 614
 		$this->socket = $s;
616
-		$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
617
-		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1);
618
-		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
615
+		$send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0);
616
+		socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1);
617
+		while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) {
619 618
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
620 619
 			    echo 'APRS user verified !'."\n";
621 620
 			    $this->connected = true;
622 621
 			    return true;
623 622
 			    break;
624 623
 			}
625
-			if (time()-$authstart > 5) {
624
+			if (time() - $authstart > 5) {
626 625
 			    echo 'APRS timeout'."\n";
627 626
 			    break;
628 627
 			}
@@ -637,7 +636,7 @@  discard block
 block discarded – undo
637 636
     public function send($data) {
638 637
 	global $globalDebug;
639 638
 	if ($this->connected === false) $this->connect();
640
-	$send = socket_send( $this->socket  , $data , strlen($data),0);
639
+	$send = socket_send($this->socket, $data, strlen($data), 0);
641 640
 	if ($send === FALSE) {
642 641
 		if ($globalDebug) echo 'Reconnect...';
643 642
 		socket_close($this->socket);
@@ -647,17 +646,17 @@  discard block
 block discarded – undo
647 646
 }
648 647
 
649 648
 class APRSSpotter extends APRS {
650
-	public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) {
649
+	public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) {
651 650
 		$Common = new Common();
652 651
 		date_default_timezone_set('UTC');
653 652
 		if ($latitude != '' && $longitude != '') {
654 653
 			$lat = $latitude;
655 654
 			$long = $longitude;
656
-			$latitude = $Common->convertDM($latitude,'latitude');
657
-			$longitude = $Common->convertDM($longitude,'longitude');
658
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
659
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
660
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
655
+			$latitude = $Common->convertDM($latitude, 'latitude');
656
+			$longitude = $Common->convertDM($longitude, 'longitude');
657
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
658
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
659
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
661 660
 			$w = $w1.$w2;
662 661
 			//$w = '00';
663 662
 			$custom = '';
@@ -684,26 +683,26 @@  discard block
 block discarded – undo
684 683
 			$geoid= round($GeoidClass->get($lat,$long)*3.28084,2);
685 684
 			$altitude_real = round($altitude_real + $geoid);
686 685
 			*/
687
-			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
686
+			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
688 687
 		}
689 688
 	}
690 689
 }
691 690
 class APRSMarine extends APRS {
692
-	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) {
691
+	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) {
693 692
 		$Common = new Common();
694 693
 		date_default_timezone_set('UTC');
695 694
 		if ($latitude != '' && $longitude != '') {
696
-			$latitude = $Common->convertDM($latitude,'latitude');
697
-			$longitude = $Common->convertDM($longitude,'longitude');
698
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
699
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
700
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
695
+			$latitude = $Common->convertDM($latitude, 'latitude');
696
+			$longitude = $Common->convertDM($longitude, 'longitude');
697
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
698
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
699
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
701 700
 			$w = $w1.$w2;
702 701
 			//$w = '00';
703 702
 			$custom = '';
704 703
 			if ($ident != '') {
705 704
 				if ($custom != '') $custom .= '/';
706
-				$custom .= 'CS='.str_replace(' ','_',$ident);
705
+				$custom .= 'CS='.str_replace(' ', '_', $ident);
707 706
 			}
708 707
 			if ($typeid != '') {
709 708
 				if ($custom != '') $custom .= '/';
@@ -723,11 +722,11 @@  discard block
 block discarded – undo
723 722
 			}
724 723
 			if ($arrival_code != '') {
725 724
 				if ($custom != '') $custom .= '/';
726
-				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
725
+				$custom .= 'AC='.str_replace(' ', '_', $arrival_code);
727 726
 			}
728 727
 			if ($custom != '') $custom = ' '.$custom;
729 728
 			$altitude = 0;
730
-			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
729
+			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
731 730
 		}
732 731
 	}
733 732
 }
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 2 patches
Indentation   +961 added lines, -961 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 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
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 if (isset($options['idsource'])) $id_source = $options['idsource'];
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
106
+	if ($globalDebug) echo "Using Server Mode\n";
107
+	$SI=new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
117
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
117
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 119
 }
120 120
 
121 121
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
122 122
 if (isset($globalMarine) && $globalMarine) {
123
-    $AIS = new AIS();
124
-    $MI = new MarineImport($Connection->db);
123
+	$AIS = new AIS();
124
+	$MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127 127
 $SBS=new SBS();
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
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() {
138
-        global $sockets;
139
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
-        die("Bye!\n");
141
-    });
142
-    pcntl_signal_dispatch();
137
+	pcntl_signal(SIGINT,  function() {
138
+		global $sockets;
139
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
+		die("Bye!\n");
141
+	});
142
+	pcntl_signal_dispatch();
143 143
 }
144 144
 
145 145
 // let's try and connect
@@ -149,36 +149,36 @@  discard block
 block discarded – undo
149 149
 $reset = 0;
150 150
 
151 151
 function connect_all($hosts) {
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;
154
-    $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
156
-    foreach ($hosts as $id => $value) {
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;
154
+	$reset++;
155
+	if ($globalDebug) echo 'Connect to all...'."\n";
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 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
-        	//$formats[$id] = 'deltadbtxt';
163
-        	$globalSources[$id]['format'] = 'deltadbtxt';
164
-        	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
-        	//$formats[$id] = 'vatsimtxt';
168
-        	$globalSources[$id]['format'] = 'vatsimtxt';
169
-        	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172
-        	//$formats[$id] = 'aircraftlistjson';
173
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
174
-        	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/opensky/i',$host)) {
177
-        	//$formats[$id] = 'aircraftlistjson';
178
-        	$globalSources[$id]['format'] = 'opensky';
179
-        	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
181
-    	    /*
161
+			if (preg_match('/deltadb.txt$/i',$host)) {
162
+			//$formats[$id] = 'deltadbtxt';
163
+			$globalSources[$id]['format'] = 'deltadbtxt';
164
+			//$last_exec['deltadbtxt'] = 0;
165
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
+			//$formats[$id] = 'vatsimtxt';
168
+			$globalSources[$id]['format'] = 'vatsimtxt';
169
+			//$last_exec['vatsimtxt'] = 0;
170
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
172
+			//$formats[$id] = 'aircraftlistjson';
173
+			$globalSources[$id]['format'] = 'aircraftlistjson';
174
+			//$last_exec['aircraftlistjson'] = 0;
175
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
+			} else if (preg_match('/opensky/i',$host)) {
177
+			//$formats[$id] = 'aircraftlistjson';
178
+			$globalSources[$id]['format'] = 'opensky';
179
+			//$last_exec['aircraftlistjson'] = 0;
180
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
181
+			/*
182 182
     	    // Disabled for now, site change source format
183 183
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
184 184
         	//$formats[$id] = 'radarvirtueljson';
@@ -190,121 +190,121 @@  discard block
 block discarded – undo
190 190
         	    exit(0);
191 191
         	}
192 192
     	    */
193
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
194
-        	//$formats[$id] = 'planeupdatefaa';
195
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
196
-        	//$last_exec['planeupdatefaa'] = 0;
197
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
198
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
199
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200
-        	    exit(0);
201
-        	}
202
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
203
-        	//$formats[$id] = 'phpvmacars';
204
-        	$globalSources[$id]['format'] = 'phpvmacars';
205
-        	//$last_exec['phpvmacars'] = 0;
206
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
207
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
208
-        	//$formats[$id] = 'phpvmacars';
209
-        	$globalSources[$id]['format'] = 'vam';
210
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
211
-            } else if (preg_match('/whazzup/i',$host)) {
212
-        	//$formats[$id] = 'whazzup';
213
-        	$globalSources[$id]['format'] = 'whazzup';
214
-        	//$last_exec['whazzup'] = 0;
215
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
216
-            } else if (preg_match('/blitzortung/i',$host)) {
217
-        	$globalSources[$id]['format'] = 'blitzortung';
218
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
219
-            } else if (preg_match('/airwhere/i',$host)) {
220
-        	$globalSources[$id]['format'] = 'airwhere';
221
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
222
-            } else if (preg_match('/recentpireps/i',$host)) {
223
-        	//$formats[$id] = 'pirepsjson';
224
-        	$globalSources[$id]['format'] = 'pirepsjson';
225
-        	//$last_exec['pirepsjson'] = 0;
226
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
227
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
228
-        	//$formats[$id] = 'fr24json';
229
-        	$globalSources[$id]['format'] = 'fr24json';
230
-        	//$last_exec['fr24json'] = 0;
231
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
232
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
233
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
234
-        	    exit(0);
235
-        	}
236
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
237
-        	//$formats[$id] = 'fr24json';
238
-        	$globalSources[$id]['format'] = 'myshiptracking';
239
-        	//$last_exec['fr24json'] = 0;
240
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
241
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
242
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
243
-        	    exit(0);
244
-        	}
245
-            //} else if (preg_match('/10001/',$host)) {
246
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
247
-        	//$formats[$id] = 'tsv';
248
-        	$globalSources[$id]['format'] = 'tsv';
249
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
250
-            }
251
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
252
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
253
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
254
-    		    if ($idf !== false) {
255
-    			$httpfeeds[$id] = $idf;
256
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
257
-    		    }
258
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
259
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
260
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
261
-	    $hostport = explode(':',$host);
262
-	    if (isset($hostport[1])) {
193
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
194
+			//$formats[$id] = 'planeupdatefaa';
195
+			$globalSources[$id]['format'] = 'planeupdatefaa';
196
+			//$last_exec['planeupdatefaa'] = 0;
197
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
198
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
199
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200
+				exit(0);
201
+			}
202
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
203
+			//$formats[$id] = 'phpvmacars';
204
+			$globalSources[$id]['format'] = 'phpvmacars';
205
+			//$last_exec['phpvmacars'] = 0;
206
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
207
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
208
+			//$formats[$id] = 'phpvmacars';
209
+			$globalSources[$id]['format'] = 'vam';
210
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
211
+			} else if (preg_match('/whazzup/i',$host)) {
212
+			//$formats[$id] = 'whazzup';
213
+			$globalSources[$id]['format'] = 'whazzup';
214
+			//$last_exec['whazzup'] = 0;
215
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
216
+			} else if (preg_match('/blitzortung/i',$host)) {
217
+			$globalSources[$id]['format'] = 'blitzortung';
218
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
219
+			} else if (preg_match('/airwhere/i',$host)) {
220
+			$globalSources[$id]['format'] = 'airwhere';
221
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
222
+			} else if (preg_match('/recentpireps/i',$host)) {
223
+			//$formats[$id] = 'pirepsjson';
224
+			$globalSources[$id]['format'] = 'pirepsjson';
225
+			//$last_exec['pirepsjson'] = 0;
226
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
227
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
228
+			//$formats[$id] = 'fr24json';
229
+			$globalSources[$id]['format'] = 'fr24json';
230
+			//$last_exec['fr24json'] = 0;
231
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
232
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
233
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
234
+				exit(0);
235
+			}
236
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
237
+			//$formats[$id] = 'fr24json';
238
+			$globalSources[$id]['format'] = 'myshiptracking';
239
+			//$last_exec['fr24json'] = 0;
240
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
241
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
242
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
243
+				exit(0);
244
+			}
245
+			//} else if (preg_match('/10001/',$host)) {
246
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
247
+			//$formats[$id] = 'tsv';
248
+			$globalSources[$id]['format'] = 'tsv';
249
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
250
+			}
251
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
252
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
253
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
254
+				if ($idf !== false) {
255
+				$httpfeeds[$id] = $idf;
256
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
257
+				}
258
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
259
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
260
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
261
+		$hostport = explode(':',$host);
262
+		if (isset($hostport[1])) {
263 263
 		$port = $hostport[1];
264 264
 		$hostn = $hostport[0];
265
-	    } else {
265
+		} else {
266 266
 		$port = $globalSources[$id]['port'];
267 267
 		$hostn = $globalSources[$id]['host'];
268
-	    }
269
-	    $Common = new Common();
270
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
271
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
272
-    	    } else {
273
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
274
-	    }
275
-	    if ($s) {
276
-    	        $sockets[$id] = $s;
277
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
278
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
268
+		}
269
+		$Common = new Common();
270
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
271
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
272
+			} else {
273
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
274
+		}
275
+		if ($s) {
276
+				$sockets[$id] = $s;
277
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
278
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
279 279
 			//$formats[$id] = 'aprs';
280 280
 			$globalSources[$id]['format'] = 'aprs';
281 281
 			//$aprs_connect = 0;
282 282
 			//$use_aprs = true;
283
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
283
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
284 284
 			$globalSources[$id]['format'] = 'vrstcp';
285
-    		    } elseif ($port == '10001') {
286
-        		//$formats[$id] = 'tsv';
287
-        		$globalSources[$id]['format'] = 'tsv';
288
-		    } elseif ($port == '30002') {
289
-        		//$formats[$id] = 'raw';
290
-        		$globalSources[$id]['format'] = 'raw';
291
-		    } elseif ($port == '5001') {
292
-        		//$formats[$id] = 'raw';
293
-        		$globalSources[$id]['format'] = 'flightgearmp';
294
-		    } elseif ($port == '30005') {
285
+				} elseif ($port == '10001') {
286
+				//$formats[$id] = 'tsv';
287
+				$globalSources[$id]['format'] = 'tsv';
288
+			} elseif ($port == '30002') {
289
+				//$formats[$id] = 'raw';
290
+				$globalSources[$id]['format'] = 'raw';
291
+			} elseif ($port == '5001') {
292
+				//$formats[$id] = 'raw';
293
+				$globalSources[$id]['format'] = 'flightgearmp';
294
+			} elseif ($port == '30005') {
295 295
 			// Not yet supported
296
-        		//$formats[$id] = 'beast';
297
-        		$globalSources[$id]['format'] = 'beast';
298
-		    //} else $formats[$id] = 'sbs';
299
-		    } else $globalSources[$id]['format'] = 'sbs';
300
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
296
+				//$formats[$id] = 'beast';
297
+				$globalSources[$id]['format'] = 'beast';
298
+			//} else $formats[$id] = 'sbs';
299
+			} else $globalSources[$id]['format'] = 'sbs';
300
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
301 301
 		}
302 302
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
303
-            } else {
303
+			} else {
304 304
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
305
-    	    }
306
-        }
307
-    }
305
+			}
306
+		}
307
+	}
308 308
 }
309 309
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
310 310
 
@@ -327,9 +327,9 @@  discard block
 block discarded – undo
327 327
 //connect_all($globalSources);
328 328
 
329 329
 if (isset($globalProxy) && $globalProxy) {
330
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
330
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
331 331
 } else {
332
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
332
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
333 333
 }
334 334
 
335 335
 // APRS Configuration
@@ -338,21 +338,21 @@  discard block
 block discarded – undo
338 338
 	die;
339 339
 }
340 340
 foreach ($globalSources as $key => $source) {
341
-    if (!isset($source['format'])) {
342
-        $globalSources[$key]['format'] = 'auto';
343
-    }
344
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
345
-        unset($globalSources[$key]);
346
-    }
341
+	if (!isset($source['format'])) {
342
+		$globalSources[$key]['format'] = 'auto';
343
+	}
344
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
345
+		unset($globalSources[$key]);
346
+	}
347 347
 }
348 348
 connect_all($globalSources);
349 349
 foreach ($globalSources as $key => $source) {
350
-    if (isset($source['format']) && $source['format'] == 'aprs') {
350
+	if (isset($source['format']) && $source['format'] == 'aprs') {
351 351
 	$aprs_connect = 0;
352 352
 	$use_aprs = true;
353 353
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
354 354
 	break;
355
-    }
355
+	}
356 356
 }
357 357
 
358 358
 if ($use_aprs) {
@@ -393,126 +393,126 @@  discard block
 block discarded – undo
393 393
 
394 394
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
395 395
 while ($i > 0) {
396
-    if (!$globalDaemon) $i = $endtime-time();
397
-    // Delete old ATC
398
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
396
+	if (!$globalDaemon) $i = $endtime-time();
397
+	// Delete old ATC
398
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
399 399
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
400
-        $ATC->deleteOldATC();
401
-    }
400
+		$ATC->deleteOldATC();
401
+	}
402 402
     
403
-    if (count($last_exec) == count($globalSources)) {
403
+	if (count($last_exec) == count($globalSources)) {
404 404
 	$max = $globalMinFetch;
405 405
 	foreach ($last_exec as $last) {
406
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
406
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
407 407
 	}
408 408
 	if ($max != $globalMinFetch) {
409
-	    if ($globalDebug) echo 'Sleeping...'."\n";
410
-	    sleep($globalMinFetch-$max+2);
409
+		if ($globalDebug) echo 'Sleeping...'."\n";
410
+		sleep($globalMinFetch-$max+2);
411
+	}
411 412
 	}
412
-    }
413 413
 
414 414
     
415
-    //foreach ($formats as $id => $value) {
416
-    foreach ($globalSources as $id => $value) {
415
+	//foreach ($formats as $id => $value) {
416
+	foreach ($globalSources as $id => $value) {
417 417
 	date_default_timezone_set('UTC');
418 418
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
419 419
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
420 420
 	if ($value['format'] == 'deltadbtxt' && 
421
-	    (
421
+		(
422 422
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
423 423
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
424
-	    )
424
+		)
425 425
 	) {
426
-	    //$buffer = $Common->getData($hosts[$id]);
427
-	    $buffer = $Common->getData($value['host']);
428
-	    if ($buffer != '') $reset = 0;
429
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
430
-	    $buffer = explode('\n',$buffer);
431
-	    foreach ($buffer as $line) {
432
-    		if ($line != '' && count($line) > 7) {
433
-    		    $line = explode(',', $line);
434
-	            $data = array();
435
-	            $data['hex'] = $line[1]; // hex
436
-	            $data['ident'] = $line[2]; // ident
437
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
438
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
439
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
440
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
441
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
442
-	            $data['verticalrate'] = ''; // vertical rate
443
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
444
-	            $data['emergency'] = ''; // emergency
445
-		    $data['datetime'] = date('Y-m-d H:i:s');
446
-		    $data['format_source'] = 'deltadbtxt';
447
-    		    $data['id_source'] = $id_source;
448
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
449
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
450
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
451
-    		    $SI->add($data);
452
-		    unset($data);
453
-    		}
454
-    	    }
455
-    	    $last_exec[$id]['last'] = time();
426
+		//$buffer = $Common->getData($hosts[$id]);
427
+		$buffer = $Common->getData($value['host']);
428
+		if ($buffer != '') $reset = 0;
429
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
430
+		$buffer = explode('\n',$buffer);
431
+		foreach ($buffer as $line) {
432
+			if ($line != '' && count($line) > 7) {
433
+				$line = explode(',', $line);
434
+				$data = array();
435
+				$data['hex'] = $line[1]; // hex
436
+				$data['ident'] = $line[2]; // ident
437
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
438
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
439
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
440
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
441
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
442
+				$data['verticalrate'] = ''; // vertical rate
443
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
444
+				$data['emergency'] = ''; // emergency
445
+			$data['datetime'] = date('Y-m-d H:i:s');
446
+			$data['format_source'] = 'deltadbtxt';
447
+				$data['id_source'] = $id_source;
448
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
449
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
450
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
451
+				$SI->add($data);
452
+			unset($data);
453
+			}
454
+			}
455
+			$last_exec[$id]['last'] = time();
456 456
 	} elseif ($value['format'] == 'aisnmeatxt' && 
457
-	    (
457
+		(
458 458
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
459 459
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
460
-	    )
460
+		)
461 461
 	) {
462
-	    date_default_timezone_set('CET');
463
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
464
-	    date_default_timezone_set('UTC');
465
-	    if ($buffer != '') $reset = 0;
466
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
467
-	    $buffer = explode('\n',$buffer);
468
-	    foreach ($buffer as $line) {
462
+		date_default_timezone_set('CET');
463
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
464
+		date_default_timezone_set('UTC');
465
+		if ($buffer != '') $reset = 0;
466
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
467
+		$buffer = explode('\n',$buffer);
468
+		foreach ($buffer as $line) {
469 469
 		if ($line != '') {
470
-		    //echo "'".$line."'\n";
471
-		    $add = false;
472
-		    $ais_data = $AIS->parse_line(trim($line));
473
-		    $data = array();
474
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
475
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
476
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
477
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
478
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
479
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
480
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
481
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
482
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
483
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
484
-		    if (isset($ais_data['timestamp'])) {
470
+			//echo "'".$line."'\n";
471
+			$add = false;
472
+			$ais_data = $AIS->parse_line(trim($line));
473
+			$data = array();
474
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
475
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
476
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
477
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
478
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
479
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
480
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
481
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
482
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
483
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
484
+			if (isset($ais_data['timestamp'])) {
485 485
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
486 486
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
487
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
488
-			    $add = true;
487
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
488
+				$add = true;
489 489
 			}
490
-		    } else {
490
+			} else {
491 491
 			$data['datetime'] = date('Y-m-d H:i:s');
492 492
 			$add = true;
493
-		    }
494
-		    $data['format_source'] = 'aisnmeatxt';
495
-    		    $data['id_source'] = $id_source;
496
-		    //print_r($data);
497
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
498
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
499
-		    unset($data);
493
+			}
494
+			$data['format_source'] = 'aisnmeatxt';
495
+				$data['id_source'] = $id_source;
496
+			//print_r($data);
497
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
498
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
499
+			unset($data);
500 500
 		}
501
-    	    }
502
-    	    $last_exec[$id]['last'] = time();
501
+			}
502
+			$last_exec[$id]['last'] = time();
503 503
 	} elseif ($value['format'] == 'aisnmeahttp') {
504
-	    $arr = $httpfeeds;
505
-	    $w = $e = null;
504
+		$arr = $httpfeeds;
505
+		$w = $e = null;
506 506
 	    
507
-	    if (isset($arr[$id])) {
507
+		if (isset($arr[$id])) {
508 508
 		$nn = stream_select($arr,$w,$e,$timeout);
509 509
 		if ($nn > 0) {
510
-		    foreach ($httpfeeds as $feed) {
510
+			foreach ($httpfeeds as $feed) {
511 511
 			$buffer = stream_get_line($feed,2000,"\n");
512 512
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
513 513
 			$buffer = explode('\n',$buffer);
514 514
 			foreach ($buffer as $line) {
515
-			    if ($line != '') {
515
+				if ($line != '') {
516 516
 				$ais_data = $AIS->parse_line(trim($line));
517 517
 				$data = array();
518 518
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -530,114 +530,114 @@  discard block
 block discarded – undo
530 530
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
531 531
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
532 532
 				if (isset($ais_data['timestamp'])) {
533
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
533
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
534 534
 				} else {
535
-				    $data['datetime'] = date('Y-m-d H:i:s');
535
+					$data['datetime'] = date('Y-m-d H:i:s');
536 536
 				}
537 537
 				$data['format_source'] = 'aisnmeahttp';
538 538
 				$data['id_source'] = $id_source;
539 539
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
540 540
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
541 541
 				unset($data);
542
-			    }
542
+				}
543
+			}
543 544
 			}
544
-		    }
545 545
 		} else {
546
-		    $format = $value['format'];
547
-		    if (isset($tt[$format])) $tt[$format]++;
548
-		    else $tt[$format] = 0;
549
-		    if ($tt[$format] > 30) {
546
+			$format = $value['format'];
547
+			if (isset($tt[$format])) $tt[$format]++;
548
+			else $tt[$format] = 0;
549
+			if ($tt[$format] > 30) {
550 550
 			if ($globalDebug) echo 'Reconnect...'."\n";
551 551
 			sleep(2);
552 552
 			$sourceeen[] = $value;
553 553
 			connect_all($sourceeen);
554 554
 			$sourceeen = array();
555
-		    }
555
+			}
556
+		}
556 557
 		}
557
-	    }
558 558
 	} elseif ($value['format'] == 'myshiptracking' && 
559
-	    (
559
+		(
560 560
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
561 561
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
562
-	    )
562
+		)
563 563
 	) {
564
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
565
-	    if ($buffer != '') {
564
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
565
+		if ($buffer != '') {
566 566
 		//echo $buffer;
567 567
 		$all_data = json_decode($buffer,true);
568 568
 		//print_r($all_data);
569 569
 		if (isset($all_data[0]['DATA'])) {
570
-		    foreach ($all_data[0]['DATA'] as $line) {
570
+			foreach ($all_data[0]['DATA'] as $line) {
571 571
 			if ($line != '') {
572
-			    $data = array();
573
-			    $data['ident'] = $line['NAME'];
574
-			    $data['mmsi'] = $line['MMSI'];
575
-			    if (strlen($data['mmsi']) > 9) {
572
+				$data = array();
573
+				$data['ident'] = $line['NAME'];
574
+				$data['mmsi'] = $line['MMSI'];
575
+				if (strlen($data['mmsi']) > 9) {
576 576
 				$data['mmsi'] = substr($data['mmsi'],-9);
577
-			    }
578
-			    $data['speed'] = $line['SOG'];
579
-			    $data['heading'] = $line['COG'];
580
-			    $data['latitude'] = $line['LAT'];
581
-			    $data['longitude'] = $line['LNG'];
582
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
583
-			    $data['imo'] = $line['IMO'];
584
-			    //$data['arrival_code'] = $ais_data['destination'];
585
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
586
-			    $data['format_source'] = 'myshiptracking';
587
-			    $data['id_source'] = $id_source;
588
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
589
-			    $MI->add($data);
590
-			    unset($data);
577
+				}
578
+				$data['speed'] = $line['SOG'];
579
+				$data['heading'] = $line['COG'];
580
+				$data['latitude'] = $line['LAT'];
581
+				$data['longitude'] = $line['LNG'];
582
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
583
+				$data['imo'] = $line['IMO'];
584
+				//$data['arrival_code'] = $ais_data['destination'];
585
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
586
+				$data['format_source'] = 'myshiptracking';
587
+				$data['id_source'] = $id_source;
588
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
589
+				$MI->add($data);
590
+				unset($data);
591 591
 			}
592
-		    }
592
+			}
593
+		}
593 594
 		}
594
-	    }
595
-	    $last_exec[$id]['last'] = time();
595
+		$last_exec[$id]['last'] = time();
596 596
 	} elseif ($value['format'] == 'boatbeaconapp' && 
597
-	    (
597
+		(
598 598
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
599 599
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
600
-	    )
600
+		)
601 601
 	) {
602
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
603
-	    if ($buffer != '') {
602
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
603
+		if ($buffer != '') {
604 604
 		$all_data = json_decode($buffer,true);
605 605
 		if (isset($all_data[0]['mmsi'])) {
606
-		    foreach ($all_data as $line) {
606
+			foreach ($all_data as $line) {
607 607
 			if ($line != '') {
608
-			    $data = array();
609
-			    $data['ident'] = $line['shipname'];
610
-			    $data['callsign'] = $line['callsign'];
611
-			    $data['mmsi'] = $line['mmsi'];
612
-			    $data['speed'] = $line['sog'];
613
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
614
-			    $data['latitude'] = $line['latitude'];
615
-			    $data['longitude'] = $line['longitude'];
616
-			    $data['type_id'] = $line['shiptype'];
617
-			    $data['arrival_code'] = $line['destination'];
618
-			    $data['datetime'] = $line['time'];
619
-			    $data['format_source'] = 'boatbeaconapp';
620
-			    $data['id_source'] = $id_source;
621
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
622
-			    $MI->add($data);
623
-			    unset($data);
608
+				$data = array();
609
+				$data['ident'] = $line['shipname'];
610
+				$data['callsign'] = $line['callsign'];
611
+				$data['mmsi'] = $line['mmsi'];
612
+				$data['speed'] = $line['sog'];
613
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
614
+				$data['latitude'] = $line['latitude'];
615
+				$data['longitude'] = $line['longitude'];
616
+				$data['type_id'] = $line['shiptype'];
617
+				$data['arrival_code'] = $line['destination'];
618
+				$data['datetime'] = $line['time'];
619
+				$data['format_source'] = 'boatbeaconapp';
620
+				$data['id_source'] = $id_source;
621
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
622
+				$MI->add($data);
623
+				unset($data);
624
+			}
624 625
 			}
625
-		    }
626 626
 		}
627 627
 		
628
-	    }
629
-    	    $last_exec[$id]['last'] = time();
628
+		}
629
+			$last_exec[$id]['last'] = time();
630 630
 	} elseif ($value['format'] == 'boatnerd' && 
631
-	    (
631
+		(
632 632
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
633 633
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
634
-	    )
634
+		)
635 635
 	) {
636
-	    $buffer = $Common->getData($value['host']);
637
-	    if ($buffer != '') {
636
+		$buffer = $Common->getData($value['host']);
637
+		if ($buffer != '') {
638 638
 		$all_data = json_decode($buffer,true);
639 639
 		if (isset($all_data['features'][0]['id'])) {
640
-		    foreach ($all_data['features'] as $line) {
640
+			foreach ($all_data['features'] as $line) {
641 641
 			$data = array();
642 642
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
643 643
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -656,78 +656,78 @@  discard block
 block discarded – undo
656 656
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
657 657
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
658 658
 			unset($data);
659
-		    }
659
+			}
660 660
 		}
661 661
 		
662
-	    }
663
-    	    $last_exec[$id]['last'] = time();
662
+		}
663
+			$last_exec[$id]['last'] = time();
664 664
 	} elseif ($value['format'] == 'shipplotter' && 
665
-	    (
665
+		(
666 666
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
667 667
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
668
-	    )
668
+		)
669 669
 	) {
670
-	    echo 'download...';
671
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
672
-	    echo 'done !'."\n";
673
-	    if ($buffer != '') $reset = 0;
674
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
675
-	    $buffer = explode('\n',$buffer);
676
-	    foreach ($buffer as $line) {
670
+		echo 'download...';
671
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
672
+		echo 'done !'."\n";
673
+		if ($buffer != '') $reset = 0;
674
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
675
+		$buffer = explode('\n',$buffer);
676
+		foreach ($buffer as $line) {
677 677
 		if ($line != '') {
678
-		    $data = array();
679
-		    $data['mmsi'] = (int)substr($line,0,9);
680
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
681
-		    //$data['status'] = substr($line,21,2);
682
-		    //$data['type'] = substr($line,24,3);
683
-		    $data['latitude'] = substr($line,29,9);
684
-		    $data['longitude'] = substr($line,41,9);
685
-		    $data['speed'] = round(substr($line,51,5));
686
-		    //$data['course'] = substr($line,57,5);
687
-		    $data['heading'] = round(substr($line,63,3));
688
-		    //$data['draft'] = substr($line,67,4);
689
-		    //$data['length'] = substr($line,72,3);
690
-		    //$data['beam'] = substr($line,76,2);
691
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
692
-		    //$data['callsign'] = trim(substr($line,100,7);
693
-		    //$data['dest'] = substr($line,108,20);
694
-		    //$data['etaDate'] = substr($line,129,5);
695
-		    //$data['etaTime'] = substr($line,135,5);
696
-		    $data['format_source'] = 'shipplotter';
697
-    		    $data['id_source'] = $id_source;
698
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
699
-		    //print_r($data);
700
-		    echo 'Add...'."\n";
701
-		    $MI->add($data);
702
-		    unset($data);
678
+			$data = array();
679
+			$data['mmsi'] = (int)substr($line,0,9);
680
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
681
+			//$data['status'] = substr($line,21,2);
682
+			//$data['type'] = substr($line,24,3);
683
+			$data['latitude'] = substr($line,29,9);
684
+			$data['longitude'] = substr($line,41,9);
685
+			$data['speed'] = round(substr($line,51,5));
686
+			//$data['course'] = substr($line,57,5);
687
+			$data['heading'] = round(substr($line,63,3));
688
+			//$data['draft'] = substr($line,67,4);
689
+			//$data['length'] = substr($line,72,3);
690
+			//$data['beam'] = substr($line,76,2);
691
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
692
+			//$data['callsign'] = trim(substr($line,100,7);
693
+			//$data['dest'] = substr($line,108,20);
694
+			//$data['etaDate'] = substr($line,129,5);
695
+			//$data['etaTime'] = substr($line,135,5);
696
+			$data['format_source'] = 'shipplotter';
697
+				$data['id_source'] = $id_source;
698
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
699
+			//print_r($data);
700
+			echo 'Add...'."\n";
701
+			$MI->add($data);
702
+			unset($data);
703 703
 		}
704
-    	    }
705
-    	    $last_exec[$id]['last'] = time();
704
+			}
705
+			$last_exec[$id]['last'] = time();
706 706
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
707 707
 	} elseif (
708
-	    (
708
+		(
709 709
 		$value['format'] == 'whazzup' && 
710 710
 		(
711
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
712
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
711
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
712
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
713 713
 		)
714
-	    ) || (
714
+		) || (
715 715
 		$value['format'] == 'vatsimtxt' && 
716 716
 		(
717
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
718
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
717
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
718
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
719
+		)
719 720
 		)
720
-	    )
721 721
 	) {
722
-	    //$buffer = $Common->getData($hosts[$id]);
723
-	    $buffer = $Common->getData($value['host']);
724
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
725
-	    $buffer = explode('\n',$buffer);
726
-	    $reset = 0;
727
-	    foreach ($buffer as $line) {
728
-    		if ($line != '') {
729
-    		    $line = explode(':', $line);
730
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
722
+		//$buffer = $Common->getData($hosts[$id]);
723
+		$buffer = $Common->getData($value['host']);
724
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
725
+		$buffer = explode('\n',$buffer);
726
+		$reset = 0;
727
+		foreach ($buffer as $line) {
728
+			if ($line != '') {
729
+				$line = explode(':', $line);
730
+				if (count($line) > 30 && $line[0] != 'callsign') {
731 731
 			$data = array();
732 732
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
733 733
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -740,37 +740,37 @@  discard block
 block discarded – undo
740 740
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
741 741
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
742 742
 			$data['latitude'] = $line[5]; // lat
743
-	        	$data['longitude'] = $line[6]; // long
744
-	        	$data['verticalrate'] = ''; // vertical rate
745
-	        	$data['squawk'] = ''; // squawk
746
-	        	$data['emergency'] = ''; // emergency
747
-	        	$data['waypoints'] = $line[30];
743
+				$data['longitude'] = $line[6]; // long
744
+				$data['verticalrate'] = ''; // vertical rate
745
+				$data['squawk'] = ''; // squawk
746
+				$data['emergency'] = ''; // emergency
747
+				$data['waypoints'] = $line[30];
748 748
 			$data['datetime'] = date('Y-m-d H:i:s');
749 749
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
750 750
 			//if (isset($line[37])) $data['last_update'] = $line[37];
751
-		        $data['departure_airport_icao'] = $line[11];
752
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
753
-		        $data['arrival_airport_icao'] = $line[13];
751
+				$data['departure_airport_icao'] = $line[11];
752
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
753
+				$data['arrival_airport_icao'] = $line[13];
754 754
 			$data['frequency'] = $line[4];
755 755
 			$data['type'] = $line[18];
756 756
 			$data['range'] = $line[19];
757 757
 			if (isset($line[35])) $data['info'] = $line[35];
758
-    			$data['id_source'] = $id_source;
759
-	    		//$data['arrival_airport_time'] = ;
760
-	    		if ($line[9] != '') {
761
-	    		    $aircraft_data = explode('/',$line[9]);
762
-	    		    if (isset($aircraft_data[1])) {
763
-	    			$data['aircraft_icao'] = $aircraft_data[1];
764
-	    		    }
765
-        		}
766
-	    		/*
758
+				$data['id_source'] = $id_source;
759
+				//$data['arrival_airport_time'] = ;
760
+				if ($line[9] != '') {
761
+					$aircraft_data = explode('/',$line[9]);
762
+					if (isset($aircraft_data[1])) {
763
+					$data['aircraft_icao'] = $aircraft_data[1];
764
+					}
765
+				}
766
+				/*
767 767
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
768 768
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
769 769
 	    		*/
770
-	    		$data['format_source'] = $value['format'];
770
+				$data['format_source'] = $value['format'];
771 771
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
772 772
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
773
-    			if ($line[3] == 'PILOT') $SI->add($data);
773
+				if ($line[3] == 'PILOT') $SI->add($data);
774 774
 			elseif ($line[3] == 'ATC') {
775 775
 				//print_r($data);
776 776
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -791,21 +791,21 @@  discard block
 block discarded – undo
791 791
 					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']);
792 792
 				}
793 793
 			}
794
-    			unset($data);
795
-    		    }
796
-    		}
797
-    	    }
798
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
799
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
800
-    	    $last_exec[$id]['last'] = time();
801
-    	} elseif ($value['format'] == 'airwhere' && 
802
-    	    (
803
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
804
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
805
-    	    )
806
-    	) {
807
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
808
-	    if ($buffer != '') {
794
+				unset($data);
795
+				}
796
+			}
797
+			}
798
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
799
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
800
+			$last_exec[$id]['last'] = time();
801
+		} elseif ($value['format'] == 'airwhere' && 
802
+			(
803
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
804
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
805
+			)
806
+		) {
807
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
808
+		if ($buffer != '') {
809 809
 		$all_data = simplexml_load_string($buffer);
810 810
 		foreach($all_data->children() as $childdata) {
811 811
 			$data = array();
@@ -827,10 +827,10 @@  discard block
 block discarded – undo
827 827
 			$SI->add($data);
828 828
 			unset($data);
829 829
 		}
830
-	    }
831
-	    $Source->deleteOldLocationByType('gs');
832
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
833
-	    if ($buffer != '') {
830
+		}
831
+		$Source->deleteOldLocationByType('gs');
832
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
833
+		if ($buffer != '') {
834 834
 		$all_data = simplexml_load_string($buffer);
835 835
 		foreach($all_data->children() as $childdata) {
836 836
 			$data = array();
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
 			}
849 849
 			unset($data);
850 850
 		}
851
-	    }
852
-	    $last_exec[$id]['last'] = time();
851
+		}
852
+		$last_exec[$id]['last'] = time();
853 853
 	/*
854 854
 	} if ($value['format'] == 'aircraftlistjson') {
855 855
 	    print_r($globalSources);
@@ -857,17 +857,17 @@  discard block
 block discarded – undo
857 857
 	    echo $globalMinFetch;
858 858
 	*/
859 859
 	} elseif ($value['format'] == 'aircraftlistjson' && 
860
-	    (
860
+		(
861 861
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
862 862
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
863
-	    )
863
+		)
864 864
 	) {
865
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
866
-	    if ($buffer != '') {
867
-	        $all_data = json_decode($buffer,true);
865
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
866
+		if ($buffer != '') {
867
+			$all_data = json_decode($buffer,true);
868 868
 		if (isset($all_data['acList'])) {
869
-		    $reset = 0;
870
-		    foreach ($all_data['acList'] as $line) {
869
+			$reset = 0;
870
+			foreach ($all_data['acList'] as $line) {
871 871
 			$data = array();
872 872
 			$data['hex'] = $line['Icao']; // hex
873 873
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -890,10 +890,10 @@  discard block
 block discarded – undo
890 890
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
891 891
 			if (isset($data['latitude'])) $SI->add($data);
892 892
 			unset($data);
893
-		    }
893
+			}
894 894
 		} elseif (is_array($all_data)) {
895
-		    $reset = 0;
896
-		    foreach ($all_data as $line) {
895
+			$reset = 0;
896
+			foreach ($all_data as $line) {
897 897
 			$data = array();
898 898
 			$data['hex'] = $line['hex']; // hex
899 899
 			$data['ident'] = $line['flight']; // ident
@@ -913,218 +913,218 @@  discard block
 block discarded – undo
913 913
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
914 914
 			$SI->add($data);
915 915
 			unset($data);
916
-		    }
916
+			}
917 917
 		}
918
-	    } elseif ($globalDebug) echo 'No data'."\n";
919
-    	    //$last_exec['aircraftlistjson'] = time();
920
-    	    $last_exec[$id]['last'] = time();
921
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
922
-    	} elseif ($value['format'] == 'planeupdatefaa' && 
923
-    	    (
924
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
925
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
926
-    	    )
927
-    	) {
928
-	    $buffer = $Common->getData($value['host']);
929
-	    $all_data = json_decode($buffer,true);
930
-	    if (isset($all_data['planes'])) {
918
+		} elseif ($globalDebug) echo 'No data'."\n";
919
+			//$last_exec['aircraftlistjson'] = time();
920
+			$last_exec[$id]['last'] = time();
921
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
922
+		} elseif ($value['format'] == 'planeupdatefaa' && 
923
+			(
924
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
925
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
926
+			)
927
+		) {
928
+		$buffer = $Common->getData($value['host']);
929
+		$all_data = json_decode($buffer,true);
930
+		if (isset($all_data['planes'])) {
931 931
 		$reset = 0;
932 932
 		foreach ($all_data['planes'] as $key => $line) {
933
-		    $data = array();
934
-		    $data['hex'] = $key; // hex
935
-		    $data['ident'] = $line[3]; // ident
936
-		    $data['altitude'] = $line[6]; // altitude
937
-		    $data['speed'] = $line[8]; // speed
938
-		    $data['heading'] = $line[7]; // heading
939
-		    $data['latitude'] = $line[4]; // lat
940
-		    $data['longitude'] = $line[5]; // long
941
-		    //$data['verticalrate'] = $line[]; // verticale rate
942
-		    $data['squawk'] = $line[10]; // squawk
943
-		    $data['emergency'] = ''; // emergency
944
-		    $data['registration'] = $line[2];
945
-		    $data['aircraft_icao'] = $line[0];
946
-		    $deparr = explode('-',$line[1]);
947
-		    if (count($deparr) == 2) {
933
+			$data = array();
934
+			$data['hex'] = $key; // hex
935
+			$data['ident'] = $line[3]; // ident
936
+			$data['altitude'] = $line[6]; // altitude
937
+			$data['speed'] = $line[8]; // speed
938
+			$data['heading'] = $line[7]; // heading
939
+			$data['latitude'] = $line[4]; // lat
940
+			$data['longitude'] = $line[5]; // long
941
+			//$data['verticalrate'] = $line[]; // verticale rate
942
+			$data['squawk'] = $line[10]; // squawk
943
+			$data['emergency'] = ''; // emergency
944
+			$data['registration'] = $line[2];
945
+			$data['aircraft_icao'] = $line[0];
946
+			$deparr = explode('-',$line[1]);
947
+			if (count($deparr) == 2) {
948 948
 			$data['departure_airport_icao'] = $deparr[0];
949 949
 			$data['arrival_airport_icao'] = $deparr[1];
950
-		    }
951
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
952
-	    	    $data['format_source'] = 'planeupdatefaa';
953
-    		    $data['id_source'] = $id_source;
954
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
955
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
956
-		    $SI->add($data);
957
-		    unset($data);
950
+			}
951
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
952
+				$data['format_source'] = 'planeupdatefaa';
953
+				$data['id_source'] = $id_source;
954
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
955
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
956
+			$SI->add($data);
957
+			unset($data);
958
+		}
958 959
 		}
959
-	    }
960
-	    //$last_exec['planeupdatefaa'] = time();
961
-	    $last_exec[$id]['last'] = time();
960
+		//$last_exec['planeupdatefaa'] = time();
961
+		$last_exec[$id]['last'] = time();
962 962
 	} elseif ($value['format'] == 'opensky' && 
963
-	    (
963
+		(
964 964
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
965 965
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
966
-	    )
966
+		)
967 967
 	) {
968
-	    $buffer = $Common->getData($value['host']);
969
-	    $all_data = json_decode($buffer,true);
970
-	    if (isset($all_data['states'])) {
968
+		$buffer = $Common->getData($value['host']);
969
+		$all_data = json_decode($buffer,true);
970
+		if (isset($all_data['states'])) {
971 971
 		$reset = 0;
972 972
 		foreach ($all_data['states'] as $key => $line) {
973
-		    $data = array();
974
-		    $data['hex'] = $line[0]; // hex
975
-		    $data['ident'] = trim($line[1]); // ident
976
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
977
-		    $data['speed'] = round($line[9]*1.94384); // speed
978
-		    $data['heading'] = round($line[10]); // heading
979
-		    $data['latitude'] = $line[6]; // lat
980
-		    $data['longitude'] = $line[5]; // long
981
-		    $data['verticalrate'] = $line[11]; // verticale rate
982
-		    //$data['squawk'] = $line[10]; // squawk
983
-		    //$data['emergency'] = ''; // emergency
984
-		    //$data['registration'] = $line[2];
985
-		    //$data['aircraft_icao'] = $line[0];
986
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
987
-		    $data['format_source'] = 'opensky';
988
-		    $data['id_source'] = $id_source;
989
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
990
-		    $SI->add($data);
991
-		    unset($data);
973
+			$data = array();
974
+			$data['hex'] = $line[0]; // hex
975
+			$data['ident'] = trim($line[1]); // ident
976
+			$data['altitude'] = round($line[7]*3.28084); // altitude
977
+			$data['speed'] = round($line[9]*1.94384); // speed
978
+			$data['heading'] = round($line[10]); // heading
979
+			$data['latitude'] = $line[6]; // lat
980
+			$data['longitude'] = $line[5]; // long
981
+			$data['verticalrate'] = $line[11]; // verticale rate
982
+			//$data['squawk'] = $line[10]; // squawk
983
+			//$data['emergency'] = ''; // emergency
984
+			//$data['registration'] = $line[2];
985
+			//$data['aircraft_icao'] = $line[0];
986
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
987
+			$data['format_source'] = 'opensky';
988
+			$data['id_source'] = $id_source;
989
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
990
+			$SI->add($data);
991
+			unset($data);
992 992
 		}
993
-	    }
994
-	    //$last_exec['planeupdatefaa'] = time();
995
-	    $last_exec[$id]['last'] = time();
993
+		}
994
+		//$last_exec['planeupdatefaa'] = time();
995
+		$last_exec[$id]['last'] = time();
996 996
 	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
997 997
 	} elseif ($value['format'] == 'fr24json' && 
998
-	    (
998
+		(
999 999
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1000 1000
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1001
-	    )
1001
+		)
1002 1002
 	) {
1003
-	    //$buffer = $Common->getData($hosts[$id]);
1004
-	    $buffer = $Common->getData($value['host']);
1005
-	    $all_data = json_decode($buffer,true);
1006
-	    if (!empty($all_data)) $reset = 0;
1007
-	    foreach ($all_data as $key => $line) {
1003
+		//$buffer = $Common->getData($hosts[$id]);
1004
+		$buffer = $Common->getData($value['host']);
1005
+		$all_data = json_decode($buffer,true);
1006
+		if (!empty($all_data)) $reset = 0;
1007
+		foreach ($all_data as $key => $line) {
1008 1008
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1009
-		    $data = array();
1010
-		    $data['hex'] = $line[0];
1011
-		    $data['ident'] = $line[16]; //$line[13]
1012
-	    	    $data['altitude'] = $line[4]; // altitude
1013
-	    	    $data['speed'] = $line[5]; // speed
1014
-	    	    $data['heading'] = $line[3]; // heading
1015
-	    	    $data['latitude'] = $line[1]; // lat
1016
-	    	    $data['longitude'] = $line[2]; // long
1017
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1018
-	    	    $data['squawk'] = $line[6]; // squawk
1019
-	    	    $data['aircraft_icao'] = $line[8];
1020
-	    	    $data['registration'] = $line[9];
1021
-		    $data['departure_airport_iata'] = $line[11];
1022
-		    $data['arrival_airport_iata'] = $line[12];
1023
-	    	    $data['emergency'] = ''; // emergency
1024
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1025
-	    	    $data['format_source'] = 'fr24json';
1026
-    		    $data['id_source'] = $id_source;
1027
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1028
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1029
-		    $SI->add($data);
1030
-		    unset($data);
1009
+			$data = array();
1010
+			$data['hex'] = $line[0];
1011
+			$data['ident'] = $line[16]; //$line[13]
1012
+				$data['altitude'] = $line[4]; // altitude
1013
+				$data['speed'] = $line[5]; // speed
1014
+				$data['heading'] = $line[3]; // heading
1015
+				$data['latitude'] = $line[1]; // lat
1016
+				$data['longitude'] = $line[2]; // long
1017
+				$data['verticalrate'] = $line[15]; // verticale rate
1018
+				$data['squawk'] = $line[6]; // squawk
1019
+				$data['aircraft_icao'] = $line[8];
1020
+				$data['registration'] = $line[9];
1021
+			$data['departure_airport_iata'] = $line[11];
1022
+			$data['arrival_airport_iata'] = $line[12];
1023
+				$data['emergency'] = ''; // emergency
1024
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1025
+				$data['format_source'] = 'fr24json';
1026
+				$data['id_source'] = $id_source;
1027
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1028
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1029
+			$SI->add($data);
1030
+			unset($data);
1031 1031
 		}
1032
-	    }
1033
-	    //$last_exec['fr24json'] = time();
1034
-	    $last_exec[$id]['last'] = time();
1032
+		}
1033
+		//$last_exec['fr24json'] = time();
1034
+		$last_exec[$id]['last'] = time();
1035 1035
 	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1036 1036
 	} elseif ($value['format'] == 'radarvirtueljson' && 
1037
-	    (
1037
+		(
1038 1038
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1039 1039
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1040
-	    )
1040
+		)
1041 1041
 	) {
1042
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1043
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1044
-	    //echo $buffer;
1045
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1046
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1047
-	    $all_data = json_decode($buffer,true);
1048
-	    if (json_last_error() != JSON_ERROR_NONE) {
1042
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1043
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1044
+		//echo $buffer;
1045
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1046
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1047
+		$all_data = json_decode($buffer,true);
1048
+		if (json_last_error() != JSON_ERROR_NONE) {
1049 1049
 		die(json_last_error_msg());
1050
-	    }
1051
-	    if (isset($all_data['mrkrs'])) {
1050
+		}
1051
+		if (isset($all_data['mrkrs'])) {
1052 1052
 		$reset = 0;
1053 1053
 		foreach ($all_data['mrkrs'] as $key => $line) {
1054
-		    if (isset($line['inf'])) {
1054
+			if (isset($line['inf'])) {
1055 1055
 			$data = array();
1056 1056
 			$data['hex'] = $line['inf']['ia'];
1057 1057
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1058
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1059
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1060
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1061
-	    		$data['latitude'] = $line['pt'][0]; // lat
1062
-	    		$data['longitude'] = $line['pt'][1]; // long
1063
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1064
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1065
-	    		//$data['aircraft_icao'] = $line[8];
1066
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1058
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1059
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1060
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1061
+				$data['latitude'] = $line['pt'][0]; // lat
1062
+				$data['longitude'] = $line['pt'][1]; // long
1063
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1064
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1065
+				//$data['aircraft_icao'] = $line[8];
1066
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1067 1067
 			//$data['departure_airport_iata'] = $line[11];
1068 1068
 			//$data['arrival_airport_iata'] = $line[12];
1069
-	    		//$data['emergency'] = ''; // emergency
1069
+				//$data['emergency'] = ''; // emergency
1070 1070
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1071
-	    		$data['format_source'] = 'radarvirtueljson';
1072
-    			$data['id_source'] = $id_source;
1071
+				$data['format_source'] = 'radarvirtueljson';
1072
+				$data['id_source'] = $id_source;
1073 1073
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1074 1074
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1075 1075
 			$SI->add($data);
1076 1076
 			unset($data);
1077
-		    }
1077
+			}
1078
+		}
1078 1079
 		}
1079
-	    }
1080
-	    //$last_exec['radarvirtueljson'] = time();
1081
-	    $last_exec[$id]['last'] = time();
1080
+		//$last_exec['radarvirtueljson'] = time();
1081
+		$last_exec[$id]['last'] = time();
1082 1082
 	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1083 1083
 	} elseif ($value['format'] == 'pirepsjson' && 
1084
-	    (
1084
+		(
1085 1085
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1086 1086
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1087
-	    )
1087
+		)
1088 1088
 	) {
1089
-	    //$buffer = $Common->getData($hosts[$id]);
1090
-	    $buffer = $Common->getData($value['host'].'?'.time());
1091
-	    $all_data = json_decode(utf8_encode($buffer),true);
1089
+		//$buffer = $Common->getData($hosts[$id]);
1090
+		$buffer = $Common->getData($value['host'].'?'.time());
1091
+		$all_data = json_decode(utf8_encode($buffer),true);
1092 1092
 	    
1093
-	    if (isset($all_data['pireps'])) {
1093
+		if (isset($all_data['pireps'])) {
1094 1094
 		$reset = 0;
1095
-	        foreach ($all_data['pireps'] as $line) {
1096
-		    $data = array();
1097
-		    $data['id'] = $line['id'];
1098
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1099
-		    $data['ident'] = $line['callsign']; // ident
1100
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1101
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1102
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1103
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1104
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1105
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1106
-		    $data['latitude'] = $line['lat']; // lat
1107
-		    $data['longitude'] = $line['lon']; // long
1108
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1109
-		    //$data['squawk'] = $line['squawk']; // squawk
1110
-		    //$data['emergency'] = ''; // emergency
1111
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1112
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1113
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1114
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1115
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1116
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1117
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1118
-		    else $data['info'] = '';
1119
-		    $data['format_source'] = 'pireps';
1120
-    		    $data['id_source'] = $id_source;
1121
-		    $data['datetime'] = date('Y-m-d H:i:s');
1122
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1123
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1124
-		    if ($line['icon'] == 'plane') {
1095
+			foreach ($all_data['pireps'] as $line) {
1096
+			$data = array();
1097
+			$data['id'] = $line['id'];
1098
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1099
+			$data['ident'] = $line['callsign']; // ident
1100
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1101
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1102
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1103
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1104
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1105
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1106
+			$data['latitude'] = $line['lat']; // lat
1107
+			$data['longitude'] = $line['lon']; // long
1108
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1109
+			//$data['squawk'] = $line['squawk']; // squawk
1110
+			//$data['emergency'] = ''; // emergency
1111
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1112
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1113
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1114
+			//$data['arrival_airport_time'] = $line['arrtime'];
1115
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1116
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1117
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1118
+			else $data['info'] = '';
1119
+			$data['format_source'] = 'pireps';
1120
+				$data['id_source'] = $id_source;
1121
+			$data['datetime'] = date('Y-m-d H:i:s');
1122
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1123
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1124
+			if ($line['icon'] == 'plane') {
1125 1125
 			$SI->add($data);
1126
-		    //    print_r($data);
1127
-    		    } elseif ($line['icon'] == 'ct') {
1126
+			//    print_r($data);
1127
+				} elseif ($line['icon'] == 'ct') {
1128 1128
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1129 1129
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1130 1130
 			$typec = substr($data['ident'],-3);
@@ -1139,148 +1139,148 @@  discard block
 block discarded – undo
1139 1139
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1140 1140
 			else $data['type'] = 'Observer';
1141 1141
 			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']);
1142
-		    }
1143
-		    unset($data);
1142
+			}
1143
+			unset($data);
1144
+		}
1144 1145
 		}
1145
-	    }
1146
-	    //$last_exec['pirepsjson'] = time();
1147
-	    $last_exec[$id]['last'] = time();
1146
+		//$last_exec['pirepsjson'] = time();
1147
+		$last_exec[$id]['last'] = time();
1148 1148
 	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1149 1149
 	} elseif ($value['format'] == 'phpvmacars' && 
1150
-	    (
1150
+		(
1151 1151
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1152 1152
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1153
-	    )
1153
+		)
1154 1154
 	) {
1155
-	    //$buffer = $Common->getData($hosts[$id]);
1156
-	    if ($globalDebug) echo 'Get Data...'."\n";
1157
-	    $buffer = $Common->getData($value['host']);
1158
-	    $all_data = json_decode($buffer,true);
1159
-	    if ($buffer != '' && is_array($all_data)) {
1155
+		//$buffer = $Common->getData($hosts[$id]);
1156
+		if ($globalDebug) echo 'Get Data...'."\n";
1157
+		$buffer = $Common->getData($value['host']);
1158
+		$all_data = json_decode($buffer,true);
1159
+		if ($buffer != '' && is_array($all_data)) {
1160 1160
 		$reset = 0;
1161 1161
 		foreach ($all_data as $line) {
1162
-	    	    $data = array();
1163
-	    	    //$data['id'] = $line['id']; // id not usable
1164
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1165
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1166
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1167
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1168
-	    	    $data['ident'] = $line['flightnum']; // ident
1169
-	    	    $data['altitude'] = $line['alt']; // altitude
1170
-	    	    $data['speed'] = $line['gs']; // speed
1171
-	    	    $data['heading'] = $line['heading']; // heading
1172
-	    	    $data['latitude'] = $line['lat']; // lat
1173
-	    	    $data['longitude'] = $line['lng']; // long
1174
-	    	    $data['verticalrate'] = ''; // verticale rate
1175
-	    	    $data['squawk'] = ''; // squawk
1176
-	    	    $data['emergency'] = ''; // emergency
1177
-	    	    //$data['datetime'] = $line['lastupdate'];
1178
-	    	    //$data['last_update'] = $line['lastupdate'];
1179
-	    	    if (isset($value['timezone'])) {
1180
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1181
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1182
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1183
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1184
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1185
-	    	    $data['departure_airport_time'] = $line['deptime'];
1186
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1187
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1188
-    		    $data['registration'] = $line['aircraft'];
1189
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1190
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1191
-		    if (isset($line['aircraftname'])) {
1162
+				$data = array();
1163
+				//$data['id'] = $line['id']; // id not usable
1164
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1165
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1166
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1167
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1168
+				$data['ident'] = $line['flightnum']; // ident
1169
+				$data['altitude'] = $line['alt']; // altitude
1170
+				$data['speed'] = $line['gs']; // speed
1171
+				$data['heading'] = $line['heading']; // heading
1172
+				$data['latitude'] = $line['lat']; // lat
1173
+				$data['longitude'] = $line['lng']; // long
1174
+				$data['verticalrate'] = ''; // verticale rate
1175
+				$data['squawk'] = ''; // squawk
1176
+				$data['emergency'] = ''; // emergency
1177
+				//$data['datetime'] = $line['lastupdate'];
1178
+				//$data['last_update'] = $line['lastupdate'];
1179
+				if (isset($value['timezone'])) {
1180
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1181
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1182
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1183
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1184
+				$data['departure_airport_icao'] = $line['depicao'];
1185
+				$data['departure_airport_time'] = $line['deptime'];
1186
+				$data['arrival_airport_icao'] = $line['arricao'];
1187
+				$data['arrival_airport_time'] = $line['arrtime'];
1188
+				$data['registration'] = $line['aircraft'];
1189
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1190
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1191
+			if (isset($line['aircraftname'])) {
1192 1192
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1193 1193
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1194
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1195
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1196
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1197
-	    		else {
1198
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1199
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1200
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1201
-	    		}
1202
-	    	    }
1203
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1204
-    		    $data['id_source'] = $id_source;
1205
-	    	    $data['format_source'] = 'phpvmacars';
1206
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1207
-		    $SI->add($data);
1208
-		    unset($data);
1194
+				$aircraft_data = explode('-',$line['aircraftname']);
1195
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1196
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1197
+				else {
1198
+					$aircraft_data = explode(' ',$line['aircraftname']);
1199
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1200
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1201
+				}
1202
+				}
1203
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1204
+				$data['id_source'] = $id_source;
1205
+				$data['format_source'] = 'phpvmacars';
1206
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1207
+			$SI->add($data);
1208
+			unset($data);
1209 1209
 		}
1210 1210
 		if ($globalDebug) echo 'No more data...'."\n";
1211 1211
 		unset($buffer);
1212 1212
 		unset($all_data);
1213
-	    }
1214
-	    //$last_exec['phpvmacars'] = time();
1215
-	    $last_exec[$id]['last'] = time();
1213
+		}
1214
+		//$last_exec['phpvmacars'] = time();
1215
+		$last_exec[$id]['last'] = time();
1216 1216
 	} elseif ($value['format'] == 'vam' && 
1217
-	    (
1217
+		(
1218 1218
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1219 1219
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1220
-	    )
1220
+		)
1221 1221
 	) {
1222
-	    //$buffer = $Common->getData($hosts[$id]);
1223
-	    if ($globalDebug) echo 'Get Data...'."\n";
1224
-	    $buffer = $Common->getData($value['host']);
1225
-	    $all_data = json_decode($buffer,true);
1226
-	    if ($buffer != '' && is_array($all_data)) {
1222
+		//$buffer = $Common->getData($hosts[$id]);
1223
+		if ($globalDebug) echo 'Get Data...'."\n";
1224
+		$buffer = $Common->getData($value['host']);
1225
+		$all_data = json_decode($buffer,true);
1226
+		if ($buffer != '' && is_array($all_data)) {
1227 1227
 		$reset = 0;
1228 1228
 		foreach ($all_data as $line) {
1229
-	    	    $data = array();
1230
-	    	    //$data['id'] = $line['id']; // id not usable
1231
-	    	    $data['id'] = trim($line['flight_id']);
1232
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1233
-	    	    $data['pilot_name'] = $line['pilot_name'];
1234
-	    	    $data['pilot_id'] = $line['pilot_id'];
1235
-	    	    $data['ident'] = trim($line['callsign']); // ident
1236
-	    	    $data['altitude'] = $line['altitude']; // altitude
1237
-	    	    $data['speed'] = $line['gs']; // speed
1238
-	    	    $data['heading'] = $line['heading']; // heading
1239
-	    	    $data['latitude'] = $line['latitude']; // lat
1240
-	    	    $data['longitude'] = $line['longitude']; // long
1241
-	    	    $data['verticalrate'] = ''; // verticale rate
1242
-	    	    $data['squawk'] = ''; // squawk
1243
-	    	    $data['emergency'] = ''; // emergency
1244
-	    	    //$data['datetime'] = $line['lastupdate'];
1245
-	    	    $data['last_update'] = $line['last_update'];
1246
-		    $data['datetime'] = date('Y-m-d H:i:s');
1247
-	    	    $data['departure_airport_icao'] = $line['departure'];
1248
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1249
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1250
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1251
-    		    //$data['registration'] = $line['aircraft'];
1252
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1253
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1254
-    		    $data['id_source'] = $id_source;
1255
-	    	    $data['format_source'] = 'vam';
1256
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1257
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1258
-		    $SI->add($data);
1259
-		    unset($data);
1229
+				$data = array();
1230
+				//$data['id'] = $line['id']; // id not usable
1231
+				$data['id'] = trim($line['flight_id']);
1232
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1233
+				$data['pilot_name'] = $line['pilot_name'];
1234
+				$data['pilot_id'] = $line['pilot_id'];
1235
+				$data['ident'] = trim($line['callsign']); // ident
1236
+				$data['altitude'] = $line['altitude']; // altitude
1237
+				$data['speed'] = $line['gs']; // speed
1238
+				$data['heading'] = $line['heading']; // heading
1239
+				$data['latitude'] = $line['latitude']; // lat
1240
+				$data['longitude'] = $line['longitude']; // long
1241
+				$data['verticalrate'] = ''; // verticale rate
1242
+				$data['squawk'] = ''; // squawk
1243
+				$data['emergency'] = ''; // emergency
1244
+				//$data['datetime'] = $line['lastupdate'];
1245
+				$data['last_update'] = $line['last_update'];
1246
+			$data['datetime'] = date('Y-m-d H:i:s');
1247
+				$data['departure_airport_icao'] = $line['departure'];
1248
+				//$data['departure_airport_time'] = $line['departure_time'];
1249
+				$data['arrival_airport_icao'] = $line['arrival'];
1250
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1251
+				//$data['registration'] = $line['aircraft'];
1252
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1253
+				$data['aircraft_icao'] = $line['plane_type'];
1254
+				$data['id_source'] = $id_source;
1255
+				$data['format_source'] = 'vam';
1256
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1257
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1258
+			$SI->add($data);
1259
+			unset($data);
1260 1260
 		}
1261 1261
 		if ($globalDebug) echo 'No more data...'."\n";
1262 1262
 		unset($buffer);
1263 1263
 		unset($all_data);
1264
-	    }
1265
-	    //$last_exec['phpvmacars'] = time();
1266
-	    $last_exec[$id]['last'] = time();
1264
+		}
1265
+		//$last_exec['phpvmacars'] = time();
1266
+		$last_exec[$id]['last'] = time();
1267 1267
 	} elseif ($value['format'] == 'blitzortung' && 
1268
-	    (
1268
+		(
1269 1269
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1270 1270
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1271
-	    )
1271
+		)
1272 1272
 	) {
1273
-	    //$buffer = $Common->getData($hosts[$id]);
1274
-	    if ($globalDebug) echo 'Get Data...'."\n";
1275
-	    $buffer = $Common->getData($value['host']);
1276
-	    $all_data = json_decode($buffer,true);
1277
-	    if ($buffer != '') {
1273
+		//$buffer = $Common->getData($hosts[$id]);
1274
+		if ($globalDebug) echo 'Get Data...'."\n";
1275
+		$buffer = $Common->getData($value['host']);
1276
+		$all_data = json_decode($buffer,true);
1277
+		if ($buffer != '') {
1278 1278
 		$Source->deleteLocationBySource('blitzortung');
1279 1279
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1280 1280
 		$buffer = explode('\n',$buffer);
1281 1281
 		foreach ($buffer as $buffer_line) {
1282
-		    $line = json_decode($buffer_line,true);
1283
-		    if (isset($line['time'])) {
1282
+			$line = json_decode($buffer_line,true);
1283
+			if (isset($line['time'])) {
1284 1284
 			$data = array();
1285 1285
 			$data['altitude'] = $line['alt']; // altitude
1286 1286
 			$data['latitude'] = $line['lat']; // lat
@@ -1292,94 +1292,94 @@  discard block
 block discarded – undo
1292 1292
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1293 1293
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1294 1294
 			unset($data);
1295
-		    }
1295
+			}
1296 1296
 		}
1297 1297
 		if ($globalDebug) echo 'No more data...'."\n";
1298 1298
 		unset($buffer);
1299
-	    }
1300
-	    $last_exec[$id]['last'] = time();
1299
+		}
1300
+		$last_exec[$id]['last'] = time();
1301 1301
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1302 1302
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1303
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1304
-    	    //$last_exec[$id]['last'] = time();
1303
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1304
+			//$last_exec[$id]['last'] = time();
1305 1305
 
1306
-	    //$read = array( $sockets[$id] );
1307
-	    $read = $sockets;
1308
-	    $write = NULL;
1309
-	    $e = NULL;
1310
-	    $n = socket_select($read, $write, $e, $timeout);
1311
-	    if ($e != NULL) var_dump($e);
1312
-	    if ($n > 0) {
1306
+		//$read = array( $sockets[$id] );
1307
+		$read = $sockets;
1308
+		$write = NULL;
1309
+		$e = NULL;
1310
+		$n = socket_select($read, $write, $e, $timeout);
1311
+		if ($e != NULL) var_dump($e);
1312
+		if ($n > 0) {
1313 1313
 		$reset = 0;
1314 1314
 		foreach ($read as $nb => $r) {
1315
-		    //$value = $formats[$nb];
1316
-		    $format = $globalSources[$nb]['format'];
1317
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1315
+			//$value = $formats[$nb];
1316
+			$format = $globalSources[$nb]['format'];
1317
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1318 1318
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1319
-		    } elseif ($format == 'vrstcp') {
1319
+			} elseif ($format == 'vrstcp') {
1320 1320
 			$buffer = @socket_read($r, 6000);
1321
-		    } else {
1321
+			} else {
1322 1322
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1323
-		    }
1324
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1325
-		    //echo $buffer."\n";
1326
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1327
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1328
-		    $error = false;
1329
-		    //$SI::del();
1330
-		    if ($format == 'vrstcp') {
1323
+			}
1324
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1325
+			//echo $buffer."\n";
1326
+			// lets play nice and handle signals such as ctrl-c/kill properly
1327
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1328
+			$error = false;
1329
+			//$SI::del();
1330
+			if ($format == 'vrstcp') {
1331 1331
 			$buffer = explode('},{',$buffer);
1332
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1333
-		    // SBS format is CSV format
1334
-		    if ($buffer !== FALSE && $buffer != '') {
1332
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1333
+			// SBS format is CSV format
1334
+			if ($buffer !== FALSE && $buffer != '') {
1335 1335
 			$tt[$format] = 0;
1336 1336
 			if ($format == 'acarssbs3') {
1337
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1338
-			    $ACARS->add(trim($buffer));
1339
-			    $ACARS->deleteLiveAcarsData();
1337
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1338
+				$ACARS->add(trim($buffer));
1339
+				$ACARS->deleteLiveAcarsData();
1340 1340
 			} elseif ($format == 'raw') {
1341
-			    // AVR format
1342
-			    $data = $SBS->parse($buffer);
1343
-			    if (is_array($data)) {
1341
+				// AVR format
1342
+				$data = $SBS->parse($buffer);
1343
+				if (is_array($data)) {
1344 1344
 				$data['datetime'] = date('Y-m-d H:i:s');
1345 1345
 				$data['format_source'] = 'raw';
1346 1346
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1347 1347
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1348 1348
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1349 1349
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1350
-			    }
1350
+				}
1351 1351
 			} elseif ($format == 'ais') {
1352
-			    $ais_data = $AIS->parse_line(trim($buffer));
1353
-			    $data = array();
1354
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1355
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1356
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1357
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1358
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1359
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1360
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1361
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1362
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1363
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1364
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1365
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1366
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1367
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1368
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1369
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1352
+				$ais_data = $AIS->parse_line(trim($buffer));
1353
+				$data = array();
1354
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1355
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1356
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1357
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1358
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1359
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1360
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1361
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1362
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1363
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1364
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1365
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1366
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1367
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1368
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1369
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1370 1370
 
1371
-			    if (isset($ais_data['timestamp'])) {
1371
+				if (isset($ais_data['timestamp'])) {
1372 1372
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1373
-			    } else {
1373
+				} else {
1374 1374
 				$data['datetime'] = date('Y-m-d H:i:s');
1375
-			    }
1376
-			    $data['format_source'] = 'aisnmea';
1377
-    			    $data['id_source'] = $id_source;
1378
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1379
-			    unset($data);
1380
-                        } elseif ($format == 'flightgearsp') {
1381
-                    	    //echo $buffer."\n";
1382
-                    	    if (strlen($buffer) > 5) {
1375
+				}
1376
+				$data['format_source'] = 'aisnmea';
1377
+					$data['id_source'] = $id_source;
1378
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1379
+				unset($data);
1380
+						} elseif ($format == 'flightgearsp') {
1381
+							//echo $buffer."\n";
1382
+							if (strlen($buffer) > 5) {
1383 1383
 				$line = explode(',',$buffer);
1384 1384
 				$data = array();
1385 1385
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1396,38 +1396,38 @@  discard block
 block discarded – undo
1396 1396
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1397 1397
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1398 1398
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1399
-			    }
1400
-                        } elseif ($format == 'acars') {
1401
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1402
-			    $ACARS->add(trim($buffer));
1403
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1404
-			    $ACARS->deleteLiveAcarsData();
1399
+				}
1400
+						} elseif ($format == 'acars') {
1401
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1402
+				$ACARS->add(trim($buffer));
1403
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1404
+				$ACARS->deleteLiveAcarsData();
1405 1405
 			} elseif ($format == 'flightgearmp') {
1406
-			    if (substr($buffer,0,1) != '#') {
1406
+				if (substr($buffer,0,1) != '#') {
1407 1407
 				$data = array();
1408 1408
 				//echo $buffer."\n";
1409 1409
 				$line = explode(' ',$buffer);
1410 1410
 				if (count($line) == 11) {
1411
-				    $userserver = explode('@',$line[0]);
1412
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1413
-				    $data['ident'] = $userserver[0];
1414
-				    $data['registration'] = $userserver[0];
1415
-				    $data['latitude'] = $line[4];
1416
-				    $data['longitude'] = $line[5];
1417
-				    $data['altitude'] = $line[6];
1418
-				    $data['datetime'] = date('Y-m-d H:i:s');
1419
-				    $aircraft_type = $line[10];
1420
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1421
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1422
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1423
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1411
+					$userserver = explode('@',$line[0]);
1412
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1413
+					$data['ident'] = $userserver[0];
1414
+					$data['registration'] = $userserver[0];
1415
+					$data['latitude'] = $line[4];
1416
+					$data['longitude'] = $line[5];
1417
+					$data['altitude'] = $line[6];
1418
+					$data['datetime'] = date('Y-m-d H:i:s');
1419
+					$aircraft_type = $line[10];
1420
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1421
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1422
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1423
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1424
+				}
1424 1425
 				}
1425
-			    }
1426 1426
 			} elseif ($format == 'beast') {
1427
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1428
-			    die;
1427
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1428
+				die;
1429 1429
 			} elseif ($format == 'vrstcp') {
1430
-			    foreach($buffer as $all_data) {
1430
+				foreach($buffer as $all_data) {
1431 1431
 				$line = json_decode('{'.$all_data.'}',true);
1432 1432
 				$data = array();
1433 1433
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1447,152 +1447,152 @@  discard block
 block discarded – undo
1447 1447
 				*/
1448 1448
 				$data['datetime'] = date('Y-m-d H:i:s');
1449 1449
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1450
-		    		$data['format_source'] = 'vrstcp';
1450
+					$data['format_source'] = 'vrstcp';
1451 1451
 				$data['id_source'] = $id_source;
1452 1452
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1453 1453
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1454 1454
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1455 1455
 				unset($data);
1456
-			    }
1456
+				}
1457 1457
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1458
-			    $line = explode("\t", $buffer);
1459
-			    for($k = 0; $k < count($line); $k=$k+2) {
1458
+				$line = explode("\t", $buffer);
1459
+				for($k = 0; $k < count($line); $k=$k+2) {
1460 1460
 				$key = $line[$k];
1461
-			        $lined[$key] = $line[$k+1];
1462
-			    }
1463
-    			    if (count($lined) > 3) {
1464
-    				$data['hex'] = $lined['hexid'];
1465
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1466
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1467
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1468
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1469
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1470
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1471
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1472
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1473
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1474
-    				$data['id_source'] = $id_source;
1475
-    				$data['format_source'] = 'tsv';
1476
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1477
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1461
+					$lined[$key] = $line[$k+1];
1462
+				}
1463
+					if (count($lined) > 3) {
1464
+					$data['hex'] = $lined['hexid'];
1465
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1466
+					$data['datetime'] = date('Y-m-d H:i:s');;
1467
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1468
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1469
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1470
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1471
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1472
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1473
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1474
+					$data['id_source'] = $id_source;
1475
+					$data['format_source'] = 'tsv';
1476
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1477
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1478 1478
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1479
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1480
-    				unset($lined);
1481
-    				unset($data);
1482
-    			    } else $error = true;
1479
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1480
+					unset($lined);
1481
+					unset($data);
1482
+					} else $error = true;
1483 1483
 			} elseif ($format == 'aprs' && $use_aprs) {
1484
-			    if ($aprs_connect == 0) {
1484
+				if ($aprs_connect == 0) {
1485 1485
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1486 1486
 				$aprs_connect = 1;
1487
-			    }
1487
+				}
1488 1488
 			    
1489
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1489
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1490 1490
 				$aprs_last_tx = time();
1491 1491
 				$data_aprs = "# Keep alive";
1492 1492
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1493
-			    }
1493
+				}
1494 1494
 			    
1495
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1496
-			    //echo 'APRS data : '.$buffer."\n";
1497
-			    $buffer = str_replace('APRS <- ','',$buffer);
1498
-			    $buffer = str_replace('APRS -> ','',$buffer);
1499
-			    //echo $buffer."\n";
1500
-			    date_default_timezone_set('UTC');
1501
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1495
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1496
+				//echo 'APRS data : '.$buffer."\n";
1497
+				$buffer = str_replace('APRS <- ','',$buffer);
1498
+				$buffer = str_replace('APRS -> ','',$buffer);
1499
+				//echo $buffer."\n";
1500
+				date_default_timezone_set('UTC');
1501
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1502 1502
 				$line = $APRS->parse($buffer);
1503 1503
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1504 1504
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1505
-				    $aprs_last_tx = time();
1506
-				    $data = array();
1507
-				    //print_r($line);
1508
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1509
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1510
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1511
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1512
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1513
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1514
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1515
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1516
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1517
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1518
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1519
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1520
-				    $data['latitude'] = $line['latitude'];
1521
-				    $data['longitude'] = $line['longitude'];
1522
-				    //$data['verticalrate'] = $line[16];
1523
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1524
-				    //else $data['speed'] = 0;
1525
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1526
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1527
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1528
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1505
+					$aprs_last_tx = time();
1506
+					$data = array();
1507
+					//print_r($line);
1508
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1509
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1510
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1511
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1512
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1513
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1514
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1515
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1516
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1517
+					else $data['datetime'] = date('Y-m-d H:i:s');
1518
+					//$data['datetime'] = date('Y-m-d H:i:s');
1519
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1520
+					$data['latitude'] = $line['latitude'];
1521
+					$data['longitude'] = $line['longitude'];
1522
+					//$data['verticalrate'] = $line[16];
1523
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1524
+					//else $data['speed'] = 0;
1525
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1526
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1527
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1528
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1529 1529
 				    
1530
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1531
-				    //else echo 'No heading...'."\n";
1532
-				    //else $data['heading'] = 0;
1533
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1534
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1535
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1536
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1537
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1538
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1539
-    				    $data['id_source'] = $id_source;
1540
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1541
-				    else $data['format_source'] = 'aprs';
1542
-				    $data['source_name'] = $line['source'];
1543
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1544
-				    else $data['source_type'] = 'flarm';
1545
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1546
-				    $currentdate = date('Y-m-d H:i:s');
1547
-				    $aprsdate = strtotime($data['datetime']);
1548
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1549
-				    // Accept data if time <= system time + 20s
1550
-				    //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1551
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1530
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1531
+					//else echo 'No heading...'."\n";
1532
+					//else $data['heading'] = 0;
1533
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1534
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1535
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1536
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1537
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1538
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1539
+						$data['id_source'] = $id_source;
1540
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1541
+					else $data['format_source'] = 'aprs';
1542
+					$data['source_name'] = $line['source'];
1543
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1544
+					else $data['source_type'] = 'flarm';
1545
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1546
+					$currentdate = date('Y-m-d H:i:s');
1547
+					$aprsdate = strtotime($data['datetime']);
1548
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1549
+					// Accept data if time <= system time + 20s
1550
+					//if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1551
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1552 1552
 					$send = $SI->add($data);
1553
-				    } elseif ($data['source_type'] == 'ais') {
1553
+					} elseif ($data['source_type'] == 'ais') {
1554 1554
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1555
-				    } elseif (isset($line['stealth'])) {
1555
+					} elseif (isset($line['stealth'])) {
1556 1556
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1557 1557
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1558
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1559
-					    //$line['symbol'] == 'Balloon' ||
1560
-					    $line['symbol'] == 'Glider' || 
1561
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1562
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1563
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1564
-					    $send = $SI->add($data);
1565
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1566
-					    $line['symbol'] == 'Yacht (Sail)' || 
1567
-					    $line['symbol'] == 'Ship (Power Boat)')) {
1568
-					    $send = $MI->add($data);
1569
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1570
-					    $line['symbol'] == 'Car' || 
1571
-					    $line['symbol'] == 'Ambulance' || 
1572
-					    $line['symbol'] == 'Van' || 
1573
-					    $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1574
-					    $line['symbol'] == 'Motorcycle' || 
1575
-					    $line['symbol'] == 'Tractor' || 
1576
-					    $line['symbol'] == 'Police' || 
1577
-					    $line['symbol'] == 'Bike' || 
1578
-					    $line['symbol'] == 'Jogger' || 
1579
-					    $line['symbol'] == 'Horse' || 
1580
-					    $line['symbol'] == 'Bus' || 
1581
-					    $line['symbol'] == 'Jeep' || 
1582
-					    $line['symbol'] == 'Recreational Vehicle' || 
1583
-					    $line['symbol'] == 'Yacht (Sail)' || 
1584
-					    $line['symbol'] == 'Ship (Power Boat)' || 
1585
-					    $line['symbol'] == 'Firetruck' || 
1586
-					    $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1587
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1588
-					    $line['symbol'] == 'SUV' ||
1589
-					    $line['symbol'] == 'Snowmobile' ||
1590
-					    $line['symbol'] == 'Mobile Satellite Station')) {
1591
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1558
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1559
+						//$line['symbol'] == 'Balloon' ||
1560
+						$line['symbol'] == 'Glider' || 
1561
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1562
+						if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1563
+						if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1564
+						$send = $SI->add($data);
1565
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1566
+						$line['symbol'] == 'Yacht (Sail)' || 
1567
+						$line['symbol'] == 'Ship (Power Boat)')) {
1568
+						$send = $MI->add($data);
1569
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1570
+						$line['symbol'] == 'Car' || 
1571
+						$line['symbol'] == 'Ambulance' || 
1572
+						$line['symbol'] == 'Van' || 
1573
+						$line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1574
+						$line['symbol'] == 'Motorcycle' || 
1575
+						$line['symbol'] == 'Tractor' || 
1576
+						$line['symbol'] == 'Police' || 
1577
+						$line['symbol'] == 'Bike' || 
1578
+						$line['symbol'] == 'Jogger' || 
1579
+						$line['symbol'] == 'Horse' || 
1580
+						$line['symbol'] == 'Bus' || 
1581
+						$line['symbol'] == 'Jeep' || 
1582
+						$line['symbol'] == 'Recreational Vehicle' || 
1583
+						$line['symbol'] == 'Yacht (Sail)' || 
1584
+						$line['symbol'] == 'Ship (Power Boat)' || 
1585
+						$line['symbol'] == 'Firetruck' || 
1586
+						$line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1587
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1588
+						$line['symbol'] == 'SUV' ||
1589
+						$line['symbol'] == 'Snowmobile' ||
1590
+						$line['symbol'] == 'Mobile Satellite Station')) {
1591
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1592 1592
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1593 1593
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1594 1594
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1595
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1595
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1596 1596
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1597 1597
 					$Source->deleteOldLocationByType('gs');
1598 1598
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1600,7 +1600,7 @@  discard block
 block discarded – undo
1600 1600
 					} else {
1601 1601
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1602 1602
 					}
1603
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1603
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1604 1604
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1605 1605
 					if ($globalDebug) echo '# Weather Station added'."\n";
1606 1606
 					$Source->deleteOldLocationByType('wx');
@@ -1610,7 +1610,7 @@  discard block
 block discarded – undo
1610 1610
 					} else {
1611 1611
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1612 1612
 					}
1613
-				    } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1613
+					} elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1614 1614
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1615 1615
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1616 1616
 					$Source->deleteOldLocationByType('lightning');
@@ -1619,11 +1619,11 @@  discard block
 block discarded – undo
1619 1619
 					} else {
1620 1620
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1621 1621
 					}
1622
-				    } elseif ($globalDebug) {
1623
-				    	echo '/!\ Not added: '.$buffer."\n";
1624
-				    	print_r($line);
1625
-				    }
1626
-				    unset($data);
1622
+					} elseif ($globalDebug) {
1623
+						echo '/!\ Not added: '.$buffer."\n";
1624
+						print_r($line);
1625
+					}
1626
+					unset($data);
1627 1627
 				}
1628 1628
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1629 1629
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1642,12 +1642,12 @@  discard block
 block discarded – undo
1642 1642
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1643 1643
 					$globalSources[$nb]['last_weather_clean'] = time();
1644 1644
 				}
1645
-			    }
1645
+				}
1646 1646
 			} else {
1647
-			    $line = explode(',', $buffer);
1648
-    			    if (count($line) > 20) {
1649
-    			    	$data['hex'] = $line[4];
1650
-    				/*
1647
+				$line = explode(',', $buffer);
1648
+					if (count($line) > 20) {
1649
+						$data['hex'] = $line[4];
1650
+					/*
1651 1651
     				$data['datetime'] = $line[6].' '.$line[7];
1652 1652
     					date_default_timezone_set($globalTimezone);
1653 1653
     					$datetime = new DateTime($data['datetime']);
@@ -1655,30 +1655,30 @@  discard block
 block discarded – undo
1655 1655
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1656 1656
     					date_default_timezone_set('UTC');
1657 1657
     				*/
1658
-    				// Force datetime to current UTC datetime
1659
-    				date_default_timezone_set('UTC');
1660
-    				$data['datetime'] = date('Y-m-d H:i:s');
1661
-    				$data['ident'] = trim($line[10]);
1662
-    				$data['latitude'] = $line[14];
1663
-    				$data['longitude'] = $line[15];
1664
-    				$data['verticalrate'] = $line[16];
1665
-    				$data['emergency'] = $line[20];
1666
-    				$data['speed'] = $line[12];
1667
-    				$data['squawk'] = $line[17];
1668
-    				$data['altitude'] = $line[11];
1669
-    				$data['heading'] = $line[13];
1670
-    				$data['ground'] = $line[21];
1671
-    				$data['emergency'] = $line[19];
1672
-    				$data['format_source'] = 'sbs';
1658
+					// Force datetime to current UTC datetime
1659
+					date_default_timezone_set('UTC');
1660
+					$data['datetime'] = date('Y-m-d H:i:s');
1661
+					$data['ident'] = trim($line[10]);
1662
+					$data['latitude'] = $line[14];
1663
+					$data['longitude'] = $line[15];
1664
+					$data['verticalrate'] = $line[16];
1665
+					$data['emergency'] = $line[20];
1666
+					$data['speed'] = $line[12];
1667
+					$data['squawk'] = $line[17];
1668
+					$data['altitude'] = $line[11];
1669
+					$data['heading'] = $line[13];
1670
+					$data['ground'] = $line[21];
1671
+					$data['emergency'] = $line[19];
1672
+					$data['format_source'] = 'sbs';
1673 1673
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1674
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1674
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1675 1675
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1676
-    				$data['id_source'] = $id_source;
1677
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1678
-    				else $error = true;
1679
-    				unset($data);
1680
-    			    } else $error = true;
1681
-			    if ($error) {
1676
+					$data['id_source'] = $id_source;
1677
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1678
+					else $error = true;
1679
+					unset($data);
1680
+					} else $error = true;
1681
+				if ($error) {
1682 1682
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1683 1683
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1684 1684
 				} else {
@@ -1694,13 +1694,13 @@  discard block
 block discarded – undo
1694 1694
 					connect_all($sourceer);
1695 1695
 					$sourceer = array();
1696 1696
 				}
1697
-			    }
1697
+				}
1698 1698
 			}
1699 1699
 			// Sleep for xxx microseconds
1700 1700
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1701
-		    } else {
1701
+			} else {
1702 1702
 			if ($format == 'flightgearmp') {
1703
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1703
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1704 1704
 				//@socket_close($r);
1705 1705
 				sleep($globalMinFetch);
1706 1706
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1709,9 +1709,9 @@  discard block
 block discarded – undo
1709 1709
 				break;
1710 1710
 				
1711 1711
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1712
-			    if (isset($tt[$format])) $tt[$format]++;
1713
-			    else $tt[$format] = 0;
1714
-			    if ($tt[$format] > 30) {
1712
+				if (isset($tt[$format])) $tt[$format]++;
1713
+				else $tt[$format] = 0;
1714
+				if ($tt[$format] > 30) {
1715 1715
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1716 1716
 				//@socket_close($r);
1717 1717
 				sleep(2);
@@ -1722,23 +1722,23 @@  discard block
 block discarded – undo
1722 1722
 				//connect_all($globalSources);
1723 1723
 				$tt[$format]=0;
1724 1724
 				break;
1725
-			    }
1725
+				}
1726
+			}
1726 1727
 			}
1727
-		    }
1728 1728
 		}
1729
-	    } else {
1729
+		} else {
1730 1730
 		$error = socket_strerror(socket_last_error());
1731 1731
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1732 1732
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1733 1733
 			if (isset($globalDebug)) echo "Restarting...\n";
1734 1734
 			// Restart the script if possible
1735 1735
 			if (is_array($sockets)) {
1736
-			    if ($globalDebug) echo "Shutdown all sockets...";
1736
+				if ($globalDebug) echo "Shutdown all sockets...";
1737 1737
 			    
1738
-			    foreach ($sockets as $sock) {
1738
+				foreach ($sockets as $sock) {
1739 1739
 				@socket_shutdown($sock,2);
1740 1740
 				@socket_close($sock);
1741
-			    }
1741
+				}
1742 1742
 			    
1743 1743
 			}
1744 1744
 			if ($globalDebug) echo "Waiting...";
@@ -1753,15 +1753,15 @@  discard block
 block discarded – undo
1753 1753
 			if ($globalDebug) echo "Restart all connections...";
1754 1754
 			connect_all($globalSources);
1755 1755
 		}
1756
-	    }
1756
+		}
1757 1757
 	}
1758 1758
 	if ($globalDaemon === false) {
1759
-	    if ($globalDebug) echo 'Check all...'."\n";
1760
-	    if (isset($SI)) $SI->checkAll();
1761
-	    if (isset($TI)) $TI->checkAll();
1762
-	    if (isset($MI)) $MI->checkAll();
1759
+		if ($globalDebug) echo 'Check all...'."\n";
1760
+		if (isset($SI)) $SI->checkAll();
1761
+		if (isset($TI)) $TI->checkAll();
1762
+		if (isset($MI)) $MI->checkAll();
1763
+	}
1763 1764
 	}
1764
-    }
1765 1765
 }
1766 1766
 
1767 1767
 ?>
Please login to merge, or discard this patch.
Spacing   +183 added lines, -183 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,30 +150,30 @@  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('/opensky/i',$host)) {
176
+    	    } else if (preg_match('/opensky/i', $host)) {
177 177
         	//$formats[$id] = 'aircraftlistjson';
178 178
         	$globalSources[$id]['format'] = 'opensky';
179 179
         	//$last_exec['aircraftlistjson'] = 0;
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
         	    exit(0);
191 191
         	}
192 192
     	    */
193
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
193
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
194 194
         	//$formats[$id] = 'planeupdatefaa';
195 195
         	$globalSources[$id]['format'] = 'planeupdatefaa';
196 196
         	//$last_exec['planeupdatefaa'] = 0;
@@ -199,32 +199,32 @@  discard block
 block discarded – undo
199 199
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200 200
         	    exit(0);
201 201
         	}
202
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
202
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
203 203
         	//$formats[$id] = 'phpvmacars';
204 204
         	$globalSources[$id]['format'] = 'phpvmacars';
205 205
         	//$last_exec['phpvmacars'] = 0;
206 206
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
207
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
207
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
208 208
         	//$formats[$id] = 'phpvmacars';
209 209
         	$globalSources[$id]['format'] = 'vam';
210 210
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
211
-            } else if (preg_match('/whazzup/i',$host)) {
211
+            } else if (preg_match('/whazzup/i', $host)) {
212 212
         	//$formats[$id] = 'whazzup';
213 213
         	$globalSources[$id]['format'] = 'whazzup';
214 214
         	//$last_exec['whazzup'] = 0;
215 215
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
216
-            } else if (preg_match('/blitzortung/i',$host)) {
216
+            } else if (preg_match('/blitzortung/i', $host)) {
217 217
         	$globalSources[$id]['format'] = 'blitzortung';
218 218
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
219
-            } else if (preg_match('/airwhere/i',$host)) {
219
+            } else if (preg_match('/airwhere/i', $host)) {
220 220
         	$globalSources[$id]['format'] = 'airwhere';
221 221
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
222
-            } else if (preg_match('/recentpireps/i',$host)) {
222
+            } else if (preg_match('/recentpireps/i', $host)) {
223 223
         	//$formats[$id] = 'pirepsjson';
224 224
         	$globalSources[$id]['format'] = 'pirepsjson';
225 225
         	//$last_exec['pirepsjson'] = 0;
226 226
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
227
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
227
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
228 228
         	//$formats[$id] = 'fr24json';
229 229
         	$globalSources[$id]['format'] = 'fr24json';
230 230
         	//$last_exec['fr24json'] = 0;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
234 234
         	    exit(0);
235 235
         	}
236
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
236
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
237 237
         	//$formats[$id] = 'fr24json';
238 238
         	$globalSources[$id]['format'] = 'myshiptracking';
239 239
         	//$last_exec['fr24json'] = 0;
@@ -243,22 +243,22 @@  discard block
 block discarded – undo
243 243
         	    exit(0);
244 244
         	}
245 245
             //} else if (preg_match('/10001/',$host)) {
246
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
246
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
247 247
         	//$formats[$id] = 'tsv';
248 248
         	$globalSources[$id]['format'] = 'tsv';
249 249
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
250 250
             }
251
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
251
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
252 252
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
253
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
253
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
254 254
     		    if ($idf !== false) {
255 255
     			$httpfeeds[$id] = $idf;
256 256
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
257 257
     		    }
258 258
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
259 259
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
260
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
261
-	    $hostport = explode(':',$host);
260
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
261
+	    $hostport = explode(':', $host);
262 262
 	    if (isset($hostport[1])) {
263 263
 		$port = $hostport[1];
264 264
 		$hostn = $hostport[0];
@@ -268,19 +268,19 @@  discard block
 block discarded – undo
268 268
 	    }
269 269
 	    $Common = new Common();
270 270
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
271
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
271
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
272 272
     	    } else {
273
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
273
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
274 274
 	    }
275 275
 	    if ($s) {
276 276
     	        $sockets[$id] = $s;
277 277
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
278
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
278
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
279 279
 			//$formats[$id] = 'aprs';
280 280
 			$globalSources[$id]['format'] = 'aprs';
281 281
 			//$aprs_connect = 0;
282 282
 			//$use_aprs = true;
283
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
283
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
284 284
 			$globalSources[$id]['format'] = 'vrstcp';
285 285
     		    } elseif ($port == '10001') {
286 286
         		//$formats[$id] = 'tsv';
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
320 320
 else $timeout = 20;
321 321
 $errno = '';
322
-$errstr='';
322
+$errstr = '';
323 323
 
324 324
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
325 325
 /* Initiate connections to all the hosts simultaneously */
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 //connect_all($globalSources);
328 328
 
329 329
 if (isset($globalProxy) && $globalProxy) {
330
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
330
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
331 331
 } else {
332 332
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
333 333
 }
@@ -357,16 +357,16 @@  discard block
 block discarded – undo
357 357
 
358 358
 if ($use_aprs) {
359 359
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
360
-	$APRS=new APRS();
360
+	$APRS = new APRS();
361 361
 	$aprs_connect = 0;
362 362
 	$aprs_keep = 120;
363 363
 	$aprs_last_tx = time();
364 364
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
365
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
365
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
366 366
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
367
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
367
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
368 368
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
369
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
369
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
370 370
 	if ($aprs_full) $aprs_filter = '';
371 371
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
372 372
 	else $aprs_pass = '-1';
@@ -380,12 +380,12 @@  discard block
 block discarded – undo
380 380
 sleep(1);
381 381
 if ($globalDebug) echo "SCAN MODE \n\n";
382 382
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
383
-$endtime = time()+$globalCronEnd;
383
+$endtime = time() + $globalCronEnd;
384 384
 $i = 1;
385 385
 $tt = array();
386 386
 // Delete all ATC
387 387
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
388
-	$ATC=new ATC($Connection->db);
388
+	$ATC = new ATC($Connection->db);
389 389
 }
390 390
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
391 391
 	$ATC->deleteAll();
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 
394 394
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
395 395
 while ($i > 0) {
396
-    if (!$globalDaemon) $i = $endtime-time();
396
+    if (!$globalDaemon) $i = $endtime - time();
397 397
     // Delete old ATC
398 398
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
399 399
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	}
408 408
 	if ($max != $globalMinFetch) {
409 409
 	    if ($globalDebug) echo 'Sleeping...'."\n";
410
-	    sleep($globalMinFetch-$max+2);
410
+	    sleep($globalMinFetch - $max + 2);
411 411
 	}
412 412
     }
413 413
 
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
 	    //$buffer = $Common->getData($hosts[$id]);
427 427
 	    $buffer = $Common->getData($value['host']);
428 428
 	    if ($buffer != '') $reset = 0;
429
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
430
-	    $buffer = explode('\n',$buffer);
429
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
430
+	    $buffer = explode('\n', $buffer);
431 431
 	    foreach ($buffer as $line) {
432 432
     		if ($line != '' && count($line) > 7) {
433 433
     		    $line = explode(',', $line);
@@ -460,11 +460,11 @@  discard block
 block discarded – undo
460 460
 	    )
461 461
 	) {
462 462
 	    date_default_timezone_set('CET');
463
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
463
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
464 464
 	    date_default_timezone_set('UTC');
465 465
 	    if ($buffer != '') $reset = 0;
466
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
467
-	    $buffer = explode('\n',$buffer);
466
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
467
+	    $buffer = explode('\n', $buffer);
468 468
 	    foreach ($buffer as $line) {
469 469
 		if ($line != '') {
470 470
 		    //echo "'".$line."'\n";
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
483 483
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
484 484
 		    if (isset($ais_data['timestamp'])) {
485
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
485
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
486 486
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
487 487
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
488 488
 			    $add = true;
@@ -505,12 +505,12 @@  discard block
 block discarded – undo
505 505
 	    $w = $e = null;
506 506
 	    
507 507
 	    if (isset($arr[$id])) {
508
-		$nn = stream_select($arr,$w,$e,$timeout);
508
+		$nn = stream_select($arr, $w, $e, $timeout);
509 509
 		if ($nn > 0) {
510 510
 		    foreach ($httpfeeds as $feed) {
511
-			$buffer = stream_get_line($feed,2000,"\n");
512
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
513
-			$buffer = explode('\n',$buffer);
511
+			$buffer = stream_get_line($feed, 2000, "\n");
512
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
513
+			$buffer = explode('\n', $buffer);
514 514
 			foreach ($buffer as $line) {
515 515
 			    if ($line != '') {
516 516
 				$ais_data = $AIS->parse_line(trim($line));
@@ -528,9 +528,9 @@  discard block
 block discarded – undo
528 528
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
529 529
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
530 530
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
531
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
531
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
532 532
 				if (isset($ais_data['timestamp'])) {
533
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
533
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
534 534
 				} else {
535 535
 				    $data['datetime'] = date('Y-m-d H:i:s');
536 536
 				}
@@ -561,10 +561,10 @@  discard block
 block discarded – undo
561 561
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
562 562
 	    )
563 563
 	) {
564
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
564
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
565 565
 	    if ($buffer != '') {
566 566
 		//echo $buffer;
567
-		$all_data = json_decode($buffer,true);
567
+		$all_data = json_decode($buffer, true);
568 568
 		//print_r($all_data);
569 569
 		if (isset($all_data[0]['DATA'])) {
570 570
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 			    $data['ident'] = $line['NAME'];
574 574
 			    $data['mmsi'] = $line['MMSI'];
575 575
 			    if (strlen($data['mmsi']) > 9) {
576
-				$data['mmsi'] = substr($data['mmsi'],-9);
576
+				$data['mmsi'] = substr($data['mmsi'], -9);
577 577
 			    }
578 578
 			    $data['speed'] = $line['SOG'];
579 579
 			    $data['heading'] = $line['COG'];
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
583 583
 			    $data['imo'] = $line['IMO'];
584 584
 			    //$data['arrival_code'] = $ais_data['destination'];
585
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
585
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
586 586
 			    $data['format_source'] = 'myshiptracking';
587 587
 			    $data['id_source'] = $id_source;
588 588
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -599,9 +599,9 @@  discard block
 block discarded – undo
599 599
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
600 600
 	    )
601 601
 	) {
602
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
602
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
603 603
 	    if ($buffer != '') {
604
-		$all_data = json_decode($buffer,true);
604
+		$all_data = json_decode($buffer, true);
605 605
 		if (isset($all_data[0]['mmsi'])) {
606 606
 		    foreach ($all_data as $line) {
607 607
 			if ($line != '') {
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 	) {
636 636
 	    $buffer = $Common->getData($value['host']);
637 637
 	    if ($buffer != '') {
638
-		$all_data = json_decode($buffer,true);
638
+		$all_data = json_decode($buffer, true);
639 639
 		if (isset($all_data['features'][0]['id'])) {
640 640
 		    foreach ($all_data['features'] as $line) {
641 641
 			$data = array();
@@ -668,27 +668,27 @@  discard block
 block discarded – undo
668 668
 	    )
669 669
 	) {
670 670
 	    echo 'download...';
671
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
671
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
672 672
 	    echo 'done !'."\n";
673 673
 	    if ($buffer != '') $reset = 0;
674
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
675
-	    $buffer = explode('\n',$buffer);
674
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
675
+	    $buffer = explode('\n', $buffer);
676 676
 	    foreach ($buffer as $line) {
677 677
 		if ($line != '') {
678 678
 		    $data = array();
679
-		    $data['mmsi'] = (int)substr($line,0,9);
680
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
679
+		    $data['mmsi'] = (int) substr($line, 0, 9);
680
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
681 681
 		    //$data['status'] = substr($line,21,2);
682 682
 		    //$data['type'] = substr($line,24,3);
683
-		    $data['latitude'] = substr($line,29,9);
684
-		    $data['longitude'] = substr($line,41,9);
685
-		    $data['speed'] = round(substr($line,51,5));
683
+		    $data['latitude'] = substr($line, 29, 9);
684
+		    $data['longitude'] = substr($line, 41, 9);
685
+		    $data['speed'] = round(substr($line, 51, 5));
686 686
 		    //$data['course'] = substr($line,57,5);
687
-		    $data['heading'] = round(substr($line,63,3));
687
+		    $data['heading'] = round(substr($line, 63, 3));
688 688
 		    //$data['draft'] = substr($line,67,4);
689 689
 		    //$data['length'] = substr($line,72,3);
690 690
 		    //$data['beam'] = substr($line,76,2);
691
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
691
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
692 692
 		    //$data['callsign'] = trim(substr($line,100,7);
693 693
 		    //$data['dest'] = substr($line,108,20);
694 694
 		    //$data['etaDate'] = substr($line,129,5);
@@ -721,8 +721,8 @@  discard block
 block discarded – undo
721 721
 	) {
722 722
 	    //$buffer = $Common->getData($hosts[$id]);
723 723
 	    $buffer = $Common->getData($value['host']);
724
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
725
-	    $buffer = explode('\n',$buffer);
724
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
725
+	    $buffer = explode('\n', $buffer);
726 726
 	    $reset = 0;
727 727
 	    foreach ($buffer as $line) {
728 728
     		if ($line != '') {
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
734 734
 			$data['pilot_id'] = $line[1];
735 735
 			$data['pilot_name'] = $line[2];
736
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
736
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
737 737
 			$data['ident'] = $line[0]; // ident
738 738
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
739 739
 			$data['speed'] = $line[8]; // speed
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
750 750
 			//if (isset($line[37])) $data['last_update'] = $line[37];
751 751
 		        $data['departure_airport_icao'] = $line[11];
752
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
752
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
753 753
 		        $data['arrival_airport_icao'] = $line[13];
754 754
 			$data['frequency'] = $line[4];
755 755
 			$data['type'] = $line[18];
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
     			$data['id_source'] = $id_source;
759 759
 	    		//$data['arrival_airport_time'] = ;
760 760
 	    		if ($line[9] != '') {
761
-	    		    $aircraft_data = explode('/',$line[9]);
761
+	    		    $aircraft_data = explode('/', $line[9]);
762 762
 	    		    if (isset($aircraft_data[1])) {
763 763
 	    			$data['aircraft_icao'] = $aircraft_data[1];
764 764
 	    		    }
@@ -773,9 +773,9 @@  discard block
 block discarded – undo
773 773
     			if ($line[3] == 'PILOT') $SI->add($data);
774 774
 			elseif ($line[3] == 'ATC') {
775 775
 				//print_r($data);
776
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
777
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
778
-				$typec = substr($data['ident'],-3);
776
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
777
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
778
+				$typec = substr($data['ident'], -3);
779 779
 				if ($typec == 'APP') $data['type'] = 'Approach';
780 780
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
781 781
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -787,8 +787,8 @@  discard block
 block discarded – undo
787 787
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
788 788
 				if (!isset($data['source_name'])) $data['source_name'] = '';
789 789
 				if (isset($ATC)) {
790
-					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']);
791
-					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']);
790
+					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']);
791
+					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']);
792 792
 				}
793 793
 			}
794 794
     			unset($data);
@@ -804,24 +804,24 @@  discard block
 block discarded – undo
804 804
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
805 805
     	    )
806 806
     	) {
807
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
807
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
808 808
 	    if ($buffer != '') {
809 809
 		$all_data = simplexml_load_string($buffer);
810
-		foreach($all_data->children() as $childdata) {
810
+		foreach ($all_data->children() as $childdata) {
811 811
 			$data = array();
812 812
 			$line = $childdata;
813 813
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
814
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
815
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
816
-			$data['latitude'] = (float)$line['pktLatitude'];
817
-			$data['longitude'] = (float)$line['pktLongitude'];
818
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
819
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
820
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
814
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
815
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
816
+			$data['latitude'] = (float) $line['pktLatitude'];
817
+			$data['longitude'] = (float) $line['pktLongitude'];
818
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
819
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
820
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
821 821
 			$data['altitude_relative'] = 'AMSL';
822
-			$data['pilot_id'] = (int)$line['pktPilotID'];
822
+			$data['pilot_id'] = (int) $line['pktPilotID'];
823 823
 			$data['aircraft_icao'] = 'PARAGLIDER';
824
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
824
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
825 825
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
826 826
 			$data['format_source'] = $value['format'];
827 827
 			$SI->add($data);
@@ -829,22 +829,22 @@  discard block
 block discarded – undo
829 829
 		}
830 830
 	    }
831 831
 	    $Source->deleteOldLocationByType('gs');
832
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
832
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
833 833
 	    if ($buffer != '') {
834 834
 		$all_data = simplexml_load_string($buffer);
835
-		foreach($all_data->children() as $childdata) {
835
+		foreach ($all_data->children() as $childdata) {
836 836
 			$data = array();
837 837
 			$line = $childdata;
838
-			$data['id'] = (int)$line['gsID'];
839
-			$data['latitude'] = (float)$line['gsLatitude'];
840
-			$data['longitude'] = (float)$line['gsLongitude'];
841
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
838
+			$data['id'] = (int) $line['gsID'];
839
+			$data['latitude'] = (float) $line['gsLatitude'];
840
+			$data['longitude'] = (float) $line['gsLongitude'];
841
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
842 842
 			$data['altitude_relative'] = 'AMSL';
843
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
843
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
844 844
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
845
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
845
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
846 846
 			} else {
847
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
847
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
848 848
 			}
849 849
 			unset($data);
850 850
 		}
@@ -862,9 +862,9 @@  discard block
 block discarded – undo
862 862
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
863 863
 	    )
864 864
 	) {
865
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
865
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
866 866
 	    if ($buffer != '') {
867
-	        $all_data = json_decode($buffer,true);
867
+	        $all_data = json_decode($buffer, true);
868 868
 		if (isset($all_data['acList'])) {
869 869
 		    $reset = 0;
870 870
 		    foreach ($all_data['acList'] as $line) {
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
881 881
 			$data['emergency'] = ''; // emergency
882 882
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
883
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
883
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
884 884
 			else $data['datetime'] = date('Y-m-d H:i:s');
885 885
 			//$data['datetime'] = date('Y-m-d H:i:s');
886 886
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
 			$data['verticalrate'] = $line['vrt']; // verticale rate
906 906
 			$data['squawk'] = $line['squawk']; // squawk
907 907
 			$data['emergency'] = ''; // emergency
908
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
908
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
909 909
 			else $data['datetime'] = date('Y-m-d H:i:s');
910 910
 			$data['format_source'] = 'aircraftlistjson';
911 911
 			$data['id_source'] = $id_source;
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
     	    )
927 927
     	) {
928 928
 	    $buffer = $Common->getData($value['host']);
929
-	    $all_data = json_decode($buffer,true);
929
+	    $all_data = json_decode($buffer, true);
930 930
 	    if (isset($all_data['planes'])) {
931 931
 		$reset = 0;
932 932
 		foreach ($all_data['planes'] as $key => $line) {
@@ -943,12 +943,12 @@  discard block
 block discarded – undo
943 943
 		    $data['emergency'] = ''; // emergency
944 944
 		    $data['registration'] = $line[2];
945 945
 		    $data['aircraft_icao'] = $line[0];
946
-		    $deparr = explode('-',$line[1]);
946
+		    $deparr = explode('-', $line[1]);
947 947
 		    if (count($deparr) == 2) {
948 948
 			$data['departure_airport_icao'] = $deparr[0];
949 949
 			$data['arrival_airport_icao'] = $deparr[1];
950 950
 		    }
951
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
951
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
952 952
 	    	    $data['format_source'] = 'planeupdatefaa';
953 953
     		    $data['id_source'] = $id_source;
954 954
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
 	    )
967 967
 	) {
968 968
 	    $buffer = $Common->getData($value['host']);
969
-	    $all_data = json_decode($buffer,true);
969
+	    $all_data = json_decode($buffer, true);
970 970
 	    if (isset($all_data['states'])) {
971 971
 		$reset = 0;
972 972
 		foreach ($all_data['states'] as $key => $line) {
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 		    //$data['emergency'] = ''; // emergency
984 984
 		    //$data['registration'] = $line[2];
985 985
 		    //$data['aircraft_icao'] = $line[0];
986
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
986
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
987 987
 		    $data['format_source'] = 'opensky';
988 988
 		    $data['id_source'] = $id_source;
989 989
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
 	) {
1003 1003
 	    //$buffer = $Common->getData($hosts[$id]);
1004 1004
 	    $buffer = $Common->getData($value['host']);
1005
-	    $all_data = json_decode($buffer,true);
1005
+	    $all_data = json_decode($buffer, true);
1006 1006
 	    if (!empty($all_data)) $reset = 0;
1007 1007
 	    foreach ($all_data as $key => $line) {
1008 1008
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1040,11 +1040,11 @@  discard block
 block discarded – undo
1040 1040
 	    )
1041 1041
 	) {
1042 1042
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1043
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1043
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1044 1044
 	    //echo $buffer;
1045
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1046
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1047
-	    $all_data = json_decode($buffer,true);
1045
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1046
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1047
+	    $all_data = json_decode($buffer, true);
1048 1048
 	    if (json_last_error() != JSON_ERROR_NONE) {
1049 1049
 		die(json_last_error_msg());
1050 1050
 	    }
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
 			//$data['departure_airport_iata'] = $line[11];
1068 1068
 			//$data['arrival_airport_iata'] = $line[12];
1069 1069
 	    		//$data['emergency'] = ''; // emergency
1070
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1070
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1071 1071
 	    		$data['format_source'] = 'radarvirtueljson';
1072 1072
     			$data['id_source'] = $id_source;
1073 1073
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1088,14 +1088,14 @@  discard block
 block discarded – undo
1088 1088
 	) {
1089 1089
 	    //$buffer = $Common->getData($hosts[$id]);
1090 1090
 	    $buffer = $Common->getData($value['host'].'?'.time());
1091
-	    $all_data = json_decode(utf8_encode($buffer),true);
1091
+	    $all_data = json_decode(utf8_encode($buffer), true);
1092 1092
 	    
1093 1093
 	    if (isset($all_data['pireps'])) {
1094 1094
 		$reset = 0;
1095 1095
 	        foreach ($all_data['pireps'] as $line) {
1096 1096
 		    $data = array();
1097 1097
 		    $data['id'] = $line['id'];
1098
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1098
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1099 1099
 		    $data['ident'] = $line['callsign']; // ident
1100 1100
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1101 1101
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1125,9 +1125,9 @@  discard block
 block discarded – undo
1125 1125
 			$SI->add($data);
1126 1126
 		    //    print_r($data);
1127 1127
     		    } elseif ($line['icon'] == 'ct') {
1128
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1129
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1130
-			$typec = substr($data['ident'],-3);
1128
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1129
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1130
+			$typec = substr($data['ident'], -3);
1131 1131
 			$data['type'] = '';
1132 1132
 			if ($typec == 'APP') $data['type'] = 'Approach';
1133 1133
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1139 1139
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1140 1140
 			else $data['type'] = 'Observer';
1141
-			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']);
1141
+			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']);
1142 1142
 		    }
1143 1143
 		    unset($data);
1144 1144
 		}
@@ -1155,14 +1155,14 @@  discard block
 block discarded – undo
1155 1155
 	    //$buffer = $Common->getData($hosts[$id]);
1156 1156
 	    if ($globalDebug) echo 'Get Data...'."\n";
1157 1157
 	    $buffer = $Common->getData($value['host']);
1158
-	    $all_data = json_decode($buffer,true);
1158
+	    $all_data = json_decode($buffer, true);
1159 1159
 	    if ($buffer != '' && is_array($all_data)) {
1160 1160
 		$reset = 0;
1161 1161
 		foreach ($all_data as $line) {
1162 1162
 	    	    $data = array();
1163 1163
 	    	    //$data['id'] = $line['id']; // id not usable
1164 1164
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1165
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1165
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1166 1166
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1167 1167
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1168 1168
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 	    	    //$data['datetime'] = $line['lastupdate'];
1178 1178
 	    	    //$data['last_update'] = $line['lastupdate'];
1179 1179
 	    	    if (isset($value['timezone'])) {
1180
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1180
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1181 1181
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1182 1182
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1183 1183
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1190,14 +1190,14 @@  discard block
 block discarded – undo
1190 1190
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1191 1191
 		    if (isset($line['aircraftname'])) {
1192 1192
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1193
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1194
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1193
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1194
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1195 1195
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1196 1196
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1197 1197
 	    		else {
1198
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1199
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1200
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1198
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1199
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1200
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1201 1201
 	    		}
1202 1202
 	    	    }
1203 1203
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1222,14 +1222,14 @@  discard block
 block discarded – undo
1222 1222
 	    //$buffer = $Common->getData($hosts[$id]);
1223 1223
 	    if ($globalDebug) echo 'Get Data...'."\n";
1224 1224
 	    $buffer = $Common->getData($value['host']);
1225
-	    $all_data = json_decode($buffer,true);
1225
+	    $all_data = json_decode($buffer, true);
1226 1226
 	    if ($buffer != '' && is_array($all_data)) {
1227 1227
 		$reset = 0;
1228 1228
 		foreach ($all_data as $line) {
1229 1229
 	    	    $data = array();
1230 1230
 	    	    //$data['id'] = $line['id']; // id not usable
1231 1231
 	    	    $data['id'] = trim($line['flight_id']);
1232
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1232
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1233 1233
 	    	    $data['pilot_name'] = $line['pilot_name'];
1234 1234
 	    	    $data['pilot_id'] = $line['pilot_id'];
1235 1235
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1273,24 +1273,24 @@  discard block
 block discarded – undo
1273 1273
 	    //$buffer = $Common->getData($hosts[$id]);
1274 1274
 	    if ($globalDebug) echo 'Get Data...'."\n";
1275 1275
 	    $buffer = $Common->getData($value['host']);
1276
-	    $all_data = json_decode($buffer,true);
1276
+	    $all_data = json_decode($buffer, true);
1277 1277
 	    if ($buffer != '') {
1278 1278
 		$Source->deleteLocationBySource('blitzortung');
1279
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1280
-		$buffer = explode('\n',$buffer);
1279
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1280
+		$buffer = explode('\n', $buffer);
1281 1281
 		foreach ($buffer as $buffer_line) {
1282
-		    $line = json_decode($buffer_line,true);
1282
+		    $line = json_decode($buffer_line, true);
1283 1283
 		    if (isset($line['time'])) {
1284 1284
 			$data = array();
1285 1285
 			$data['altitude'] = $line['alt']; // altitude
1286 1286
 			$data['latitude'] = $line['lat']; // lat
1287 1287
 			$data['longitude'] = $line['lon']; // long
1288
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1288
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1289 1289
 			$data['id_source'] = $id_source;
1290 1290
 			$data['format_source'] = 'blitzortung';
1291 1291
 			$SI->add($data);
1292 1292
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1293
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1293
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1294 1294
 			unset($data);
1295 1295
 		    }
1296 1296
 		}
@@ -1315,11 +1315,11 @@  discard block
 block discarded – undo
1315 1315
 		    //$value = $formats[$nb];
1316 1316
 		    $format = $globalSources[$nb]['format'];
1317 1317
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1318
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1318
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1319 1319
 		    } elseif ($format == 'vrstcp') {
1320 1320
 			$buffer = @socket_read($r, 6000);
1321 1321
 		    } else {
1322
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1322
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1323 1323
 		    }
1324 1324
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1325 1325
 		    //echo $buffer."\n";
@@ -1328,8 +1328,8 @@  discard block
 block discarded – undo
1328 1328
 		    $error = false;
1329 1329
 		    //$SI::del();
1330 1330
 		    if ($format == 'vrstcp') {
1331
-			$buffer = explode('},{',$buffer);
1332
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1331
+			$buffer = explode('},{', $buffer);
1332
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1333 1333
 		    // SBS format is CSV format
1334 1334
 		    if ($buffer !== FALSE && $buffer != '') {
1335 1335
 			$tt[$format] = 0;
@@ -1363,13 +1363,13 @@  discard block
 block discarded – undo
1363 1363
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1364 1364
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1365 1365
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1366
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1366
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1367 1367
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1368 1368
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1369 1369
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1370 1370
 
1371 1371
 			    if (isset($ais_data['timestamp'])) {
1372
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1372
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1373 1373
 			    } else {
1374 1374
 				$data['datetime'] = date('Y-m-d H:i:s');
1375 1375
 			    }
@@ -1380,10 +1380,10 @@  discard block
 block discarded – undo
1380 1380
                         } elseif ($format == 'flightgearsp') {
1381 1381
                     	    //echo $buffer."\n";
1382 1382
                     	    if (strlen($buffer) > 5) {
1383
-				$line = explode(',',$buffer);
1383
+				$line = explode(',', $buffer);
1384 1384
 				$data = array();
1385 1385
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1386
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1386
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1387 1387
 				$data['ident'] = $line[6];
1388 1388
 				$data['aircraft_name'] = $line[7];
1389 1389
 				$data['longitude'] = $line[1];
@@ -1400,16 +1400,16 @@  discard block
 block discarded – undo
1400 1400
                         } elseif ($format == 'acars') {
1401 1401
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1402 1402
 			    $ACARS->add(trim($buffer));
1403
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1403
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1404 1404
 			    $ACARS->deleteLiveAcarsData();
1405 1405
 			} elseif ($format == 'flightgearmp') {
1406
-			    if (substr($buffer,0,1) != '#') {
1406
+			    if (substr($buffer, 0, 1) != '#') {
1407 1407
 				$data = array();
1408 1408
 				//echo $buffer."\n";
1409
-				$line = explode(' ',$buffer);
1409
+				$line = explode(' ', $buffer);
1410 1410
 				if (count($line) == 11) {
1411
-				    $userserver = explode('@',$line[0]);
1412
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1411
+				    $userserver = explode('@', $line[0]);
1412
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1413 1413
 				    $data['ident'] = $userserver[0];
1414 1414
 				    $data['registration'] = $userserver[0];
1415 1415
 				    $data['latitude'] = $line[4];
@@ -1417,8 +1417,8 @@  discard block
 block discarded – undo
1417 1417
 				    $data['altitude'] = $line[6];
1418 1418
 				    $data['datetime'] = date('Y-m-d H:i:s');
1419 1419
 				    $aircraft_type = $line[10];
1420
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1421
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1420
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1421
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1422 1422
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1423 1423
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1424 1424
 				}
@@ -1427,8 +1427,8 @@  discard block
 block discarded – undo
1427 1427
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1428 1428
 			    die;
1429 1429
 			} elseif ($format == 'vrstcp') {
1430
-			    foreach($buffer as $all_data) {
1431
-				$line = json_decode('{'.$all_data.'}',true);
1430
+			    foreach ($buffer as $all_data) {
1431
+				$line = json_decode('{'.$all_data.'}', true);
1432 1432
 				$data = array();
1433 1433
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1434 1434
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1454,16 +1454,16 @@  discard block
 block discarded – undo
1454 1454
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1455 1455
 				unset($data);
1456 1456
 			    }
1457
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1457
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1458 1458
 			    $line = explode("\t", $buffer);
1459
-			    for($k = 0; $k < count($line); $k=$k+2) {
1459
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1460 1460
 				$key = $line[$k];
1461
-			        $lined[$key] = $line[$k+1];
1461
+			        $lined[$key] = $line[$k + 1];
1462 1462
 			    }
1463 1463
     			    if (count($lined) > 3) {
1464 1464
     				$data['hex'] = $lined['hexid'];
1465 1465
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1466
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1466
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1467 1467
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1468 1468
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1469 1469
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1482,23 +1482,23 @@  discard block
 block discarded – undo
1482 1482
     			    } else $error = true;
1483 1483
 			} elseif ($format == 'aprs' && $use_aprs) {
1484 1484
 			    if ($aprs_connect == 0) {
1485
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1485
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1486 1486
 				$aprs_connect = 1;
1487 1487
 			    }
1488 1488
 			    
1489
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1489
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1490 1490
 				$aprs_last_tx = time();
1491 1491
 				$data_aprs = "# Keep alive";
1492
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1492
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1493 1493
 			    }
1494 1494
 			    
1495 1495
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1496 1496
 			    //echo 'APRS data : '.$buffer."\n";
1497
-			    $buffer = str_replace('APRS <- ','',$buffer);
1498
-			    $buffer = str_replace('APRS -> ','',$buffer);
1497
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1498
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1499 1499
 			    //echo $buffer."\n";
1500 1500
 			    date_default_timezone_set('UTC');
1501
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1501
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1502 1502
 				$line = $APRS->parse($buffer);
1503 1503
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1504 1504
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1513,7 +1513,7 @@  discard block
 block discarded – undo
1513 1513
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1514 1514
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1515 1515
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1516
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1516
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1517 1517
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1518 1518
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1519 1519
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1595,29 +1595,29 @@  discard block
 block discarded – undo
1595 1595
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1596 1596
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1597 1597
 					$Source->deleteOldLocationByType('gs');
1598
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1599
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1598
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1599
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1600 1600
 					} else {
1601
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1601
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1602 1602
 					}
1603 1603
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1604 1604
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1605 1605
 					if ($globalDebug) echo '# Weather Station added'."\n";
1606 1606
 					$Source->deleteOldLocationByType('wx');
1607 1607
 					$weather_data = json_encode($line);
1608
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1609
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1608
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1609
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1610 1610
 					} else {
1611
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1611
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1612 1612
 					}
1613 1613
 				    } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1614 1614
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1615 1615
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1616 1616
 					$Source->deleteOldLocationByType('lightning');
1617
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1618
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1617
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1618
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1619 1619
 					} else {
1620
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1620
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1621 1621
 					}
1622 1622
 				    } elseif ($globalDebug) {
1623 1623
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1626,7 +1626,7 @@  discard block
 block discarded – undo
1626 1626
 				    unset($data);
1627 1627
 				}
1628 1628
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1629
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1629
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1630 1630
 				}
1631 1631
 				/*
1632 1632
 				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')) {
@@ -1635,7 +1635,7 @@  discard block
 block discarded – undo
1635 1635
 				*/
1636 1636
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1637 1637
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1638
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1638
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1639 1639
 					$Source->deleteOldLocationByType('lightning');
1640 1640
 					$Source->deleteOldLocationByType('wx');
1641 1641
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1720,7 +1720,7 @@  discard block
 block discarded – undo
1720 1720
 				connect_all($sourceee);
1721 1721
 				$sourceee = array();
1722 1722
 				//connect_all($globalSources);
1723
-				$tt[$format]=0;
1723
+				$tt[$format] = 0;
1724 1724
 				break;
1725 1725
 			    }
1726 1726
 			}
@@ -1729,14 +1729,14 @@  discard block
 block discarded – undo
1729 1729
 	    } else {
1730 1730
 		$error = socket_strerror(socket_last_error());
1731 1731
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1732
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1732
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1733 1733
 			if (isset($globalDebug)) echo "Restarting...\n";
1734 1734
 			// Restart the script if possible
1735 1735
 			if (is_array($sockets)) {
1736 1736
 			    if ($globalDebug) echo "Shutdown all sockets...";
1737 1737
 			    
1738 1738
 			    foreach ($sockets as $sock) {
1739
-				@socket_shutdown($sock,2);
1739
+				@socket_shutdown($sock, 2);
1740 1740
 				@socket_close($sock);
1741 1741
 			    }
1742 1742
 			    
Please login to merge, or discard this patch.