Completed
Push — master ( 5eede3...37e7ec )
by Yannick
39:37 queued 09:31
created
require/class.AIS.php 1 patch
Spacing   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -29,31 +29,31 @@  discard block
 block discarded – undo
29 29
 
30 30
 	private function make_latf($temp) { // unsigned long 
31 31
 		$flat = 0.0; // float
32
-		$temp = $temp & 0x07FFFFFF;
33
-		if ($temp & 0x04000000) {
34
-			$temp = $temp ^ 0x07FFFFFF;
32
+		$temp = $temp&0x07FFFFFF;
33
+		if ($temp&0x04000000) {
34
+			$temp = $temp^0x07FFFFFF;
35 35
 			$temp += 1;
36
-			$flat = (float)($temp / (60.0 * 10000.0));
36
+			$flat = (float) ($temp/(60.0*10000.0));
37 37
 			$flat *= -1.0;
38
-		} else $flat = (float)($temp / (60.0 * 10000.0));
38
+		} else $flat = (float) ($temp/(60.0*10000.0));
39 39
 		return $flat; // float
40 40
 	}
41 41
 
42 42
 	private function make_lonf($temp) { // unsigned long
43 43
 		$flon = 0.0; // float
44
-		$temp = $temp & 0x0FFFFFFF;
45
-		if ($temp & 0x08000000) {
46
-			$temp = $temp ^ 0x0FFFFFFF;
44
+		$temp = $temp&0x0FFFFFFF;
45
+		if ($temp&0x08000000) {
46
+			$temp = $temp^0x0FFFFFFF;
47 47
 			$temp += 1;
48
-			$flon = (float)($temp / (60.0 * 10000.0));
48
+			$flon = (float) ($temp/(60.0*10000.0));
49 49
 			$flon *= -1.0;
50
-		} else $flon = (float)($temp / (60.0 * 10000.0));
50
+		} else $flon = (float) ($temp/(60.0*10000.0));
51 51
 		return $flon;
52 52
 	}
53 53
 
54 54
 	private function ascii_2_dec($chr) {
55
-		$dec=ord($chr);//get decimal ascii code
56
-		$hex=dechex($dec);//convert decimal to hex
55
+		$dec = ord($chr); //get decimal ascii code
56
+		$hex = dechex($dec); //convert decimal to hex
57 57
 		return ($dec);
58 58
 	}
59 59
 	
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 		//only process in the following range: 48-87, 96-119
73 73
 		if ($ascii < 48) { }
74 74
 		else {
75
-			if($ascii>119) { }
75
+			if ($ascii > 119) { }
76 76
 			else {
77
-				if ($ascii>87 && $ascii<96) ;
77
+				if ($ascii > 87 && $ascii < 96);
78 78
 				else {
79
-					$ascii=$ascii+40;
80
-					if ($ascii>128){
81
-						$ascii=$ascii+32;
79
+					$ascii = $ascii + 40;
80
+					if ($ascii > 128) {
81
+						$ascii = $ascii + 32;
82 82
 					} else {
83
-						$ascii=$ascii+40;
83
+						$ascii = $ascii + 40;
84 84
 					}
85 85
 				}
86 86
 			}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	}
90 90
 
91 91
 	private function dec_2_6bit($dec) {
92
-		$bin=decbin($dec);
92
+		$bin = decbin($dec);
93 93
 		return(substr($bin, -6)); 
94 94
 	}
95 95
 
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 		);
108 108
 		// "
109 109
 		$rv = '';
110
-		if ($_size % 6 == 0) {
111
-			$len = $_size / 6;
112
-			for ($i=0; $i<$len; $i++) {
113
-				$offset = $i * 6;
114
-				$rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ];
110
+		if ($_size%6 == 0) {
111
+			$len = $_size/6;
112
+			for ($i = 0; $i < $len; $i++) {
113
+				$offset = $i*6;
114
+				$rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))];
115 115
 			}
116 116
 		}
117 117
 		return $rv;
@@ -138,93 +138,93 @@  discard block
 block discarded – undo
138 138
 		$ro->eta_hour = '';
139 139
 		$ro->eta_minute = '';
140 140
 		$ro->ts = time();
141
-		$ro->id = bindec(substr($_aisdata,0,6));
142
-		$ro->mmsi = bindec(substr($_aisdata,8,30));
141
+		$ro->id = bindec(substr($_aisdata, 0, 6));
142
+		$ro->mmsi = bindec(substr($_aisdata, 8, 30));
143 143
 		if ($ro->id >= 1 && $ro->id <= 3) {
144
-			$ro->cog = bindec(substr($_aisdata,116,12))/10;
145
-			$ro->sog = bindec(substr($_aisdata,50,10))/10;
146
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
147
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
144
+			$ro->cog = bindec(substr($_aisdata, 116, 12))/10;
145
+			$ro->sog = bindec(substr($_aisdata, 50, 10))/10;
146
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
147
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
148 148
 			$ro->cls = 1; // class A
149 149
 		} else if ($ro->id == 4) {
150
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,79,28)));
151
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,107,27)));
150
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 79, 28)));
151
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 107, 27)));
152 152
 			$ro->cls = 1; // class A
153 153
 		} else if ($ro->id == 5) {
154
-			$ro->imo = bindec(substr($_aisdata,40,30));
155
-			$ro->callsign = $this->binchar($_aisdata,70,42);
156
-			$ro->name = $this->binchar($_aisdata,112,120);
157
-			$ro->typeid = bindec(substr($_aisdata,232,8));
154
+			$ro->imo = bindec(substr($_aisdata, 40, 30));
155
+			$ro->callsign = $this->binchar($_aisdata, 70, 42);
156
+			$ro->name = $this->binchar($_aisdata, 112, 120);
157
+			$ro->typeid = bindec(substr($_aisdata, 232, 8));
158 158
 			$ro->type = $this->getShipType($ro->typeid);
159 159
 			//$ro->to_bow = bindec(substr($_aisdata,240,9));
160 160
 			//$ro->to_stern = bindec(substr($_aisdata,249,9));
161 161
 			//$ro->to_port = bindec(substr($_aisdata,258,6));
162 162
 			//$ro->to_starboard = bindec(substr($_aisdata,264,6));
163
-			$ro->eta_month = bindec(substr($_aisdata,274,4));
164
-			$ro->eta_day = bindec(substr($_aisdata,278,5));
165
-			$ro->eta_hour = bindec(substr($_aisdata,283,5));
166
-			$ro->eta_minute = bindec(substr($_aisdata,288,6));
163
+			$ro->eta_month = bindec(substr($_aisdata, 274, 4));
164
+			$ro->eta_day = bindec(substr($_aisdata, 278, 5));
165
+			$ro->eta_hour = bindec(substr($_aisdata, 283, 5));
166
+			$ro->eta_minute = bindec(substr($_aisdata, 288, 6));
167 167
 			//$ro->draught = bindec(substr($_aisdata,294,8));
168
-			$ro->destination = $this->binchar($_aisdata,302,120);
168
+			$ro->destination = $this->binchar($_aisdata, 302, 120);
169 169
 			$ro->cls = 1; // class A
170 170
 		} else if ($ro->id == 9) {
171 171
 			// Search and Rescue aircraft position report
172 172
 		} else if ($ro->id == 18) {
173
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
174
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
175
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
176
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
177
-			$ro->heading = bindec(substr($_aisdata,124,9));
173
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
174
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
175
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28)));
176
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27)));
177
+			$ro->heading = bindec(substr($_aisdata, 124, 9));
178 178
 			if ($ro->heading == 511) $ro->heading = '';
179 179
 			$ro->cls = 2; // class B
180 180
 		} else if ($ro->id == 19) {
181
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
182
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
183
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
184
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
185
-			$ro->name = $this->binchar($_aisdata,143,120);
181
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
182
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
183
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
184
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
185
+			$ro->name = $this->binchar($_aisdata, 143, 120);
186 186
 			$ro->cls = 2; // class B
187
-			$ro->heading = bindec(substr($_aisdata,124,9));
187
+			$ro->heading = bindec(substr($_aisdata, 124, 9));
188 188
 			if ($ro->heading == 511) $ro->heading = '';
189
-			$ro->typeid = bindec(substr($_aisdata,263,8));
189
+			$ro->typeid = bindec(substr($_aisdata, 263, 8));
190 190
 			$ro->type = $this->getShipType($ro->typeid);
191 191
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
192 192
 			//$ro->to_stern = bindec(substr($_aisdata,280,9));
193 193
 			//$ro->to_port = bindec(substr($_aisdata,289,6));
194 194
 			//$ro->to_starboard = bindec(substr($_aisdata,295,6));
195 195
 		} else if ($ro->id == 21) {
196
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,164,28)));
197
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,192,27)));
198
-			$ro->name = $this->binchar($_aisdata,43,120);
196
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 164, 28)));
197
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 192, 27)));
198
+			$ro->name = $this->binchar($_aisdata, 43, 120);
199 199
 			//$ro->to_bow = bindec(substr($_aisdata,219,9));
200 200
 			//$ro->to_stern = bindec(substr($_aisdata,228,9));
201 201
 			//$ro->to_port = bindec(substr($_aisdata,237,6));
202 202
 			//$ro->to_starboard = bindec(substr($_aisdata,243,6));
203 203
 			$ro->cls = 2; // class B
204 204
 		} else if ($ro->id == 24) {
205
-			$pn = bindec(substr($_aisdata,38,2));
205
+			$pn = bindec(substr($_aisdata, 38, 2));
206 206
 			if ($pn == 0) {
207
-				$ro->name = $this->binchar($_aisdata,40,120);
207
+				$ro->name = $this->binchar($_aisdata, 40, 120);
208 208
 			}
209
-			$ro->typeid = bindec(substr($_aisdata,40,8));
209
+			$ro->typeid = bindec(substr($_aisdata, 40, 8));
210 210
 			$ro->type = $this->getShipType($ro->typeid);
211
-			$ro->callsign = $this->binchar($_aisdata,90,42);
211
+			$ro->callsign = $this->binchar($_aisdata, 90, 42);
212 212
 			//$ro->to_bow = bindec(substr($_aisdata,132,9));
213 213
 			//$ro->to_stern = bindec(substr($_aisdata,141,9));
214 214
 			//$ro->to_port = bindec(substr($_aisdata,150,6));
215 215
 			//$ro->to_starboard = bindec(substr($_aisdata,156,6));
216 216
 			$ro->cls = 2; // class B
217 217
 		} else if ($ro->id == 27) {
218
-			$ro->cog = bindec(substr($_aisdata,85,9));
218
+			$ro->cog = bindec(substr($_aisdata, 85, 9));
219 219
 			if ($ro->cog == 511) $ro->cog = 0.0;
220
-			$ro->sog = bindec(substr($_aisdata,79,6));
220
+			$ro->sog = bindec(substr($_aisdata, 79, 6));
221 221
 			if ($ro->sog == 63) $ro->sog = 0.0;
222
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
223
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
222
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 44, 18))*10);
223
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 62, 17))*10);
224 224
 			$ro->cls = 1; // class A
225 225
 		
226 226
 		}
227
-		$ro->statusid = bindec(substr($_aisdata,38,4));
227
+		$ro->statusid = bindec(substr($_aisdata, 38, 4));
228 228
 		$ro->status = $this->getStatus($ro->statusid);
229 229
 		//var_dump($ro); // dump results here for demo purpose
230 230
 		return $ro;
@@ -355,14 +355,14 @@  discard block
 block discarded – undo
355 355
 		global $port; // tcpip port...
356 356
 		
357 357
 		static $debug_counter = 0;
358
-		$aisdata168='';//six bit array of ascii characters
358
+		$aisdata168 = ''; //six bit array of ascii characters
359 359
 		$ais_nmea_array = str_split($_itu); // convert to an array
360 360
 		foreach ($ais_nmea_array as $value) {
361 361
 			$dec = $this->ascii_2_dec($value);
362 362
 			$bit8 = $this->asciidec_2_8bit($dec);
363 363
 			$bit6 = $this->dec_2_6bit($bit8);
364 364
 			//echo $value ."-" .$bit6 ."";
365
-			$aisdata168 .=$bit6;
365
+			$aisdata168 .= $bit6;
366 366
 		}
367 367
 		//echo $aisdata168 . "<br/>";
368 368
 		//return $this->decode_ais($aisdata168, $aux);
@@ -385,24 +385,24 @@  discard block
 block discarded – undo
385 385
 		// calculate checksum after ! till *
386 386
 		// assume 1st ! is valid
387 387
 		// find * ensure that it is at correct position
388
-		$end = strrpos ( $rawdata , '*' );
388
+		$end = strrpos($rawdata, '*');
389 389
 		if ($end === FALSE) return -1; // check for NULLS!!!
390
-		$cs = substr( $rawdata, $end + 1 );
391
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
392
-		$dcs = (int)hexdec( $cs );
393
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
394
-		if ( $chksum == $dcs ) { // NMEA checksum pass
390
+		$cs = substr($rawdata, $end + 1);
391
+		if (strlen($cs) != 2) return -1; // correct cs length
392
+		$dcs = (int) hexdec($cs);
393
+		for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum
394
+		if ($chksum == $dcs) { // NMEA checksum pass
395 395
 			$pcs = explode(',', $rawdata);
396 396
 			// !AI??? identifier
397 397
 			if (!isset($pcs[1])) {
398 398
 				echo "ERROR,INVALID_DATA ".time()." $rawdata\n";
399 399
 				return -1;
400 400
 			}
401
-			$num_seq = (int)$pcs[1]; // number of sequences
402
-			$seq = (int)$pcs[2]; // get sequence
401
+			$num_seq = (int) $pcs[1]; // number of sequences
402
+			$seq = (int) $pcs[2]; // get sequence
403 403
 			// get msg sequence id
404 404
 			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
405
-			else $msg_sid = (int)$pcs[3]; // multipart message
405
+			else $msg_sid = (int) $pcs[3]; // multipart message
406 406
 			$ais_ch = $pcs[4]; // get AIS channel
407 407
 			// message sequence checking
408 408
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 					}
436 436
 				}
437 437
 				$itu = $itu.$pcs[5]; // get itu message
438
-				$filler += (int)$pcs[6][0]; // get filler
438
+				$filler += (int) $pcs[6][0]; // get filler
439 439
 				if ($num_seq == 1 // valid single message
440 440
 				    || $num_seq == $pseq // valid multi-part message
441 441
 				) {
@@ -455,13 +455,13 @@  discard block
 block discarded – undo
455 455
 		$cbuf = $cbuf.$ibuf;
456 456
 		$last_pos = 0;
457 457
 		$result = new stdClass();
458
-		while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) {
458
+		while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) {
459 459
 		//while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) {
460 460
 			//DEBUG echo $cbuf;
461
-			if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim?
461
+			if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim?
462 462
 				$tst = substr($cbuf, $start - 3, ($end - $start + 3));
463 463
 				//DEBUG echo "[$start $end $tst]\n";
464
-				$result = $this->process_ais_raw( $tst, "" );
464
+				$result = $this->process_ais_raw($tst, "");
465 465
 				$last_pos = $end + 1;
466 466
 			} else break;
467 467
 		}
@@ -473,41 +473,41 @@  discard block
 block discarded – undo
473 473
 	// incoming data from serial or IP comms
474 474
 	public function process_ais_line($cbuf) {
475 475
 		$result = new stdClass();
476
-		$start = strpos($cbuf,"VDM");
476
+		$start = strpos($cbuf, "VDM");
477 477
 		$tst = substr($cbuf, $start - 3);
478
-		$result = $this->process_ais_raw( $tst, "" );
478
+		$result = $this->process_ais_raw($tst, "");
479 479
 		return $result;
480 480
 	}
481 481
 
482 482
 	/* AIS Encoding
483 483
 	*/
484
-	private function mk_ais_lat( $lat ) {
484
+	private function mk_ais_lat($lat) {
485 485
 		//$lat = 1.2569;
486
-		if ($lat<0.0) {
486
+		if ($lat < 0.0) {
487 487
 			$lat = -$lat;
488
-			$neg=true;
489
-		} else $neg=false;
488
+			$neg = true;
489
+		} else $neg = false;
490 490
 		$latd = 0x00000000;
491
-		$latd = intval ($lat * 600000.0);
492
-		if ($neg==true) {
491
+		$latd = intval($lat*600000.0);
492
+		if ($neg == true) {
493 493
 			$latd = ~$latd;
494
-			$latd+=1;
494
+			$latd += 1;
495 495
 			$latd &= 0x07FFFFFF;
496 496
 		}
497 497
 		return $latd;
498 498
 	}
499 499
 
500
-	private function mk_ais_lon( $lon ) {
500
+	private function mk_ais_lon($lon) {
501 501
 		//$lon = 103.851;
502
-		if ($lon<0.0) {
502
+		if ($lon < 0.0) {
503 503
 			$lon = -$lon;
504
-			$neg=true;
505
-		} else $neg=false;
504
+			$neg = true;
505
+		} else $neg = false;
506 506
 		$lond = 0x00000000;
507
-		$lond = intval ($lon * 600000.0);
508
-		if ($neg==true) {
507
+		$lond = intval($lon*600000.0);
508
+		if ($neg == true) {
509 509
 			$lond = ~$lond;
510
-			$lond+=1;
510
+			$lond += 1;
511 511
 			$lond &= 0x0FFFFFFF;
512 512
 		}
513 513
 		return $lond;
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
 
516 516
 	private function char2bin($name, $max_len) {
517 517
 		$len = strlen($name);
518
-		if ($len > $max_len) $name = substr($name,0,$max_len);
519
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
518
+		if ($len > $max_len) $name = substr($name, 0, $max_len);
519
+		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6);
520 520
 		else $pad = '';
521 521
 		$rv = '';
522 522
 		$ais_chars = array(
@@ -533,26 +533,26 @@  discard block
 block discarded – undo
533 533
 		if ($_a) foreach ($_a as $_1) {
534 534
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
535 535
 			else $dec = 0;
536
-			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
536
+			$bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT);
537 537
 			$rv .= $bin;
538 538
 			//echo "$_1 $dec ($bin)<br/>";
539 539
 		}
540 540
 		return $rv.$pad;
541 541
 	}
542 542
 
543
-	private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') {
543
+	private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') {
544 544
 		$len_bit = strlen($_enc);
545
-		$rem6 = $len_bit % 6;
545
+		$rem6 = $len_bit%6;
546 546
 		$pad6_len = 0;
547 547
 		if ($rem6) $pad6_len = 6 - $rem6;
548 548
 		//echo  $pad6_len.'<br>';
549 549
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
550
-		$len_enc = strlen($_enc) / 6;
550
+		$len_enc = strlen($_enc)/6;
551 551
 		//echo $_enc.' '.$len_enc.'<br/>';
552 552
 		$itu = '';
553
-		for ($i=0; $i<$len_enc; $i++) {
554
-			$offset = $i * 6;
555
-			$dec = bindec(substr($_enc,$offset,6));
553
+		for ($i = 0; $i < $len_enc; $i++) {
554
+			$offset = $i*6;
555
+			$dec = bindec(substr($_enc, $offset, 6));
556 556
 			if ($dec < 40) $dec += 48;
557 557
 			else $dec += 56;
558 558
 			//echo chr($dec)." $dec<br/>";
@@ -562,15 +562,15 @@  discard block
 block discarded – undo
562 562
 		$chksum = 0;
563 563
 		$itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0";
564 564
 		$len_itu = strlen($itu);
565
-		for ($i=0; $i<$len_itu; $i++) {
566
-			$chksum ^= ord( $itu[$i] );
565
+		for ($i = 0; $i < $len_itu; $i++) {
566
+			$chksum ^= ord($itu[$i]);
567 567
 		}
568
-		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
569
-		$lsb = $chksum & 0x0F;
570
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
568
+		$hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
569
+		$lsb = $chksum&0x0F;
570
+		if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb];
571 571
 		else $lsbc = '0';
572
-		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
573
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
572
+		$msb = (($chksum&0xF0) >> 4)&0x0F;
573
+		if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb];
574 574
 		else $msbc = '0';
575 575
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
576 576
 		return $itu;
@@ -595,14 +595,14 @@  discard block
 block discarded – undo
595 595
 
596 596
 	public function mmsitype($mmsi) {
597 597
 		if (strlen($mmsi) == 9) {
598
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
599
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
600
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
601
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
602
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
603
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
604
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
605
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
598
+			if (substr($mmsi, 0, 3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
599
+			elseif (substr($mmsi, 0, 3) == '972') return 'MOB (Man Overboard) device';
600
+			elseif (substr($mmsi, 0, 3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
601
+			elseif (substr($mmsi, 0, 3) == '111') return 'SAR (Search and Rescue) aircraft';
602
+			elseif (substr($mmsi, 0, 2) == '98') return 'Auxiliary craft associated with a parent ship';
603
+			elseif (substr($mmsi, 0, 2) == '99') return 'Aids to Navigation';
604
+			elseif (substr($mmsi, 0, 2) == '00') return 'Coastal stations';
605
+			elseif (substr($mmsi, 0, 1) == '0') return 'Group of ships';
606 606
 			else return 'Ship';
607 607
 		}
608 608
 
@@ -613,19 +613,19 @@  discard block
 block discarded – undo
613 613
 		global $globalDebug;
614 614
 		$result = array();
615 615
 		$data = new stdClass();
616
-		$start = strpos($buffer,"VDM");
616
+		$start = strpos($buffer, "VDM");
617 617
 		$tst = substr($buffer, $start - 3);
618
-		$data = $this->process_ais_raw( $tst, "" );
618
+		$data = $this->process_ais_raw($tst, "");
619 619
 		if (!is_object($data)) {
620 620
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
621 621
 			return array();
622 622
 		}
623 623
 		if ($data->lon != 0) $result['longitude'] = $data->lon;
624 624
 		if ($data->lat != 0) $result['latitude'] = $data->lat;
625
-		$result['ident'] = trim(str_replace('@','',$data->name));
625
+		$result['ident'] = trim(str_replace('@', '', $data->name));
626 626
 		$result['timestamp'] = $data->ts;
627 627
 		$result['mmsi'] = $data->mmsi;
628
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
628
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'], 0, 3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
629 629
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
630 630
 		if ($data->sog != -1.0) $result['speed'] = $data->sog;
631 631
 		if ($data->heading !== '') $result['heading'] = $data->heading;
@@ -635,16 +635,16 @@  discard block
 block discarded – undo
635 635
 		if ($data->type !== '') $result['type'] = $data->type;
636 636
 		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
637 637
 		if ($data->imo !== '') $result['imo'] = $data->imo;
638
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
638
+		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@', '', $data->callsign));
639 639
 		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 !== '') {
640
-			$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');
640
+			$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');
641 641
 			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
642 642
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
643
-			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
643
+			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00');
644 644
 			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
645 645
 		}
646 646
 		if ($data->destination != '') {
647
-			$dest = trim(str_replace('@','',$data->destination));
647
+			$dest = trim(str_replace('@', '', $data->destination));
648 648
 			if ($dest != '') $result['destination'] = $dest;
649 649
 		}
650 650
 		$result['all'] = (array) $data;
Please login to merge, or discard this patch.
sitemap.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
19 19
 
20 20
 		$spotter_array = $Spotter->getAllFlightsforSitemap();
21
-		foreach($spotter_array as $spotter_item)
21
+		foreach ($spotter_array as $spotter_item)
22 22
 		{
23 23
 			$output .= '<url>';
24 24
 			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/flightid/'.$spotter_item['spotter_id'].'</loc>';
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 	$output .= '</urlset>';
30 30
 	
31 31
 	
32
-} else if (isset($_GET['type']) && $_GET['type'] == "aircraft"){
32
+} else if (isset($_GET['type']) && $_GET['type'] == "aircraft") {
33 33
 
34 34
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
35 35
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
36 36
 		$aircraft_types = $Stats->getAllAircraftTypes();
37 37
 		if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes();
38
-		foreach($aircraft_types as $aircraft_item)
38
+		foreach ($aircraft_types as $aircraft_item)
39 39
 		{
40 40
 			$output .= '<url>';
41 41
 			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/aircraft/'.urlencode($aircraft_item['aircraft_icao']).'</loc>';
@@ -46,13 +46,13 @@  discard block
 block discarded – undo
46 46
 	$output .= '</urlset>';
47 47
 	
48 48
 	
49
-} else if (isset($_GET['type']) && $_GET['type'] == "registration"){
49
+} else if (isset($_GET['type']) && $_GET['type'] == "registration") {
50 50
 
51 51
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
52 52
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
53 53
 
54 54
 		$aircraft_registrations = $Spotter->getAllAircraftRegistrations();
55
-		foreach($aircraft_registrations as $aircraft_item)
55
+		foreach ($aircraft_registrations as $aircraft_item)
56 56
 		{
57 57
 			$output .= '<url>';
58 58
 			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/registration/'.urlencode($aircraft_item['registration']).'</loc>';
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 		}
63 63
 	$output .= '</urlset>';
64 64
 	
65
-} else if (isset($_GET['type']) && $_GET['type'] == "airline"){
65
+} else if (isset($_GET['type']) && $_GET['type'] == "airline") {
66 66
 
67 67
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
68 68
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
69 69
 
70 70
 		$airline_names = $Stats->getAllAirlineNames();
71
-		foreach($airline_names as $airline_item)
71
+		foreach ($airline_names as $airline_item)
72 72
 		{
73 73
 			$output .= '<url>';
74 74
 			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airline/'.urlencode($airline_item['airline_icao']).'</loc>';
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 		}
79 79
 	$output .= '</urlset>';
80 80
 	
81
-} else if (isset($_GET['type']) && $_GET['type'] == "airport"){
81
+} else if (isset($_GET['type']) && $_GET['type'] == "airport") {
82 82
 
83 83
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
84 84
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
85 85
 
86 86
 		$airport_names = $Stats->getAllAirportNames();
87 87
 		if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames();
88
-		foreach($airport_names as $airport_item)
88
+		foreach ($airport_names as $airport_item)
89 89
 		{
90 90
 			$output .= '<url>';
91 91
 			    $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airport/'.$airport_item['airport_icao'].'</loc>';
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 		}
96 96
 	$output .= '</urlset>';
97 97
 	
98
-} else if (isset($_GET['type']) && $_GET['type'] == "manufacturer"){
98
+} else if (isset($_GET['type']) && $_GET['type'] == "manufacturer") {
99 99
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
100 100
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
101 101
 	$manufacturer_names = $Stats->getAllManufacturers();
102 102
 	if (empty($manufacturer_names)) $manufacturer_names = $Spotter->getAllManufacturers();
103
-	foreach($manufacturer_names as $manufacturer_item)
103
+	foreach ($manufacturer_names as $manufacturer_item)
104 104
 	{
105 105
 		$output .= '<url>';
106 106
 		$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/manufacturer/'.urlencode(strtolower(str_replace(" ", "-", $manufacturer_item['aircraft_manufacturer']))).'</loc>';
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 		$output .= '</url>';
110 110
 	}
111 111
 	$output .= '</urlset>';
112
-} else if (isset($_GET['type']) && $_GET['type'] == "country"){
112
+} else if (isset($_GET['type']) && $_GET['type'] == "country") {
113 113
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
114 114
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
115 115
 	$country_names = $Spotter->getAllCountries();
116
-	foreach($country_names as $country_item)
116
+	foreach ($country_names as $country_item)
117 117
 	{
118 118
 		$output .= '<url>';
119 119
 		$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/country/'.urlencode(strtolower(str_replace(" ", "-", $country_item['country']))).'</loc>';
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 		$output .= '</url>';
123 123
 	}
124 124
 	$output .= '</urlset>';
125
-} else if (isset($_GET['type']) && $_GET['type'] == "ident"){
125
+} else if (isset($_GET['type']) && $_GET['type'] == "ident") {
126 126
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
127 127
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
128 128
 	$ident_names = $Spotter->getAllIdents();
129
-	foreach($ident_names as $ident_item)
129
+	foreach ($ident_names as $ident_item)
130 130
 	{
131 131
 		if (ctype_alnum($ident_item['ident'])) {
132 132
 			$output .= '<url>';
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
 		}
138 138
 	}
139 139
 	$output .= '</urlset>';
140
-} else if (isset($_GET['type']) && $_GET['type'] == "marine-ident"){
140
+} else if (isset($_GET['type']) && $_GET['type'] == "marine-ident") {
141 141
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
142 142
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
143 143
 	$ident_names = $Marine->getAllIdents();
144
-	foreach($ident_names as $ident_item)
144
+	foreach ($ident_names as $ident_item)
145 145
 	{
146 146
 		if (ctype_alnum($ident_item['ident'])) {
147 147
 			$output .= '<url>';
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 		}
153 153
 	}
154 154
 	$output .= '</urlset>';
155
-} else if (isset($_GET['type']) && $_GET['type'] == "date"){
155
+} else if (isset($_GET['type']) && $_GET['type'] == "date") {
156 156
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
157 157
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
158 158
 	$date_names = $Spotter->getAllDates();
159
-	foreach($date_names as $date_item)
159
+	foreach ($date_names as $date_item)
160 160
 	{
161 161
 		$output .= '<url>';
162 162
 		$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/date/'.date("Y-m-d", strtotime($date_item['date'])).'</loc>';
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 		$output .= '</url>';
166 166
 	}
167 167
 	$output .= '</urlset>';
168
-} else if (isset($_GET['type']) && $_GET['type'] == "marine-date"){
168
+} else if (isset($_GET['type']) && $_GET['type'] == "marine-date") {
169 169
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
170 170
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
171 171
 	$date_names = $Marine->getAllDates();
172
-	foreach($date_names as $date_item)
172
+	foreach ($date_names as $date_item)
173 173
 	{
174 174
 		$output .= '<url>';
175 175
 		$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/date/'.date("Y-m-d", strtotime($date_item['date'])).'</loc>';
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
 		$output .= '</url>';
179 179
 	}
180 180
 	$output .= '</urlset>';
181
-} else if (isset($_GET['type']) && $_GET['type'] == "route"){
181
+} else if (isset($_GET['type']) && $_GET['type'] == "route") {
182 182
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
183 183
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
184 184
 	$route_names = $Spotter->getAllRoutes();
185
-	foreach($route_names as $route_item)
185
+	foreach ($route_names as $route_item)
186 186
 	{
187 187
 		$output .= '<url>';
188 188
 		$output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/route/'.$route_item['airport_departure_icao'].'/'.$route_item['airport_arrival_icao'].'</loc>';
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 		$output .= '</url>';
192 192
 	}
193 193
 	$output .= '</urlset>';
194
-} else if (isset($_GET['type']) && $_GET['type'] == "static"){
194
+} else if (isset($_GET['type']) && $_GET['type'] == "static") {
195 195
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
196 196
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
197 197
 	/* STATIC PAGES */
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	$output .= '<changefreq>daily</changefreq>';
310 310
 	$output .= '</url>';
311 311
 	$output .= '</urlset>';
312
-} else if (isset($_GET['type']) && $_GET['type'] == "marine-static"){
312
+} else if (isset($_GET['type']) && $_GET['type'] == "marine-static") {
313 313
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
314 314
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
315 315
 	/* STATIC PAGES */
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 	$output .= '<changefreq>daily</changefreq>';
336 336
 	$output .= '</url>';
337 337
 	$output .= '</urlset>';
338
-} else if (isset($_GET['type']) && $_GET['type'] == "tracker-static"){
338
+} else if (isset($_GET['type']) && $_GET['type'] == "tracker-static") {
339 339
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
340 340
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
341 341
 	/* STATIC PAGES */
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Spacing   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
 	    die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
53
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
54 54
     }
55 55
 }
56 56
 
57
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
57
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65 65
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
66
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
67 67
     else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106 106
     if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
107
+    $SI = new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
111 111
     $SI->connect();
112 112
 */
113
-} else $SI=new SpotterImport($Connection->db);
113
+} else $SI = new SpotterImport($Connection->db);
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
     $MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127
-$SBS=new SBS();
127
+$SBS = new SBS();
128 128
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
129
-	$ACARS=new ACARS($Connection->db,true);
130
-	$Source=new Source($Connection->db);
129
+	$ACARS = new ACARS($Connection->db, true);
130
+	$Source = new Source($Connection->db);
131 131
 }
132
-$Common=new Common();
132
+$Common = new Common();
133 133
 date_default_timezone_set('UTC');
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
137
+    pcntl_signal(SIGINT, function() {
138 138
         global $sockets;
139 139
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140 140
         die("Bye!\n");
@@ -150,30 +150,30 @@  discard block
 block discarded – undo
150 150
 
151 151
 function connect_all($hosts) {
152 152
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
153
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
154 154
     $reset++;
155 155
     if ($globalDebug) echo 'Connect to all...'."\n";
156 156
     foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
160
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
+            if (preg_match('/deltadb.txt$/i', $host)) {
162 162
         	//$formats[$id] = 'deltadbtxt';
163 163
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 164
         	//$last_exec['deltadbtxt'] = 0;
165 165
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
166
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
167 167
         	//$formats[$id] = 'vatsimtxt';
168 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 169
         	//$last_exec['vatsimtxt'] = 0;
170 170
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
171
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
172 172
         	//$formats[$id] = 'aircraftlistjson';
173 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 174
         	//$last_exec['aircraftlistjson'] = 0;
175 175
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/opensky/i',$host)) {
176
+    	    } else if (preg_match('/opensky/i', $host)) {
177 177
         	//$formats[$id] = 'aircraftlistjson';
178 178
         	$globalSources[$id]['format'] = 'opensky';
179 179
         	//$last_exec['aircraftlistjson'] = 0;
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
         	    exit(0);
191 191
         	}
192 192
     	    */
193
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
193
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
194 194
         	//$formats[$id] = 'planeupdatefaa';
195 195
         	$globalSources[$id]['format'] = 'planeupdatefaa';
196 196
         	//$last_exec['planeupdatefaa'] = 0;
@@ -199,32 +199,32 @@  discard block
 block discarded – undo
199 199
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200 200
         	    exit(0);
201 201
         	}
202
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
202
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
203 203
         	//$formats[$id] = 'phpvmacars';
204 204
         	$globalSources[$id]['format'] = 'phpvmacars';
205 205
         	//$last_exec['phpvmacars'] = 0;
206 206
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
207
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
207
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
208 208
         	//$formats[$id] = 'phpvmacars';
209 209
         	$globalSources[$id]['format'] = 'vam';
210 210
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
211
-            } else if (preg_match('/whazzup/i',$host)) {
211
+            } else if (preg_match('/whazzup/i', $host)) {
212 212
         	//$formats[$id] = 'whazzup';
213 213
         	$globalSources[$id]['format'] = 'whazzup';
214 214
         	//$last_exec['whazzup'] = 0;
215 215
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
216
-            } else if (preg_match('/blitzortung/i',$host)) {
216
+            } else if (preg_match('/blitzortung/i', $host)) {
217 217
         	$globalSources[$id]['format'] = 'blitzortung';
218 218
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
219
-            } else if (preg_match('/airwhere/i',$host)) {
219
+            } else if (preg_match('/airwhere/i', $host)) {
220 220
         	$globalSources[$id]['format'] = 'airwhere';
221 221
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
222
-            } else if (preg_match('/recentpireps/i',$host)) {
222
+            } else if (preg_match('/recentpireps/i', $host)) {
223 223
         	//$formats[$id] = 'pirepsjson';
224 224
         	$globalSources[$id]['format'] = 'pirepsjson';
225 225
         	//$last_exec['pirepsjson'] = 0;
226 226
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
227
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
227
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
228 228
         	//$formats[$id] = 'fr24json';
229 229
         	$globalSources[$id]['format'] = 'fr24json';
230 230
         	//$last_exec['fr24json'] = 0;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
234 234
         	    exit(0);
235 235
         	}
236
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
236
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
237 237
         	//$formats[$id] = 'fr24json';
238 238
         	$globalSources[$id]['format'] = 'myshiptracking';
239 239
         	//$last_exec['fr24json'] = 0;
@@ -243,22 +243,22 @@  discard block
 block discarded – undo
243 243
         	    exit(0);
244 244
         	}
245 245
             //} else if (preg_match('/10001/',$host)) {
246
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
246
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
247 247
         	//$formats[$id] = 'tsv';
248 248
         	$globalSources[$id]['format'] = 'tsv';
249 249
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
250 250
             }
251
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
251
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
252 252
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
253
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
253
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
254 254
     		    if ($idf !== false) {
255 255
     			$httpfeeds[$id] = $idf;
256 256
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
257 257
     		    }
258 258
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
259 259
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
260
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
261
-	    $hostport = explode(':',$host);
260
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
261
+	    $hostport = explode(':', $host);
262 262
 	    if (isset($hostport[1])) {
263 263
 		$port = $hostport[1];
264 264
 		$hostn = $hostport[0];
@@ -268,19 +268,19 @@  discard block
 block discarded – undo
268 268
 	    }
269 269
 	    $Common = new Common();
270 270
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
271
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
271
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
272 272
     	    } else {
273
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
273
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
274 274
 	    }
275 275
 	    if ($s) {
276 276
     	        $sockets[$id] = $s;
277 277
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
278
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
278
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
279 279
 			//$formats[$id] = 'aprs';
280 280
 			$globalSources[$id]['format'] = 'aprs';
281 281
 			//$aprs_connect = 0;
282 282
 			//$use_aprs = true;
283
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
283
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
284 284
 			$globalSources[$id]['format'] = 'vrstcp';
285 285
     		    } elseif ($port == '10001') {
286 286
         		//$formats[$id] = 'tsv';
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
320 320
 else $timeout = 20;
321 321
 $errno = '';
322
-$errstr='';
322
+$errstr = '';
323 323
 
324 324
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
325 325
 /* Initiate connections to all the hosts simultaneously */
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 //connect_all($globalSources);
328 328
 
329 329
 if (isset($globalProxy) && $globalProxy) {
330
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
330
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
331 331
 } else {
332 332
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
333 333
 }
@@ -357,16 +357,16 @@  discard block
 block discarded – undo
357 357
 
358 358
 if ($use_aprs) {
359 359
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
360
-	$APRS=new APRS();
360
+	$APRS = new APRS();
361 361
 	$aprs_connect = 0;
362 362
 	$aprs_keep = 120;
363 363
 	$aprs_last_tx = time();
364 364
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
365
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
365
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
366 366
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
367
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
367
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
368 368
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
369
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
369
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
370 370
 	if ($aprs_full) $aprs_filter = '';
371 371
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
372 372
 	else $aprs_pass = '-1';
@@ -380,12 +380,12 @@  discard block
 block discarded – undo
380 380
 sleep(1);
381 381
 if ($globalDebug) echo "SCAN MODE \n\n";
382 382
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
383
-$endtime = time()+$globalCronEnd;
383
+$endtime = time() + $globalCronEnd;
384 384
 $i = 1;
385 385
 $tt = array();
386 386
 // Delete all ATC
387 387
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
388
-	$ATC=new ATC($Connection->db);
388
+	$ATC = new ATC($Connection->db);
389 389
 }
390 390
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
391 391
 	$ATC->deleteAll();
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 
394 394
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
395 395
 while ($i > 0) {
396
-    if (!$globalDaemon) $i = $endtime-time();
396
+    if (!$globalDaemon) $i = $endtime - time();
397 397
     // Delete old ATC
398 398
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
399 399
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	}
408 408
 	if ($max != $globalMinFetch) {
409 409
 	    if ($globalDebug) echo 'Sleeping...'."\n";
410
-	    sleep($globalMinFetch-$max+2);
410
+	    sleep($globalMinFetch - $max + 2);
411 411
 	}
412 412
     }
413 413
 
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
 	    //$buffer = $Common->getData($hosts[$id]);
427 427
 	    $buffer = $Common->getData($value['host']);
428 428
 	    if ($buffer != '') $reset = 0;
429
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
430
-	    $buffer = explode('\n',$buffer);
429
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
430
+	    $buffer = explode('\n', $buffer);
431 431
 	    foreach ($buffer as $line) {
432 432
     		if ($line != '' && count($line) > 7) {
433 433
     		    $line = explode(',', $line);
@@ -460,11 +460,11 @@  discard block
 block discarded – undo
460 460
 	    )
461 461
 	) {
462 462
 	    date_default_timezone_set('CET');
463
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
463
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
464 464
 	    date_default_timezone_set('UTC');
465 465
 	    if ($buffer != '') $reset = 0;
466
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
467
-	    $buffer = explode('\n',$buffer);
466
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
467
+	    $buffer = explode('\n', $buffer);
468 468
 	    foreach ($buffer as $line) {
469 469
 		if ($line != '') {
470 470
 		    //echo "'".$line."'\n";
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
483 483
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
484 484
 		    if (isset($ais_data['timestamp'])) {
485
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
485
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
486 486
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
487 487
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
488 488
 			    $add = true;
@@ -505,15 +505,15 @@  discard block
 block discarded – undo
505 505
 	    $w = $e = null;
506 506
 	    
507 507
 	    if (isset($arr[$id])) {
508
-		$nn = stream_select($arr,$w,$e,$timeout);
508
+		$nn = stream_select($arr, $w, $e, $timeout);
509 509
 		if ($nn > 0) {
510 510
 		    foreach ($httpfeeds as $feed) {
511
-			$buffer = stream_get_line($feed,2000,"\n");
511
+			$buffer = stream_get_line($feed, 2000, "\n");
512 512
 			if ($buffer === FALSE) {
513 513
 			    connect_all($globalSources);
514 514
 			}
515
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
516
-			$buffer = explode('\n',$buffer);
515
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
516
+			$buffer = explode('\n', $buffer);
517 517
 			foreach ($buffer as $line) {
518 518
 			    if ($line != '') {
519 519
 				$ais_data = $AIS->parse_line(trim($line));
@@ -531,9 +531,9 @@  discard block
 block discarded – undo
531 531
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
532 532
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
533 533
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
534
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
534
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
535 535
 				if (isset($ais_data['timestamp'])) {
536
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
536
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
537 537
 				} else {
538 538
 				    $data['datetime'] = date('Y-m-d H:i:s');
539 539
 				}
@@ -565,10 +565,10 @@  discard block
 block discarded – undo
565 565
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
566 566
 	    )
567 567
 	) {
568
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
568
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
569 569
 	    if ($buffer != '') {
570 570
 		//echo $buffer;
571
-		$all_data = json_decode($buffer,true);
571
+		$all_data = json_decode($buffer, true);
572 572
 		//print_r($all_data);
573 573
 		if (isset($all_data[0]['DATA'])) {
574 574
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 			    $data['ident'] = $line['NAME'];
578 578
 			    $data['mmsi'] = $line['MMSI'];
579 579
 			    if (strlen($data['mmsi']) > 9) {
580
-				$data['mmsi'] = substr($data['mmsi'],-9);
580
+				$data['mmsi'] = substr($data['mmsi'], -9);
581 581
 			    }
582 582
 			    $data['speed'] = $line['SOG'];
583 583
 			    $data['heading'] = $line['COG'];
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
587 587
 			    $data['imo'] = $line['IMO'];
588 588
 			    //$data['arrival_code'] = $ais_data['destination'];
589
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
589
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
590 590
 			    $data['format_source'] = 'myshiptracking';
591 591
 			    $data['id_source'] = $id_source;
592 592
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -603,9 +603,9 @@  discard block
 block discarded – undo
603 603
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
604 604
 	    )
605 605
 	) {
606
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
606
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
607 607
 	    if ($buffer != '') {
608
-		$all_data = json_decode($buffer,true);
608
+		$all_data = json_decode($buffer, true);
609 609
 		if (isset($all_data[0]['mmsi'])) {
610 610
 		    foreach ($all_data as $line) {
611 611
 			if ($line != '') {
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 	) {
640 640
 	    $buffer = $Common->getData($value['host']);
641 641
 	    if ($buffer != '') {
642
-		$all_data = json_decode($buffer,true);
642
+		$all_data = json_decode($buffer, true);
643 643
 		if (isset($all_data['features'][0]['id'])) {
644 644
 		    foreach ($all_data['features'] as $line) {
645 645
 			$data = array();
@@ -672,27 +672,27 @@  discard block
 block discarded – undo
672 672
 	    )
673 673
 	) {
674 674
 	    echo 'download...';
675
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
675
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
676 676
 	    echo 'done !'."\n";
677 677
 	    if ($buffer != '') $reset = 0;
678
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
679
-	    $buffer = explode('\n',$buffer);
678
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
679
+	    $buffer = explode('\n', $buffer);
680 680
 	    foreach ($buffer as $line) {
681 681
 		if ($line != '') {
682 682
 		    $data = array();
683
-		    $data['mmsi'] = (int)substr($line,0,9);
684
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
683
+		    $data['mmsi'] = (int) substr($line, 0, 9);
684
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
685 685
 		    //$data['status'] = substr($line,21,2);
686 686
 		    //$data['type'] = substr($line,24,3);
687
-		    $data['latitude'] = substr($line,29,9);
688
-		    $data['longitude'] = substr($line,41,9);
689
-		    $data['speed'] = round(substr($line,51,5));
687
+		    $data['latitude'] = substr($line, 29, 9);
688
+		    $data['longitude'] = substr($line, 41, 9);
689
+		    $data['speed'] = round(substr($line, 51, 5));
690 690
 		    //$data['course'] = substr($line,57,5);
691
-		    $data['heading'] = round(substr($line,63,3));
691
+		    $data['heading'] = round(substr($line, 63, 3));
692 692
 		    //$data['draft'] = substr($line,67,4);
693 693
 		    //$data['length'] = substr($line,72,3);
694 694
 		    //$data['beam'] = substr($line,76,2);
695
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
695
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
696 696
 		    //$data['callsign'] = trim(substr($line,100,7);
697 697
 		    //$data['dest'] = substr($line,108,20);
698 698
 		    //$data['etaDate'] = substr($line,129,5);
@@ -725,8 +725,8 @@  discard block
 block discarded – undo
725 725
 	) {
726 726
 	    //$buffer = $Common->getData($hosts[$id]);
727 727
 	    $buffer = $Common->getData($value['host']);
728
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
729
-	    $buffer = explode('\n',$buffer);
728
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
729
+	    $buffer = explode('\n', $buffer);
730 730
 	    $reset = 0;
731 731
 	    foreach ($buffer as $line) {
732 732
     		if ($line != '') {
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
738 738
 			$data['pilot_id'] = $line[1];
739 739
 			$data['pilot_name'] = $line[2];
740
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
740
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
741 741
 			$data['ident'] = $line[0]; // ident
742 742
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
743 743
 			$data['speed'] = $line[8]; // speed
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
754 754
 			//if (isset($line[37])) $data['last_update'] = $line[37];
755 755
 		        $data['departure_airport_icao'] = $line[11];
756
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
756
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
757 757
 		        $data['arrival_airport_icao'] = $line[13];
758 758
 			$data['frequency'] = $line[4];
759 759
 			$data['type'] = $line[18];
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
     			$data['id_source'] = $id_source;
763 763
 	    		//$data['arrival_airport_time'] = ;
764 764
 	    		if ($line[9] != '') {
765
-	    		    $aircraft_data = explode('/',$line[9]);
765
+	    		    $aircraft_data = explode('/', $line[9]);
766 766
 	    		    if (isset($aircraft_data[1])) {
767 767
 	    			$data['aircraft_icao'] = $aircraft_data[1];
768 768
 	    		    }
@@ -777,9 +777,9 @@  discard block
 block discarded – undo
777 777
     			if ($line[3] == 'PILOT') $SI->add($data);
778 778
 			elseif ($line[3] == 'ATC') {
779 779
 				//print_r($data);
780
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
781
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
782
-				$typec = substr($data['ident'],-3);
780
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
781
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
782
+				$typec = substr($data['ident'], -3);
783 783
 				if ($typec == 'APP') $data['type'] = 'Approach';
784 784
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
785 785
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -791,8 +791,8 @@  discard block
 block discarded – undo
791 791
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
792 792
 				if (!isset($data['source_name'])) $data['source_name'] = '';
793 793
 				if (isset($ATC)) {
794
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
795
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
794
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
795
+					else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
796 796
 				}
797 797
 			}
798 798
     			unset($data);
@@ -808,24 +808,24 @@  discard block
 block discarded – undo
808 808
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
809 809
     	    )
810 810
     	) {
811
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
811
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
812 812
 	    if ($buffer != '') {
813 813
 		$all_data = simplexml_load_string($buffer);
814
-		foreach($all_data->children() as $childdata) {
814
+		foreach ($all_data->children() as $childdata) {
815 815
 			$data = array();
816 816
 			$line = $childdata;
817 817
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
818
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
819
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
820
-			$data['latitude'] = (float)$line['pktLatitude'];
821
-			$data['longitude'] = (float)$line['pktLongitude'];
822
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
823
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
824
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
818
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
819
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
820
+			$data['latitude'] = (float) $line['pktLatitude'];
821
+			$data['longitude'] = (float) $line['pktLongitude'];
822
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
823
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
824
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
825 825
 			$data['altitude_relative'] = 'AMSL';
826
-			$data['pilot_id'] = (int)$line['pktPilotID'];
826
+			$data['pilot_id'] = (int) $line['pktPilotID'];
827 827
 			$data['aircraft_icao'] = 'PARAGLIDER';
828
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
828
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
829 829
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
830 830
 			$data['format_source'] = $value['format'];
831 831
 			$SI->add($data);
@@ -833,22 +833,22 @@  discard block
 block discarded – undo
833 833
 		}
834 834
 	    }
835 835
 	    $Source->deleteOldLocationByType('gs');
836
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
836
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
837 837
 	    if ($buffer != '') {
838 838
 		$all_data = simplexml_load_string($buffer);
839
-		foreach($all_data->children() as $childdata) {
839
+		foreach ($all_data->children() as $childdata) {
840 840
 			$data = array();
841 841
 			$line = $childdata;
842
-			$data['id'] = (int)$line['gsID'];
843
-			$data['latitude'] = (float)$line['gsLatitude'];
844
-			$data['longitude'] = (float)$line['gsLongitude'];
845
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
842
+			$data['id'] = (int) $line['gsID'];
843
+			$data['latitude'] = (float) $line['gsLatitude'];
844
+			$data['longitude'] = (float) $line['gsLongitude'];
845
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
846 846
 			$data['altitude_relative'] = 'AMSL';
847
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
847
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
848 848
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
849
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
849
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
850 850
 			} else {
851
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
851
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
852 852
 			}
853 853
 			unset($data);
854 854
 		}
@@ -866,9 +866,9 @@  discard block
 block discarded – undo
866 866
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
867 867
 	    )
868 868
 	) {
869
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
869
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
870 870
 	    if ($buffer != '') {
871
-	        $all_data = json_decode($buffer,true);
871
+	        $all_data = json_decode($buffer, true);
872 872
 		if (isset($all_data['acList'])) {
873 873
 		    $reset = 0;
874 874
 		    foreach ($all_data['acList'] as $line) {
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
885 885
 			$data['emergency'] = ''; // emergency
886 886
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
887
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
887
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
888 888
 			else $data['datetime'] = date('Y-m-d H:i:s');
889 889
 			//$data['datetime'] = date('Y-m-d H:i:s');
890 890
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 			$data['verticalrate'] = $line['vrt']; // verticale rate
910 910
 			$data['squawk'] = $line['squawk']; // squawk
911 911
 			$data['emergency'] = ''; // emergency
912
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
912
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
913 913
 			else $data['datetime'] = date('Y-m-d H:i:s');
914 914
 			$data['format_source'] = 'aircraftlistjson';
915 915
 			$data['id_source'] = $id_source;
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
     	    )
931 931
     	) {
932 932
 	    $buffer = $Common->getData($value['host']);
933
-	    $all_data = json_decode($buffer,true);
933
+	    $all_data = json_decode($buffer, true);
934 934
 	    if (isset($all_data['planes'])) {
935 935
 		$reset = 0;
936 936
 		foreach ($all_data['planes'] as $key => $line) {
@@ -947,12 +947,12 @@  discard block
 block discarded – undo
947 947
 		    $data['emergency'] = ''; // emergency
948 948
 		    $data['registration'] = $line[2];
949 949
 		    $data['aircraft_icao'] = $line[0];
950
-		    $deparr = explode('-',$line[1]);
950
+		    $deparr = explode('-', $line[1]);
951 951
 		    if (count($deparr) == 2) {
952 952
 			$data['departure_airport_icao'] = $deparr[0];
953 953
 			$data['arrival_airport_icao'] = $deparr[1];
954 954
 		    }
955
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
955
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
956 956
 	    	    $data['format_source'] = 'planeupdatefaa';
957 957
     		    $data['id_source'] = $id_source;
958 958
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
 	    )
971 971
 	) {
972 972
 	    $buffer = $Common->getData($value['host']);
973
-	    $all_data = json_decode($buffer,true);
973
+	    $all_data = json_decode($buffer, true);
974 974
 	    if (isset($all_data['states'])) {
975 975
 		$reset = 0;
976 976
 		foreach ($all_data['states'] as $key => $line) {
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 		    //$data['emergency'] = ''; // emergency
988 988
 		    //$data['registration'] = $line[2];
989 989
 		    //$data['aircraft_icao'] = $line[0];
990
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
990
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
991 991
 		    $data['format_source'] = 'opensky';
992 992
 		    $data['id_source'] = $id_source;
993 993
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 	) {
1007 1007
 	    //$buffer = $Common->getData($hosts[$id]);
1008 1008
 	    $buffer = $Common->getData($value['host']);
1009
-	    $all_data = json_decode($buffer,true);
1009
+	    $all_data = json_decode($buffer, true);
1010 1010
 	    if (!empty($all_data)) $reset = 0;
1011 1011
 	    foreach ($all_data as $key => $line) {
1012 1012
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1044,11 +1044,11 @@  discard block
 block discarded – undo
1044 1044
 	    )
1045 1045
 	) {
1046 1046
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1047
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1047
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1048 1048
 	    //echo $buffer;
1049
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1050
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1051
-	    $all_data = json_decode($buffer,true);
1049
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1050
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1051
+	    $all_data = json_decode($buffer, true);
1052 1052
 	    if (json_last_error() != JSON_ERROR_NONE) {
1053 1053
 		die(json_last_error_msg());
1054 1054
 	    }
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 			//$data['departure_airport_iata'] = $line[11];
1072 1072
 			//$data['arrival_airport_iata'] = $line[12];
1073 1073
 	    		//$data['emergency'] = ''; // emergency
1074
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1074
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1075 1075
 	    		$data['format_source'] = 'radarvirtueljson';
1076 1076
     			$data['id_source'] = $id_source;
1077 1077
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1092,14 +1092,14 @@  discard block
 block discarded – undo
1092 1092
 	) {
1093 1093
 	    //$buffer = $Common->getData($hosts[$id]);
1094 1094
 	    $buffer = $Common->getData($value['host'].'?'.time());
1095
-	    $all_data = json_decode(utf8_encode($buffer),true);
1095
+	    $all_data = json_decode(utf8_encode($buffer), true);
1096 1096
 	    
1097 1097
 	    if (isset($all_data['pireps'])) {
1098 1098
 		$reset = 0;
1099 1099
 	        foreach ($all_data['pireps'] as $line) {
1100 1100
 		    $data = array();
1101 1101
 		    $data['id'] = $line['id'];
1102
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1102
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1103 1103
 		    $data['ident'] = $line['callsign']; // ident
1104 1104
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1105 1105
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1129,9 +1129,9 @@  discard block
 block discarded – undo
1129 1129
 			$SI->add($data);
1130 1130
 		    //    print_r($data);
1131 1131
     		    } elseif ($line['icon'] == 'ct') {
1132
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1133
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1134
-			$typec = substr($data['ident'],-3);
1132
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1133
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1134
+			$typec = substr($data['ident'], -3);
1135 1135
 			$data['type'] = '';
1136 1136
 			if ($typec == 'APP') $data['type'] = 'Approach';
1137 1137
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1143 1143
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1144 1144
 			else $data['type'] = 'Observer';
1145
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1145
+			if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
1146 1146
 		    }
1147 1147
 		    unset($data);
1148 1148
 		}
@@ -1159,14 +1159,14 @@  discard block
 block discarded – undo
1159 1159
 	    //$buffer = $Common->getData($hosts[$id]);
1160 1160
 	    if ($globalDebug) echo 'Get Data...'."\n";
1161 1161
 	    $buffer = $Common->getData($value['host']);
1162
-	    $all_data = json_decode($buffer,true);
1162
+	    $all_data = json_decode($buffer, true);
1163 1163
 	    if ($buffer != '' && is_array($all_data)) {
1164 1164
 		$reset = 0;
1165 1165
 		foreach ($all_data as $line) {
1166 1166
 	    	    $data = array();
1167 1167
 	    	    //$data['id'] = $line['id']; // id not usable
1168 1168
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1169
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1169
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1170 1170
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1171 1171
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1172 1172
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 	    	    //$data['datetime'] = $line['lastupdate'];
1182 1182
 	    	    //$data['last_update'] = $line['lastupdate'];
1183 1183
 	    	    if (isset($value['timezone'])) {
1184
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1184
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1185 1185
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1186 1186
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1187 1187
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1194,14 +1194,14 @@  discard block
 block discarded – undo
1194 1194
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1195 1195
 		    if (isset($line['aircraftname'])) {
1196 1196
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1197
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1198
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1197
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1198
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1199 1199
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1200 1200
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1201 1201
 	    		else {
1202
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1203
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1204
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1202
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1203
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1204
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1205 1205
 	    		}
1206 1206
 	    	    }
1207 1207
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1226,14 +1226,14 @@  discard block
 block discarded – undo
1226 1226
 	    //$buffer = $Common->getData($hosts[$id]);
1227 1227
 	    if ($globalDebug) echo 'Get Data...'."\n";
1228 1228
 	    $buffer = $Common->getData($value['host']);
1229
-	    $all_data = json_decode($buffer,true);
1229
+	    $all_data = json_decode($buffer, true);
1230 1230
 	    if ($buffer != '' && is_array($all_data)) {
1231 1231
 		$reset = 0;
1232 1232
 		foreach ($all_data as $line) {
1233 1233
 	    	    $data = array();
1234 1234
 	    	    //$data['id'] = $line['id']; // id not usable
1235 1235
 	    	    $data['id'] = trim($line['flight_id']);
1236
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1236
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1237 1237
 	    	    $data['pilot_name'] = $line['pilot_name'];
1238 1238
 	    	    $data['pilot_id'] = $line['pilot_id'];
1239 1239
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1277,24 +1277,24 @@  discard block
 block discarded – undo
1277 1277
 	    //$buffer = $Common->getData($hosts[$id]);
1278 1278
 	    if ($globalDebug) echo 'Get Data...'."\n";
1279 1279
 	    $buffer = $Common->getData($value['host']);
1280
-	    $all_data = json_decode($buffer,true);
1280
+	    $all_data = json_decode($buffer, true);
1281 1281
 	    if ($buffer != '') {
1282 1282
 		$Source->deleteLocationBySource('blitzortung');
1283
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1284
-		$buffer = explode('\n',$buffer);
1283
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1284
+		$buffer = explode('\n', $buffer);
1285 1285
 		foreach ($buffer as $buffer_line) {
1286
-		    $line = json_decode($buffer_line,true);
1286
+		    $line = json_decode($buffer_line, true);
1287 1287
 		    if (isset($line['time'])) {
1288 1288
 			$data = array();
1289 1289
 			$data['altitude'] = $line['alt']; // altitude
1290 1290
 			$data['latitude'] = $line['lat']; // lat
1291 1291
 			$data['longitude'] = $line['lon']; // long
1292
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1292
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1293 1293
 			$data['id_source'] = $id_source;
1294 1294
 			$data['format_source'] = 'blitzortung';
1295 1295
 			$SI->add($data);
1296 1296
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1297
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1297
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1298 1298
 			unset($data);
1299 1299
 		    }
1300 1300
 		}
@@ -1319,11 +1319,11 @@  discard block
 block discarded – undo
1319 1319
 		    //$value = $formats[$nb];
1320 1320
 		    $format = $globalSources[$nb]['format'];
1321 1321
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1322
-			$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
1322
+			$buffer = socket_read($r, 6000, PHP_NORMAL_READ);
1323 1323
 		    } elseif ($format == 'vrstcp') {
1324 1324
 			$buffer = socket_read($r, 6000);
1325 1325
 		    } else {
1326
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1326
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1327 1327
 		    }
1328 1328
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1329 1329
 		    //echo $buffer."\n";
@@ -1333,8 +1333,8 @@  discard block
 block discarded – undo
1333 1333
 		    //$SI::del();
1334 1334
 		    if ($buffer !== FALSE) {
1335 1335
 			if ($format == 'vrstcp') {
1336
-			    $buffer = explode('},{',$buffer);
1337
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1336
+			    $buffer = explode('},{', $buffer);
1337
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1338 1338
 		    }
1339 1339
 		    // SBS format is CSV format
1340 1340
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1369,13 +1369,13 @@  discard block
 block discarded – undo
1369 1369
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1370 1370
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1371 1371
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1372
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1372
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1373 1373
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1374 1374
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1375 1375
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1376 1376
 
1377 1377
 			    if (isset($ais_data['timestamp'])) {
1378
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1378
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1379 1379
 			    } else {
1380 1380
 				$data['datetime'] = date('Y-m-d H:i:s');
1381 1381
 			    }
@@ -1386,10 +1386,10 @@  discard block
 block discarded – undo
1386 1386
                         } elseif ($format == 'flightgearsp') {
1387 1387
                     	    //echo $buffer."\n";
1388 1388
                     	    if (strlen($buffer) > 5) {
1389
-				$line = explode(',',$buffer);
1389
+				$line = explode(',', $buffer);
1390 1390
 				$data = array();
1391 1391
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1392
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1392
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1393 1393
 				$data['ident'] = $line[6];
1394 1394
 				$data['aircraft_name'] = $line[7];
1395 1395
 				$data['longitude'] = $line[1];
@@ -1406,16 +1406,16 @@  discard block
 block discarded – undo
1406 1406
                         } elseif ($format == 'acars') {
1407 1407
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1408 1408
 			    $ACARS->add(trim($buffer));
1409
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1409
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1410 1410
 			    $ACARS->deleteLiveAcarsData();
1411 1411
 			} elseif ($format == 'flightgearmp') {
1412
-			    if (substr($buffer,0,1) != '#') {
1412
+			    if (substr($buffer, 0, 1) != '#') {
1413 1413
 				$data = array();
1414 1414
 				//echo $buffer."\n";
1415
-				$line = explode(' ',$buffer);
1415
+				$line = explode(' ', $buffer);
1416 1416
 				if (count($line) == 11) {
1417
-				    $userserver = explode('@',$line[0]);
1418
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1417
+				    $userserver = explode('@', $line[0]);
1418
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1419 1419
 				    $data['ident'] = $userserver[0];
1420 1420
 				    $data['registration'] = $userserver[0];
1421 1421
 				    $data['latitude'] = $line[4];
@@ -1423,8 +1423,8 @@  discard block
 block discarded – undo
1423 1423
 				    $data['altitude'] = $line[6];
1424 1424
 				    $data['datetime'] = date('Y-m-d H:i:s');
1425 1425
 				    $aircraft_type = $line[10];
1426
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1427
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1426
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1427
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1428 1428
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1429 1429
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1430 1430
 				}
@@ -1433,8 +1433,8 @@  discard block
 block discarded – undo
1433 1433
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1434 1434
 			    die;
1435 1435
 			} elseif ($format == 'vrstcp') {
1436
-			    foreach($buffer as $all_data) {
1437
-				$line = json_decode('{'.$all_data.'}',true);
1436
+			    foreach ($buffer as $all_data) {
1437
+				$line = json_decode('{'.$all_data.'}', true);
1438 1438
 				$data = array();
1439 1439
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1440 1440
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1460,16 +1460,16 @@  discard block
 block discarded – undo
1460 1460
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1461 1461
 				unset($data);
1462 1462
 			    }
1463
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1463
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1464 1464
 			    $line = explode("\t", $buffer);
1465
-			    for($k = 0; $k < count($line); $k=$k+2) {
1465
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1466 1466
 				$key = $line[$k];
1467
-			        $lined[$key] = $line[$k+1];
1467
+			        $lined[$key] = $line[$k + 1];
1468 1468
 			    }
1469 1469
     			    if (count($lined) > 3) {
1470 1470
     				$data['hex'] = $lined['hexid'];
1471 1471
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1472
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1472
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1473 1473
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1474 1474
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1475 1475
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1488,23 +1488,23 @@  discard block
 block discarded – undo
1488 1488
     			    } else $error = true;
1489 1489
 			} elseif ($format == 'aprs' && $use_aprs) {
1490 1490
 			    if ($aprs_connect == 0) {
1491
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1491
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1492 1492
 				$aprs_connect = 1;
1493 1493
 			    }
1494 1494
 			    
1495
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1495
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1496 1496
 				$aprs_last_tx = time();
1497 1497
 				$data_aprs = "# Keep alive";
1498
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1498
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1499 1499
 			    }
1500 1500
 			    
1501 1501
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1502 1502
 			    //echo 'APRS data : '.$buffer."\n";
1503
-			    $buffer = str_replace('APRS <- ','',$buffer);
1504
-			    $buffer = str_replace('APRS -> ','',$buffer);
1503
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1504
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1505 1505
 			    //echo $buffer."\n";
1506 1506
 			    date_default_timezone_set('UTC');
1507
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1507
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1508 1508
 				$line = $APRS->parse($buffer);
1509 1509
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1510 1510
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1519,7 +1519,7 @@  discard block
 block discarded – undo
1519 1519
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1520 1520
 				    //if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1521 1521
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1522
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1522
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1523 1523
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1524 1524
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1525 1525
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1601,29 +1601,29 @@  discard block
 block discarded – undo
1601 1601
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1602 1602
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1603 1603
 					$Source->deleteOldLocationByType('gs');
1604
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1605
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1604
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1605
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1606 1606
 					} else {
1607
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1607
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1608 1608
 					}
1609 1609
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1610 1610
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1611 1611
 					if ($globalDebug) echo '# Weather Station added'."\n";
1612 1612
 					$Source->deleteOldLocationByType('wx');
1613 1613
 					$weather_data = json_encode($line);
1614
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1615
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1614
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1615
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1616 1616
 					} else {
1617
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1617
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1618 1618
 					}
1619 1619
 				    } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1620 1620
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1621 1621
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1622 1622
 					$Source->deleteOldLocationByType('lightning');
1623
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1624
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1623
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1624
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1625 1625
 					} else {
1626
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1626
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1627 1627
 					}
1628 1628
 				    } elseif ($globalDebug) {
1629 1629
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
 				    unset($data);
1633 1633
 				}
1634 1634
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1635
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1635
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1636 1636
 				}
1637 1637
 				/*
1638 1638
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
@@ -1641,7 +1641,7 @@  discard block
 block discarded – undo
1641 1641
 				*/
1642 1642
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1643 1643
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1644
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1644
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1645 1645
 					$Source->deleteOldLocationByType('lightning');
1646 1646
 					$Source->deleteOldLocationByType('wx');
1647 1647
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
 				connect_all($sourceee);
1727 1727
 				$sourceee = array();
1728 1728
 				//connect_all($globalSources);
1729
-				$tt[$format]=0;
1729
+				$tt[$format] = 0;
1730 1730
 				break;
1731 1731
 			    }
1732 1732
 			}
@@ -1735,14 +1735,14 @@  discard block
 block discarded – undo
1735 1735
 	    } else {
1736 1736
 		$error = socket_strerror(socket_last_error());
1737 1737
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1738
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1738
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1739 1739
 			if (isset($globalDebug)) echo "Restarting...\n";
1740 1740
 			// Restart the script if possible
1741 1741
 			if (is_array($sockets)) {
1742 1742
 			    if ($globalDebug) echo "Shutdown all sockets...";
1743 1743
 			    
1744 1744
 			    foreach ($sockets as $sock) {
1745
-				@socket_shutdown($sock,2);
1745
+				@socket_shutdown($sock, 2);
1746 1746
 				@socket_close($sock);
1747 1747
 			    }
1748 1748
 			    
Please login to merge, or discard this patch.