Completed
Push — master ( 31d65f...71c11a )
by Yannick
08:06
created
require/class.APRS.php 1 patch
Spacing   +95 added lines, -96 removed lines patch added patch discarded remove patch
@@ -90,8 +90,7 @@  discard block
 block discarded – undo
90 90
 	
91 91
 
92 92
     private function urshift($n, $s) {
93
-	return ($n >= 0) ? ($n >> $s) :
94
-	    (($n & 0x7fffffff) >> $s) | 
93
+	return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
95 94
 		(0x40000000 >> ($s - 1));
96 95
     }
97 96
 
@@ -103,7 +102,7 @@  discard block
 block discarded – undo
103 102
 	//$split_input = str_split($input);
104 103
 
105 104
 	/* Find the end of header checking for NULL bytes while doing it. */
106
-	$splitpos = strpos($input,':');
105
+	$splitpos = strpos($input, ':');
107 106
 	
108 107
 	/* Check that end was found and body has at least one byte. */
109 108
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -113,15 +112,15 @@  discard block
 block discarded – undo
113 112
 	
114 113
 	if ($debug) echo 'input : '.$input."\n";
115 114
 	/* Save header and body. */
116
-	$body = substr($input,$splitpos+1,$input_len);
115
+	$body = substr($input, $splitpos + 1, $input_len);
117 116
 	$body_len = strlen($body);
118
-	$header = substr($input,0,$splitpos);
117
+	$header = substr($input, 0, $splitpos);
119 118
 	//$header_len = strlen($header);
120 119
 	if ($debug) echo 'header : '.$header."\n";
121 120
 	
122 121
 	/* Parse source, target and path. */
123 122
 	//FLRDF0A52>APRS,qAS,LSTB
124
-	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
123
+	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
125 124
 	    $ident = $matches[1];
126 125
 	    $all_elements = $matches[2];
127 126
 	    if ($ident == 'AIRCRAFT') {
@@ -135,14 +134,14 @@  discard block
 block discarded – undo
135 134
 		$result['ident'] = $ident;
136 135
 	    }
137 136
 	} else return false;
138
-	$elements = explode(',',$all_elements);
137
+	$elements = explode(',', $all_elements);
139 138
 	$source = end($elements);
140 139
 	$result['source'] = $source;
141 140
 	foreach ($elements as $element) {
142
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
141
+	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
143 142
 	        //echo "ok";
144 143
 	        //if ($element == 'TCPIP*') return false;
145
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
144
+	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
146 145
 		if ($debug) echo 'element : '.$element."\n";
147 146
 		return false;
148 147
 	    }
@@ -155,12 +154,12 @@  discard block
 block discarded – undo
155 154
 	    */
156 155
 	}
157 156
 	
158
-	$type = substr($body,0,1);
157
+	$type = substr($body, 0, 1);
159 158
 	if ($debug) echo 'type : '.$type."\n";
160 159
 	if ($type == ';') {
161 160
 		if (isset($result['source_type']) && $result['source_type'] == 'sbs') {
162
-			$result['address'] = trim(substr($body,1,9));
163
-		} else $result['ident'] = trim(substr($body,1,9));
161
+			$result['address'] = trim(substr($body, 1, 9));
162
+		} else $result['ident'] = trim(substr($body, 1, 9));
164 163
 	} elseif ($type == ',') {
165 164
 		// Invalid data or test data
166 165
 		return false;
@@ -168,24 +167,24 @@  discard block
 block discarded – undo
168 167
 	
169 168
 	// Check for Timestamp
170 169
 	$find = false;
171
-	$body_parse = substr($body,1);
170
+	$body_parse = substr($body, 1);
172 171
 	//echo 'Body : '.$body."\n";
173
-	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
174
-	    $body_parse = substr($body_parse,10);
172
+	if (preg_match('/^;(.){9}\*/', $body, $matches)) {
173
+	    $body_parse = substr($body_parse, 10);
175 174
 	    $find = true;
176 175
 	    //echo $body_parse."\n";
177 176
 	}
178
-	if (preg_match('/^`(.*)\//',$body,$matches)) {
179
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
177
+	if (preg_match('/^`(.*)\//', $body, $matches)) {
178
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
180 179
 	    $find = true;
181 180
 	    //echo $body_parse."\n";
182 181
 	}
183
-	if (preg_match("/^'(.*)\//",$body,$matches)) {
184
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
182
+	if (preg_match("/^'(.*)\//", $body, $matches)) {
183
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
185 184
 	    $find = true;
186 185
 	    //echo $body_parse."\n";
187 186
 	}
188
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
187
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
189 188
 	    $find = true;
190 189
 	    //print_r($matches);
191 190
 	    $timestamp = $matches[0];
@@ -200,19 +199,19 @@  discard block
 block discarded – undo
200 199
 		// This work or not ?
201 200
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
202 201
 	    }
203
-	    $body_parse = substr($body_parse,7);
202
+	    $body_parse = substr($body_parse, 7);
204 203
 	    $result['timestamp'] = $timestamp;
205 204
 	    //echo date('Ymd H:i:s',$timestamp);
206 205
 	}
207
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
206
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
208 207
 	    $find = true;
209 208
 	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
210
-	    $body_parse = substr($body_parse,8);
209
+	    $body_parse = substr($body_parse, 8);
211 210
 	    $result['timestamp'] = $timestamp;
212 211
 	    //echo date('Ymd H:i:s',$timestamp);
213 212
 	}
214 213
 	//if (strlen($body_parse) > 19) {
215
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
214
+	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
216 215
 	    $find = true;
217 216
 		// 4658.70N/00707.78Ez
218 217
 		//print_r(str_split($body_parse));
@@ -238,11 +237,11 @@  discard block
 block discarded – undo
238 237
 	    */
239 238
 		$latitude = $lat + floatval($lat_min)/60;
240 239
 		$longitude = $lon + floatval($lon_min)/60;
241
-		if ($sind == 'S') $latitude = 0-$latitude;
242
-		if ($wind == 'W') $longitude = 0-$longitude;
240
+		if ($sind == 'S') $latitude = 0 - $latitude;
241
+		if ($wind == 'W') $longitude = 0 - $longitude;
243 242
 		$result['latitude'] = $latitude;
244 243
 		$result['longitude'] = $longitude;
245
-		$body_parse = substr($body_parse,18);
244
+		$body_parse = substr($body_parse, 18);
246 245
 		$body_parse_len = strlen($body_parse);
247 246
 	    }
248 247
 	    $body_parse_len = strlen($body_parse);
@@ -270,7 +269,7 @@  discard block
 block discarded – undo
270 269
 		//echo $body_parse;
271 270
 			//if ($type != ';' && $type != '>') {
272 271
 			if ($type != '') {
273
-			$body_parse = substr($body_parse,1);
272
+			$body_parse = substr($body_parse, 1);
274 273
 			$body_parse_len = strlen($body_parse);
275 274
 			$result['symbol_code'] = $symbol_code;
276 275
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
@@ -281,15 +280,15 @@  discard block
 block discarded – undo
281 280
 		    //$body_parse_len = strlen($body_parse);
282 281
 		    if ($body_parse_len >= 7) {
283 282
 			
284
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
285
-		    	    $course = substr($body_parse,0,3);
283
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
284
+		    	    $course = substr($body_parse, 0, 3);
286 285
 		    	    $tmp_s = intval($course);
287 286
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
288
-		    	    $speed = substr($body_parse,4,3);
287
+		    	    $speed = substr($body_parse, 4, 3);
289 288
 		    	    if ($speed != '...') {
290 289
 		    		    $result['speed'] = round($speed*1.852);
291 290
 		    	    }
292
-		    	    $body_parse = substr($body_parse,7);
291
+		    	    $body_parse = substr($body_parse, 7);
293 292
 		        }
294 293
 		        // Check PHGR, PHG, RNG
295 294
 		    } 
@@ -299,12 +298,12 @@  discard block
 block discarded – undo
299 298
 		    }
300 299
 		    */
301 300
 		    if (strlen($body_parse) > 0) {
302
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
301
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
303 302
 		            $altitude = intval($matches[1]);
304 303
 		            //$result['altitude'] = round($altitude*0.3048);
305 304
 		            $result['altitude'] = $altitude;
306 305
 		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
307
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
306
+		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse));
308 307
 		        }
309 308
 		    }
310 309
 		    
@@ -315,56 +314,56 @@  discard block
 block discarded – undo
315 314
 		    }
316 315
 		    */
317 316
 		    // DAO
318
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
317
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
319 318
 			    $dao = $matches[1];
320
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
319
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
321 320
 				$dao_split = str_split($dao);
322
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
323
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
321
+			        $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
322
+			        $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
324 323
 			    
325 324
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
326 325
 				else $result['latitude'] += $lat_off;
327 326
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
328 327
 				else $result['longitude'] += $lon_off;
329 328
 			    }
330
-		            $body_parse = substr($body_parse,6);
329
+		            $body_parse = substr($body_parse, 6);
331 330
 		    }
332 331
 		    
333
-		    if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) {
332
+		    if (preg_match('/CS=([0-9A-Z]*)/', $body_parse, $matches)) {
334 333
 			$result['ident'] = $matches[1];
335 334
 		    }
336
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
335
+		    if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) {
337 336
 			$result['squawk'] = $matches[1];
338 337
 		    }
339
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
338
+		    if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) {
340 339
 			$result['aircraft_icao'] = $matches[1];
341 340
 		    }
342
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
341
+		    if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) {
343 342
 			$result['typeid'] = $matches[1];
344 343
 		    }
345
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
344
+		    if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) {
346 345
 			$result['imo'] = $matches[1];
347 346
 		    }
348
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
347
+		    if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) {
349 348
 			$result['arrival_date'] = $matches[1];
350 349
 		    }
351
-		    if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) {
350
+		    if (preg_match('/AC=([0-9A-Z]*)/', $body_parse, $matches)) {
352 351
 			$result['arrival_code'] = $matches[1];
353 352
 		    }
354 353
 		    // OGN comment
355 354
 		   // echo "Before OGN : ".$body_parse."\n";
356 355
 		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
357
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
356
+		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
358 357
 			$id = $matches[1];
359 358
 			//$mode = substr($id,0,2);
360
-			$address = substr($id,2);
359
+			$address = substr($id, 2);
361 360
 			//print_r($matches);
362
-			$addressType = (intval(substr($id,0,2),16))&3;
361
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
363 362
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
364 363
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
365 364
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
366 365
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
367
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
366
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
368 367
 			$result['aircrafttype_code'] = $aircraftType;
369 368
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
370 369
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -381,7 +380,7 @@  discard block
 block discarded – undo
381 380
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
382 381
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
383 382
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
384
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
383
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
385 384
 			$result['stealth'] = $stealth;
386 385
 			$result['address'] = $address;
387 386
 		    }
@@ -393,72 +392,72 @@  discard block
 block discarded – undo
393 392
 		    //$body_parse = substr($body_parse,1);
394 393
 		    //$body_parse_len = strlen($body_parse);
395 394
 
396
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
395
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
397 396
 			    $result['wind_dir'] = intval($matches[1]);
398
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
399
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
400
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
401
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
402
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
397
+			    $result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
398
+			    $result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
399
+			    $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1);
400
+		    	    $body_parse = substr($body_parse, strlen($matches[0]) + 1);
401
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
403 402
 			$result['wind_dir'] = intval($matches[1]);
404
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
405
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
406
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
407
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
408
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
403
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
404
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
405
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
406
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
407
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
409 408
 			$result['wind_dir'] = intval($matches[1]);
410
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
411
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
412
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
413
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
409
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
410
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
411
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
412
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
414 413
 			$result['wind_dir'] = intval($matches[1]);
415
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
416
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
417
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
414
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
415
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
416
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
418 417
 		    }
419
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
420
-			$result['temp'] = round(5/9*(($matches[1])-32),1);
418
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) {
419
+			$result['temp'] = round(5/9*(($matches[1]) - 32), 1);
421 420
 		    }
422 421
 		}
423 422
 		} else $result['comment'] = trim($body_parse);
424 423
 
425 424
 	    }
426 425
 	//}
427
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
428
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
426
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
427
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
429 428
 	if ($debug) print_r($result);
430 429
 	return $result;
431 430
     }
432 431
     
433 432
     function connect() {
434
-	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
433
+	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport;
435 434
 	$aprs_connect = 0;
436 435
 	$aprs_keep = 120;
437 436
 	$aprs_last_tx = time();
438 437
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
439
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
438
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
440 439
 	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
441
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
440
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
442 441
 	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
443 442
 	else $aprs_pass = '-1';
444 443
 	
445
-	$aprs_filter  = '';
444
+	$aprs_filter = '';
446 445
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
447 446
 	$Common = new Common();
448
-	$s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr);
447
+	$s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr);
449 448
 	if ($s !== false) {
450 449
 		echo 'Connected to APRS server! '."\n";
451 450
 		$authstart = time();
452 451
 		$this->socket = $s;
453
-		$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
454
-		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
452
+		$send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0);
453
+		while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) {
455 454
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
456 455
 			    echo 'APRS user verified !'."\n";
457 456
 			    $this->connected = true;
458 457
 			    return true;
459 458
 			    break;
460 459
 			}
461
-			if (time()-$authstart > 5) {
460
+			if (time() - $authstart > 5) {
462 461
 			    echo 'APRS timeout'."\n";
463 462
 			    break;
464 463
 			}
@@ -468,20 +467,20 @@  discard block
 block discarded – undo
468 467
     
469 468
     function send($data) {
470 469
 	if ($this->connected === false) $this->connect();
471
-	$send = socket_send( $this->socket  , $data , strlen($data),0);
470
+	$send = socket_send($this->socket, $data, strlen($data), 0);
472 471
 	if ($send === FALSE) $this->connect();
473 472
     }
474 473
 }
475 474
 
476 475
 class APRSSpotter extends APRS {
477
-	function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) {
476
+	function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) {
478 477
 		$Common = new Common();
479 478
 		if ($latitude != '' && $longitude != '') {
480
-			$latitude = $Common->convertDM($latitude,'latitude');
481
-			$longitude = $Common->convertDM($longitude,'longitude');
482
-			$coordinate = str_pad($latitude['deg'].number_format($latitude['min'],2,'.',''),7,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'],2,'.',''),8,'0',STR_PAD_LEFT).$longitude['NSEW'];
483
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
484
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
479
+			$latitude = $Common->convertDM($latitude, 'latitude');
480
+			$longitude = $Common->convertDM($longitude, 'longitude');
481
+			$coordinate = str_pad($latitude['deg'].number_format($latitude['min'], 2, '.', ''), 7, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'], 2, '.', ''), 8, '0', STR_PAD_LEFT).$longitude['NSEW'];
482
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
483
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
485 484
 			$w = $w1.$w2;
486 485
 			//$w = '00';
487 486
 			$custom = '';
@@ -498,19 +497,19 @@  discard block
 block discarded – undo
498 497
 				$custom .= 'AI='.$aircraft_icao;
499 498
 			}
500 499
 			if ($custom != '') $custom = ' '.$custom;
501
-			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
500
+			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
502 501
 		}
503 502
 	}
504 503
 }
505 504
 class APRSMarine extends APRS {
506
-	function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source,$source_name,$over_country) {
505
+	function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country) {
507 506
 		$Common = new Common();
508 507
 		if ($latitude != '' && $longitude != '') {
509
-			$latitude = $Common->convertDM($latitude,'latitude');
510
-			$longitude = $Common->convertDM($longitude,'longitude');
511
-			$coordinate = str_pad($latitude['deg'].number_format($latitude['min'],2,'.',''),7,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'],2,'.',''),8,'0',STR_PAD_LEFT).$longitude['NSEW'];
512
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
513
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
508
+			$latitude = $Common->convertDM($latitude, 'latitude');
509
+			$longitude = $Common->convertDM($longitude, 'longitude');
510
+			$coordinate = str_pad($latitude['deg'].number_format($latitude['min'], 2, '.', ''), 7, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'], 2, '.', ''), 8, '0', STR_PAD_LEFT).$longitude['NSEW'];
511
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
512
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
514 513
 			$w = $w1.$w2;
515 514
 			//$w = '00';
516 515
 			$custom = '';
@@ -536,7 +535,7 @@  discard block
 block discarded – undo
536 535
 			}
537 536
 			if ($custom != '') $custom = ' '.$custom;
538 537
 			$altitude = 0;
539
-			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
538
+			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
540 539
 		}
541 540
 	}
542 541
 }
Please login to merge, or discard this patch.