Completed
Push — master ( 9fb1e4...96d9e7 )
by Yannick
35:21
created
require/class.APRS.php 1 patch
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -3,10 +3,10 @@  discard block
 block discarded – undo
3 3
 require_once(dirname(__FILE__).'/class.Common.php');
4 4
 require_once(dirname(__FILE__).'/class.GeoidHeight.php');
5 5
 class aprs {
6
-    private $socket;
7
-    private $connected = false;
6
+	private $socket;
7
+	private $connected = false;
8 8
 
9
-    protected $symbols = array('/!' => 'Police',
9
+	protected $symbols = array('/!' => 'Police',
10 10
 	'/#' => 'DIGI',
11 11
 	'/$' => 'Phone',
12 12
 	'/%' => 'DX Cluster',
@@ -166,13 +166,13 @@  discard block
 block discarded – undo
166 166
 	'\~' => 'TNC Stream SW');
167 167
 	
168 168
 
169
-    private function urshift($n, $s) {
169
+	private function urshift($n, $s) {
170 170
 	return ($n >= 0) ? ($n >> $s) :
171
-	    (($n & 0x7fffffff) >> $s) | 
171
+		(($n & 0x7fffffff) >> $s) | 
172 172
 		(0x40000000 >> ($s - 1));
173
-    }
173
+	}
174 174
 
175
-    public function parse($input) {
175
+	public function parse($input) {
176 176
 	global $globalDebug;
177 177
 	$debug = false;
178 178
 	$result = array();
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	
185 185
 	/* Check that end was found and body has at least one byte. */
186 186
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
187
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
188
-	    return false;
187
+		if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
188
+		return false;
189 189
 	}
190 190
 	
191 191
 	if ($debug) echo 'input : '.$input."\n";
@@ -199,34 +199,34 @@  discard block
 block discarded – undo
199 199
 	/* Parse source, target and path. */
200 200
 	//FLRDF0A52>APRS,qAS,LSTB
201 201
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
202
-	    $ident = $matches[1];
203
-	    $all_elements = $matches[2];
204
-	    if ($ident == 'AIRCRAFT') {
202
+		$ident = $matches[1];
203
+		$all_elements = $matches[2];
204
+		if ($ident == 'AIRCRAFT') {
205 205
 		$result['format_source'] = 'famaprs';
206 206
 		$result['source_type'] = 'modes';
207
-	    } elseif ($ident == 'MARINE') {
207
+		} elseif ($ident == 'MARINE') {
208 208
 		$result['format_source'] = 'famaprs';
209 209
 		$result['source_type'] = 'ais';
210
-	    } else {
210
+		} else {
211 211
 		if ($debug) echo 'ident : '.$ident."\n";
212 212
 		$result['ident'] = $ident;
213
-	    }
213
+		}
214 214
 	} else {
215
-	    if ($debug) 'No ident'."\n";
216
-	    return false;
215
+		if ($debug) 'No ident'."\n";
216
+		return false;
217 217
 	}
218 218
 	$elements = explode(',',$all_elements);
219 219
 	$source = end($elements);
220 220
 	$result['source'] = $source;
221 221
 	foreach ($elements as $element) {
222
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
223
-	        //echo "ok";
224
-	        //if ($element == 'TCPIP*') return false;
225
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
222
+		if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
223
+			//echo "ok";
224
+			//if ($element == 'TCPIP*') return false;
225
+		} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
226 226
 		if ($debug) echo 'element : '.$element."\n";
227 227
 		return false;
228
-	    }
229
-	    /*
228
+		}
229
+		/*
230 230
 	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) {
231 231
 		//echo "ok";
232 232
 	    } else {
@@ -253,48 +253,48 @@  discard block
 block discarded – undo
253 253
 	$body_parse = substr($body,1);
254 254
 	//echo 'Body : '.$body."\n";
255 255
 	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
256
-	    $body_parse = substr($body_parse,10);
257
-	    $find = true;
258
-	    //echo $body_parse."\n";
256
+		$body_parse = substr($body_parse,10);
257
+		$find = true;
258
+		//echo $body_parse."\n";
259 259
 	}
260 260
 	if (preg_match('/^`(.*)\//',$body,$matches)) {
261
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
262
-	    $find = true;
263
-	    //echo $body_parse."\n";
261
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
262
+		$find = true;
263
+		//echo $body_parse."\n";
264 264
 	}
265 265
 	if (preg_match("/^'(.*)\//",$body,$matches)) {
266
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
267
-	    $find = true;
268
-	    //echo $body_parse."\n";
266
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
267
+		$find = true;
268
+		//echo $body_parse."\n";
269 269
 	}
270 270
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
271
-	    $find = true;
272
-	    //print_r($matches);
273
-	    $timestamp = $matches[0];
274
-	    if ($matches[4] == 'h') {
271
+		$find = true;
272
+		//print_r($matches);
273
+		$timestamp = $matches[0];
274
+		if ($matches[4] == 'h') {
275 275
 		$timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]);
276 276
 		//echo 'timestamp : '.$timestamp.' - now : '.time()."\n";
277 277
 		/*
278 278
 		if (time() + 3900 < $timestamp) $timestamp -= 86400;
279 279
 		elseif (time() - 82500 > $timestamp) $timestamp += 86400;
280 280
 		*/
281
-	    } elseif ($matches[4] == 'z' || $matches[4] == '/') {
281
+		} elseif ($matches[4] == 'z' || $matches[4] == '/') {
282 282
 		// This work or not ?
283 283
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
284
-	    }
285
-	    $body_parse = substr($body_parse,7);
286
-	    $result['timestamp'] = $timestamp;
287
-	    //echo date('Ymd H:i:s',$timestamp);
284
+		}
285
+		$body_parse = substr($body_parse,7);
286
+		$result['timestamp'] = $timestamp;
287
+		//echo date('Ymd H:i:s',$timestamp);
288 288
 	}
289 289
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
290
-	    $find = true;
291
-	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
292
-	    $body_parse = substr($body_parse,8);
293
-	    $result['timestamp'] = $timestamp;
294
-	    //echo date('Ymd H:i:s',$timestamp);
290
+		$find = true;
291
+		$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
292
+		$body_parse = substr($body_parse,8);
293
+		$result['timestamp'] = $timestamp;
294
+		//echo date('Ymd H:i:s',$timestamp);
295 295
 	}
296 296
 	//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)) {
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)) {
298 298
 		$find = true;
299 299
 		// 4658.70N/00707.78Ez
300 300
 		//print_r(str_split($body_parse));
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 		$lon = intval($lon_deg);
314 314
 		if ($lat > 89 || $lon > 179) return false;
315 315
 	    
316
-	    /*
316
+		/*
317 317
 	    $tmp_5b = str_replace('.','',$lat_min);
318 318
 	    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) {
319 319
 	        print_r($matches);
@@ -327,9 +327,9 @@  discard block
 block discarded – undo
327 327
 		$result['longitude'] = $longitude;
328 328
 		$body_parse = substr($body_parse,18);
329 329
 		$body_parse_len = strlen($body_parse);
330
-	    }
331
-	    $body_parse_len = strlen($body_parse);
332
-	    if ($body_parse_len > 0) {
330
+		}
331
+		$body_parse_len = strlen($body_parse);
332
+		if ($body_parse_len > 0) {
333 333
 		/*
334 334
 		if (!isset($result['timestamp']) && !isset($result['latitude'])) {
335 335
 			$body_split = str_split($body);
@@ -363,95 +363,95 @@  discard block
 block discarded – undo
363 363
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
364 364
 			if ($symbol_code != '_') {
365 365
 			}
366
-		    //$body_parse = substr($body_parse,1);
367
-		    //$body_parse = trim($body_parse);
368
-		    //$body_parse_len = strlen($body_parse);
369
-		    if ($body_parse_len >= 7) {
366
+			//$body_parse = substr($body_parse,1);
367
+			//$body_parse = trim($body_parse);
368
+			//$body_parse_len = strlen($body_parse);
369
+			if ($body_parse_len >= 7) {
370 370
 			
371
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
372
-		    	    $course = substr($body_parse,0,3);
373
-		    	    $tmp_s = intval($course);
374
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
375
-		    	    $speed = substr($body_parse,4,3);
376
-		    	    if ($speed != '...') {
377
-		    		//$result['speed'] = round($speed*1.852);
378
-		    		$result['speed'] = intval($speed);
379
-		    	    }
380
-		    	    $body_parse = substr($body_parse,7);
381
-		        }
382
-		        // Check PHGR, PHG, RNG
383
-		    } 
384
-		    /*
371
+				if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
372
+					$course = substr($body_parse,0,3);
373
+					$tmp_s = intval($course);
374
+					if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
375
+					$speed = substr($body_parse,4,3);
376
+					if ($speed != '...') {
377
+					//$result['speed'] = round($speed*1.852);
378
+					$result['speed'] = intval($speed);
379
+					}
380
+					$body_parse = substr($body_parse,7);
381
+				}
382
+				// Check PHGR, PHG, RNG
383
+			} 
384
+			/*
385 385
 		    else if ($body_parse_len > 0) {
386 386
 			$rest = $body_parse;
387 387
 		    }
388 388
 		    */
389
-		    if (strlen($body_parse) > 0) {
390
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
391
-		            $altitude = intval($matches[1]);
392
-		            //$result['altitude'] = round($altitude*0.3048);
393
-		            $result['altitude'] = $altitude;
394
-		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
395
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
396
-		        }
397
-		    }
389
+			if (strlen($body_parse) > 0) {
390
+				if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
391
+					$altitude = intval($matches[1]);
392
+					//$result['altitude'] = round($altitude*0.3048);
393
+					$result['altitude'] = $altitude;
394
+					//$body_parse = trim(substr($body_parse,strlen($matches[0])));
395
+					$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
396
+				}
397
+			}
398 398
 		    
399
-		    // Telemetry
400
-		    /*
399
+			// Telemetry
400
+			/*
401 401
 		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) {
402 402
 		        // Nothing yet...
403 403
 		    }
404 404
 		    */
405
-		    // DAO
405
+			// DAO
406 406
 		    
407
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
407
+			if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
408 408
 			    
409
-			    $dao = $matches[1];
410
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
409
+				$dao = $matches[1];
410
+				if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
411 411
 				$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;
412
+					$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
413
+					$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
414 414
 			    
415 415
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
416 416
 				else $result['latitude'] += $lat_off;
417 417
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
418 418
 				else $result['longitude'] += $lon_off;
419
-			    }
419
+				}
420 420
 			    
421
-		            $body_parse = substr($body_parse,6);
422
-		    }
423
-		    echo 'bodyparse : '.$body_parse."\n";
424
-		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
421
+					$body_parse = substr($body_parse,6);
422
+			}
423
+			echo 'bodyparse : '.$body_parse."\n";
424
+			if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
425 425
 			$result['ident'] = str_replace('_',' ',$matches[1]);
426
-		    }
427
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
426
+			}
427
+			if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
428 428
 			$result['squawk'] = $matches[1];
429
-		    }
430
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
429
+			}
430
+			if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
431 431
 			$result['aircraft_icao'] = $matches[1];
432
-		    }
433
-		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
432
+			}
433
+			if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
434 434
 			$result['verticalrate'] = $matches[1];
435
-		    }
436
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
435
+			}
436
+			if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
437 437
 			$result['typeid'] = $matches[1];
438
-		    }
439
-		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
438
+			}
439
+			if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
440 440
 			$result['statusid'] = $matches[1];
441
-		    }
442
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
441
+			}
442
+			if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
443 443
 			$result['imo'] = $matches[1];
444
-		    }
445
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
444
+			}
445
+			if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
446 446
 			$result['arrival_date'] = $matches[1];
447
-		    }
448
-		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
447
+			}
448
+			if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
449 449
 			$result['arrival_code'] = str_replace('_',' ',$matches[1]);
450
-		    }
451
-		    // OGN comment
450
+			}
451
+			// OGN comment
452 452
 		   // echo "Before OGN : ".$body_parse."\n";
453
-		    //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}) ([+-])([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)) {
455 455
 			$id = $matches[1];
456 456
 			//$mode = substr($id,0,2);
457 457
 			$address = substr($id,2);
@@ -481,42 +481,42 @@  discard block
 block discarded – undo
481 481
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
482 482
 			$result['stealth'] = $stealth;
483 483
 			$result['address'] = $address;
484
-		    }
484
+			}
485 485
 		    
486
-		    //Comment
487
-		    $result['comment'] = trim($body_parse);
486
+			//Comment
487
+			$result['comment'] = trim($body_parse);
488 488
 		//} else {
489
-		    // parse weather
490
-		    //$body_parse = substr($body_parse,1);
491
-		    //$body_parse_len = strlen($body_parse);
492
-		    //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)) {
494
-			    $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)) {
489
+			// parse weather
490
+			//$body_parse = substr($body_parse,1);
491
+			//$body_parse_len = strlen($body_parse);
492
+			//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)) {
494
+				$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)) {
500 500
 			$result['wind_dir'] = intval($matches[1]);
501 501
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
502 502
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
503 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)) {
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)) {
506 506
 			$result['wind_dir'] = intval($matches[1]);
507 507
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
508 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)) {
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)) {
511 511
 			$result['wind_dir'] = intval($matches[1]);
512 512
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
513 513
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
514
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
515
-		    }
516
-		    //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
517
-		    //g012t088r000p000P000h38b10110
518
-		    //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)) {
514
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
515
+			}
516
+			//if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
517
+			//g012t088r000p000P000h38b10110
518
+			//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 520
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
521 521
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
522 522
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
 			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
525 525
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
526 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)) {
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 529
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
530 530
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
531 531
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
@@ -533,8 +533,8 @@  discard block
 block discarded – undo
533 533
 			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
534 534
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
535 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)) {
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 538
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
539 539
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
540 540
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
@@ -542,58 +542,58 @@  discard block
 block discarded – undo
542 542
 			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
543 543
 			if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
544 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)) {
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 547
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
548 548
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
549 549
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
550 550
 			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
551 551
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
552 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)) {
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 555
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
556 556
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
557 557
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
558 558
 			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
559 559
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
560 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)) {
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 563
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
564 564
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
565 565
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
566 566
 			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
567 567
 			if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
568 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)) {
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 571
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
572 572
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
573 573
 			if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
574 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)) {
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 577
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
578 578
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
579 579
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
580 580
 			if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
581 581
 			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
582
-		        $body_parse = substr($body_parse,strlen($matches[0]));
583
-		    }
584
-		    $result['comment'] = trim($body_parse);
582
+				$body_parse = substr($body_parse,strlen($matches[0]));
583
+			}
584
+			$result['comment'] = trim($body_parse);
585 585
 		}
586 586
 		} else $result['comment'] = trim($body_parse);
587 587
 
588
-	    }
588
+		}
589 589
 	//}
590 590
 	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
591 591
 	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
592 592
 	if ($debug) print_r($result);
593 593
 	return $result;
594
-    }
594
+	}
595 595
     
596
-    public function connect() {
596
+	public function connect() {
597 597
 	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
598 598
 	$aprs_connect = 0;
599 599
 	$aprs_keep = 120;
@@ -617,24 +617,24 @@  discard block
 block discarded – undo
617 617
 		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1);
618 618
 		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
619 619
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
620
-			    echo 'APRS user verified !'."\n";
621
-			    $this->connected = true;
622
-			    return true;
623
-			    break;
620
+				echo 'APRS user verified !'."\n";
621
+				$this->connected = true;
622
+				return true;
623
+				break;
624 624
 			}
625 625
 			if (time()-$authstart > 5) {
626
-			    echo 'APRS timeout'."\n";
627
-			    break;
626
+				echo 'APRS timeout'."\n";
627
+				break;
628 628
 			}
629 629
 		}
630 630
 	}
631
-    }
631
+	}
632 632
 
633
-    public function disconnect() {
633
+	public function disconnect() {
634 634
 	socket_close($this->socket);
635
-    }
635
+	}
636 636
     
637
-    public function send($data) {
637
+	public function send($data) {
638 638
 	global $globalDebug;
639 639
 	if ($this->connected === false) $this->connect();
640 640
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 		socket_close($this->socket);
644 644
 		$this->connect();
645 645
 	}
646
-    }
646
+	}
647 647
 }
648 648
 
649 649
 class APRSSpotter extends APRS {
Please login to merge, or discard this patch.
live-czml.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -39,30 +39,30 @@  discard block
 block discarded – undo
39 39
 
40 40
 
41 41
 function quaternionrotate($heading, $attitude = 0, $bank = 0) {
42
-    // Assuming the angles are in radians.
43
-    $c1 = cos($heading/2);
44
-    $s1 = sin($heading/2);
45
-    $c2 = cos($attitude/2);
46
-    $s2 = sin($attitude/2);
47
-    $c3 = cos($bank/2);
48
-    $s3 = sin($bank/2);
49
-    $c1c2 = $c1*$c2;
50
-    $s1s2 = $s1*$s2;
51
-    $w =$c1c2*$c3 - $s1s2*$s3;
52
-    $x =$c1c2*$s3 + $s1s2*$c3;
53
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
54
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
55
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
42
+	// Assuming the angles are in radians.
43
+	$c1 = cos($heading/2);
44
+	$s1 = sin($heading/2);
45
+	$c2 = cos($attitude/2);
46
+	$s2 = sin($attitude/2);
47
+	$c3 = cos($bank/2);
48
+	$s3 = sin($bank/2);
49
+	$c1c2 = $c1*$c2;
50
+	$s1s2 = $s1*$s2;
51
+	$w =$c1c2*$c3 - $s1s2*$s3;
52
+	$x =$c1c2*$s3 + $s1s2*$c3;
53
+	$y =$s1*$c2*$c3 + $c1*$s2*$s3;
54
+	$z =$c1*$s2*$c3 - $s1*$c2*$s3;
55
+	return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
56 56
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
57 57
 
58 58
 }
59 59
 
60 60
 
61 61
 if (isset($_GET['download'])) {
62
-    if ($_GET['download'] == "true")
63
-    {
62
+	if ($_GET['download'] == "true")
63
+	{
64 64
 	header('Content-disposition: attachment; filename="flightairmap.json"');
65
-    }
65
+	}
66 66
 }
67 67
 header('Content-Type: text/javascript');
68 68
 
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
 			$image = "images/placeholder_thumb.png";
253 253
 		}
254 254
 
255
-                if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
256
-                elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
257
-                elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
258
-                if ($prev_flightaware_id != $id) {
255
+				if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
256
+				elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
257
+				elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
258
+				if ($prev_flightaware_id != $id) {
259 259
 			if ($prev_flightaware_id != '') {
260 260
 				/*
261 261
 				if ($nblatlong == 1) {
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 							$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
334 334
 							$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
335 335
 						} else $aircraft_shadow = '';
336
-	    					$output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5';
336
+							$output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5';
337 337
 						if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true' && isset($_COOKIE['IconColor'])) {
338 338
 							$rgb = $Common->hex2rgb($_COOKIE['IconColor']);
339 339
 							$output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}';
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 							$rgb = $Common->hex2rgb($_COOKIE['IconColor']);
365 365
 							$output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}';
366 366
 						}
367
-    						$output .= '},';
367
+							$output .= '},';
368 368
 					} elseif (isset($modelsdb[$aircraft_icao])) {
369 369
 						$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_icao].'","scale" : 1.0,"minimumPixelSize": 20';
370 370
 						$output .= ',"heightReference": "'.$heightrelative.'"';
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 							$rgb = $Common->hex2rgb($_COOKIE['IconColor']);
373 373
 							$output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}';
374 374
 						}
375
-    						$output .= '},';
375
+							$output .= '},';
376 376
 					} elseif ($aircraft_icao != '') {
377 377
 						$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
378 378
 						if (isset($aircraft_info[0]['engine_type'])) {
Please login to merge, or discard this patch.
js/map-aircraft.3d.js.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -265,22 +265,22 @@  discard block
 block discarded – undo
265 265
 			var entityid = entity.id;
266 266
 			var lastupdateentity = entity.properties.lastupdate;
267 267
 			<?php 
268
-			    if (isset($globalMapUseBbox) && $globalMapUseBbox) {
269
-			    // Remove flights not in latest CZML
268
+				if (isset($globalMapUseBbox) && $globalMapUseBbox) {
269
+				// Remove flights not in latest CZML
270 270
 			?>
271 271
 			if (lastupdateentity != lastupdate) {
272 272
 				viewer.dataSources.get(dsn).entities.remove(entity);
273 273
 				czmlds.entities.removeById(entityid);
274 274
 			}
275 275
 			<?php
276
-			    } else {
276
+				} else {
277 277
 			?>
278 278
 			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
279 279
 				viewer.dataSources.get(dsn).entities.remove(entity);
280 280
 				czmlds.entities.removeById(entityid);
281 281
 			}
282 282
 			<?php
283
-			    }
283
+				}
284 284
 			?>
285 285
 		}
286 286
 	}
@@ -708,12 +708,12 @@  discard block
 block discarded – undo
708 708
 	update_airportsLayer();
709 709
 }
710 710
 <?php
711
-    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
711
+	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
712 712
 ?>
713 713
 update_atcLayer();
714 714
 setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
715 715
 <?php
716
-    }
716
+	}
717 717
 ?>
718 718
 
719 719
 function iconColor(color) {
Please login to merge, or discard this patch.
js/map-marine.3d.js.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,20 +41,20 @@  discard block
 block discarded – undo
41 41
 			var entityid = entity.id;
42 42
 			var lastupdateentity = entity.properties.lastupdate;
43 43
 			<?php 
44
-			    if (isset($globalMapUseBbox) && $globalMapUseBbox) {
44
+				if (isset($globalMapUseBbox) && $globalMapUseBbox) {
45 45
 			?>
46 46
 			if (lastupdateentity != lastupdatemarine) {
47 47
 				viewer.dataSources.get(dsn).entities.remove(entity);
48 48
 				czmldsmarine.entities.removeById(entityid);
49 49
 			}
50 50
 			<?php
51
-			    } else {
51
+				} else {
52 52
 			?>
53 53
 			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
54 54
 				viewer.dataSources.get(dsn).entities.remove(entity);
55 55
 			}
56 56
 			<?php
57
-			    }
57
+				}
58 58
 			?>
59 59
 		}
60 60
 	}
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 function updateMarineData() {
77 77
 	lastupdatemarine = Date.now();
78 78
 <?php
79
-    if (isset($globalMapUseBbox) && $globalMapUseBbox) {
79
+	if (isset($globalMapUseBbox) && $globalMapUseBbox) {
80 80
 ?>
81 81
 	var livemarinedata = czmldsmarine.process('<?php print $globalURL; ?>/live-czml.php?marine&coord='+bbox()+'&update=' + lastupdatemarine);
82 82
 <?php
83
-    } else {
83
+	} else {
84 84
 ?>
85 85
 	var livemarinedata = czmldsmarine.process('<?php print $globalURL; ?>/live-czml.php?marine&update=' + lastupdatemarine);
86 86
 <?php
87
-    }
87
+	}
88 88
 ?>
89 89
 	livemarinedata.then(function (data) { 
90 90
 		displayMarineData(data);
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
132 132
 camera.moveEnd.addEventListener(function() {
133 133
 <?php
134
-    if (isset($globalMapUseBbox) && $globalMapUseBbox) {
134
+	if (isset($globalMapUseBbox) && $globalMapUseBbox) {
135 135
 ?>
136 136
 	updateMarineData();
137 137
 <?php
138
-    }
138
+	}
139 139
 ?>
140 140
 });
141 141
 
Please login to merge, or discard this patch.