Completed
Push — master ( 438a8c...d8fba4 )
by Yannick
35:59
created
require/class.AIS.php 2 patches
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -117,31 +117,31 @@  discard block
 block discarded – undo
117 117
 
118 118
 	private function make_latf($temp) { // unsigned long 
119 119
 		$flat = 0.0; // float
120
-		$temp = $temp & 0x07FFFFFF;
121
-		if ($temp & 0x04000000) {
122
-			$temp = $temp ^ 0x07FFFFFF;
120
+		$temp = $temp&0x07FFFFFF;
121
+		if ($temp&0x04000000) {
122
+			$temp = $temp^0x07FFFFFF;
123 123
 			$temp += 1;
124
-			$flat = (float)($temp / (60.0 * 10000.0));
124
+			$flat = (float) ($temp/(60.0*10000.0));
125 125
 			$flat *= -1.0;
126
-		} else $flat = (float)($temp / (60.0 * 10000.0));
126
+		} else $flat = (float) ($temp/(60.0*10000.0));
127 127
 		return $flat; // float
128 128
 	}
129 129
 
130 130
 	private function make_lonf($temp) { // unsigned long
131 131
 		$flon = 0.0; // float
132
-		$temp = $temp & 0x0FFFFFFF;
133
-		if ($temp & 0x08000000) {
134
-			$temp = $temp ^ 0x0FFFFFFF;
132
+		$temp = $temp&0x0FFFFFFF;
133
+		if ($temp&0x08000000) {
134
+			$temp = $temp^0x0FFFFFFF;
135 135
 			$temp += 1;
136
-			$flon = (float)($temp / (60.0 * 10000.0));
136
+			$flon = (float) ($temp/(60.0*10000.0));
137 137
 			$flon *= -1.0;
138
-		} else $flon = (float)($temp / (60.0 * 10000.0));
138
+		} else $flon = (float) ($temp/(60.0*10000.0));
139 139
 		return $flon;
140 140
 	}
141 141
 
142 142
 	private function ascii_2_dec($chr) {
143
-		$dec=ord($chr);//get decimal ascii code
144
-		$hex=dechex($dec);//convert decimal to hex
143
+		$dec = ord($chr); //get decimal ascii code
144
+		$hex = dechex($dec); //convert decimal to hex
145 145
 		return ($dec);
146 146
 	}
147 147
 	
@@ -160,15 +160,15 @@  discard block
 block discarded – undo
160 160
 		//only process in the following range: 48-87, 96-119
161 161
 		if ($ascii < 48) { }
162 162
 		else {
163
-			if($ascii>119) { }
163
+			if ($ascii > 119) { }
164 164
 			else {
165
-				if ($ascii>87 && $ascii<96) ;
165
+				if ($ascii > 87 && $ascii < 96);
166 166
 				else {
167
-					$ascii=$ascii+40;
168
-					if ($ascii>128){
169
-						$ascii=$ascii+32;
167
+					$ascii = $ascii + 40;
168
+					if ($ascii > 128) {
169
+						$ascii = $ascii + 32;
170 170
 					} else {
171
-						$ascii=$ascii+40;
171
+						$ascii = $ascii + 40;
172 172
 					}
173 173
 				}
174 174
 			}
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	}
178 178
 
179 179
 	private function dec_2_6bit($dec) {
180
-		$bin=decbin($dec);
180
+		$bin = decbin($dec);
181 181
 		return(substr($bin, -6)); 
182 182
 	}
183 183
 
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 		);
196 196
 		// "
197 197
 		$rv = '';
198
-		if ($_size % 6 == 0) {
199
-			$len = $_size / 6;
200
-			for ($i=0; $i<$len; $i++) {
201
-				$offset = $i * 6;
202
-				$rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ];
198
+		if ($_size%6 == 0) {
199
+			$len = $_size/6;
200
+			for ($i = 0; $i < $len; $i++) {
201
+				$offset = $i*6;
202
+				$rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))];
203 203
 			}
204 204
 		}
205 205
 		return $rv;
@@ -226,93 +226,93 @@  discard block
 block discarded – undo
226 226
 		$ro->eta_hour = '';
227 227
 		$ro->eta_minute = '';
228 228
 		$ro->ts = time();
229
-		$ro->id = bindec(substr($_aisdata,0,6));
230
-		$ro->mmsi = bindec(substr($_aisdata,8,30));
229
+		$ro->id = bindec(substr($_aisdata, 0, 6));
230
+		$ro->mmsi = bindec(substr($_aisdata, 8, 30));
231 231
 		if ($ro->id >= 1 && $ro->id <= 3) {
232
-			$ro->cog = bindec(substr($_aisdata,116,12))/10;
233
-			$ro->sog = bindec(substr($_aisdata,50,10))/10;
234
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
235
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
232
+			$ro->cog = bindec(substr($_aisdata, 116, 12))/10;
233
+			$ro->sog = bindec(substr($_aisdata, 50, 10))/10;
234
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
235
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
236 236
 			$ro->cls = 1; // class A
237 237
 		} else if ($ro->id == 4) {
238
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,79,28)));
239
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,107,27)));
238
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 79, 28)));
239
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 107, 27)));
240 240
 			$ro->cls = 1; // class A
241 241
 		} else if ($ro->id == 5) {
242
-			$ro->imo = bindec(substr($_aisdata,40,30));
243
-			$ro->callsign = $this->binchar($_aisdata,70,42);
244
-			$ro->name = $this->binchar($_aisdata,112,120);
245
-			$ro->typeid = bindec(substr($_aisdata,232,8));
242
+			$ro->imo = bindec(substr($_aisdata, 40, 30));
243
+			$ro->callsign = $this->binchar($_aisdata, 70, 42);
244
+			$ro->name = $this->binchar($_aisdata, 112, 120);
245
+			$ro->typeid = bindec(substr($_aisdata, 232, 8));
246 246
 			$ro->type = $this->getShipType($ro->typeid);
247 247
 			//$ro->to_bow = bindec(substr($_aisdata,240,9));
248 248
 			//$ro->to_stern = bindec(substr($_aisdata,249,9));
249 249
 			//$ro->to_port = bindec(substr($_aisdata,258,6));
250 250
 			//$ro->to_starboard = bindec(substr($_aisdata,264,6));
251
-			$ro->eta_month = bindec(substr($_aisdata,274,4));
252
-			$ro->eta_day = bindec(substr($_aisdata,278,5));
253
-			$ro->eta_hour = bindec(substr($_aisdata,283,5));
254
-			$ro->eta_minute = bindec(substr($_aisdata,288,6));
251
+			$ro->eta_month = bindec(substr($_aisdata, 274, 4));
252
+			$ro->eta_day = bindec(substr($_aisdata, 278, 5));
253
+			$ro->eta_hour = bindec(substr($_aisdata, 283, 5));
254
+			$ro->eta_minute = bindec(substr($_aisdata, 288, 6));
255 255
 			//$ro->draught = bindec(substr($_aisdata,294,8));
256
-			$ro->destination = $this->binchar($_aisdata,302,120);
256
+			$ro->destination = $this->binchar($_aisdata, 302, 120);
257 257
 			$ro->cls = 1; // class A
258 258
 		} else if ($ro->id == 9) {
259 259
 			// Search and Rescue aircraft position report
260 260
 		} else if ($ro->id == 18) {
261
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
262
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
263
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
264
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
265
-			$ro->heading = bindec(substr($_aisdata,124,9));
261
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
262
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
263
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28)));
264
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27)));
265
+			$ro->heading = bindec(substr($_aisdata, 124, 9));
266 266
 			if ($ro->heading == 511) $ro->heading = '';
267 267
 			$ro->cls = 2; // class B
268 268
 		} else if ($ro->id == 19) {
269
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
270
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
271
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
272
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
273
-			$ro->name = $this->binchar($_aisdata,143,120);
269
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
270
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
271
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
272
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
273
+			$ro->name = $this->binchar($_aisdata, 143, 120);
274 274
 			$ro->cls = 2; // class B
275
-			$ro->heading = bindec(substr($_aisdata,124,9));
275
+			$ro->heading = bindec(substr($_aisdata, 124, 9));
276 276
 			if ($ro->heading == 511) $ro->heading = '';
277
-			$ro->typeid = bindec(substr($_aisdata,263,8));
277
+			$ro->typeid = bindec(substr($_aisdata, 263, 8));
278 278
 			$ro->type = $this->getShipType($ro->typeid);
279 279
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
280 280
 			//$ro->to_stern = bindec(substr($_aisdata,280,9));
281 281
 			//$ro->to_port = bindec(substr($_aisdata,289,6));
282 282
 			//$ro->to_starboard = bindec(substr($_aisdata,295,6));
283 283
 		} else if ($ro->id == 21) {
284
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,164,28)));
285
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,192,27)));
286
-			$ro->name = $this->binchar($_aisdata,43,120);
284
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 164, 28)));
285
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 192, 27)));
286
+			$ro->name = $this->binchar($_aisdata, 43, 120);
287 287
 			//$ro->to_bow = bindec(substr($_aisdata,219,9));
288 288
 			//$ro->to_stern = bindec(substr($_aisdata,228,9));
289 289
 			//$ro->to_port = bindec(substr($_aisdata,237,6));
290 290
 			//$ro->to_starboard = bindec(substr($_aisdata,243,6));
291 291
 			$ro->cls = 2; // class B
292 292
 		} else if ($ro->id == 24) {
293
-			$pn = bindec(substr($_aisdata,38,2));
293
+			$pn = bindec(substr($_aisdata, 38, 2));
294 294
 			if ($pn == 0) {
295
-				$ro->name = $this->binchar($_aisdata,40,120);
295
+				$ro->name = $this->binchar($_aisdata, 40, 120);
296 296
 			}
297
-			$ro->typeid = bindec(substr($_aisdata,40,8));
297
+			$ro->typeid = bindec(substr($_aisdata, 40, 8));
298 298
 			$ro->type = $this->getShipType($ro->typeid);
299
-			$ro->callsign = $this->binchar($_aisdata,90,42);
299
+			$ro->callsign = $this->binchar($_aisdata, 90, 42);
300 300
 			//$ro->to_bow = bindec(substr($_aisdata,132,9));
301 301
 			//$ro->to_stern = bindec(substr($_aisdata,141,9));
302 302
 			//$ro->to_port = bindec(substr($_aisdata,150,6));
303 303
 			//$ro->to_starboard = bindec(substr($_aisdata,156,6));
304 304
 			$ro->cls = 2; // class B
305 305
 		} else if ($ro->id == 27) {
306
-			$ro->cog = bindec(substr($_aisdata,85,9));
306
+			$ro->cog = bindec(substr($_aisdata, 85, 9));
307 307
 			if ($ro->cog == 511) $ro->cog = 0.0;
308
-			$ro->sog = bindec(substr($_aisdata,79,6));
308
+			$ro->sog = bindec(substr($_aisdata, 79, 6));
309 309
 			if ($ro->sog == 63) $ro->sog = 0.0;
310
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
311
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
310
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 44, 18))*10);
311
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 62, 17))*10);
312 312
 			$ro->cls = 1; // class A
313 313
 		
314 314
 		}
315
-		$ro->statusid = bindec(substr($_aisdata,38,4));
315
+		$ro->statusid = bindec(substr($_aisdata, 38, 4));
316 316
 		$ro->status = $this->getStatus($ro->statusid);
317 317
 		return $ro;
318 318
 	}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	}
360 360
 
361 361
 	public function getShipTypeID($type) {
362
-		$typeid = array_search($type,$this->shiptype);
362
+		$typeid = array_search($type, $this->shiptype);
363 363
 		if ($typeid !== FALSE) return $typeid;
364 364
 		elseif ($type == 'Cargo' || $type == 'General Cargo' || $type == 'Bulk Carrier' || $type == 'Container Ship' || $type == 'Cargo A' || $type == 'Reefer' || $type == 'Vehicles Carrier' || $type == 'Ro-Ro Cargo') return 70;
365 365
 		elseif ($type == 'Passengers Ship' || $type == 'Passenger' || $type == 'Ro-Ro/Passenger Ship' || $type == 'Motor Passenger') return 60;
@@ -381,14 +381,14 @@  discard block
 block discarded – undo
381 381
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
382 382
 		global $port; // tcpip port...
383 383
 		static $debug_counter = 0;
384
-		$aisdata168='';//six bit array of ascii characters
384
+		$aisdata168 = ''; //six bit array of ascii characters
385 385
 		$ais_nmea_array = str_split($_itu); // convert to an array
386 386
 		foreach ($ais_nmea_array as $value) {
387 387
 			$dec = $this->ascii_2_dec($value);
388 388
 			$bit8 = $this->asciidec_2_8bit($dec);
389 389
 			$bit6 = $this->dec_2_6bit($bit8);
390 390
 			//echo $value ."-" .$bit6 ."";
391
-			$aisdata168 .=$bit6;
391
+			$aisdata168 .= $bit6;
392 392
 		}
393 393
 		//echo $aisdata168 . "<br/>";
394 394
 		//return $this->decode_ais($aisdata168, $aux);
@@ -411,24 +411,24 @@  discard block
 block discarded – undo
411 411
 		// calculate checksum after ! till *
412 412
 		// assume 1st ! is valid
413 413
 		// find * ensure that it is at correct position
414
-		$end = strrpos ( $rawdata , '*' );
414
+		$end = strrpos($rawdata, '*');
415 415
 		if ($end === FALSE) return -1; // check for NULLS!!!
416
-		$cs = substr( $rawdata, $end + 1 );
417
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
418
-		$dcs = (int)hexdec( $cs );
419
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
420
-		if ( $chksum == $dcs ) { // NMEA checksum pass
416
+		$cs = substr($rawdata, $end + 1);
417
+		if (strlen($cs) != 2) return -1; // correct cs length
418
+		$dcs = (int) hexdec($cs);
419
+		for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum
420
+		if ($chksum == $dcs) { // NMEA checksum pass
421 421
 			$pcs = explode(',', $rawdata);
422 422
 			// !AI??? identifier
423 423
 			if (!isset($pcs[1])) {
424 424
 				echo "ERROR,INVALID_DATA ".time()." $rawdata\n";
425 425
 				return -1;
426 426
 			}
427
-			$num_seq = (int)$pcs[1]; // number of sequences
428
-			$seq = (int)$pcs[2]; // get sequence
427
+			$num_seq = (int) $pcs[1]; // number of sequences
428
+			$seq = (int) $pcs[2]; // get sequence
429 429
 			// get msg sequence id
430 430
 			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
431
-			else $msg_sid = (int)$pcs[3]; // multipart message
431
+			else $msg_sid = (int) $pcs[3]; // multipart message
432 432
 			$ais_ch = $pcs[4]; // get AIS channel
433 433
 			// message sequence checking
434 434
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 					}
462 462
 				}
463 463
 				$itu = $itu.$pcs[5]; // get itu message
464
-				$filler += (int)$pcs[6][0]; // get filler
464
+				$filler += (int) $pcs[6][0]; // get filler
465 465
 				if ($num_seq == 1 // valid single message
466 466
 				    || $num_seq == $pseq // valid multi-part message
467 467
 				) {
@@ -483,13 +483,13 @@  discard block
 block discarded – undo
483 483
 		$cbuf = $cbuf.$ibuf;
484 484
 		$last_pos = 0;
485 485
 		$result = new stdClass();
486
-		while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) {
486
+		while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) {
487 487
 		//while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) {
488 488
 			//DEBUG echo $cbuf;
489
-			if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim?
489
+			if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim?
490 490
 				$tst = substr($cbuf, $start - 3, ($end - $start + 3));
491 491
 				//DEBUG echo "[$start $end $tst]\n";
492
-				$result = $this->process_ais_raw( $tst, "" );
492
+				$result = $this->process_ais_raw($tst, "");
493 493
 				$last_pos = $end + 1;
494 494
 			} else break;
495 495
 		}
@@ -501,41 +501,41 @@  discard block
 block discarded – undo
501 501
 	// incoming data from serial or IP comms
502 502
 	public function process_ais_line($cbuf) {
503 503
 		$result = new stdClass();
504
-		$start = strpos($cbuf,"VDM");
504
+		$start = strpos($cbuf, "VDM");
505 505
 		$tst = substr($cbuf, $start - 3);
506
-		$result = $this->process_ais_raw( $tst, "" );
506
+		$result = $this->process_ais_raw($tst, "");
507 507
 		return $result;
508 508
 	}
509 509
 
510 510
 	/* AIS Encoding
511 511
 	*/
512
-	private function mk_ais_lat( $lat ) {
512
+	private function mk_ais_lat($lat) {
513 513
 		//$lat = 1.2569;
514
-		if ($lat<0.0) {
514
+		if ($lat < 0.0) {
515 515
 			$lat = -$lat;
516
-			$neg=true;
517
-		} else $neg=false;
516
+			$neg = true;
517
+		} else $neg = false;
518 518
 		$latd = 0x00000000;
519
-		$latd = intval ($lat * 600000.0);
520
-		if ($neg==true) {
519
+		$latd = intval($lat*600000.0);
520
+		if ($neg == true) {
521 521
 			$latd = ~$latd;
522
-			$latd+=1;
522
+			$latd += 1;
523 523
 			$latd &= 0x07FFFFFF;
524 524
 		}
525 525
 		return $latd;
526 526
 	}
527 527
 
528
-	private function mk_ais_lon( $lon ) {
528
+	private function mk_ais_lon($lon) {
529 529
 		//$lon = 103.851;
530
-		if ($lon<0.0) {
530
+		if ($lon < 0.0) {
531 531
 			$lon = -$lon;
532
-			$neg=true;
533
-		} else $neg=false;
532
+			$neg = true;
533
+		} else $neg = false;
534 534
 		$lond = 0x00000000;
535
-		$lond = intval ($lon * 600000.0);
536
-		if ($neg==true) {
535
+		$lond = intval($lon*600000.0);
536
+		if ($neg == true) {
537 537
 			$lond = ~$lond;
538
-			$lond+=1;
538
+			$lond += 1;
539 539
 			$lond &= 0x0FFFFFFF;
540 540
 		}
541 541
 		return $lond;
@@ -543,8 +543,8 @@  discard block
 block discarded – undo
543 543
 
544 544
 	private function char2bin($name, $max_len) {
545 545
 		$len = strlen($name);
546
-		if ($len > $max_len) $name = substr($name,0,$max_len);
547
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
546
+		if ($len > $max_len) $name = substr($name, 0, $max_len);
547
+		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6);
548 548
 		else $pad = '';
549 549
 		$rv = '';
550 550
 		$ais_chars = array(
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 			foreach ($_a as $_1) {
563 563
 				if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
564 564
 				else $dec = 0;
565
-				$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
565
+				$bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT);
566 566
 				$rv .= $bin;
567 567
 				//echo "$_1 $dec ($bin)<br/>";
568 568
 			}
@@ -570,19 +570,19 @@  discard block
 block discarded – undo
570 570
 		return $rv.$pad;
571 571
 	}
572 572
 
573
-	private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') {
573
+	private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') {
574 574
 		$len_bit = strlen($_enc);
575
-		$rem6 = $len_bit % 6;
575
+		$rem6 = $len_bit%6;
576 576
 		$pad6_len = 0;
577 577
 		if ($rem6) $pad6_len = 6 - $rem6;
578 578
 		//echo  $pad6_len.'<br>';
579 579
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
580
-		$len_enc = strlen($_enc) / 6;
580
+		$len_enc = strlen($_enc)/6;
581 581
 		//echo $_enc.' '.$len_enc.'<br/>';
582 582
 		$itu = '';
583
-		for ($i=0; $i<$len_enc; $i++) {
584
-			$offset = $i * 6;
585
-			$dec = bindec(substr($_enc,$offset,6));
583
+		for ($i = 0; $i < $len_enc; $i++) {
584
+			$offset = $i*6;
585
+			$dec = bindec(substr($_enc, $offset, 6));
586 586
 			if ($dec < 40) $dec += 48;
587 587
 			else $dec += 56;
588 588
 			//echo chr($dec)." $dec<br/>";
@@ -592,15 +592,15 @@  discard block
 block discarded – undo
592 592
 		$chksum = 0;
593 593
 		$itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0";
594 594
 		$len_itu = strlen($itu);
595
-		for ($i=0; $i<$len_itu; $i++) {
596
-			$chksum ^= ord( $itu[$i] );
595
+		for ($i = 0; $i < $len_itu; $i++) {
596
+			$chksum ^= ord($itu[$i]);
597 597
 		}
598
-		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
599
-		$lsb = $chksum & 0x0F;
600
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
598
+		$hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
599
+		$lsb = $chksum&0x0F;
600
+		if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb];
601 601
 		else $lsbc = '0';
602
-		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
603
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
602
+		$msb = (($chksum&0xF0) >> 4)&0x0F;
603
+		if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb];
604 604
 		else $msbc = '0';
605 605
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
606 606
 		return $itu;
@@ -626,14 +626,14 @@  discard block
 block discarded – undo
626 626
 
627 627
 	public function mmsitype($mmsi) {
628 628
 		if (strlen($mmsi) == 9) {
629
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
630
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
631
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
632
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
633
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
634
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
635
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
636
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
629
+			if (substr($mmsi, 0, 3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
630
+			elseif (substr($mmsi, 0, 3) == '972') return 'MOB (Man Overboard) device';
631
+			elseif (substr($mmsi, 0, 3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
632
+			elseif (substr($mmsi, 0, 3) == '111') return 'SAR (Search and Rescue) aircraft';
633
+			elseif (substr($mmsi, 0, 2) == '98') return 'Auxiliary craft associated with a parent ship';
634
+			elseif (substr($mmsi, 0, 2) == '99') return 'Aids to Navigation';
635
+			elseif (substr($mmsi, 0, 2) == '00') return 'Coastal stations';
636
+			elseif (substr($mmsi, 0, 1) == '0') return 'Group of ships';
637 637
 			else return 'Ship';
638 638
 		}
639 639
 
@@ -643,19 +643,19 @@  discard block
 block discarded – undo
643 643
 	public function parse_line($buffer) {
644 644
 		global $globalDebug;
645 645
 		$result = array();
646
-		$start = strpos($buffer,"VDM");
646
+		$start = strpos($buffer, "VDM");
647 647
 		$tst = substr($buffer, $start - 3);
648
-		$data = $this->process_ais_raw( $tst, "" );
648
+		$data = $this->process_ais_raw($tst, "");
649 649
 		if (!is_object($data)) {
650 650
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
651 651
 			return array();
652 652
 		}
653 653
 		if ($data->lon != 0) $result['longitude'] = $data->lon;
654 654
 		if ($data->lat != 0) $result['latitude'] = $data->lat;
655
-		$result['ident'] = trim(str_replace('@','',$data->name));
655
+		$result['ident'] = trim(str_replace('@', '', $data->name));
656 656
 		$result['timestamp'] = $data->ts;
657 657
 		$result['mmsi'] = $data->mmsi;
658
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
658
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'], 0, 3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
659 659
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
660 660
 		if ($data->sog != -1.0) $result['speed'] = $data->sog;
661 661
 		if ($data->heading !== '') $result['heading'] = $data->heading;
@@ -665,16 +665,16 @@  discard block
 block discarded – undo
665 665
 		if ($data->type !== '') $result['type'] = $data->type;
666 666
 		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
667 667
 		if ($data->imo !== '') $result['imo'] = $data->imo;
668
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
668
+		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@', '', $data->callsign));
669 669
 		if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') {
670
-			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
670
+			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d", $data->eta_month).'-'.sprintf("%02d", $data->eta_day).' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00');
671 671
 			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
672 672
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
673
-			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
673
+			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00');
674 674
 			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
675 675
 		}
676 676
 		if ($data->destination != '') {
677
-			$dest = trim(str_replace('@','',$data->destination));
677
+			$dest = trim(str_replace('@', '', $data->destination));
678 678
 			if ($dest != '') $result['destination'] = $dest;
679 679
 		}
680 680
 		$result['all'] = (array) $data;
Please login to merge, or discard this patch.
Braces   +204 added lines, -79 removed lines patch added patch discarded remove patch
@@ -123,7 +123,9 @@  discard block
 block discarded – undo
123 123
 			$temp += 1;
124 124
 			$flat = (float)($temp / (60.0 * 10000.0));
125 125
 			$flat *= -1.0;
126
-		} else $flat = (float)($temp / (60.0 * 10000.0));
126
+		} else {
127
+			$flat = (float)($temp / (60.0 * 10000.0));
128
+		}
127 129
 		return $flat; // float
128 130
 	}
129 131
 
@@ -135,7 +137,9 @@  discard block
 block discarded – undo
135 137
 			$temp += 1;
136 138
 			$flon = (float)($temp / (60.0 * 10000.0));
137 139
 			$flon *= -1.0;
138
-		} else $flon = (float)($temp / (60.0 * 10000.0));
140
+		} else {
141
+			$flon = (float)($temp / (60.0 * 10000.0));
142
+		}
139 143
 		return $flon;
140 144
 	}
141 145
 
@@ -158,10 +162,8 @@  discard block
 block discarded – undo
158 162
     */
159 163
 	private function asciidec_2_8bit($ascii) {
160 164
 		//only process in the following range: 48-87, 96-119
161
-		if ($ascii < 48) { }
162
-		else {
163
-			if($ascii>119) { }
164
-			else {
165
+		if ($ascii < 48) { } else {
166
+			if($ascii>119) { } else {
165 167
 				if ($ascii>87 && $ascii<96) ;
166 168
 				else {
167 169
 					$ascii=$ascii+40;
@@ -263,7 +265,9 @@  discard block
 block discarded – undo
263 265
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
264 266
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
265 267
 			$ro->heading = bindec(substr($_aisdata,124,9));
266
-			if ($ro->heading == 511) $ro->heading = '';
268
+			if ($ro->heading == 511) {
269
+				$ro->heading = '';
270
+			}
267 271
 			$ro->cls = 2; // class B
268 272
 		} else if ($ro->id == 19) {
269 273
 			$ro->cog = bindec(substr($_aisdata,112,12))/10;
@@ -273,7 +277,9 @@  discard block
 block discarded – undo
273 277
 			$ro->name = $this->binchar($_aisdata,143,120);
274 278
 			$ro->cls = 2; // class B
275 279
 			$ro->heading = bindec(substr($_aisdata,124,9));
276
-			if ($ro->heading == 511) $ro->heading = '';
280
+			if ($ro->heading == 511) {
281
+				$ro->heading = '';
282
+			}
277 283
 			$ro->typeid = bindec(substr($_aisdata,263,8));
278 284
 			$ro->type = $this->getShipType($ro->typeid);
279 285
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
@@ -304,9 +310,13 @@  discard block
 block discarded – undo
304 310
 			$ro->cls = 2; // class B
305 311
 		} else if ($ro->id == 27) {
306 312
 			$ro->cog = bindec(substr($_aisdata,85,9));
307
-			if ($ro->cog == 511) $ro->cog = 0.0;
313
+			if ($ro->cog == 511) {
314
+				$ro->cog = 0.0;
315
+			}
308 316
 			$ro->sog = bindec(substr($_aisdata,79,6));
309
-			if ($ro->sog == 63) $ro->sog = 0.0;
317
+			if ($ro->sog == 63) {
318
+				$ro->sog = 0.0;
319
+			}
310 320
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
311 321
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
312 322
 			$ro->cls = 1; // class A
@@ -354,28 +364,48 @@  discard block
 block discarded – undo
354 364
 	}
355 365
 	
356 366
 	public function getShipType($code) {
357
-		if (isset($this->shiptype[$code])) return $this->shiptype[$code];
358
-		else return '';
367
+		if (isset($this->shiptype[$code])) {
368
+			return $this->shiptype[$code];
369
+		} else {
370
+			return '';
371
+		}
359 372
 	}
360 373
 
361 374
 	public function getShipTypeID($type) {
362 375
 		$typeid = array_search($type,$this->shiptype);
363
-		if ($typeid !== FALSE) return $typeid;
364
-		elseif ($type == 'Cargo' || $type == 'General Cargo' || $type == 'Bulk Carrier' || $type == 'Container Ship' || $type == 'Cargo A' || $type == 'Reefer' || $type == 'Vehicles Carrier' || $type == 'Ro-Ro Cargo') return 70;
365
-		elseif ($type == 'Passengers Ship' || $type == 'Passenger' || $type == 'Ro-Ro/Passenger Ship' || $type == 'Motor Passenger') return 60;
366
-		elseif ($type == 'Tanker' || $type == 'Crude Oil Tanker' || $type == 'Oil Products Tanker' || $type == 'Oil/Chemical Tanker' || $type == 'Bunkering Tanker') return 80;
367
-		elseif ($type == 'Lpg Tanker' || $type == 'Lng Tanker') return 84;
368
-		elseif ($type == 'Sailing Vessel') return 36;
369
-		elseif ($type == 'Yacht') return 37;
370
-		elseif ($type == 'Trailing Suction Hopper Dredger' || $type == 'Drilling Jack Up' || $type == 'Suction Dredger' || $type == 'Hopper Dredger') return 33;
371
-		elseif ($type == 'High speed craft') return 40;
372
-		elseif ($type == 'Crew Boat') return 53;
373
-		elseif ($type == 'Icebreaker') return 52;
374
-		elseif ($type == 'Pollution Control Vessel') return 54;
375
-		elseif ($type == 'Other Type') return 90;
376
-		elseif ($type == 'Anchor Handling Vessel' || $type == 'Offshore Supply Ship' || $type == 'Research/Survey Vessel' || $type == 'Utility Vessel' || $type == 'Pipe Burying Vessel' || $type == 'Heavy Lift Vessel' || $type == 'Crane Ship' || $type == 'Buoy-laying Vessel') return 59;
377
-		elseif ($type == 'Fish Carrier' || $type == 'Trawler' || $type == 'Trawlers' || $type == 'Fishing Vessel' || $type == 'Trawlers|unknown Not Fishing' || $type == 'Purse Seines|trawlers' || $type == 'Purse Seines' || $type == 'Trollers' || $type == 'Set Longlines' || $type == 'Set Gillnets|trawlers') return 30;
378
-		else return 0;
376
+		if ($typeid !== FALSE) {
377
+			return $typeid;
378
+		} elseif ($type == 'Cargo' || $type == 'General Cargo' || $type == 'Bulk Carrier' || $type == 'Container Ship' || $type == 'Cargo A' || $type == 'Reefer' || $type == 'Vehicles Carrier' || $type == 'Ro-Ro Cargo') {
379
+			return 70;
380
+		} elseif ($type == 'Passengers Ship' || $type == 'Passenger' || $type == 'Ro-Ro/Passenger Ship' || $type == 'Motor Passenger') {
381
+			return 60;
382
+		} elseif ($type == 'Tanker' || $type == 'Crude Oil Tanker' || $type == 'Oil Products Tanker' || $type == 'Oil/Chemical Tanker' || $type == 'Bunkering Tanker') {
383
+			return 80;
384
+		} elseif ($type == 'Lpg Tanker' || $type == 'Lng Tanker') {
385
+			return 84;
386
+		} elseif ($type == 'Sailing Vessel') {
387
+			return 36;
388
+		} elseif ($type == 'Yacht') {
389
+			return 37;
390
+		} elseif ($type == 'Trailing Suction Hopper Dredger' || $type == 'Drilling Jack Up' || $type == 'Suction Dredger' || $type == 'Hopper Dredger') {
391
+			return 33;
392
+		} elseif ($type == 'High speed craft') {
393
+			return 40;
394
+		} elseif ($type == 'Crew Boat') {
395
+			return 53;
396
+		} elseif ($type == 'Icebreaker') {
397
+			return 52;
398
+		} elseif ($type == 'Pollution Control Vessel') {
399
+			return 54;
400
+		} elseif ($type == 'Other Type') {
401
+			return 90;
402
+		} elseif ($type == 'Anchor Handling Vessel' || $type == 'Offshore Supply Ship' || $type == 'Research/Survey Vessel' || $type == 'Utility Vessel' || $type == 'Pipe Burying Vessel' || $type == 'Heavy Lift Vessel' || $type == 'Crane Ship' || $type == 'Buoy-laying Vessel') {
403
+			return 59;
404
+		} elseif ($type == 'Fish Carrier' || $type == 'Trawler' || $type == 'Trawlers' || $type == 'Fishing Vessel' || $type == 'Trawlers|unknown Not Fishing' || $type == 'Purse Seines|trawlers' || $type == 'Purse Seines' || $type == 'Trollers' || $type == 'Set Longlines' || $type == 'Set Gillnets|trawlers') {
405
+			return 30;
406
+		} else {
407
+			return 0;
408
+		}
379 409
 	}
380 410
 
381 411
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
@@ -412,11 +442,20 @@  discard block
 block discarded – undo
412 442
 		// assume 1st ! is valid
413 443
 		// find * ensure that it is at correct position
414 444
 		$end = strrpos ( $rawdata , '*' );
415
-		if ($end === FALSE) return -1; // check for NULLS!!!
445
+		if ($end === FALSE) {
446
+			return -1;
447
+		}
448
+		// check for NULLS!!!
416 449
 		$cs = substr( $rawdata, $end + 1 );
417
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
450
+		if ( strlen($cs) != 2 ) {
451
+			return -1;
452
+		}
453
+		// correct cs length
418 454
 		$dcs = (int)hexdec( $cs );
419
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
455
+		for ( $alias=1; $alias<$end; $alias++) {
456
+			$chksum ^= ord( $rawdata[$alias] );
457
+		}
458
+		// perform XOR for NMEA checksum
420 459
 		if ( $chksum == $dcs ) { // NMEA checksum pass
421 460
 			$pcs = explode(',', $rawdata);
422 461
 			// !AI??? identifier
@@ -427,8 +466,14 @@  discard block
 block discarded – undo
427 466
 			$num_seq = (int)$pcs[1]; // number of sequences
428 467
 			$seq = (int)$pcs[2]; // get sequence
429 468
 			// get msg sequence id
430
-			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
431
-			else $msg_sid = (int)$pcs[3]; // multipart message
469
+			if ($pcs[3] == '') {
470
+				$msg_sid = -1;
471
+			}
472
+			// non-multipart message, set to -1
473
+			else {
474
+				$msg_sid = (int)$pcs[3];
475
+			}
476
+			// multipart message
432 477
 			$ais_ch = $pcs[4]; // get AIS channel
433 478
 			// message sequence checking
434 479
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -491,10 +536,18 @@  discard block
 block discarded – undo
491 536
 				//DEBUG echo "[$start $end $tst]\n";
492 537
 				$result = $this->process_ais_raw( $tst, "" );
493 538
 				$last_pos = $end + 1;
494
-			} else break;
539
+			} else {
540
+				break;
541
+			}
542
+		}
543
+		if ($last_pos > 0) {
544
+			$cbuf = substr($cbuf, $last_pos);
495 545
 		}
496
-		if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move...
497
-		if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode...
546
+		// move...
547
+		if (strlen($cbuf) > 1024) {
548
+			$cbuf = "";
549
+		}
550
+		// prevent overflow simple mode...
498 551
 		return $result;
499 552
 	}
500 553
 
@@ -514,7 +567,9 @@  discard block
 block discarded – undo
514 567
 		if ($lat<0.0) {
515 568
 			$lat = -$lat;
516 569
 			$neg=true;
517
-		} else $neg=false;
570
+		} else {
571
+			$neg=false;
572
+		}
518 573
 		$latd = 0x00000000;
519 574
 		$latd = intval ($lat * 600000.0);
520 575
 		if ($neg==true) {
@@ -530,7 +585,9 @@  discard block
 block discarded – undo
530 585
 		if ($lon<0.0) {
531 586
 			$lon = -$lon;
532 587
 			$neg=true;
533
-		} else $neg=false;
588
+		} else {
589
+			$neg=false;
590
+		}
534 591
 		$lond = 0x00000000;
535 592
 		$lond = intval ($lon * 600000.0);
536 593
 		if ($neg==true) {
@@ -543,9 +600,14 @@  discard block
 block discarded – undo
543 600
 
544 601
 	private function char2bin($name, $max_len) {
545 602
 		$len = strlen($name);
546
-		if ($len > $max_len) $name = substr($name,0,$max_len);
547
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
548
-		else $pad = '';
603
+		if ($len > $max_len) {
604
+			$name = substr($name,0,$max_len);
605
+		}
606
+		if ($len < $max_len) {
607
+			$pad = str_repeat('0', ($max_len - $len) * 6);
608
+		} else {
609
+			$pad = '';
610
+		}
549 611
 		$rv = '';
550 612
 		$ais_chars = array(
551 613
 		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
@@ -560,8 +622,11 @@  discard block
 block discarded – undo
560 622
 		$_a = str_split($name);
561 623
 		if (!empty($_a)) {
562 624
 			foreach ($_a as $_1) {
563
-				if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
564
-				else $dec = 0;
625
+				if (isset($ais_chars[$_1])) {
626
+					$dec = $ais_chars[$_1];
627
+				} else {
628
+					$dec = 0;
629
+				}
565 630
 				$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
566 631
 				$rv .= $bin;
567 632
 				//echo "$_1 $dec ($bin)<br/>";
@@ -574,7 +639,9 @@  discard block
 block discarded – undo
574 639
 		$len_bit = strlen($_enc);
575 640
 		$rem6 = $len_bit % 6;
576 641
 		$pad6_len = 0;
577
-		if ($rem6) $pad6_len = 6 - $rem6;
642
+		if ($rem6) {
643
+			$pad6_len = 6 - $rem6;
644
+		}
578 645
 		//echo  $pad6_len.'<br>';
579 646
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
580 647
 		$len_enc = strlen($_enc) / 6;
@@ -583,8 +650,11 @@  discard block
 block discarded – undo
583 650
 		for ($i=0; $i<$len_enc; $i++) {
584 651
 			$offset = $i * 6;
585 652
 			$dec = bindec(substr($_enc,$offset,6));
586
-			if ($dec < 40) $dec += 48;
587
-			else $dec += 56;
653
+			if ($dec < 40) {
654
+				$dec += 48;
655
+			} else {
656
+				$dec += 56;
657
+			}
588 658
 			//echo chr($dec)." $dec<br/>";
589 659
 			$itu .= chr($dec);
590 660
 		}
@@ -597,26 +667,42 @@  discard block
 block discarded – undo
597 667
 		}
598 668
 		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
599 669
 		$lsb = $chksum & 0x0F;
600
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
601
-		else $lsbc = '0';
670
+		if ($lsb >=0 && $lsb <= 15 ) {
671
+			$lsbc = $hex_arr[$lsb];
672
+		} else {
673
+			$lsbc = '0';
674
+		}
602 675
 		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
603
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
604
-		else $msbc = '0';
676
+		if ($msb >=0 && $msb <= 15 ) {
677
+			$msbc = $hex_arr[$msb];
678
+		} else {
679
+			$msbc = '0';
680
+		}
605 681
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
606 682
 		return $itu;
607 683
 	}
608 684
 
609 685
 	public function parse($buffer) {
610 686
 		$data = $this->process_ais_buf($buffer);
611
-		if (!is_object($data)) return array();
687
+		if (!is_object($data)) {
688
+			return array();
689
+		}
612 690
 		$result = array();
613
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
614
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
691
+		if ($data->lon != 0) {
692
+			$result['longitude'] = $data->lon;
693
+		}
694
+		if ($data->lat != 0) {
695
+			$result['latitude'] = $data->lat;
696
+		}
615 697
 		$result['ident'] = trim($data->name);
616 698
 		$result['timestamp'] = $data->ts;
617 699
 		$result['mmsi'] = $data->mmsi;
618
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
619
-		if ($data->cog != 0) $result['heading'] = $data->cog;
700
+		if ($data->sog != -1.0) {
701
+			$result['speed'] = $data->sog;
702
+		}
703
+		if ($data->cog != 0) {
704
+			$result['heading'] = $data->cog;
705
+		}
620 706
 		/*
621 707
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
622 708
 		    $ro->id = bindec(substr($_aisdata,0,6));
@@ -626,15 +712,25 @@  discard block
 block discarded – undo
626 712
 
627 713
 	public function mmsitype($mmsi) {
628 714
 		if (strlen($mmsi) == 9) {
629
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
630
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
631
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
632
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
633
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
634
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
635
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
636
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
637
-			else return 'Ship';
715
+			if (substr($mmsi,0,3) == '974') {
716
+				return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
717
+			} elseif (substr($mmsi,0,3) == '972') {
718
+				return 'MOB (Man Overboard) device';
719
+			} elseif (substr($mmsi,0,3) == '970') {
720
+				return 'AIS SART (Search and Rescue Transmitter)';
721
+			} elseif (substr($mmsi,0,3) == '111') {
722
+				return 'SAR (Search and Rescue) aircraft';
723
+			} elseif (substr($mmsi,0,2) == '98') {
724
+				return 'Auxiliary craft associated with a parent ship';
725
+			} elseif (substr($mmsi,0,2) == '99') {
726
+				return 'Aids to Navigation';
727
+			} elseif (substr($mmsi,0,2) == '00') {
728
+				return 'Coastal stations';
729
+			} elseif (substr($mmsi,0,1) == '0') {
730
+				return 'Group of ships';
731
+			} else {
732
+				return 'Ship';
733
+			}
638 734
 		}
639 735
 
640 736
 	
@@ -650,32 +746,61 @@  discard block
 block discarded – undo
650 746
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
651 747
 			return array();
652 748
 		}
653
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
654
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
749
+		if ($data->lon != 0) {
750
+			$result['longitude'] = $data->lon;
751
+		}
752
+		if ($data->lat != 0) {
753
+			$result['latitude'] = $data->lat;
754
+		}
655 755
 		$result['ident'] = trim(str_replace('@','',$data->name));
656 756
 		$result['timestamp'] = $data->ts;
657 757
 		$result['mmsi'] = $data->mmsi;
658
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
758
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') {
759
+			$result['mmsi'] = '3'.$result['mmsi'];
760
+		}
659 761
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
660
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
661
-		if ($data->heading !== '') $result['heading'] = $data->heading;
662
-		elseif ($data->cog != 0) $result['heading'] = $data->cog;
663
-		if ($data->status != '') $result['status'] = $data->status;
664
-		if ($data->statusid !== '') $result['statusid'] = $data->statusid;
665
-		if ($data->type !== '') $result['type'] = $data->type;
666
-		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
667
-		if ($data->imo !== '') $result['imo'] = $data->imo;
668
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
762
+		if ($data->sog != -1.0) {
763
+			$result['speed'] = $data->sog;
764
+		}
765
+		if ($data->heading !== '') {
766
+			$result['heading'] = $data->heading;
767
+		} elseif ($data->cog != 0) {
768
+			$result['heading'] = $data->cog;
769
+		}
770
+		if ($data->status != '') {
771
+			$result['status'] = $data->status;
772
+		}
773
+		if ($data->statusid !== '') {
774
+			$result['statusid'] = $data->statusid;
775
+		}
776
+		if ($data->type !== '') {
777
+			$result['type'] = $data->type;
778
+		}
779
+		if ($data->typeid !== '') {
780
+			$result['typeid'] = $data->typeid;
781
+		}
782
+		if ($data->imo !== '') {
783
+			$result['imo'] = $data->imo;
784
+		}
785
+		if ($data->callsign !== '') {
786
+			$result['callsign'] = trim(str_replace('@','',$data->callsign));
787
+		}
669 788
 		if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') {
670 789
 			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
671
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
790
+			if ($eta_ts != '') {
791
+				$result['eta_ts'] = $eta_ts;
792
+			}
672 793
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
673 794
 			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
674
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
795
+			if ($eta_ts != '') {
796
+				$result['eta_ts'] = $eta_ts;
797
+			}
675 798
 		}
676 799
 		if ($data->destination != '') {
677 800
 			$dest = trim(str_replace('@','',$data->destination));
678
-			if ($dest != '') $result['destination'] = $dest;
801
+			if ($dest != '') {
802
+				$result['destination'] = $dest;
803
+			}
679 804
 		}
680 805
 		$result['all'] = (array) $data;
681 806
 		/*
Please login to merge, or discard this patch.
require/class.ACARS.php 3 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 	}
33 33
 
34 34
 	/**
35
-	* Change IATA to ICAO value for ident
36
-	*
37
-	* @param String $ident ident
38
-	* @return String the icao
39
-	*/
35
+	 * Change IATA to ICAO value for ident
36
+	 *
37
+	 * @param String $ident ident
38
+	 * @return String the icao
39
+	 */
40 40
 	public function ident2icao($ident) {
41 41
 		if (substr($ident,0,2) == 'AF') {
42 42
 			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 	/**
55
-	* Deletes all info in the live table
56
-	*
57
-	* @return String success or false
58
-	*
59
-	*/
55
+	 * Deletes all info in the live table
56
+	 *
57
+	 * @return String success or false
58
+	 *
59
+	 */
60 60
 	public function deleteLiveAcarsData()
61 61
 	{
62 62
 		global $globalDBdriver;
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
 	}
77 77
 
78 78
 	/**
79
-	* Deletes all info in the archive table
80
-	*
81
-	* @return String success or false
82
-	*
83
-	*/
79
+	 * Deletes all info in the archive table
80
+	 *
81
+	 * @return String success or false
82
+	 *
83
+	 */
84 84
 	public function deleteArchiveAcarsData()
85 85
 	{
86 86
 		global $globalACARSArchiveKeepMonths, $globalDBdriver;
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 
102 102
 
103 103
 	/**
104
-	* Parse ACARS data
105
-	*
106
-	* @param String ACARS data in acarsdec data
107
-	*
108
-	*/
104
+	 * Parse ACARS data
105
+	 *
106
+	 * @param String ACARS data in acarsdec data
107
+	 *
108
+	 */
109 109
 	public function parse($data) {
110 110
 		global $globalDebug, $globalACARSArchive;
111 111
 		//$Image = new Image($this->db);
@@ -735,11 +735,11 @@  discard block
 block discarded – undo
735 735
 	}
736 736
 
737 737
 	/**
738
-	* Add ACARS data
739
-	*
740
-	* @param String ACARS data in acarsdec data
741
-	*
742
-	*/
738
+	 * Add ACARS data
739
+	 *
740
+	 * @param String ACARS data in acarsdec data
741
+	 *
742
+	 */
743 743
 	public function add($data) {
744 744
 		global $globalDebug, $globalACARSArchive;
745 745
 		$Image = new Image($this->db);
@@ -786,15 +786,15 @@  discard block
 block discarded – undo
786 786
 	}
787 787
 
788 788
 	/**
789
-	* Add Live ACARS data in DB
790
-	*
791
-	* @param String $ident ident
792
-	* @param String $registration Registration of the aircraft
793
-	* @param String $label Label of the ACARS message
794
-	* @param String $block_id Block id of the ACARS message
795
-	* @param String $msg_no Number of the ACARS message
796
-	* @param String $message ACARS message
797
-	*/
789
+	 * Add Live ACARS data in DB
790
+	 *
791
+	 * @param String $ident ident
792
+	 * @param String $registration Registration of the aircraft
793
+	 * @param String $label Label of the ACARS message
794
+	 * @param String $block_id Block id of the ACARS message
795
+	 * @param String $msg_no Number of the ACARS message
796
+	 * @param String $message ACARS message
797
+	 */
798 798
 	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
799 799
 		global $globalDebug;
800 800
 		date_default_timezone_set('UTC');
@@ -830,15 +830,15 @@  discard block
 block discarded – undo
830 830
 	}
831 831
 
832 832
 	/**
833
-	* Add Archive ACARS data in DB
834
-	*
835
-	* @param String $ident ident
836
-	* @param String $registration Registration of the aircraft
837
-	* @param String $label Label of the ACARS message
838
-	* @param String $block_id Block id of the ACARS message
839
-	* @param String $msg_no Number of the ACARS message
840
-	* @param String $message ACARS message
841
-	*/
833
+	 * Add Archive ACARS data in DB
834
+	 *
835
+	 * @param String $ident ident
836
+	 * @param String $registration Registration of the aircraft
837
+	 * @param String $label Label of the ACARS message
838
+	 * @param String $block_id Block id of the ACARS message
839
+	 * @param String $msg_no Number of the ACARS message
840
+	 * @param String $message ACARS message
841
+	 */
842 842
 	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
843 843
 		global $globalDebug;
844 844
 		date_default_timezone_set('UTC');
@@ -869,11 +869,11 @@  discard block
 block discarded – undo
869 869
 	}
870 870
 
871 871
 	/**
872
-	* Get Message title from label from DB
873
-	*
874
-	* @param String $label
875
-	* @return String Return ACARS title
876
-	*/
872
+	 * Get Message title from label from DB
873
+	 *
874
+	 * @param String $label
875
+	 * @return String Return ACARS title
876
+	 */
877 877
 	public function getTitlefromLabel($label) {
878 878
 		$Connection = new Connection($this->db);
879 879
 		$this->db = $Connection->db;
@@ -892,10 +892,10 @@  discard block
 block discarded – undo
892 892
 	}
893 893
 
894 894
 	/**
895
-	* List all Message title & label from DB
896
-	*
897
-	* @return Array Return ACARS data in array
898
-	*/
895
+	 * List all Message title & label from DB
896
+	 *
897
+	 * @return Array Return ACARS data in array
898
+	 */
899 899
 	public function getAllTitleLabel() {
900 900
 		$query = "SELECT * FROM acars_label ORDER BY title";
901 901
 		$query_values = array();
@@ -912,11 +912,11 @@  discard block
 block discarded – undo
912 912
 	}
913 913
 
914 914
 	/**
915
-	* Get Live ACARS data from DB
916
-	*
917
-	* @param String $ident
918
-	* @return Array Return ACARS data in array
919
-	*/
915
+	 * Get Live ACARS data from DB
916
+	 *
917
+	 * @param String $ident
918
+	 * @return Array Return ACARS data in array
919
+	 */
920 920
 	public function getLiveAcarsData($ident) {
921 921
 		$query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC";
922 922
 		$query_values = array(':ident' => $ident);
@@ -933,10 +933,10 @@  discard block
 block discarded – undo
933 933
 	}
934 934
 
935 935
 	/**
936
-	* Get Latest ACARS data from DB
937
-	*
938
-	* @return Array Return ACARS data in array
939
-	*/
936
+	 * Get Latest ACARS data from DB
937
+	 *
938
+	 * @return Array Return ACARS data in array
939
+	 */
940 940
 	public function getLatestAcarsData($limit = '',$label = '') {
941 941
 		global $globalURL, $globalDBdriver;
942 942
 		$Image = new Image($this->db);
@@ -1024,10 +1024,10 @@  discard block
 block discarded – undo
1024 1024
 	}
1025 1025
 
1026 1026
 	/**
1027
-	* Get Archive ACARS data from DB
1028
-	*
1029
-	* @return Array Return ACARS data in array
1030
-	*/
1027
+	 * Get Archive ACARS data from DB
1028
+	 *
1029
+	 * @return Array Return ACARS data in array
1030
+	 */
1031 1031
 	public function getArchiveAcarsData($limit = '',$label = '') {
1032 1032
 		global $globalURL, $globalDBdriver;
1033 1033
 		$Image = new Image($this->db);
@@ -1116,13 +1116,13 @@  discard block
 block discarded – undo
1116 1116
 	}
1117 1117
 
1118 1118
 	/**
1119
-	* Add ModeS data to DB
1120
-	*
1121
-	* @param String $ident ident
1122
-	* @param String $registration Registration of the aircraft
1123
-	* @param String $icao
1124
-	* @param String $ICAOTypeCode
1125
-	*/
1119
+	 * Add ModeS data to DB
1120
+	 *
1121
+	 * @param String $ident ident
1122
+	 * @param String $registration Registration of the aircraft
1123
+	 * @param String $icao
1124
+	 * @param String $ICAOTypeCode
1125
+	 */
1126 1126
 	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1127 1127
 		global $globalDebug, $globalDBdriver;
1128 1128
 		$ident = trim($ident);
Please login to merge, or discard this patch.
Spacing   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	/*
22 22
 	 * Initialize DB connection
23 23
 	*/
24
-	public function __construct($dbc = null,$fromACARSscript = false) {
24
+	public function __construct($dbc = null, $fromACARSscript = false) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27 27
 		if ($this->db === null) die('Error: No DB connection. (ACARS)');
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 	* @return String the icao
39 39
 	*/
40 40
 	public function ident2icao($ident) {
41
-		if (substr($ident,0,2) == 'AF') {
42
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
41
+		if (substr($ident, 0, 2) == 'AF') {
42
+			if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
+			else $icao = 'AFR'.ltrim(substr($ident, 2), '0');
44 44
 		} else {
45 45
 			$Spotter = new Spotter($this->db);
46
-			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
46
+			$identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2));
47 47
 			if (isset($identicao[0])) {
48
-				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
48
+				$icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0');
49 49
 			} else $icao = $ident;
50 50
 		}
51 51
 		return $icao;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
 			$sth = $this->db->prepare($query);
71 71
 			$sth->execute();
72
-		} catch(PDOException $e) {
72
+		} catch (PDOException $e) {
73 73
 			return "error";
74 74
 		}
75 75
 		return "success";
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
 			$sth = $this->db->prepare($query);
95 95
 			$sth->execute();
96
-		} catch(PDOException $e) {
96
+		} catch (PDOException $e) {
97 97
 			return "error";
98 98
 		}
99 99
 		return "success";
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
 		$ident = '';
119 119
 		$message = '';
120 120
 		$result = array();
121
-		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
122
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
123
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
124
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
121
+		$n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
122
+		if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
123
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
124
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
125 125
 		if ($n != 0) {
126
-			$registration = str_replace('.','',$registration);
127
-			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
126
+			$registration = str_replace('.', '', $registration);
127
+			$result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message);
128 128
 			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
129 129
 		} else $message = $data;
130 130
 		$decode = array();
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 				$temp = '';
145 145
 				$n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp);
146 146
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
147
-					$latitude = $la / 10000.0;
148
-					$longitude = $ln / 10000.0;
147
+					$latitude = $la/10000.0;
148
+					$longitude = $ln/10000.0;
149 149
 					if ($lac == 'S') $latitude = '-'.$latitude;
150 150
 					if ($lnc == 'W') $longitude = '-'.$longitude;
151 151
 					// Temp not always available
152 152
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
153
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
154
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
153
+					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt);
154
+					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C');
155 155
 
156 156
 					//$icao = $Translation->checkTranslation($ident);
157 157
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -163,19 +163,19 @@  discard block
 block discarded – undo
163 163
 				$dhour = '';
164 164
 				$darr = '';
165 165
 				$ahour = '';
166
-				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
166
+				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour);
167 167
 				if ($n == 4 && strlen($darr) == 4) {
168
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
169
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
170
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
168
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
169
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
170
+					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n";
171 171
 					//$icao = ACARS->ident2icao($ident);
172 172
 					//$icao = $Translation->checkTranslation($ident);
173 173
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
174 174
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
175 175
 					$found = true;
176 176
 				}
177
-				elseif ($n == 2 || $n  == 4) {
178
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
177
+				elseif ($n == 2 || $n == 4) {
178
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
179 179
 					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
180 180
 					//$icao = ACARS->ident2icao($ident);
181 181
 					//$icao = $Translation->checkTranslation($ident);
@@ -233,11 +233,11 @@  discard block
 block discarded – undo
233 233
 				$ahour = '';
234 234
 				$aair = '';
235 235
 				$apiste = '';
236
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
236
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste);
237 237
 				if ($n > 8) {
238
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
239
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
240
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
238
+					if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
239
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
240
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
241 241
 					$icao = trim($aident);
242 242
 
243 243
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
 				if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
263 263
 					$las = $las.'.'.$lass;
264 264
 					$lns = $lns.'.'.$lns;
265
-					$latitude = $las / 1000.0;
266
-					$longitude = $lns / 1000.0;
265
+					$latitude = $las/1000.0;
266
+					$longitude = $lns/1000.0;
267 267
 					if ($lac == 'S') $latitude = '-'.$latitude;
268 268
 					if ($lnc == 'W') $longitude = '-'.$longitude;
269 269
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
@@ -358,17 +358,17 @@  discard block
 block discarded – undo
358 358
 				$alt = '';
359 359
 				$fuel = '';
360 360
 				$speed = '';
361
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
361
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
362 362
 				if ($n == 9) {
363 363
 					//if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
364 364
 					$icao = trim($aident);
365 365
 					$decode['icao'] = $icao;
366
-					$latitude = $las / 100.0;
367
-					$longitude = $lns / 100.0;
366
+					$latitude = $las/100.0;
367
+					$longitude = $lns/100.0;
368 368
 					if ($lac == 'S') $latitude = '-'.$latitude;
369 369
 					if ($lnc == 'W') $longitude = '-'.$longitude;
370 370
 
371
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
371
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed);
372 372
 					$found = true;
373 373
 				}
374 374
 			}
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 					if ($lac == 'S') $latitude = '-'.$latitude;
388 388
 					if ($lnc == 'W') $longitude = '-'.$longitude;
389 389
 
390
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
390
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
391 391
 					$found = true;
392 392
 				}
393 393
 			}
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 				$dair = '';
421 421
 				$darr = '';
422 422
 				$aident = '';
423
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
423
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
424 424
 				if ($n == 8) {
425 425
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
426 426
 					$icao = trim($aident);
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 				*/
453 453
 				$dair = '';
454 454
 				$darr = '';
455
-				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
455
+				$n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr);
456 456
 				if ($n == 3) {
457 457
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
458 458
 					//$icao = $Translation->checkTranslation($ident);
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 				*/
468 468
 				$dair = '';
469 469
 				$darr = '';
470
-				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
470
+				$n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr);
471 471
 				if ($n == 3) {
472 472
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
473 473
 					//$icao = $Translation->checkTranslation($ident);
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 				}
478 478
 			}
479 479
 			if (!$found) {
480
-				$n = sscanf($message,'MET01%4c',$airport);
480
+				$n = sscanf($message, 'MET01%4c', $airport);
481 481
 				if ($n == 1) {
482 482
 					if ($globalDebug) echo 'airport name : '.$airport;
483 483
 					$decode = array('Airport/Waypoint name' => $airport);
@@ -485,241 +485,241 @@  discard block
 block discarded – undo
485 485
 				}
486 486
 			}
487 487
 			if ($label == 'H1') {
488
-				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
489
-					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
488
+				if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) {
489
+					$decode = array_merge(array('Message nature' => 'Equipment failure'), $decode);
490 490
 				}
491
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
492
-					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
491
+				elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) {
492
+					$decode = array_merge(array('Message nature' => 'Take off performance data'), $decode);
493 493
 				}
494
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
495
-					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
494
+				elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) {
495
+					$decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode);
496 496
 				}
497
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
498
-					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
497
+				elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) {
498
+					$decode = array_merge(array('Message nature' => 'Weather observation'), $decode);
499 499
 				}
500
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
501
-					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
500
+				elseif (preg_match(':^#DFB/PIREP:', $message)) {
501
+					$decode = array_merge(array('Message nature' => 'Pilot Report'), $decode);
502 502
 				}
503
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
504
-					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
503
+				elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) {
504
+					$decode = array_merge(array('Message nature' => 'Engine Data'), $decode);
505 505
 				}
506
-				elseif (preg_match(':^#M1AAEP:',$message)) {
507
-					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
506
+				elseif (preg_match(':^#M1AAEP:', $message)) {
507
+					$decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode);
508 508
 				}
509
-				elseif (preg_match(':^#M2APWD:',$message)) {
510
-					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
509
+				elseif (preg_match(':^#M2APWD:', $message)) {
510
+					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode);
511 511
 				}
512
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
513
-					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
512
+				elseif (preg_match(':^#M1BREQPWI:', $message)) {
513
+					$decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode);
514 514
 				}
515
-				elseif (preg_match(':^#CF:',$message)) {
516
-					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
515
+				elseif (preg_match(':^#CF:', $message)) {
516
+					$decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode);
517 517
 				}
518
-				elseif (preg_match(':^#DF:',$message)) {
519
-					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
518
+				elseif (preg_match(':^#DF:', $message)) {
519
+					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode);
520 520
 				}
521
-				elseif (preg_match(':^#EC:',$message)) {
522
-					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
521
+				elseif (preg_match(':^#EC:', $message)) {
522
+					$decode = array_merge(array('Message nature' => 'Engine Display System'), $decode);
523 523
 				}
524
-				elseif (preg_match(':^#EI:',$message)) {
525
-					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
524
+				elseif (preg_match(':^#EI:', $message)) {
525
+					$decode = array_merge(array('Message nature' => 'Engine Report'), $decode);
526 526
 				}
527
-				elseif (preg_match(':^#H1:',$message)) {
528
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
527
+				elseif (preg_match(':^#H1:', $message)) {
528
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode);
529 529
 				}
530
-				elseif (preg_match(':^#H2:',$message)) {
531
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
530
+				elseif (preg_match(':^#H2:', $message)) {
531
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode);
532 532
 				}
533
-				elseif (preg_match(':^#HD:',$message)) {
534
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
533
+				elseif (preg_match(':^#HD:', $message)) {
534
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode);
535 535
 				}
536
-				elseif (preg_match(':^#M1:',$message)) {
537
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
536
+				elseif (preg_match(':^#M1:', $message)) {
537
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode);
538 538
 				}
539
-				elseif (preg_match(':^#M2:',$message)) {
540
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
539
+				elseif (preg_match(':^#M2:', $message)) {
540
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode);
541 541
 				}
542
-				elseif (preg_match(':^#M3:',$message)) {
543
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
542
+				elseif (preg_match(':^#M3:', $message)) {
543
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode);
544 544
 				}
545
-				elseif (preg_match(':^#MD:',$message)) {
546
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
545
+				elseif (preg_match(':^#MD:', $message)) {
546
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode);
547 547
 				}
548
-				elseif (preg_match(':^#PS:',$message)) {
549
-					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
548
+				elseif (preg_match(':^#PS:', $message)) {
549
+					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode);
550 550
 				}
551
-				elseif (preg_match(':^#S1:',$message)) {
552
-					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
551
+				elseif (preg_match(':^#S1:', $message)) {
552
+					$decode = array_merge(array('Message nature' => 'SDU - Left'), $decode);
553 553
 				}
554
-				elseif (preg_match(':^#S2:',$message)) {
555
-					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
554
+				elseif (preg_match(':^#S2:', $message)) {
555
+					$decode = array_merge(array('Message nature' => 'SDU - Right'), $decode);
556 556
 				}
557
-				elseif (preg_match(':^#SD:',$message)) {
558
-					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
557
+				elseif (preg_match(':^#SD:', $message)) {
558
+					$decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode);
559 559
 				}
560
-				elseif (preg_match(':^#T[0-8]:',$message)) {
561
-					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
560
+				elseif (preg_match(':^#T[0-8]:', $message)) {
561
+					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode);
562 562
 				}
563
-				elseif (preg_match(':^#WO:',$message)) {
564
-					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
563
+				elseif (preg_match(':^#WO:', $message)) {
564
+					$decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode);
565 565
 				}
566
-				elseif (preg_match(':^#A1:',$message)) {
567
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
566
+				elseif (preg_match(':^#A1:', $message)) {
567
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode);
568 568
 				}
569
-				elseif (preg_match(':^#A3:',$message)) {
570
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
569
+				elseif (preg_match(':^#A3:', $message)) {
570
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode);
571 571
 				}
572
-				elseif (preg_match(':^#A4:',$message)) {
573
-					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
572
+				elseif (preg_match(':^#A4:', $message)) {
573
+					$decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode);
574 574
 				}
575
-				elseif (preg_match(':^#A6:',$message)) {
576
-					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
575
+				elseif (preg_match(':^#A6:', $message)) {
576
+					$decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode);
577 577
 				}
578
-				elseif (preg_match(':^#A8:',$message)) {
579
-					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
578
+				elseif (preg_match(':^#A8:', $message)) {
579
+					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode);
580 580
 				}
581
-				elseif (preg_match(':^#A9:',$message)) {
582
-					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
581
+				elseif (preg_match(':^#A9:', $message)) {
582
+					$decode = array_merge(array('Message nature' => 'ATIS report'), $decode);
583 583
 				}
584
-				elseif (preg_match(':^#A0:',$message)) {
585
-					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
584
+				elseif (preg_match(':^#A0:', $message)) {
585
+					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode);
586 586
 				}
587
-				elseif (preg_match(':^#AA:',$message)) {
588
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
587
+				elseif (preg_match(':^#AA:', $message)) {
588
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
589 589
 				}
590
-				elseif (preg_match(':^#AB:',$message)) {
591
-					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
590
+				elseif (preg_match(':^#AB:', $message)) {
591
+					$decode = array_merge(array('Message nature' => 'TWIP Report'), $decode);
592 592
 				}
593
-				elseif (preg_match(':^#AC:',$message)) {
594
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
593
+				elseif (preg_match(':^#AC:', $message)) {
594
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode);
595 595
 				}
596
-				elseif (preg_match(':^#AD:',$message)) {
597
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
596
+				elseif (preg_match(':^#AD:', $message)) {
597
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode);
598 598
 				}
599
-				elseif (preg_match(':^#AF:',$message)) {
600
-					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
599
+				elseif (preg_match(':^#AF:', $message)) {
600
+					$decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode);
601 601
 				}
602
-				elseif (preg_match(':^#B1:',$message)) {
603
-					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
602
+				elseif (preg_match(':^#B1:', $message)) {
603
+					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode);
604 604
 				}
605
-				elseif (preg_match(':^#B2:',$message)) {
606
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
605
+				elseif (preg_match(':^#B2:', $message)) {
606
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode);
607 607
 				}
608
-				elseif (preg_match(':^#B3:',$message)) {
609
-					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
608
+				elseif (preg_match(':^#B3:', $message)) {
609
+					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode);
610 610
 				}
611
-				elseif (preg_match(':^#B4:',$message)) {
612
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
611
+				elseif (preg_match(':^#B4:', $message)) {
612
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode);
613 613
 				}
614
-				elseif (preg_match(':^#B6:',$message)) {
615
-					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
614
+				elseif (preg_match(':^#B6:', $message)) {
615
+					$decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode);
616 616
 				}
617
-				elseif (preg_match(':^#B8:',$message)) {
618
-					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
617
+				elseif (preg_match(':^#B8:', $message)) {
618
+					$decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode);
619 619
 				}
620
-				elseif (preg_match(':^#B9:',$message)) {
621
-					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
620
+				elseif (preg_match(':^#B9:', $message)) {
621
+					$decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode);
622 622
 				}
623
-				elseif (preg_match(':^#B0:',$message)) {
624
-					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
623
+				elseif (preg_match(':^#B0:', $message)) {
624
+					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode);
625 625
 				}
626
-				elseif (preg_match(':^#BA:',$message)) {
627
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
626
+				elseif (preg_match(':^#BA:', $message)) {
627
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
628 628
 				}
629
-				elseif (preg_match(':^#BB:',$message)) {
630
-					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
629
+				elseif (preg_match(':^#BB:', $message)) {
630
+					$decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode);
631 631
 				}
632
-				elseif (preg_match(':^#BC:',$message)) {
633
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
632
+				elseif (preg_match(':^#BC:', $message)) {
633
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode);
634 634
 				}
635
-				elseif (preg_match(':^#BD:',$message)) {
636
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
635
+				elseif (preg_match(':^#BD:', $message)) {
636
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode);
637 637
 				}
638
-				elseif (preg_match(':^#BE:',$message)) {
639
-					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
638
+				elseif (preg_match(':^#BE:', $message)) {
639
+					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode);
640 640
 				}
641
-				elseif (preg_match(':^#BF:',$message)) {
642
-					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
641
+				elseif (preg_match(':^#BF:', $message)) {
642
+					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode);
643 643
 				}
644
-				elseif (preg_match(':^#H3:',$message)) {
645
-					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
644
+				elseif (preg_match(':^#H3:', $message)) {
645
+					$decode = array_merge(array('Message nature' => 'Icing Report'), $decode);
646 646
 				}
647 647
 			}
648 648
 			if ($label == '10') {
649
-				if (preg_match(':^DTO01:',$message)) {
650
-					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
649
+				if (preg_match(':^DTO01:', $message)) {
650
+					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode);
651 651
 				}
652
-				elseif (preg_match(':^AIS01:',$message)) {
653
-					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
652
+				elseif (preg_match(':^AIS01:', $message)) {
653
+					$decode = array_merge(array('Message nature' => 'AIS Request'), $decode);
654 654
 				}
655
-				elseif (preg_match(':^FTX01:',$message)) {
656
-					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
655
+				elseif (preg_match(':^FTX01:', $message)) {
656
+					$decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode);
657 657
 				}
658
-				elseif (preg_match(':^FPL01:',$message)) {
659
-					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
658
+				elseif (preg_match(':^FPL01:', $message)) {
659
+					$decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode);
660 660
 				}
661
-				elseif (preg_match(':^WAB01:',$message)) {
662
-					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
661
+				elseif (preg_match(':^WAB01:', $message)) {
662
+					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode);
663 663
 				}
664
-				elseif (preg_match(':^MET01:',$message)) {
665
-					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
664
+				elseif (preg_match(':^MET01:', $message)) {
665
+					$decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode);
666 666
 				}
667
-				elseif (preg_match(':^WAB02:',$message)) {
668
-					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
667
+				elseif (preg_match(':^WAB02:', $message)) {
668
+					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode);
669 669
 				}
670 670
 			}
671 671
 			if ($label == '15') {
672
-				if (preg_match(':^FST01:',$message)) {
673
-					$decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode);
672
+				if (preg_match(':^FST01:', $message)) {
673
+					$decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode);
674 674
 				}
675 675
 			}
676 676
 			if (!$found && $label == 'SA') {
677
-				$n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at);
677
+				$n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at);
678 678
 				if ($n == 4) {
679 679
 					$vsta = array('Version' => $version);
680 680
 					if ($state == 'E') {
681
-						$vsta = array_merge($vsta,array('Link state' => 'Established'));
681
+						$vsta = array_merge($vsta, array('Link state' => 'Established'));
682 682
 					}
683 683
 					elseif ($state == 'L') {
684
-						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
684
+						$vsta = array_merge($vsta, array('Link state' => 'Lost'));
685 685
 					}
686 686
 					else {
687
-						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
687
+						$vsta = array_merge($vsta, array('Link state' => 'Unknown'));
688 688
 					}
689 689
 					if ($type == 'V') {
690
-						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
690
+						$vsta = array_merge($vsta, array('Link type' => 'VHF ACARS'));
691 691
 					}
692 692
 					elseif ($type == 'S') {
693
-						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
693
+						$vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM'));
694 694
 					}
695 695
 					elseif ($type == 'H') {
696
-						$vsta = array_merge($vsta,array('Link type' => 'HF'));
696
+						$vsta = array_merge($vsta, array('Link type' => 'HF'));
697 697
 					}
698 698
 					elseif ($type == 'G') {
699
-						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
699
+						$vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM'));
700 700
 					}
701 701
 					elseif ($type == 'C') {
702
-						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
702
+						$vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM'));
703 703
 					}
704 704
 					elseif ($type == '2') {
705
-						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
705
+						$vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2'));
706 706
 					}
707 707
 					elseif ($type == 'X') {
708
-						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
708
+						$vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero'));
709 709
 					}
710 710
 					elseif ($type == 'I') {
711
-						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
711
+						$vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM'));
712 712
 					}
713 713
 					else {
714
-						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
714
+						$vsta = array_merge($vsta, array('Link type' => 'Unknown'));
715 715
 					}
716
-					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
717
-					$decode = array_merge($vsta,$decode);
716
+					$vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2))));
717
+					$decode = array_merge($vsta, $decode);
718 718
 				}
719 719
 			}
720 720
 
721 721
 			$title = $this->getTitlefromLabel($label);
722
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
722
+			if ($title != '') $decode = array_merge(array('Message title' => $title), $decode);
723 723
 			/*
724 724
 			// Business jets always use GS0001
725 725
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -747,13 +747,13 @@  discard block
 block discarded – undo
747 747
 		$Translation = new Translation($this->db);
748 748
 		$message = $this->parse($data);
749 749
 		if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') {
750
-			$ident = (string)$message['ident'];
750
+			$ident = (string) $message['ident'];
751 751
 			$label = $message['label'];
752 752
 			$block_id = $message['block_id'];
753 753
 			$msg_no = $message['msg_no'];
754 754
 			$msg = $message['message'];
755 755
 			$decode = $message['decode'];
756
-			$registration = (string)$message['registration'];
756
+			$registration = (string) $message['registration'];
757 757
 			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
758 758
 			else $latitude = '';
759 759
 			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
@@ -767,20 +767,20 @@  discard block
 block discarded – undo
767 767
 				$Image->addSpotterImage($registration);
768 768
 			}
769 769
 			// Business jets always use GS0001
770
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
770
+			if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude);
771 771
 			if ($globalDebug && isset($info) && $info != '') echo $info;
772 772
 			if (count($decode) > 0) $decode_json = json_encode($decode);
773 773
 			else $decode_json = '';
774 774
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
775
-				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
775
+				$Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS');
776 776
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
777
-				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
777
+				$Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS');
778 778
 			}
779
-			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
780
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
781
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
779
+			$result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
780
+			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F');
781
+			if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
782 782
 			if ($globalDebug && count($decode) > 0) {
783
-				echo "Human readable data : ".implode(' - ',$decode)."\n";
783
+				echo "Human readable data : ".implode(' - ', $decode)."\n";
784 784
 			}
785 785
 		}
786 786
 	}
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 	* @param String $msg_no Number of the ACARS message
796 796
 	* @param String $message ACARS message
797 797
 	*/
798
-	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
798
+	public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
799 799
 		global $globalDebug;
800 800
 		date_default_timezone_set('UTC');
801 801
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
@@ -803,21 +803,21 @@  discard block
 block discarded – undo
803 803
 			$this->db = $Connection->db;
804 804
 			if ($globalDebug) echo "Test if not already in Live ACARS table...";
805 805
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
806
-			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
806
+			$query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message);
807 807
 			try {
808 808
 				$stht = $this->db->prepare($query_test);
809 809
 				$stht->execute($query_test_values);
810
-			} catch(PDOException $e) {
810
+			} catch (PDOException $e) {
811 811
 				return "error : ".$e->getMessage();
812 812
 			}
813 813
 			if ($stht->fetchColumn() == 0) {
814 814
 				if ($globalDebug) echo "Add Live ACARS data...";
815 815
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
816
-				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
816
+				$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s"));
817 817
 				try {
818 818
 					$sth = $this->db->prepare($query);
819 819
 					$sth->execute($query_values);
820
-				} catch(PDOException $e) {
820
+				} catch (PDOException $e) {
821 821
 					return "error : ".$e->getMessage();
822 822
 				}
823 823
 			} else {
@@ -839,10 +839,10 @@  discard block
 block discarded – undo
839 839
 	* @param String $msg_no Number of the ACARS message
840 840
 	* @param String $message ACARS message
841 841
 	*/
842
-	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
842
+	public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
843 843
 		global $globalDebug;
844 844
 		date_default_timezone_set('UTC');
845
-		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) {
845
+		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) {
846 846
 			/*
847 847
 				    if ($globalDebug) echo "Test if not already in Archive ACARS table...";
848 848
 			    	    $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message";
@@ -857,11 +857,11 @@  discard block
 block discarded – undo
857 857
 			*/
858 858
 			if ($globalDebug) echo "Add Live ACARS data...";
859 859
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
860
-			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
860
+			$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
861 861
 			try {
862 862
 				$sth = $this->db->prepare($query);
863 863
 				$sth->execute($query_values);
864
-			} catch(PDOException $e) {
864
+			} catch (PDOException $e) {
865 865
 				return "error : ".$e->getMessage();
866 866
 			}
867 867
 			if ($globalDebug) echo "Done\n";
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 		try {
883 883
 			$sth = $this->db->prepare($query);
884 884
 			$sth->execute($query_values);
885
-		} catch(PDOException $e) {
885
+		} catch (PDOException $e) {
886 886
 			echo "error : ".$e->getMessage();
887 887
 			return '';
888 888
 		}
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 		try {
903 903
 			$sth = $this->db->prepare($query);
904 904
 			$sth->execute($query_values);
905
-		} catch(PDOException $e) {
905
+		} catch (PDOException $e) {
906 906
 			echo "error : ".$e->getMessage();
907 907
 			return array();
908 908
 		}
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
 		try {
924 924
 			$sth = $this->db->prepare($query);
925 925
 			$sth->execute($query_values);
926
-		} catch(PDOException $e) {
926
+		} catch (PDOException $e) {
927 927
 			echo "error : ".$e->getMessage();
928 928
 			return array();
929 929
 		}
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 	*
938 938
 	* @return Array Return ACARS data in array
939 939
 	*/
940
-	public function getLatestAcarsData($limit = '',$label = '') {
940
+	public function getLatestAcarsData($limit = '', $label = '') {
941 941
 		global $globalURL, $globalDBdriver;
942 942
 		$Image = new Image($this->db);
943 943
 		$Spotter = new Spotter($this->db);
@@ -948,8 +948,8 @@  discard block
 block discarded – undo
948 948
 		if ($limit != "")
949 949
 		{
950 950
 			$limit_array = explode(",", $limit);
951
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
952
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
951
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
952
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
953 953
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
954 954
 			{
955 955
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -965,46 +965,46 @@  discard block
 block discarded – undo
965 965
 		try {
966 966
 			$sth = $this->db->prepare($query);
967 967
 			$sth->execute($query_values);
968
-		} catch(PDOException $e) {
968
+		} catch (PDOException $e) {
969 969
 			return "error : ".$e->getMessage();
970 970
 		}
971 971
 		$i = 0;
972 972
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
973 973
 			$data = array();
974 974
 			if ($row['registration'] != '') {
975
-				$row['registration'] = str_replace('.','',$row['registration']);
975
+				$row['registration'] = str_replace('.', '', $row['registration']);
976 976
 				$image_array = $Image->getSpotterImage($row['registration']);
977
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
978
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
979
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
977
+				if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
978
+				else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
979
+			} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
980 980
 			if ($row['registration'] == '') $row['registration'] = 'NA';
981 981
 			if ($row['ident'] == '') $row['ident'] = 'NA';
982
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
982
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
983 983
 			if (isset($identicao[0])) {
984
-				if (substr($row['ident'],0,2) == 'AF') {
985
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
986
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
987
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
988
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
984
+				if (substr($row['ident'], 0, 2) == 'AF') {
985
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
986
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
987
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
988
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
989 989
 			} else $icao = $row['ident'];
990
-			$icao = $Translation->checkTranslation($icao,false);
991
-			$decode = json_decode($row['decode'],true);
990
+			$icao = $Translation->checkTranslation($icao, false);
991
+			$decode = json_decode($row['decode'], true);
992 992
 			$found = false;
993
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
993
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
994 994
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
995 995
 				if (isset($airport_info[0]['icao'])) {
996 996
 					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
997 997
 					$found = true;
998 998
 				}
999 999
 			}
1000
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1000
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1001 1001
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1002 1002
 				if (isset($airport_info[0]['icao'])) {
1003 1003
 					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1004 1004
 					$found = true;
1005 1005
 				}
1006 1006
 			}
1007
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1007
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1008 1008
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1009 1009
 				if (isset($airport_info[0]['icao'])) {
1010 1010
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 				}
1013 1013
 			}
1014 1014
 			if ($found) $row['decode'] = json_encode($decode);
1015
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1015
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1016 1016
 			$result[] = $data;
1017 1017
 			$i++;
1018 1018
 		}
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 	*
1029 1029
 	* @return Array Return ACARS data in array
1030 1030
 	*/
1031
-	public function getArchiveAcarsData($limit = '',$label = '') {
1031
+	public function getArchiveAcarsData($limit = '', $label = '') {
1032 1032
 		global $globalURL, $globalDBdriver;
1033 1033
 		$Image = new Image($this->db);
1034 1034
 		$Spotter = new Spotter($this->db);
@@ -1038,8 +1038,8 @@  discard block
 block discarded – undo
1038 1038
 		if ($limit != "")
1039 1039
 		{
1040 1040
 			$limit_array = explode(",", $limit);
1041
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1041
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1042
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1043 1043
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1044 1044
 			{
1045 1045
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -1060,44 +1060,44 @@  discard block
 block discarded – undo
1060 1060
 		try {
1061 1061
 			$sth = $this->db->prepare($query);
1062 1062
 			$sth->execute($query_values);
1063
-		} catch(PDOException $e) {
1063
+		} catch (PDOException $e) {
1064 1064
 			return "error : ".$e->getMessage();
1065 1065
 		}
1066
-		$i=0;
1066
+		$i = 0;
1067 1067
 		$result = array();
1068 1068
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1069 1069
 			$data = array();
1070 1070
 			if ($row['registration'] != '') {
1071
-				$row['registration'] = str_replace('.','',$row['registration']);
1071
+				$row['registration'] = str_replace('.', '', $row['registration']);
1072 1072
 				$image_array = $Image->getSpotterImage($row['registration']);
1073
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1074
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1075
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1073
+				if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
1074
+				else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1075
+			} else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1076 1076
 			$icao = '';
1077 1077
 			if ($row['registration'] == '') $row['registration'] = 'NA';
1078 1078
 			if ($row['ident'] == '') $row['ident'] = 'NA';
1079
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1079
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
1080 1080
 			if (isset($identicao[0])) {
1081
-				if (substr($row['ident'],0,2) == 'AF') {
1082
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1083
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1084
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1085
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1081
+				if (substr($row['ident'], 0, 2) == 'AF') {
1082
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1083
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1084
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1085
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1086 1086
 			} else $icao = $row['ident'];
1087 1087
 			$icao = $Translation->checkTranslation($icao);
1088
-			$decode = json_decode($row['decode'],true);
1088
+			$decode = json_decode($row['decode'], true);
1089 1089
 			$found = false;
1090
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1090
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1091 1091
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1092 1092
 				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1093 1093
 				$found = true;
1094 1094
 			}
1095
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1095
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1096 1096
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1097 1097
 				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1098 1098
 				$found = true;
1099 1099
 			}
1100
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1100
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1101 1101
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1102 1102
 				if (isset($airport_info[0]['icao'])) {
1103 1103
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
 				}
1106 1106
 			}
1107 1107
 			if ($found) $row['decode'] = json_encode($decode);
1108
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1108
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1109 1109
 			$result[] = $data;
1110 1110
 			$i++;
1111 1111
 		}
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 	* @param String $icao
1124 1124
 	* @param String $ICAOTypeCode
1125 1125
 	*/
1126
-	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1126
+	public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') {
1127 1127
 		global $globalDebug, $globalDBdriver;
1128 1128
 		$ident = trim($ident);
1129 1129
 		$Translation = new Translation($this->db);
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
 			if ($globalDebug) echo "Ident or registration null, exit\n";
1137 1137
 			return '';
1138 1138
 		}
1139
-		$registration = str_replace('.','',$registration);
1139
+		$registration = str_replace('.', '', $registration);
1140 1140
 		$ident = $Translation->ident2icao($ident);
1141 1141
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1142 1142
 		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
 		try {
1146 1146
 			$sthsi = $this->db->prepare($querysi);
1147 1147
 			$sthsi->execute($querysi_values);
1148
-		} catch(PDOException $e) {
1148
+		} catch (PDOException $e) {
1149 1149
 			if ($globalDebug) echo $e->getMessage();
1150 1150
 			return "error : ".$e->getMessage();
1151 1151
 		}
@@ -1155,8 +1155,8 @@  discard block
 block discarded – undo
1155 1155
 			$Translation = new Translation($this->db);
1156 1156
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1157 1157
 			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1158
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1159
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1158
+			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS');
1159
+			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS');
1160 1160
 		} else {
1161 1161
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1162 1162
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
 				try {
1165 1165
 					$sth = $this->db->prepare($query);
1166 1166
 					$sth->execute($query_values);
1167
-				} catch(PDOException $e) {
1167
+				} catch (PDOException $e) {
1168 1168
 					if ($globalDebug) echo $e->getMessage();
1169 1169
 					return "error : ".$e->getMessage();
1170 1170
 				}
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
 				$sth->closeCursor();
1173 1173
 				if (isset($result['modes'])) $hex = $result['modes'];
1174 1174
 				else $hex = '';
1175
-				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1175
+				$SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS');
1176 1176
 				if ($this->fromACARSscript) $this->SI->add($SI_data);
1177 1177
 			}
1178 1178
 		}
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
 		try {
1183 1183
 			$sth = $this->db->prepare($query);
1184 1184
 			$sth->execute($query_values);
1185
-		} catch(PDOException $e) {
1185
+		} catch (PDOException $e) {
1186 1186
 			if ($globalDebug) echo $e->getMessage();
1187 1187
 			return "error : ".$e->getMessage();
1188 1188
 		}
@@ -1192,7 +1192,7 @@  discard block
 block discarded – undo
1192 1192
 			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1193 1193
 			else $ModeS = '';
1194 1194
 			if ($ModeS == '') {
1195
-				$id = explode('-',$result['flightaware_id']);
1195
+				$id = explode('-', $result['flightaware_id']);
1196 1196
 				$ModeS = $id[0];
1197 1197
 			}
1198 1198
 			if ($ModeS != '') {
@@ -1202,20 +1202,20 @@  discard block
 block discarded – undo
1202 1202
 				try {
1203 1203
 					$sthc = $this->db->prepare($queryc);
1204 1204
 					$sthc->execute($queryc_values);
1205
-				} catch(PDOException $e) {
1205
+				} catch (PDOException $e) {
1206 1206
 					if ($globalDebug) echo $e->getMessage();
1207 1207
 					return "error : ".$e->getMessage();
1208 1208
 				}
1209 1209
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1210 1210
 				$sthc->closeCursor();
1211
-				if (count($row) ==  0) {
1211
+				if (count($row) == 0) {
1212 1212
 					if ($globalDebug) echo " Add to ModeS table - ";
1213 1213
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1214
-					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1214
+					$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1215 1215
 					try {
1216 1216
 						$sthi = $this->db->prepare($queryi);
1217 1217
 						$sthi->execute($queryi_values);
1218
-					} catch(PDOException $e) {
1218
+					} catch (PDOException $e) {
1219 1219
 						if ($globalDebug) echo $e->getMessage();
1220 1220
 						return "error : ".$e->getMessage();
1221 1221
 					}
@@ -1223,15 +1223,15 @@  discard block
 block discarded – undo
1223 1223
 					if ($globalDebug) echo " Update ModeS table - ";
1224 1224
 					if ($ICAOTypeCode != '') {
1225 1225
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1226
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1226
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1227 1227
 					} else {
1228 1228
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1229
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration);
1229
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration);
1230 1230
 					}
1231 1231
 					try {
1232 1232
 						$sthi = $this->db->prepare($queryi);
1233 1233
 						$sthi->execute($queryi_values);
1234
-					} catch(PDOException $e) {
1234
+					} catch (PDOException $e) {
1235 1235
 						if ($globalDebug) echo $e->getMessage();
1236 1236
 						return "error : ".$e->getMessage();
1237 1237
 					}
@@ -1268,12 +1268,12 @@  discard block
 block discarded – undo
1268 1268
 					elseif ($globalDBdriver == 'pgsql') {
1269 1269
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1270 1270
 					}
1271
-					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
1271
+					$queryi_values = array(':Registration' => $registration, ':ident' => $icao);
1272 1272
 				}
1273 1273
 				try {
1274 1274
 					$sthi = $this->db->prepare($queryi);
1275 1275
 					$sthi->execute($queryi_values);
1276
-				} catch(PDOException $e) {
1276
+				} catch (PDOException $e) {
1277 1277
 					if ($globalDebug) echo $e->getMessage();
1278 1278
 					return "error : ".$e->getMessage();
1279 1279
 				}
Please login to merge, or discard this patch.
Braces   +415 added lines, -263 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 	public function __construct($dbc = null,$fromACARSscript = false) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27
-		if ($this->db === null) die('Error: No DB connection. (ACARS)');
27
+		if ($this->db === null) {
28
+			die('Error: No DB connection. (ACARS)');
29
+		}
28 30
 		if ($fromACARSscript) {
29 31
 			$this->fromACARSscript = true;
30 32
 			$this->SI = new SpotterImport($this->db);
@@ -39,14 +41,19 @@  discard block
 block discarded – undo
39 41
 	*/
40 42
 	public function ident2icao($ident) {
41 43
 		if (substr($ident,0,2) == 'AF') {
42
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
44
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
45
+				$icao = $ident;
46
+			} else {
47
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
48
+			}
44 49
 		} else {
45 50
 			$Spotter = new Spotter($this->db);
46 51
 			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
47 52
 			if (isset($identicao[0])) {
48 53
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
49
-			} else $icao = $ident;
54
+			} else {
55
+				$icao = $ident;
56
+			}
50 57
 		}
51 58
 		return $icao;
52 59
 	}
@@ -119,14 +126,24 @@  discard block
 block discarded – undo
119 126
 		$message = '';
120 127
 		$result = array();
121 128
 		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
122
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
123
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
124
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
129
+		if ($n == 0) {
130
+			$n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
131
+		}
132
+		if ($n == 0) {
133
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
134
+		}
135
+		if ($n == 0) {
136
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
137
+		}
125 138
 		if ($n != 0) {
126 139
 			$registration = str_replace('.','',$registration);
127 140
 			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
128
-			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
129
-		} else $message = $data;
141
+			if ($globalDebug) {
142
+				echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
143
+			}
144
+		} else {
145
+			$message = $data;
146
+		}
130 147
 		$decode = array();
131 148
 		$found = false;
132 149
 //		if ($registration != '' && $ident != '' && $registration != '!') {
@@ -146,12 +163,21 @@  discard block
 block discarded – undo
146 163
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
147 164
 					$latitude = $la / 10000.0;
148 165
 					$longitude = $ln / 10000.0;
149
-					if ($lac == 'S') $latitude = '-'.$latitude;
150
-					if ($lnc == 'W') $longitude = '-'.$longitude;
166
+					if ($lac == 'S') {
167
+						$latitude = '-'.$latitude;
168
+					}
169
+					if ($lnc == 'W') {
170
+						$longitude = '-'.$longitude;
171
+					}
151 172
 					// Temp not always available
152
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
153
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
154
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
173
+					if ($globalDebug) {
174
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
175
+					}
176
+					if ($temp == '') {
177
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
178
+					} else {
179
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
180
+					}
155 181
 
156 182
 					//$icao = $Translation->checkTranslation($ident);
157 183
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -165,25 +191,35 @@  discard block
 block discarded – undo
165 191
 				$ahour = '';
166 192
 				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
167 193
 				if ($n == 4 && strlen($darr) == 4) {
168
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
169
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
170
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
194
+					if ($dhour != '') {
195
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
196
+					}
197
+					if ($ahour != '') {
198
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
199
+					}
200
+					if ($globalDebug) {
201
+						echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
202
+					}
171 203
 					//$icao = ACARS->ident2icao($ident);
172 204
 					//$icao = $Translation->checkTranslation($ident);
173 205
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
174 206
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
175 207
 					$found = true;
176
-				}
177
-				elseif ($n == 2 || $n  == 4) {
178
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
179
-					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
208
+				} elseif ($n == 2 || $n  == 4) {
209
+					if ($dhour != '') {
210
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
211
+					}
212
+					if ($globalDebug) {
213
+						echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
214
+					}
180 215
 					//$icao = ACARS->ident2icao($ident);
181 216
 					//$icao = $Translation->checkTranslation($ident);
182 217
 					$decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
183 218
 					$found = true;
184
-				}
185
-				elseif ($n == 1) {
186
-					if ($globalDebug) echo 'airport arrival : '.$darr."\n";
219
+				} elseif ($n == 1) {
220
+					if ($globalDebug) {
221
+						echo 'airport arrival : '.$darr."\n";
222
+					}
187 223
 					//$icao = ACARS->ident2icao($ident);
188 224
 					//$icao = $Translation->checkTranslation($ident);
189 225
 					$decode = array('Arrival airport' => $darr);
@@ -201,7 +237,9 @@  discard block
 block discarded – undo
201 237
 				$darr = '';
202 238
 				$n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
203 239
 				if ($n == 4) {
204
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
240
+					if ($globalDebug) {
241
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
242
+					}
205 243
 					//$icao = ACARS->ident2icao($ident);
206 244
 					//$icao = $Translation->checkTranslation($ident);
207 245
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -235,14 +273,23 @@  discard block
 block discarded – undo
235 273
 				$apiste = '';
236 274
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
237 275
 				if ($n > 8) {
238
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
239
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
240
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
276
+					if ($globalDebug) {
277
+						echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
278
+					}
279
+					if ($dhour != '') {
280
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
281
+					}
282
+					if ($ahour != '') {
283
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
284
+					}
241 285
 					$icao = trim($aident);
242 286
 
243 287
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
244
-					if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
245
-					else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
288
+					if ($ahour == '') {
289
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
290
+					} else {
291
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
292
+					}
246 293
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
247 294
 					$decode['icao'] = $icao;
248 295
 					$found = true;
@@ -264,9 +311,15 @@  discard block
 block discarded – undo
264 311
 					$lns = $lns.'.'.$lns;
265 312
 					$latitude = $las / 1000.0;
266 313
 					$longitude = $lns / 1000.0;
267
-					if ($lac == 'S') $latitude = '-'.$latitude;
268
-					if ($lnc == 'W') $longitude = '-'.$longitude;
269
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
314
+					if ($lac == 'S') {
315
+						$latitude = '-'.$latitude;
316
+					}
317
+					if ($lnc == 'W') {
318
+						$longitude = '-'.$longitude;
319
+					}
320
+					if ($globalDebug) {
321
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
322
+					}
270 323
 					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
271 324
 					$found = true;
272 325
 				}
@@ -284,7 +337,9 @@  discard block
 block discarded – undo
284 337
 				$darr = '';
285 338
 				$n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
286 339
 				if ($n == 4) {
287
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
340
+					if ($globalDebug) {
341
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
342
+					}
288 343
 					//$icao = $Translation->checkTranslation($ident);
289 344
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
290 345
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -297,7 +352,9 @@  discard block
 block discarded – undo
297 352
 				$darr = '';
298 353
 				$n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
299 354
 				if ($n == 4) {
300
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
355
+					if ($globalDebug) {
356
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
357
+					}
301 358
 					//$icao = $Translation->checkTranslation($ident);
302 359
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
303 360
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -310,7 +367,9 @@  discard block
 block discarded – undo
310 367
 				$darr = '';
311 368
 				$n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
312 369
 				if ($n == 2) {
313
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
370
+					if ($globalDebug) {
371
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
372
+					}
314 373
 					//$icao = $Translation->checkTranslation($ident);
315 374
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
316 375
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -324,7 +383,9 @@  discard block
 block discarded – undo
324 383
 				$darr = '';
325 384
 				$n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
326 385
 				if ($n == 6) {
327
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
386
+					if ($globalDebug) {
387
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
388
+					}
328 389
 					//$icao = $Translation->checkTranslation($ident);
329 390
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
330 391
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -337,7 +398,9 @@  discard block
 block discarded – undo
337 398
 				$darr = '';
338 399
 				$n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
339 400
 				if ($n == 7) {
340
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
401
+					if ($globalDebug) {
402
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
403
+					}
341 404
 					//$icao = $Translation->checkTranslation($ident);
342 405
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
343 406
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -365,8 +428,12 @@  discard block
 block discarded – undo
365 428
 					$decode['icao'] = $icao;
366 429
 					$latitude = $las / 100.0;
367 430
 					$longitude = $lns / 100.0;
368
-					if ($lac == 'S') $latitude = '-'.$latitude;
369
-					if ($lnc == 'W') $longitude = '-'.$longitude;
431
+					if ($lac == 'S') {
432
+						$latitude = '-'.$latitude;
433
+					}
434
+					if ($lnc == 'W') {
435
+						$longitude = '-'.$longitude;
436
+					}
370 437
 
371 438
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
372 439
 					$found = true;
@@ -384,8 +451,12 @@  discard block
 block discarded – undo
384 451
 				if ($n == 4) {
385 452
 					$latitude = $las;
386 453
 					$longitude = $lns;
387
-					if ($lac == 'S') $latitude = '-'.$latitude;
388
-					if ($lnc == 'W') $longitude = '-'.$longitude;
454
+					if ($lac == 'S') {
455
+						$latitude = '-'.$latitude;
456
+					}
457
+					if ($lnc == 'W') {
458
+						$longitude = '-'.$longitude;
459
+					}
389 460
 
390 461
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
391 462
 					$found = true;
@@ -401,7 +472,9 @@  discard block
 block discarded – undo
401 472
 				$darr = '';
402 473
 				$n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
403 474
 				if ($n == 5) {
404
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
475
+					if ($globalDebug) {
476
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
477
+					}
405 478
 					//$icao = $Translation->checkTranslation($ident);
406 479
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
407 480
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -422,7 +495,9 @@  discard block
 block discarded – undo
422 495
 				$aident = '';
423 496
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
424 497
 				if ($n == 8) {
425
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
498
+					if ($globalDebug) {
499
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
500
+					}
426 501
 					$icao = trim($aident);
427 502
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
428 503
 					$decode['icao'] = $icao;
@@ -439,7 +514,9 @@  discard block
 block discarded – undo
439 514
 				$darr = '';
440 515
 				$n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
441 516
 				if ($n == 5) {
442
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
517
+					if ($globalDebug) {
518
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
519
+					}
443 520
 					//$icao = $Translation->checkTranslation($ident);
444 521
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
445 522
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -454,7 +531,9 @@  discard block
 block discarded – undo
454 531
 				$darr = '';
455 532
 				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
456 533
 				if ($n == 3) {
457
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
534
+					if ($globalDebug) {
535
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
536
+					}
458 537
 					//$icao = $Translation->checkTranslation($ident);
459 538
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
460 539
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -469,7 +548,9 @@  discard block
 block discarded – undo
469 548
 				$darr = '';
470 549
 				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
471 550
 				if ($n == 3) {
472
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
551
+					if ($globalDebug) {
552
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
553
+					}
473 554
 					//$icao = $Translation->checkTranslation($ident);
474 555
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
475 556
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -479,7 +560,9 @@  discard block
 block discarded – undo
479 560
 			if (!$found) {
480 561
 				$n = sscanf($message,'MET01%4c',$airport);
481 562
 				if ($n == 1) {
482
-					if ($globalDebug) echo 'airport name : '.$airport;
563
+					if ($globalDebug) {
564
+						echo 'airport name : '.$airport;
565
+					}
483 566
 					$decode = array('Airport/Waypoint name' => $airport);
484 567
 					$found = true;
485 568
 				}
@@ -487,184 +570,126 @@  discard block
 block discarded – undo
487 570
 			if ($label == 'H1') {
488 571
 				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
489 572
 					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
490
-				}
491
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
573
+				} elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
492 574
 					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
493
-				}
494
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
575
+				} elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
495 576
 					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
496
-				}
497
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
577
+				} elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
498 578
 					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
499
-				}
500
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
579
+				} elseif (preg_match(':^#DFB/PIREP:',$message)) {
501 580
 					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
502
-				}
503
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
581
+				} elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
504 582
 					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
505
-				}
506
-				elseif (preg_match(':^#M1AAEP:',$message)) {
583
+				} elseif (preg_match(':^#M1AAEP:',$message)) {
507 584
 					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
508
-				}
509
-				elseif (preg_match(':^#M2APWD:',$message)) {
585
+				} elseif (preg_match(':^#M2APWD:',$message)) {
510 586
 					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
511
-				}
512
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
587
+				} elseif (preg_match(':^#M1BREQPWI:',$message)) {
513 588
 					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
514
-				}
515
-				elseif (preg_match(':^#CF:',$message)) {
589
+				} elseif (preg_match(':^#CF:',$message)) {
516 590
 					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
517
-				}
518
-				elseif (preg_match(':^#DF:',$message)) {
591
+				} elseif (preg_match(':^#DF:',$message)) {
519 592
 					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
520
-				}
521
-				elseif (preg_match(':^#EC:',$message)) {
593
+				} elseif (preg_match(':^#EC:',$message)) {
522 594
 					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
523
-				}
524
-				elseif (preg_match(':^#EI:',$message)) {
595
+				} elseif (preg_match(':^#EI:',$message)) {
525 596
 					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
526
-				}
527
-				elseif (preg_match(':^#H1:',$message)) {
597
+				} elseif (preg_match(':^#H1:',$message)) {
528 598
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
529
-				}
530
-				elseif (preg_match(':^#H2:',$message)) {
599
+				} elseif (preg_match(':^#H2:',$message)) {
531 600
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
532
-				}
533
-				elseif (preg_match(':^#HD:',$message)) {
601
+				} elseif (preg_match(':^#HD:',$message)) {
534 602
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
535
-				}
536
-				elseif (preg_match(':^#M1:',$message)) {
603
+				} elseif (preg_match(':^#M1:',$message)) {
537 604
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
538
-				}
539
-				elseif (preg_match(':^#M2:',$message)) {
605
+				} elseif (preg_match(':^#M2:',$message)) {
540 606
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
541
-				}
542
-				elseif (preg_match(':^#M3:',$message)) {
607
+				} elseif (preg_match(':^#M3:',$message)) {
543 608
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
544
-				}
545
-				elseif (preg_match(':^#MD:',$message)) {
609
+				} elseif (preg_match(':^#MD:',$message)) {
546 610
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
547
-				}
548
-				elseif (preg_match(':^#PS:',$message)) {
611
+				} elseif (preg_match(':^#PS:',$message)) {
549 612
 					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
550
-				}
551
-				elseif (preg_match(':^#S1:',$message)) {
613
+				} elseif (preg_match(':^#S1:',$message)) {
552 614
 					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
553
-				}
554
-				elseif (preg_match(':^#S2:',$message)) {
615
+				} elseif (preg_match(':^#S2:',$message)) {
555 616
 					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
556
-				}
557
-				elseif (preg_match(':^#SD:',$message)) {
617
+				} elseif (preg_match(':^#SD:',$message)) {
558 618
 					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
559
-				}
560
-				elseif (preg_match(':^#T[0-8]:',$message)) {
619
+				} elseif (preg_match(':^#T[0-8]:',$message)) {
561 620
 					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
562
-				}
563
-				elseif (preg_match(':^#WO:',$message)) {
621
+				} elseif (preg_match(':^#WO:',$message)) {
564 622
 					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
565
-				}
566
-				elseif (preg_match(':^#A1:',$message)) {
623
+				} elseif (preg_match(':^#A1:',$message)) {
567 624
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
568
-				}
569
-				elseif (preg_match(':^#A3:',$message)) {
625
+				} elseif (preg_match(':^#A3:',$message)) {
570 626
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
571
-				}
572
-				elseif (preg_match(':^#A4:',$message)) {
627
+				} elseif (preg_match(':^#A4:',$message)) {
573 628
 					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
574
-				}
575
-				elseif (preg_match(':^#A6:',$message)) {
629
+				} elseif (preg_match(':^#A6:',$message)) {
576 630
 					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
577
-				}
578
-				elseif (preg_match(':^#A8:',$message)) {
631
+				} elseif (preg_match(':^#A8:',$message)) {
579 632
 					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
580
-				}
581
-				elseif (preg_match(':^#A9:',$message)) {
633
+				} elseif (preg_match(':^#A9:',$message)) {
582 634
 					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
583
-				}
584
-				elseif (preg_match(':^#A0:',$message)) {
635
+				} elseif (preg_match(':^#A0:',$message)) {
585 636
 					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
586
-				}
587
-				elseif (preg_match(':^#AA:',$message)) {
637
+				} elseif (preg_match(':^#AA:',$message)) {
588 638
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
589
-				}
590
-				elseif (preg_match(':^#AB:',$message)) {
639
+				} elseif (preg_match(':^#AB:',$message)) {
591 640
 					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
592
-				}
593
-				elseif (preg_match(':^#AC:',$message)) {
641
+				} elseif (preg_match(':^#AC:',$message)) {
594 642
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
595
-				}
596
-				elseif (preg_match(':^#AD:',$message)) {
643
+				} elseif (preg_match(':^#AD:',$message)) {
597 644
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
598
-				}
599
-				elseif (preg_match(':^#AF:',$message)) {
645
+				} elseif (preg_match(':^#AF:',$message)) {
600 646
 					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
601
-				}
602
-				elseif (preg_match(':^#B1:',$message)) {
647
+				} elseif (preg_match(':^#B1:',$message)) {
603 648
 					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
604
-				}
605
-				elseif (preg_match(':^#B2:',$message)) {
649
+				} elseif (preg_match(':^#B2:',$message)) {
606 650
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
607
-				}
608
-				elseif (preg_match(':^#B3:',$message)) {
651
+				} elseif (preg_match(':^#B3:',$message)) {
609 652
 					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
610
-				}
611
-				elseif (preg_match(':^#B4:',$message)) {
653
+				} elseif (preg_match(':^#B4:',$message)) {
612 654
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
613
-				}
614
-				elseif (preg_match(':^#B6:',$message)) {
655
+				} elseif (preg_match(':^#B6:',$message)) {
615 656
 					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
616
-				}
617
-				elseif (preg_match(':^#B8:',$message)) {
657
+				} elseif (preg_match(':^#B8:',$message)) {
618 658
 					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
619
-				}
620
-				elseif (preg_match(':^#B9:',$message)) {
659
+				} elseif (preg_match(':^#B9:',$message)) {
621 660
 					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
622
-				}
623
-				elseif (preg_match(':^#B0:',$message)) {
661
+				} elseif (preg_match(':^#B0:',$message)) {
624 662
 					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
625
-				}
626
-				elseif (preg_match(':^#BA:',$message)) {
663
+				} elseif (preg_match(':^#BA:',$message)) {
627 664
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
628
-				}
629
-				elseif (preg_match(':^#BB:',$message)) {
665
+				} elseif (preg_match(':^#BB:',$message)) {
630 666
 					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
631
-				}
632
-				elseif (preg_match(':^#BC:',$message)) {
667
+				} elseif (preg_match(':^#BC:',$message)) {
633 668
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
634
-				}
635
-				elseif (preg_match(':^#BD:',$message)) {
669
+				} elseif (preg_match(':^#BD:',$message)) {
636 670
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
637
-				}
638
-				elseif (preg_match(':^#BE:',$message)) {
671
+				} elseif (preg_match(':^#BE:',$message)) {
639 672
 					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
640
-				}
641
-				elseif (preg_match(':^#BF:',$message)) {
673
+				} elseif (preg_match(':^#BF:',$message)) {
642 674
 					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
643
-				}
644
-				elseif (preg_match(':^#H3:',$message)) {
675
+				} elseif (preg_match(':^#H3:',$message)) {
645 676
 					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
646 677
 				}
647 678
 			}
648 679
 			if ($label == '10') {
649 680
 				if (preg_match(':^DTO01:',$message)) {
650 681
 					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
651
-				}
652
-				elseif (preg_match(':^AIS01:',$message)) {
682
+				} elseif (preg_match(':^AIS01:',$message)) {
653 683
 					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
654
-				}
655
-				elseif (preg_match(':^FTX01:',$message)) {
684
+				} elseif (preg_match(':^FTX01:',$message)) {
656 685
 					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
657
-				}
658
-				elseif (preg_match(':^FPL01:',$message)) {
686
+				} elseif (preg_match(':^FPL01:',$message)) {
659 687
 					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
660
-				}
661
-				elseif (preg_match(':^WAB01:',$message)) {
688
+				} elseif (preg_match(':^WAB01:',$message)) {
662 689
 					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
663
-				}
664
-				elseif (preg_match(':^MET01:',$message)) {
690
+				} elseif (preg_match(':^MET01:',$message)) {
665 691
 					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
666
-				}
667
-				elseif (preg_match(':^WAB02:',$message)) {
692
+				} elseif (preg_match(':^WAB02:',$message)) {
668 693
 					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
669 694
 				}
670 695
 			}
@@ -679,38 +704,28 @@  discard block
 block discarded – undo
679 704
 					$vsta = array('Version' => $version);
680 705
 					if ($state == 'E') {
681 706
 						$vsta = array_merge($vsta,array('Link state' => 'Established'));
682
-					}
683
-					elseif ($state == 'L') {
707
+					} elseif ($state == 'L') {
684 708
 						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
685
-					}
686
-					else {
709
+					} else {
687 710
 						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
688 711
 					}
689 712
 					if ($type == 'V') {
690 713
 						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
691
-					}
692
-					elseif ($type == 'S') {
714
+					} elseif ($type == 'S') {
693 715
 						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
694
-					}
695
-					elseif ($type == 'H') {
716
+					} elseif ($type == 'H') {
696 717
 						$vsta = array_merge($vsta,array('Link type' => 'HF'));
697
-					}
698
-					elseif ($type == 'G') {
718
+					} elseif ($type == 'G') {
699 719
 						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
700
-					}
701
-					elseif ($type == 'C') {
720
+					} elseif ($type == 'C') {
702 721
 						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
703
-					}
704
-					elseif ($type == '2') {
722
+					} elseif ($type == '2') {
705 723
 						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
706
-					}
707
-					elseif ($type == 'X') {
724
+					} elseif ($type == 'X') {
708 725
 						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
709
-					}
710
-					elseif ($type == 'I') {
726
+					} elseif ($type == 'I') {
711 727
 						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
712
-					}
713
-					else {
728
+					} else {
714 729
 						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
715 730
 					}
716 731
 					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
@@ -719,7 +734,9 @@  discard block
 block discarded – undo
719 734
 			}
720 735
 
721 736
 			$title = $this->getTitlefromLabel($label);
722
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
737
+			if ($title != '') {
738
+				$decode = array_merge(array('Message title' => $title),$decode);
739
+			}
723 740
 			/*
724 741
 			// Business jets always use GS0001
725 742
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -754,31 +771,54 @@  discard block
 block discarded – undo
754 771
 			$msg = $message['message'];
755 772
 			$decode = $message['decode'];
756 773
 			$registration = (string)$message['registration'];
757
-			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
758
-			else $latitude = '';
759
-			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
760
-			else $longitude = '';
761
-			if (isset($decode['airicao'])) $airicao = $decode['airicao'];
762
-			else $airicao = '';
763
-			if (isset($decode['icao'])) $icao = $decode['icao'];
764
-			else $icao = $Translation->checkTranslation($ident);
774
+			if (isset($decode['latitude'])) {
775
+				$latitude = $decode['latitude'];
776
+			} else {
777
+				$latitude = '';
778
+			}
779
+			if (isset($decode['longitude'])) {
780
+				$longitude = $decode['longitude'];
781
+			} else {
782
+				$longitude = '';
783
+			}
784
+			if (isset($decode['airicao'])) {
785
+				$airicao = $decode['airicao'];
786
+			} else {
787
+				$airicao = '';
788
+			}
789
+			if (isset($decode['icao'])) {
790
+				$icao = $decode['icao'];
791
+			} else {
792
+				$icao = $Translation->checkTranslation($ident);
793
+			}
765 794
 			$image_array = $Image->getSpotterImage($registration);
766 795
 			if (!isset($image_array[0]['registration'])) {
767 796
 				$Image->addSpotterImage($registration);
768 797
 			}
769 798
 			// Business jets always use GS0001
770
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
771
-			if ($globalDebug && isset($info) && $info != '') echo $info;
772
-			if (count($decode) > 0) $decode_json = json_encode($decode);
773
-			else $decode_json = '';
799
+			if ($ident != 'GS0001') {
800
+				$info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
801
+			}
802
+			if ($globalDebug && isset($info) && $info != '') {
803
+				echo $info;
804
+			}
805
+			if (count($decode) > 0) {
806
+				$decode_json = json_encode($decode);
807
+			} else {
808
+				$decode_json = '';
809
+			}
774 810
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
775 811
 				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
776 812
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
777 813
 				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
778 814
 			}
779 815
 			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
780
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
781
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
816
+			if (!isset($globalACARSArchive)) {
817
+				$globalACARSArchive = array('10','80','81','82','3F');
818
+			}
819
+			if ($result && in_array($label,$globalACARSArchive)) {
820
+				$this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
821
+			}
782 822
 			if ($globalDebug && count($decode) > 0) {
783 823
 				echo "Human readable data : ".implode(' - ',$decode)."\n";
784 824
 			}
@@ -801,7 +841,9 @@  discard block
 block discarded – undo
801 841
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
802 842
 			$Connection = new Connection($this->db);
803 843
 			$this->db = $Connection->db;
804
-			if ($globalDebug) echo "Test if not already in Live ACARS table...";
844
+			if ($globalDebug) {
845
+				echo "Test if not already in Live ACARS table...";
846
+			}
805 847
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
806 848
 			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
807 849
 			try {
@@ -811,7 +853,9 @@  discard block
 block discarded – undo
811 853
 				return "error : ".$e->getMessage();
812 854
 			}
813 855
 			if ($stht->fetchColumn() == 0) {
814
-				if ($globalDebug) echo "Add Live ACARS data...";
856
+				if ($globalDebug) {
857
+					echo "Add Live ACARS data...";
858
+				}
815 859
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
816 860
 				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
817 861
 				try {
@@ -821,10 +865,14 @@  discard block
 block discarded – undo
821 865
 					return "error : ".$e->getMessage();
822 866
 				}
823 867
 			} else {
824
-				if ($globalDebug) echo "Data already in DB...\n";
868
+				if ($globalDebug) {
869
+					echo "Data already in DB...\n";
870
+				}
825 871
 				return false;
826 872
 			}
827
-			if ($globalDebug) echo "Done\n";
873
+			if ($globalDebug) {
874
+				echo "Done\n";
875
+			}
828 876
 			return true;
829 877
 		}
830 878
 	}
@@ -855,7 +903,9 @@  discard block
 block discarded – undo
855 903
 			    	    }
856 904
 				    if ($stht->fetchColumn() == 0) {
857 905
 			*/
858
-			if ($globalDebug) echo "Add Live ACARS data...";
906
+			if ($globalDebug) {
907
+				echo "Add Live ACARS data...";
908
+			}
859 909
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
860 910
 			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
861 911
 			try {
@@ -864,7 +914,9 @@  discard block
 block discarded – undo
864 914
 			} catch(PDOException $e) {
865 915
 				return "error : ".$e->getMessage();
866 916
 			}
867
-			if ($globalDebug) echo "Done\n";
917
+			if ($globalDebug) {
918
+				echo "Done\n";
919
+			}
868 920
 		}
869 921
 	}
870 922
 
@@ -887,8 +939,11 @@  discard block
 block discarded – undo
887 939
 			return '';
888 940
 		}
889 941
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
890
-		if (count($row) > 0) return $row[0]['title'];
891
-		else return '';
942
+		if (count($row) > 0) {
943
+			return $row[0]['title'];
944
+		} else {
945
+			return '';
946
+		}
892 947
 	}
893 948
 
894 949
 	/**
@@ -907,8 +962,11 @@  discard block
 block discarded – undo
907 962
 			return array();
908 963
 		}
909 964
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
910
-		if (count($row) > 0) return $row;
911
-		else return array();
965
+		if (count($row) > 0) {
966
+			return $row;
967
+		} else {
968
+			return array();
969
+		}
912 970
 	}
913 971
 
914 972
 	/**
@@ -928,8 +986,11 @@  discard block
 block discarded – undo
928 986
 			return array();
929 987
 		}
930 988
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
931
-		if (count($row) > 0) return $row[0];
932
-		else return array();
989
+		if (count($row) > 0) {
990
+			return $row[0];
991
+		} else {
992
+			return array();
993
+		}
933 994
 	}
934 995
 
935 996
 	/**
@@ -974,19 +1035,35 @@  discard block
 block discarded – undo
974 1035
 			if ($row['registration'] != '') {
975 1036
 				$row['registration'] = str_replace('.','',$row['registration']);
976 1037
 				$image_array = $Image->getSpotterImage($row['registration']);
977
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
978
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
979
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
980
-			if ($row['registration'] == '') $row['registration'] = 'NA';
981
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1038
+				if (count($image_array) > 0) {
1039
+					$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1040
+				} else {
1041
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1042
+				}
1043
+			} else {
1044
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1045
+			}
1046
+			if ($row['registration'] == '') {
1047
+				$row['registration'] = 'NA';
1048
+			}
1049
+			if ($row['ident'] == '') {
1050
+				$row['ident'] = 'NA';
1051
+			}
982 1052
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
983 1053
 			if (isset($identicao[0])) {
984 1054
 				if (substr($row['ident'],0,2) == 'AF') {
985
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
986
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
987
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1055
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1056
+						$icao = $row['ident'];
1057
+					} else {
1058
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1059
+					}
1060
+				} else {
1061
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1062
+				}
988 1063
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
989
-			} else $icao = $row['ident'];
1064
+			} else {
1065
+				$icao = $row['ident'];
1066
+			}
990 1067
 			$icao = $Translation->checkTranslation($icao,false);
991 1068
 			$decode = json_decode($row['decode'],true);
992 1069
 			$found = false;
@@ -1011,7 +1088,9 @@  discard block
 block discarded – undo
1011 1088
 					$found = true;
1012 1089
 				}
1013 1090
 			}
1014
-			if ($found) $row['decode'] = json_encode($decode);
1091
+			if ($found) {
1092
+				$row['decode'] = json_encode($decode);
1093
+			}
1015 1094
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1016 1095
 			$result[] = $data;
1017 1096
 			$i++;
@@ -1019,8 +1098,9 @@  discard block
 block discarded – undo
1019 1098
 		if (isset($result)) {
1020 1099
 			$result[0]['query_number_rows'] = $i;
1021 1100
 			return $result;
1101
+		} else {
1102
+			return array();
1022 1103
 		}
1023
-		else return array();
1024 1104
 	}
1025 1105
 
1026 1106
 	/**
@@ -1070,31 +1150,51 @@  discard block
 block discarded – undo
1070 1150
 			if ($row['registration'] != '') {
1071 1151
 				$row['registration'] = str_replace('.','',$row['registration']);
1072 1152
 				$image_array = $Image->getSpotterImage($row['registration']);
1073
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1074
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1075
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1153
+				if (count($image_array) > 0) {
1154
+					$data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1155
+				} else {
1156
+					$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1157
+				}
1158
+			} else {
1159
+				$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1160
+			}
1076 1161
 			$icao = '';
1077
-			if ($row['registration'] == '') $row['registration'] = 'NA';
1078
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1162
+			if ($row['registration'] == '') {
1163
+				$row['registration'] = 'NA';
1164
+			}
1165
+			if ($row['ident'] == '') {
1166
+				$row['ident'] = 'NA';
1167
+			}
1079 1168
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1080 1169
 			if (isset($identicao[0])) {
1081 1170
 				if (substr($row['ident'],0,2) == 'AF') {
1082
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1083
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1084
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1171
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1172
+						$icao = $row['ident'];
1173
+					} else {
1174
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1175
+					}
1176
+				} else {
1177
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1178
+				}
1085 1179
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1086
-			} else $icao = $row['ident'];
1180
+			} else {
1181
+				$icao = $row['ident'];
1182
+			}
1087 1183
 			$icao = $Translation->checkTranslation($icao);
1088 1184
 			$decode = json_decode($row['decode'],true);
1089 1185
 			$found = false;
1090 1186
 			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1091 1187
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1092
-				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1188
+				if (isset($airport_info[0]['icao'])) {
1189
+					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1190
+				}
1093 1191
 				$found = true;
1094 1192
 			}
1095 1193
 			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1096 1194
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1097
-				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1195
+				if (isset($airport_info[0]['icao'])) {
1196
+					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1197
+				}
1098 1198
 				$found = true;
1099 1199
 			}
1100 1200
 			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
@@ -1104,7 +1204,9 @@  discard block
 block discarded – undo
1104 1204
 					$found = true;
1105 1205
 				}
1106 1206
 			}
1107
-			if ($found) $row['decode'] = json_encode($decode);
1207
+			if ($found) {
1208
+				$row['decode'] = json_encode($decode);
1209
+			}
1108 1210
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1109 1211
 			$result[] = $data;
1110 1212
 			$i++;
@@ -1112,7 +1214,9 @@  discard block
 block discarded – undo
1112 1214
 		if (!empty($result)) {
1113 1215
 			$result[0]['query_number_rows'] = $i;
1114 1216
 			return $result;
1115
-		} else return array();
1217
+		} else {
1218
+			return array();
1219
+		}
1116 1220
 	}
1117 1221
 
1118 1222
 	/**
@@ -1128,25 +1232,37 @@  discard block
 block discarded – undo
1128 1232
 		$ident = trim($ident);
1129 1233
 		$Translation = new Translation($this->db);
1130 1234
 		$Spotter = new Spotter($this->db);
1131
-		if ($globalDebug) echo "Test if we add ModeS data...";
1235
+		if ($globalDebug) {
1236
+			echo "Test if we add ModeS data...";
1237
+		}
1132 1238
 		//if ($icao == '') $icao = ACARS->ident2icao($ident);
1133
-		if ($icao == '') $icao = $Translation->checkTranslation($ident);
1134
-		if ($globalDebug) echo '- Ident : '.$icao.' - ';
1239
+		if ($icao == '') {
1240
+			$icao = $Translation->checkTranslation($ident);
1241
+		}
1242
+		if ($globalDebug) {
1243
+			echo '- Ident : '.$icao.' - ';
1244
+		}
1135 1245
 		if ($ident == '' || $registration == '') {
1136
-			if ($globalDebug) echo "Ident or registration null, exit\n";
1246
+			if ($globalDebug) {
1247
+				echo "Ident or registration null, exit\n";
1248
+			}
1137 1249
 			return '';
1138 1250
 		}
1139 1251
 		$registration = str_replace('.','',$registration);
1140 1252
 		$ident = $Translation->ident2icao($ident);
1141 1253
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1142
-		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
1254
+		if ($globalDebug) {
1255
+			echo "Check if needed to add translation ".$ident.'... ';
1256
+		}
1143 1257
 		$querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1";
1144 1258
 		$querysi_values = array(':registration' => $registration);
1145 1259
 		try {
1146 1260
 			$sthsi = $this->db->prepare($querysi);
1147 1261
 			$sthsi->execute($querysi_values);
1148 1262
 		} catch(PDOException $e) {
1149
-			if ($globalDebug) echo $e->getMessage();
1263
+			if ($globalDebug) {
1264
+				echo $e->getMessage();
1265
+			}
1150 1266
 			return "error : ".$e->getMessage();
1151 1267
 		}
1152 1268
 		$resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
@@ -1154,9 +1270,14 @@  discard block
 block discarded – undo
1154 1270
 		if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
1155 1271
 			$Translation = new Translation($this->db);
1156 1272
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1157
-			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1158
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1159
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1273
+			if ($globalDebug) {
1274
+				echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1275
+			}
1276
+			if ($ident != $trans_ident) {
1277
+				$Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1278
+			} elseif ($trans_ident == $ident) {
1279
+				$Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1280
+			}
1160 1281
 		} else {
1161 1282
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1162 1283
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1165,32 +1286,46 @@  discard block
 block discarded – undo
1165 1286
 					$sth = $this->db->prepare($query);
1166 1287
 					$sth->execute($query_values);
1167 1288
 				} catch(PDOException $e) {
1168
-					if ($globalDebug) echo $e->getMessage();
1289
+					if ($globalDebug) {
1290
+						echo $e->getMessage();
1291
+					}
1169 1292
 					return "error : ".$e->getMessage();
1170 1293
 				}
1171 1294
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1172 1295
 				$sth->closeCursor();
1173
-				if (isset($result['modes'])) $hex = $result['modes'];
1174
-				else $hex = '';
1296
+				if (isset($result['modes'])) {
1297
+					$hex = $result['modes'];
1298
+				} else {
1299
+					$hex = '';
1300
+				}
1175 1301
 				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1176
-				if ($this->fromACARSscript) $this->SI->add($SI_data);
1302
+				if ($this->fromACARSscript) {
1303
+					$this->SI->add($SI_data);
1304
+				}
1177 1305
 			}
1178 1306
 		}
1179
-		if ($globalDebug) echo 'Done'."\n";
1307
+		if ($globalDebug) {
1308
+			echo 'Done'."\n";
1309
+		}
1180 1310
 		$query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1";
1181 1311
 		$query_values = array(':ident' => $icao);
1182 1312
 		try {
1183 1313
 			$sth = $this->db->prepare($query);
1184 1314
 			$sth->execute($query_values);
1185 1315
 		} catch(PDOException $e) {
1186
-			if ($globalDebug) echo $e->getMessage();
1316
+			if ($globalDebug) {
1317
+				echo $e->getMessage();
1318
+			}
1187 1319
 			return "error : ".$e->getMessage();
1188 1320
 		}
1189 1321
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
1190 1322
 		$sth->closeCursor();
1191 1323
 		if (isset($result['flightaware_id'])) {
1192
-			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1193
-			else $ModeS = '';
1324
+			if (isset($result['ModeS'])) {
1325
+				$ModeS = $result['ModeS'];
1326
+			} else {
1327
+				$ModeS = '';
1328
+			}
1194 1329
 			if ($ModeS == '') {
1195 1330
 				$id = explode('-',$result['flightaware_id']);
1196 1331
 				$ModeS = $id[0];
@@ -1203,24 +1338,32 @@  discard block
 block discarded – undo
1203 1338
 					$sthc = $this->db->prepare($queryc);
1204 1339
 					$sthc->execute($queryc_values);
1205 1340
 				} catch(PDOException $e) {
1206
-					if ($globalDebug) echo $e->getMessage();
1341
+					if ($globalDebug) {
1342
+						echo $e->getMessage();
1343
+					}
1207 1344
 					return "error : ".$e->getMessage();
1208 1345
 				}
1209 1346
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1210 1347
 				$sthc->closeCursor();
1211 1348
 				if (count($row) ==  0) {
1212
-					if ($globalDebug) echo " Add to ModeS table - ";
1349
+					if ($globalDebug) {
1350
+						echo " Add to ModeS table - ";
1351
+					}
1213 1352
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1214 1353
 					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1215 1354
 					try {
1216 1355
 						$sthi = $this->db->prepare($queryi);
1217 1356
 						$sthi->execute($queryi_values);
1218 1357
 					} catch(PDOException $e) {
1219
-						if ($globalDebug) echo $e->getMessage();
1358
+						if ($globalDebug) {
1359
+							echo $e->getMessage();
1360
+						}
1220 1361
 						return "error : ".$e->getMessage();
1221 1362
 					}
1222 1363
 				} else {
1223
-					if ($globalDebug) echo " Update ModeS table - ";
1364
+					if ($globalDebug) {
1365
+						echo " Update ModeS table - ";
1366
+					}
1224 1367
 					if ($ICAOTypeCode != '') {
1225 1368
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1226 1369
 						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
@@ -1232,7 +1375,9 @@  discard block
 block discarded – undo
1232 1375
 						$sthi = $this->db->prepare($queryi);
1233 1376
 						$sthi->execute($queryi_values);
1234 1377
 					} catch(PDOException $e) {
1235
-						if ($globalDebug) echo $e->getMessage();
1378
+						if ($globalDebug) {
1379
+							echo $e->getMessage();
1380
+						}
1236 1381
 						return "error : ".$e->getMessage();
1237 1382
 					}
1238 1383
 				}
@@ -1253,7 +1398,9 @@  discard block
 block discarded – undo
1253 1398
 					    return "error : ".$e->getMessage();
1254 1399
 				}
1255 1400
 				*/
1256
-				if ($globalDebug) echo " Update Spotter_output table - ";
1401
+				if ($globalDebug) {
1402
+					echo " Update Spotter_output table - ";
1403
+				}
1257 1404
 				if ($ICAOTypeCode != '') {
1258 1405
 					if ($globalDBdriver == 'mysql') {
1259 1406
 						$queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
@@ -1264,8 +1411,7 @@  discard block
 block discarded – undo
1264 1411
 				} else {
1265 1412
 					if ($globalDBdriver == 'mysql') {
1266 1413
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
1267
-					}
1268
-					elseif ($globalDBdriver == 'pgsql') {
1414
+					} elseif ($globalDBdriver == 'pgsql') {
1269 1415
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1270 1416
 					}
1271 1417
 					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
@@ -1274,14 +1420,20 @@  discard block
 block discarded – undo
1274 1420
 					$sthi = $this->db->prepare($queryi);
1275 1421
 					$sthi->execute($queryi_values);
1276 1422
 				} catch(PDOException $e) {
1277
-					if ($globalDebug) echo $e->getMessage();
1423
+					if ($globalDebug) {
1424
+						echo $e->getMessage();
1425
+					}
1278 1426
 					return "error : ".$e->getMessage();
1279 1427
 				}
1280 1428
 			}
1281 1429
 		} else {
1282
-			if ($globalDebug) echo " Can't find ModeS in spotter_output - ";
1430
+			if ($globalDebug) {
1431
+				echo " Can't find ModeS in spotter_output - ";
1432
+			}
1433
+		}
1434
+		if ($globalDebug) {
1435
+			echo "Done\n";
1283 1436
 		}
1284
-		if ($globalDebug) echo "Done\n";
1285 1437
 	}
1286 1438
 }
1287 1439
 ?>
Please login to merge, or discard this patch.
live-geojson.php 2 patches
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -65,18 +65,18 @@  discard block
 block discarded – undo
65 65
 $min = true;
66 66
 $allhistory = false;
67 67
 $filter['source'] = array();
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
70
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
72
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
73
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
78
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
79
-if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT);
68
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
69
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
70
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
71
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
72
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
73
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
74
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING);
75
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
76
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
77
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
78
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
79
+if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'], FILTER_SANITIZE_NUMBER_INT);
80 80
 if (isset($_COOKIE['filter_blocked']) && $_COOKIE['filter_blocked'] == 'true') $filter['blocked'] = true;
81 81
 
82 82
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 
86 86
 
87 87
 if (isset($_COOKIE['map_2d_limit'])) {
88
-	$limit = filter_var($_COOKIE['map_2d_limit'],FILTER_SANITIZE_NUMBER_INT);
88
+	$limit = filter_var($_COOKIE['map_2d_limit'], FILTER_SANITIZE_NUMBER_INT);
89 89
 }
90 90
 
91 91
 $spotter_array = array();
92 92
 
93 93
 if (isset($_GET['ident'])) {
94
-	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
94
+	$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
95 95
 	if ($tracker) {
96 96
 		$spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident);
97 97
 	} elseif ($marine) {
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 	$allhistory = true;
107 107
 } elseif (isset($_GET['flightaware_id'])) {
108
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
108
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
109 109
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
110 110
 	if (empty($spotter_array)) {
111 111
 		$from_archive = true;
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
 	}
114 114
 	$allhistory = true;
115 115
 } elseif (isset($_GET['famtrack_id'])) {
116
-	$famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING));
116
+	$famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING));
117 117
 	$spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id);
118 118
 	$allhistory = true;
119 119
 } elseif (isset($_GET['fammarine_id'])) {
120
-	$fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING));
120
+	$fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING));
121 121
 	$spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id);
122 122
 	$allhistory = true;
123 123
 /*
@@ -137,15 +137,15 @@  discard block
 block discarded – undo
137 137
 */
138 138
 } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min && !isset($_GET['archive'])) {
139 139
 	$usecoord = true;
140
-	$coord = explode(',',$_GET['coord']);
141
-	if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
140
+	$coord = explode(',', $_GET['coord']);
141
+	if (filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) 
142 142
 	    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
143 143
 		if ($tracker) {
144
-			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
144
+			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter);
145 145
 		} elseif ($marine) {
146
-			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter);
146
+			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter);
147 147
 		} else {
148
-			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$limit,$filter);
148
+			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $limit, $filter);
149 149
 		}
150 150
 	} else {
151 151
 		if ($tracker) {
@@ -153,41 +153,41 @@  discard block
 block discarded – undo
153 153
 		} elseif ($marine) {
154 154
 			$spotter_array = $MarineLive->getMinLiveMarineData($filter);
155 155
 		} else {
156
-			$spotter_array = $SpotterLive->getMinLiveSpotterData($limit,$filter);
156
+			$spotter_array = $SpotterLive->getMinLiveSpotterData($limit, $filter);
157 157
 		}
158 158
 	}
159 159
 } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) {
160 160
 	$from_archive = true;
161 161
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
162 162
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
163
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
164
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
165
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
166
-	$begindate = date('Y-m-d H:i:s',$begindate);
167
-	$enddate = date('Y-m-d H:i:s',$enddate);
168
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
163
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
164
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
165
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
166
+	$begindate = date('Y-m-d H:i:s', $begindate);
167
+	$enddate = date('Y-m-d H:i:s', $enddate);
168
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
169 169
 } elseif ($min) {
170 170
 	if ($tracker) {
171 171
 		$spotter_array = $TrackerLive->getMinLiveTrackerData($filter);
172 172
 	} elseif ($marine) {
173 173
 		$spotter_array = $MarineLive->getMinLiveMarineData($filter);
174 174
 	} else {
175
-		$spotter_array = $SpotterLive->getMinLiveSpotterData($limit,$filter);
175
+		$spotter_array = $SpotterLive->getMinLiveSpotterData($limit, $filter);
176 176
 	}
177 177
 #	$min = true;
178 178
 } else {
179 179
 	if ($tracker) {
180
-		$spotter_array = $TrackerLive->getLiveTrackerData('','',$filter);
180
+		$spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter);
181 181
 	} elseif ($marine) {
182
-		$spotter_array = $marineLive->getLiveMarineData('','',$filter);
182
+		$spotter_array = $marineLive->getLiveMarineData('', '', $filter);
183 183
 	} else {
184
-		$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
184
+		$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
185 185
 	}
186 186
 }
187 187
 
188 188
 if ($usecoord) {
189 189
 	if (isset($_GET['archive'])) {
190
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
190
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
191 191
 	} else {
192 192
 		if ($tracker) {
193 193
 			$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 	if ($flightcnt == '') $flightcnt = 0;
201 201
 } else $flightcnt = 0;
202 202
 
203
-$sqltime = round(microtime(true)-$begintime,2);
203
+$sqltime = round(microtime(true) - $begintime, 2);
204 204
 
205
-$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
205
+$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
206 206
 if ($currenttime != '') $currenttime = round($currenttime/1000);
207 207
 
208 208
 if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation === FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		if (!empty($spotter_array) && is_array($spotter_array))
222 222
 		{
223 223
 			$output .= '"features": [';
224
-			foreach($spotter_array as $spotter_item)
224
+			foreach ($spotter_array as $spotter_item)
225 225
 			{
226 226
 				$j++;
227 227
 				unset($idistance);
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
 */
279 279
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
280 280
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
281
-							if ($compress) $output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
282
-							else $output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
281
+							if ($compress) $output .= '"c": '.json_encode(str_replace('\\', '', $spotter_item['ident'])).',';
282
+							else $output .= '"callsign": '.json_encode(str_replace('\\', '', $spotter_item['ident'])).',';
283 283
 							//'
284 284
 						} else {
285 285
 							if ($compress) $output .= '"c": "NA",';
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 						}
292 292
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
293 293
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
294
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
294
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
295 295
 						} elseif (isset($spotter_item['aircraft_type'])) {
296 296
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
297 297
 						} elseif (!$min) {
@@ -377,19 +377,19 @@  discard block
 block discarded – undo
377 377
 									else $output .= '"aircraft_shadow": "car.png",';
378 378
 								}
379 379
 							} elseif ($marine) {
380
-								if (isset($spotter_item['type']) && ($spotter_item['type']  == '50&#39; Performance Cruiser' || $spotter_item['type']  == '50\' Performance Cruiser' || $spotter_item['type'] == 'Sail')) {
380
+								if (isset($spotter_item['type']) && ($spotter_item['type'] == '50&#39; Performance Cruiser' || $spotter_item['type'] == '50\' Performance Cruiser' || $spotter_item['type'] == 'Sail')) {
381 381
 									if ($compress) $output .= '"as": "50perfcruiser.png",';
382 382
 									else $output .= '"aircraft_shadow": "50perfcruiser.png",';
383
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Sailaway Cruiser 38') {
383
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Sailaway Cruiser 38') {
384 384
 									if ($compress) $output .= '"as": "cruiser38.png",';
385 385
 									else $output .= '"aircraft_shadow": "cruiser38.png",';
386
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Mini Transat') {
386
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Mini Transat') {
387 387
 									if ($compress) $output .= '"as": "transat.png",';
388 388
 									else $output .= '"aircraft_shadow": "transat.png",';
389
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == '52&#39; Cruising Cat') {
389
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == '52&#39; Cruising Cat') {
390 390
 									if ($compress) $output .= '"as": "catamaran.png",';
391 391
 									else $output .= '"aircraft_shadow": "catamaran.png",';
392
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Caribbean Rose') {
392
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Caribbean Rose') {
393 393
 									if ($compress) $output .= '"as": "carib.png",';
394 394
 									else $output .= '"aircraft_shadow": "carib.png",';
395 395
 								} else {
@@ -455,15 +455,15 @@  discard block
 block discarded – undo
455 455
 						if (isset($archivespeed) || $usenextlatlon) {
456 456
 							if (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
457 457
 								if (isset($spotter_item['arrival_airport_latitude'])) {
458
-									$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
459
-									$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
458
+									$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
459
+									$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
460 460
 									$farr_lat = $spotter_item['arrival_airport_latitude'];
461 461
 									$farr_lon = $spotter_item['arrival_airport_longitude'];
462 462
 								} else {
463 463
 									$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
464 464
 									if (isset($aairport[0]['latitude'])) {
465
-										$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
466
-										$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
465
+										$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
466
+										$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
467 467
 										$farr_lat = $aairport[0]['latitude'];
468 468
 										$farr_lon = $aairport[0]['longitude'];
469 469
 									}
@@ -476,59 +476,59 @@  discard block
 block discarded – undo
476 476
 						if ($currenttime != '') {
477 477
 							if (strtotime($spotter_item['date']) < $currenttime) {
478 478
 								if (isset($archivespeed)) {
479
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
480
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
479
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
480
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
481 481
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
482 482
 									else {
483
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
484
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
483
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
484
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
485 485
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
486 486
 										else {
487
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
487
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
488 488
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
489 489
 										}
490 490
 									}
491 491
 								} elseif ($usenextlatlon) {
492
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
493
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
492
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
493
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
494 494
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
495 495
 									else {
496
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
497
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
496
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
497
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
498 498
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
499 499
 										else {
500
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
500
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
501 501
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
502 502
 										}
503 503
 									}
504 504
 								}
505 505
 							} else {
506 506
 								if (isset($archivespeed)) {
507
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
507
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
508 508
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
509 509
 								} elseif ($usenextlatlon) {
510
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
510
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
511 511
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
512 512
 								}
513 513
 							}
514 514
 						} else {
515 515
 							if (isset($archivespeed)) {
516
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
517
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
516
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
517
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
518 518
 								if (!isset($idistance) || $fdistance < $idistance) {
519 519
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
520 520
 								} else {
521
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed);
521
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed);
522 522
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
523 523
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
524 524
 								}
525 525
 							} elseif ($usenextlatlon) {
526
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
527
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
526
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
527
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
528 528
 								if (!isset($idistance) || $fdistance < $idistance) {
529 529
 										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
530 530
 								} else {
531
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading);
531
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading);
532 532
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
533 533
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
534 534
 								}
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 
538 538
 						if (!$min) $output .= '"image": "'.$image.'",';
539 539
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
540
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
540
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
541 541
 						}
542 542
 						if (isset($spotter_item['image_source_website'])) {
543 543
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
572 572
 						}
573 573
 						if (isset($spotter_item['acars'])) {
574
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
574
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
575 575
 						}
576 576
 						// type when not aircraft ?
577 577
 						if (isset($spotter_item['type'])) {
@@ -591,12 +591,12 @@  discard block
 block discarded – undo
591 591
 								if ($currenttime != '') {
592 592
 									if (strtotime($spotter_item['date']) < $currenttime) {
593 593
 										if (!isset($archivespeed)) $archivespeed = 1;
594
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
595
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
594
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
595
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
596 596
 										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
597 597
 										else {
598
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
599
-											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
598
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
599
+											$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
600 600
 											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
601 601
 											else {
602 602
 												$output .= $spotter_item['longitude'].', ';
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
                 
676 676
 			}
677 677
 */
678
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
678
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
679 679
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
680 680
 				
681 681
 				if (
@@ -683,11 +683,11 @@  discard block
 block discarded – undo
683 683
 				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
684 684
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
685 685
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
686
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
686
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
687 687
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
688
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
688
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id']))
689 689
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
690
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
690
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid']))
691 691
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
692 692
 				    ) {
693 693
 					if ($tracker) {
@@ -716,9 +716,9 @@  discard block
 block discarded – undo
716 716
 							require(dirname(__FILE__).'/require/class.MapMatching.php');
717 717
 							$MapMatching = new MapMatching();
718 718
 							if (isset($spotter_item['date_iso_8601'])) {
719
-								$spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date_iso_8601'])))));
719
+								$spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date_iso_8601'])))));
720 720
 							} else {
721
-								$spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date'])))));
721
+								$spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date'])))));
722 722
 							}
723 723
 							$spotter_history_array = $MapMatching->match($spotter_history_array_mm);
724 724
 						}
@@ -750,9 +750,9 @@  discard block
 block discarded – undo
750 750
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
751 751
 							}
752 752
 							$output_history .= '[';
753
-							$output_history .=  $spotter_history['longitude'].', ';
754
-							$output_history .=  $spotter_history['latitude'].', ';
755
-							$output_history .=  $spotter_history['altitude']*30.48;
753
+							$output_history .= $spotter_history['longitude'].', ';
754
+							$output_history .= $spotter_history['latitude'].', ';
755
+							$output_history .= $spotter_history['altitude']*30.48;
756 756
 							$output_history .= '],';
757 757
 							/*
758 758
 							if ($from_archive === false) {
@@ -775,8 +775,8 @@  discard block
 block discarded – undo
775 775
 								$d = true;
776 776
 							}
777 777
 							$output_history .= '[';
778
-							$output_history .=  $spotter_history['longitude'].', ';
779
-							$output_history .=  $spotter_history['latitude'];
778
+							$output_history .= $spotter_history['longitude'].', ';
779
+							$output_history .= $spotter_history['latitude'];
780 780
 							$output_history .= '],';
781 781
 							/*
782 782
 							if ($from_archive === false) {
@@ -792,9 +792,9 @@  discard block
 block discarded – undo
792 792
 						//echo $output_history;
793 793
 						if ($from_archive === false && !isset($spotter_history_array[0]['mapmatching_engine'])) {
794 794
 							$output_historyd = '[';
795
-							$output_historyd .=  $spotter_item['longitude'].', ';
796
-							$output_historyd .=  $spotter_item['latitude'];
797
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
795
+							$output_historyd .= $spotter_item['longitude'].', ';
796
+							$output_historyd .= $spotter_item['latitude'];
797
+							if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48;
798 798
 							$output_historyd .= '],';
799 799
 							//$output_history = $output_historyd.$output_history;
800 800
 							$output_history = $output_history.$output_historyd;
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
 							$last = array_pop($spotter_history_array);
803 803
 							$latitude = $last['latitude'];
804 804
 							$longitude = $last['longitude'];
805
-							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}','"coordinates": ['.$longitude.', '.$latitude.']}',$output);
805
+							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}', '"coordinates": ['.$longitude.', '.$latitude.']}', $output);
806 806
 						}
807 807
 						
808 808
 						$output_history  = substr($output_history, 0, -1);
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
 					
815 815
 				}
816 816
 				
817
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
817
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
818 818
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
819 819
 				     && (isset($spotter_item['departure_airport']) 
820 820
 				        && $spotter_item['departure_airport'] != 'NA' 
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
 
849 849
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
850 850
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
851
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
851
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
852 852
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
853 853
 				     && (isset($spotter_item['arrival_airport']) 
854 854
 				        && $spotter_item['arrival_airport'] != 'NA' 
@@ -875,11 +875,11 @@  discard block
 block discarded – undo
875 875
 					}
876 876
 				    }
877 877
 				    if ($havedata) {
878
-					$line = $Common->greatCircle($spotter_item['latitude'],$spotter_item['longitude'],$end_lat,$end_lon);
878
+					$line = $Common->greatCircle($spotter_item['latitude'], $spotter_item['longitude'], $end_lat, $end_lon);
879 879
 					foreach ($line[0] as $coord) {
880 880
 						$output_dest .= '['.$coord[0].','.$coord[1].'],';
881 881
 					}
882
-					$output_dest  = substr($output_dest, 0, -1);
882
+					$output_dest = substr($output_dest, 0, -1);
883 883
 				    }
884 884
 				    $output_dest .= ']}},';
885 885
 				    if ($havedata) $output .= $output_dest;
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 			$output  = substr($output, 0, -1);
890 890
 			$output .= ']';
891 891
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
892
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
892
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
893 893
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
894 894
 			$output .= '"fc": "'.$j.'"';
895 895
 		} else {
Please login to merge, or discard this patch.
Braces   +364 added lines, -147 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 $tracker = false;
13 13
 $marine = false;
14 14
 $usecoord = false;
15
-if (isset($_GET['test'])) exit();
15
+if (isset($_GET['test'])) {
16
+	exit();
17
+}
16 18
 if (isset($_GET['tracker'])) {
17 19
     $tracker = true;
18 20
 }
@@ -57,31 +59,62 @@  discard block
 block discarded – undo
57 59
 }
58 60
 header('Content-Type: text/javascript');
59 61
 
60
-if (!isset($globalJsonCompress)) $compress = true;
61
-else $compress = $globalJsonCompress;
62
+if (!isset($globalJsonCompress)) {
63
+	$compress = true;
64
+} else {
65
+	$compress = $globalJsonCompress;
66
+}
62 67
 
63 68
 $limit = 0;
64 69
 $from_archive = false;
65 70
 $min = true;
66 71
 $allhistory = false;
67 72
 $filter['source'] = array();
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
70
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
72
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
73
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
78
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
79
-if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT);
80
-if (isset($_COOKIE['filter_blocked']) && $_COOKIE['filter_blocked'] == 'true') $filter['blocked'] = true;
73
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
74
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
75
+}
76
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
77
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
78
+}
79
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
80
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
81
+}
82
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
83
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
84
+}
85
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
86
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
87
+}
88
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
89
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
90
+}
91
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') {
92
+	$filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
93
+}
94
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
95
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
96
+}
97
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
98
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
99
+}
100
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
101
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
102
+}
103
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
104
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
105
+}
106
+if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') {
107
+	$filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT);
108
+}
109
+if (isset($_COOKIE['filter_blocked']) && $_COOKIE['filter_blocked'] == 'true') {
110
+	$filter['blocked'] = true;
111
+}
81 112
 
82 113
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
83 114
 	$min = true;
84
-} else $min = false;
115
+} else {
116
+	$min = false;
117
+}
85 118
 
86 119
 
87 120
 if (isset($_COOKIE['map_2d_limit'])) {
@@ -197,24 +230,38 @@  discard block
 block discarded – undo
197 230
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
198 231
 		}
199 232
 	}
200
-	if ($flightcnt == '') $flightcnt = 0;
201
-} else $flightcnt = 0;
233
+	if ($flightcnt == '') {
234
+		$flightcnt = 0;
235
+	}
236
+	} else {
237
+	$flightcnt = 0;
238
+}
202 239
 
203 240
 $sqltime = round(microtime(true)-$begintime,2);
204 241
 
205 242
 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
206
-if ($currenttime != '') $currenttime = round($currenttime/1000);
243
+if ($currenttime != '') {
244
+	$currenttime = round($currenttime/1000);
245
+}
207 246
 
208
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation === FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
209
-else $usenextlatlon = true;
210
-if ($usenextlatlon === false) $currenttime = '';
247
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation === FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
248
+	$usenextlatlon = false;
249
+} else {
250
+	$usenextlatlon = true;
251
+}
252
+if ($usenextlatlon === false) {
253
+	$currenttime = '';
254
+}
211 255
 $j = 0;
212 256
 $prev_flightaware_id = '';
213 257
 $aircrafts_shadow = array();
214 258
 $output = '{';
215 259
 	$output .= '"type": "FeatureCollection",';
216
-		if ($min) $output .= '"minimal": "true",';
217
-		else $output .= '"minimal": "false",';
260
+		if ($min) {
261
+			$output .= '"minimal": "true",';
262
+		} else {
263
+			$output .= '"minimal": "false",';
264
+		}
218 265
 		//$output .= '"fc": "'.$flightcnt.'",';
219 266
 		$output .= '"sqt": "'.$sqltime.'",';
220 267
 
@@ -259,18 +306,29 @@  discard block
 block discarded – undo
259 306
 						}
260 307
 						$output .= '"properties": {';
261 308
 						if (isset($spotter_item['flightaware_id'])) {
262
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
263
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
309
+							if ($compress) {
310
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
311
+							} else {
312
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
313
+							}
264 314
 						} elseif (isset($spotter_item['famtrackid'])) {
265
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
266
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
315
+							if ($compress) {
316
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
317
+							} else {
318
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
319
+							}
267 320
 						} elseif (isset($spotter_item['fammarine_id'])) {
268
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
269
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
321
+							if ($compress) {
322
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
323
+							} else {
324
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
325
+							}
270 326
 						}
271 327
 						$output .= '"fc": "'.$flightcnt.'",';
272 328
 						$output .= '"sqt": "'.$sqltime.'",';
273
-						if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
329
+						if (isset($begindate)) {
330
+							$output .= '"archive_date": "'.$begindate.'",';
331
+						}
274 332
 
275 333
 /*
276 334
 							if ($min) $output .= '"minimal": "true",';
@@ -278,16 +336,25 @@  discard block
 block discarded – undo
278 336
 */
279 337
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
280 338
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
281
-							if ($compress) $output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
282
-							else $output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
339
+							if ($compress) {
340
+								$output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
341
+							} else {
342
+								$output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
343
+							}
283 344
 							//'
284 345
 						} else {
285
-							if ($compress) $output .= '"c": "NA",';
286
-							else $output .= '"callsign": "NA",';
346
+							if ($compress) {
347
+								$output .= '"c": "NA",';
348
+							} else {
349
+								$output .= '"callsign": "NA",';
350
+							}
287 351
 						}
288 352
 						if (isset($spotter_item['registration'])) {
289
-							if ($compress) $output .= '"reg": '.json_encode($spotter_item['registration']).',';
290
-							else $output .= '"registration": '.json_encode($spotter_item['registration']).',';
353
+							if ($compress) {
354
+								$output .= '"reg": '.json_encode($spotter_item['registration']).',';
355
+							} else {
356
+								$output .= '"registration": '.json_encode($spotter_item['registration']).',';
357
+							}
291 358
 						}
292 359
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
293 360
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
@@ -298,20 +365,30 @@  discard block
 block discarded – undo
298 365
 							$output .= '"aircraft_name": "NA",';
299 366
 						}
300 367
 						if (isset($spotter_item['aircraft_icao'])) {
301
-							if ($compress) $output .= '"ai": "'.$spotter_item['aircraft_icao'].'",';
302
-							else $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
368
+							if ($compress) {
369
+								$output .= '"ai": "'.$spotter_item['aircraft_icao'].'",';
370
+							} else {
371
+								$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
372
+							}
303 373
 						}
304 374
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker && !$marine) {
305
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
306
-							else {
375
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
376
+								$spotter_item['aircraft_shadow'] = '';
377
+							} else {
307 378
 								$aircraft_icao = $spotter_item['aircraft_icao'];
308
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
309
-								else {
379
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
380
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
381
+								} else {
310 382
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
311
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
312
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
313
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
314
-									else $spotter_item['aircraft_shadow'] = '';
383
+									if (count($aircraft_info) > 0) {
384
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
385
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
386
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
387
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
388
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
389
+									} else {
390
+										$spotter_item['aircraft_shadow'] = '';
391
+									}
315 392
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
316 393
 								}
317 394
 							}
@@ -319,90 +396,171 @@  discard block
 block discarded – undo
319 396
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
320 397
 							if ($tracker) {
321 398
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
322
-									if ($compress) $output .= '"as": "ambulance.png",';
323
-									else $output .= '"aircraft_shadow": "ambulance.png",';
399
+									if ($compress) {
400
+										$output .= '"as": "ambulance.png",';
401
+									} else {
402
+										$output .= '"aircraft_shadow": "ambulance.png",';
403
+									}
324 404
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
325
-									if ($compress) $output .= '"as": "police.png",';
326
-									else $output .= '"aircraft_shadow": "police.png",';
405
+									if ($compress) {
406
+										$output .= '"as": "police.png",';
407
+									} else {
408
+										$output .= '"aircraft_shadow": "police.png",';
409
+									}
327 410
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
328
-									if ($compress) $output .= '"as": "ship.png",';
329
-									else $output .= '"aircraft_shadow": "ship.png",';
411
+									if ($compress) {
412
+										$output .= '"as": "ship.png",';
413
+									} else {
414
+										$output .= '"aircraft_shadow": "ship.png",';
415
+									}
330 416
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
331
-									if ($compress) $output .= '"as": "ship.png",';
332
-									else $output .= '"aircraft_shadow": "ship.png",';
417
+									if ($compress) {
418
+										$output .= '"as": "ship.png",';
419
+									} else {
420
+										$output .= '"aircraft_shadow": "ship.png",';
421
+									}
333 422
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
334
-									if ($compress) $output .= '"as": "ship.png",';
335
-									else $output .= '"aircraft_shadow": "ship.png",';
423
+									if ($compress) {
424
+										$output .= '"as": "ship.png",';
425
+									} else {
426
+										$output .= '"aircraft_shadow": "ship.png",';
427
+									}
336 428
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
337
-									if ($compress) $output .= '"as": "truck.png",';
338
-									else $output .= '"aircraft_shadow": "truck.png",';
429
+									if ($compress) {
430
+										$output .= '"as": "truck.png",';
431
+									} else {
432
+										$output .= '"aircraft_shadow": "truck.png",';
433
+									}
339 434
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
340
-									if ($compress) $output .= '"as": "truck.png",';
341
-									else $output .= '"aircraft_shadow": "truck.png",';
435
+									if ($compress) {
436
+										$output .= '"as": "truck.png",';
437
+									} else {
438
+										$output .= '"aircraft_shadow": "truck.png",';
439
+									}
342 440
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
343
-									if ($compress) $output .= '"as": "aircraft.png",';
344
-									else $output .= '"aircraft_shadow": "aircraft.png",';
441
+									if ($compress) {
442
+										$output .= '"as": "aircraft.png",';
443
+									} else {
444
+										$output .= '"aircraft_shadow": "aircraft.png",';
445
+									}
345 446
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
346
-									if ($compress) $output .= '"as": "aircraft.png",';
347
-									else $output .= '"aircraft_shadow": "aircraft.png",';
447
+									if ($compress) {
448
+										$output .= '"as": "aircraft.png",';
449
+									} else {
450
+										$output .= '"aircraft_shadow": "aircraft.png",';
451
+									}
348 452
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
349
-									if ($compress) $output .= '"as": "helico.png",';
350
-									else $output .= '"aircraft_shadow": "helico.png",';
453
+									if ($compress) {
454
+										$output .= '"as": "helico.png",';
455
+									} else {
456
+										$output .= '"aircraft_shadow": "helico.png",';
457
+									}
351 458
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
352
-									if ($compress) $output .= '"as": "rail.png",';
353
-									else $output .= '"aircraft_shadow": "rail.png",';
459
+									if ($compress) {
460
+										$output .= '"as": "rail.png",';
461
+									} else {
462
+										$output .= '"aircraft_shadow": "rail.png",';
463
+									}
354 464
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
355
-									if ($compress) $output .= '"as": "firetruck.png",';
356
-									else $output .= '"aircraft_shadow": "firetruck.png",';
465
+									if ($compress) {
466
+										$output .= '"as": "firetruck.png",';
467
+									} else {
468
+										$output .= '"aircraft_shadow": "firetruck.png",';
469
+									}
357 470
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
358
-									if ($compress) $output .= '"as": "bus.png",';
359
-									else $output .= '"aircraft_shadow": "bus.png",';
471
+									if ($compress) {
472
+										$output .= '"as": "bus.png",';
473
+									} else {
474
+										$output .= '"aircraft_shadow": "bus.png",';
475
+									}
360 476
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
361
-									if ($compress) $output .= '"as": "phone.png",';
362
-									else $output .= '"aircraft_shadow": "phone.png",';
477
+									if ($compress) {
478
+										$output .= '"as": "phone.png",';
479
+									} else {
480
+										$output .= '"aircraft_shadow": "phone.png",';
481
+									}
363 482
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
364
-									if ($compress) $output .= '"as": "jogger.png",';
365
-									else $output .= '"aircraft_shadow": "jogger.png",';
483
+									if ($compress) {
484
+										$output .= '"as": "jogger.png",';
485
+									} else {
486
+										$output .= '"aircraft_shadow": "jogger.png",';
487
+									}
366 488
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
367
-									if ($compress) $output .= '"as": "bike.png",';
368
-									else $output .= '"aircraft_shadow": "bike.png",';
489
+									if ($compress) {
490
+										$output .= '"as": "bike.png",';
491
+									} else {
492
+										$output .= '"aircraft_shadow": "bike.png",';
493
+									}
369 494
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
370
-									if ($compress) $output .= '"as": "motorcycle.png",';
371
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
495
+									if ($compress) {
496
+										$output .= '"as": "motorcycle.png",';
497
+									} else {
498
+										$output .= '"aircraft_shadow": "motorcycle.png",';
499
+									}
372 500
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
373
-									if ($compress) $output .= '"as": "balloon.png",';
374
-									else $output .= '"aircraft_shadow": "balloon.png",';
501
+									if ($compress) {
502
+										$output .= '"as": "balloon.png",';
503
+									} else {
504
+										$output .= '"aircraft_shadow": "balloon.png",';
505
+									}
375 506
 								} else {
376
-									if ($compress) $output .= '"as": "car.png",';
377
-									else $output .= '"aircraft_shadow": "car.png",';
507
+									if ($compress) {
508
+										$output .= '"as": "car.png",';
509
+									} else {
510
+										$output .= '"aircraft_shadow": "car.png",';
511
+									}
378 512
 								}
379 513
 							} elseif ($marine) {
380 514
 								if (isset($spotter_item['type']) && ($spotter_item['type']  == '50&#39; Performance Cruiser' || $spotter_item['type']  == '50\' Performance Cruiser' || $spotter_item['type'] == 'Sail')) {
381
-									if ($compress) $output .= '"as": "50perfcruiser.png",';
382
-									else $output .= '"aircraft_shadow": "50perfcruiser.png",';
515
+									if ($compress) {
516
+										$output .= '"as": "50perfcruiser.png",';
517
+									} else {
518
+										$output .= '"aircraft_shadow": "50perfcruiser.png",';
519
+									}
383 520
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Sailaway Cruiser 38') {
384
-									if ($compress) $output .= '"as": "cruiser38.png",';
385
-									else $output .= '"aircraft_shadow": "cruiser38.png",';
521
+									if ($compress) {
522
+										$output .= '"as": "cruiser38.png",';
523
+									} else {
524
+										$output .= '"aircraft_shadow": "cruiser38.png",';
525
+									}
386 526
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Mini Transat') {
387
-									if ($compress) $output .= '"as": "transat.png",';
388
-									else $output .= '"aircraft_shadow": "transat.png",';
527
+									if ($compress) {
528
+										$output .= '"as": "transat.png",';
529
+									} else {
530
+										$output .= '"aircraft_shadow": "transat.png",';
531
+									}
389 532
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == '52&#39; Cruising Cat') {
390
-									if ($compress) $output .= '"as": "catamaran.png",';
391
-									else $output .= '"aircraft_shadow": "catamaran.png",';
533
+									if ($compress) {
534
+										$output .= '"as": "catamaran.png",';
535
+									} else {
536
+										$output .= '"aircraft_shadow": "catamaran.png",';
537
+									}
392 538
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Caribbean Rose') {
393
-									if ($compress) $output .= '"as": "carib.png",';
394
-									else $output .= '"aircraft_shadow": "carib.png",';
539
+									if ($compress) {
540
+										$output .= '"as": "carib.png",';
541
+									} else {
542
+										$output .= '"aircraft_shadow": "carib.png",';
543
+									}
395 544
 								} else {
396
-									if ($compress) $output .= '"as": "ship.png",';
397
-									else $output .= '"aircraft_shadow": "ship.png",';
545
+									if ($compress) {
546
+										$output .= '"as": "ship.png",';
547
+									} else {
548
+										$output .= '"aircraft_shadow": "ship.png",';
549
+									}
398 550
 								}
399 551
 							} else {
400
-								if ($compress) $output .= '"as": "default.png",';
401
-								else $output .= '"aircraft_shadow": "default.png",';
552
+								if ($compress) {
553
+									$output .= '"as": "default.png",';
554
+								} else {
555
+									$output .= '"aircraft_shadow": "default.png",';
556
+								}
402 557
 							}
403 558
 						} else {
404
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
405
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
559
+							if ($compress) {
560
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
561
+							} else {
562
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
563
+							}
406 564
 						}
407 565
 						if (isset($spotter_item['airline_name'])) {
408 566
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -410,8 +568,11 @@  discard block
 block discarded – undo
410 568
 							$output .= '"airline_name": "NA",';
411 569
 						}
412 570
 						if (isset($spotter_item['departure_airport'])) {
413
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
414
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
571
+							if ($compress) {
572
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
573
+							} else {
574
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
575
+							}
415 576
 						}
416 577
 						if (isset($spotter_item['departure_airport_city'])) {
417 578
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -423,8 +584,11 @@  discard block
 block discarded – undo
423 584
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
424 585
 						}
425 586
 						if (isset($spotter_item['arrival_airport'])) {
426
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
427
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
587
+							if ($compress) {
588
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
589
+							} else {
590
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
591
+							}
428 592
 						}
429 593
 						if (isset($spotter_item['arrival_airport_city'])) {
430 594
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -443,11 +607,17 @@  discard block
 block discarded – undo
443 607
 						}
444 608
 						
445 609
 						if (isset($spotter_item['real_altitude'])) {
446
-							if ($compress) $output .= '"a": "'.($spotter_item['real_altitude']/100).'",';
447
-							else $output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",';
610
+							if ($compress) {
611
+								$output .= '"a": "'.($spotter_item['real_altitude']/100).'",';
612
+							} else {
613
+								$output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",';
614
+							}
448 615
 						} elseif (isset($spotter_item['altitude'])) {
449
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
450
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
616
+							if ($compress) {
617
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
618
+							} else {
619
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
620
+							}
451 621
 						}
452 622
 						
453 623
 						$heading = $spotter_item['heading'];
@@ -471,19 +641,24 @@  discard block
 block discarded – undo
471 641
 							}
472 642
 						}
473 643
 						
474
-						if ($compress)$output .= '"h": "'.$heading.'",';
475
-						else $output .= '"heading": "'.$heading.'",';
644
+						if ($compress) {
645
+							$output .= '"h": "'.$heading.'",';
646
+						} else {
647
+							$output .= '"heading": "'.$heading.'",';
648
+						}
476 649
 						if ($currenttime != '') {
477 650
 							if (strtotime($spotter_item['date']) < $currenttime) {
478 651
 								if (isset($archivespeed)) {
479 652
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
480 653
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
481
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
482
-									else {
654
+									if (!isset($idistance) || $fdistance < $idistance) {
655
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
656
+									} else {
483 657
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
484 658
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
485
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
486
-										else {
659
+										if (!isset($idistance) || $fdistance < $idistance) {
660
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
661
+										} else {
487 662
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
488 663
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
489 664
 										}
@@ -491,12 +666,14 @@  discard block
 block discarded – undo
491 666
 								} elseif ($usenextlatlon) {
492 667
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
493 668
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
494
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
495
-									else {
669
+									if (!isset($idistance) || $fdistance < $idistance) {
670
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
671
+									} else {
496 672
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
497 673
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
498
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
499
-										else {
674
+										if (!isset($idistance) || $fdistance < $idistance) {
675
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
676
+										} else {
500 677
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
501 678
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
502 679
 										}
@@ -535,7 +712,9 @@  discard block
 block discarded – undo
535 712
 							}
536 713
 						}
537 714
 
538
-						if (!$min) $output .= '"image": "'.$image.'",';
715
+						if (!$min) {
716
+							$output .= '"image": "'.$image.'",';
717
+						}
539 718
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
540 719
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
541 720
 						}
@@ -543,8 +722,11 @@  discard block
 block discarded – undo
543 722
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
544 723
 						}
545 724
 						if (isset($spotter_item['squawk'])) {
546
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
547
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
725
+							if ($compress) {
726
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
727
+							} else {
728
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
729
+							}
548 730
 						}
549 731
 						if (isset($spotter_item['squawk_usage'])) {
550 732
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -575,14 +757,23 @@  discard block
 block discarded – undo
575 757
 						}
576 758
 						// type when not aircraft ?
577 759
 						if (isset($spotter_item['type'])) {
578
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
579
-							else $output .= '"type": "'.$spotter_item['type'].'"';
760
+							if ($compress) {
761
+								$output .= '"t": "'.$spotter_item['type'].'"';
762
+							} else {
763
+								$output .= '"type": "'.$spotter_item['type'].'"';
764
+							}
580 765
 						} elseif ($marine) {
581
-							if ($compress) $output .= '"t": "ship"';
582
-							else $output .= '"type": "ship"';
766
+							if ($compress) {
767
+								$output .= '"t": "ship"';
768
+							} else {
769
+								$output .= '"type": "ship"';
770
+							}
583 771
 						} else {
584
-							if ($compress) $output .= '"t": "aircraft"';
585
-							else $output .= '"type": "aircraft"';
772
+							if ($compress) {
773
+								$output .= '"t": "aircraft"';
774
+							} else {
775
+								$output .= '"type": "aircraft"';
776
+							}
586 777
 						}
587 778
 						$output .= '},';
588 779
 						$output .= '"geometry": {';
@@ -590,15 +781,19 @@  discard block
 block discarded – undo
590 781
 								$output .= '"coordinates": [';
591 782
 								if ($currenttime != '') {
592 783
 									if (strtotime($spotter_item['date']) < $currenttime) {
593
-										if (!isset($archivespeed)) $archivespeed = 1;
784
+										if (!isset($archivespeed)) {
785
+											$archivespeed = 1;
786
+										}
594 787
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
595 788
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
596
-										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
597
-										else {
789
+										if (!isset($idistance) || $fdistance < $idistance) {
790
+											$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
791
+										} else {
598 792
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
599 793
 											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
600
-											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
601
-											else {
794
+											if (!isset($idistance) || $fdistance < $idistance) {
795
+												$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
796
+											} else {
602 797
 												$output .= $spotter_item['longitude'].', ';
603 798
 												$output .= $spotter_item['latitude'];
604 799
 											}
@@ -676,7 +871,9 @@  discard block
 block discarded – undo
676 871
 			}
677 872
 */
678 873
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
679
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
874
+				if ($history == '' && isset($_COOKIE['history'])) {
875
+					$history = $_COOKIE['history'];
876
+				}
680 877
 				
681 878
 				if (
682 879
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -746,8 +943,11 @@  discard block
 block discarded – undo
746 943
 									$output_history .= ']}},';
747 944
 									$output .= $output_history;
748 945
 								}
749
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
750
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
946
+								if ($compress) {
947
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
948
+								} else {
949
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
950
+								}
751 951
 							}
752 952
 							$output_history .= '[';
753 953
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -768,10 +968,15 @@  discard block
 block discarded – undo
768 968
 							if ($d === false) {
769 969
 								if ($compress) {
770 970
 									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",';
771
-									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
772
-									elseif (isset($spotter_history_array[0]['mapmatching_engine'])) $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
971
+									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') {
972
+										$output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
973
+									} elseif (isset($spotter_history_array[0]['mapmatching_engine'])) {
974
+										$output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
975
+									}
773 976
 									$output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": [';
774
-								} else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
977
+								} else {
978
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
979
+								}
775 980
 								$d = true;
776 981
 							}
777 982
 							$output_history .= '[';
@@ -794,7 +999,9 @@  discard block
 block discarded – undo
794 999
 							$output_historyd = '[';
795 1000
 							$output_historyd .=  $spotter_item['longitude'].', ';
796 1001
 							$output_historyd .=  $spotter_item['latitude'];
797
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
1002
+							if (isset($spotter_history['altitude'])) {
1003
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
1004
+							}
798 1005
 							$output_historyd .= '],';
799 1006
 							//$output_history = $output_historyd.$output_history;
800 1007
 							$output_history = $output_history.$output_historyd;
@@ -822,8 +1029,11 @@  discard block
 block discarded – undo
822 1029
 				        && $spotter_item['arrival_airport'] != 'NA' 
823 1030
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
824 1031
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
825
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
826
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
1032
+				    if ($compress) {
1033
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
1034
+				    } else {
1035
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
1036
+				    }
827 1037
 				    if (isset($spotter_item['departure_airport_latitude'])) {
828 1038
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
829 1039
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -856,8 +1066,11 @@  discard block
 block discarded – undo
856 1066
 				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
857 1067
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
858 1068
 				    $havedata = false;
859
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
860
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1069
+				    if ($compress) {
1070
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1071
+				    } else {
1072
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1073
+				    }
861 1074
 				    
862 1075
 				    //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
863 1076
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -882,7 +1095,9 @@  discard block
 block discarded – undo
882 1095
 					$output_dest  = substr($output_dest, 0, -1);
883 1096
 				    }
884 1097
 				    $output_dest .= ']}},';
885
-				    if ($havedata) $output .= $output_dest;
1098
+				    if ($havedata) {
1099
+				    	$output .= $output_dest;
1100
+				    }
886 1101
 				    unset($output_dest);
887 1102
 				}
888 1103
 			}
@@ -890,7 +1105,9 @@  discard block
 block discarded – undo
890 1105
 			$output .= ']';
891 1106
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
892 1107
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
893
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
1108
+			if (isset($begindate)) {
1109
+				$output .= '"archive_date": "'.$begindate.'",';
1110
+			}
894 1111
 			$output .= '"fc": "'.$j.'"';
895 1112
 		} else {
896 1113
 			$output .= '"features": ';
Please login to merge, or discard this patch.