Completed
Push — master ( 134c31...3567d1 )
by Yannick
12:14
created
require/class.APRS.php 4 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -89,6 +89,10 @@  discard block
 block discarded – undo
89 89
 	'y' => 'Yagi At QTH');
90 90
 	
91 91
 
92
+    /**
93
+     * @param integer $n
94
+     * @param integer $s
95
+     */
92 96
     private function urshift($n, $s) {
93 97
 	return ($n >= 0) ? ($n >> $s) :
94 98
 	    (($n & 0x7fffffff) >> $s) | 
@@ -475,6 +479,9 @@  discard block
 block discarded – undo
475 479
 	socket_close($this->socket);
476 480
     }
477 481
     
482
+    /**
483
+     * @param string $data
484
+     */
478 485
     public function send($data) {
479 486
 	if ($this->connected === false) $this->connect();
480 487
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
Please login to merge, or discard this patch.
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -2,10 +2,10 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/settings.php');
3 3
 require_once(dirname(__FILE__).'/class.Common.php');
4 4
 class aprs {
5
-    private $socket;
6
-    private $connected = false;
5
+	private $socket;
6
+	private $connected = false;
7 7
 
8
-    protected $symbols = array('!' => 'Police',
8
+	protected $symbols = array('!' => 'Police',
9 9
 	'#' => 'DIGI',
10 10
 	'$' => 'Phone',
11 11
 	'%' => 'DX Cluster',
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 	'y' => 'Yagi At QTH');
90 90
 	
91 91
 
92
-    private function urshift($n, $s) {
92
+	private function urshift($n, $s) {
93 93
 	return ($n >= 0) ? ($n >> $s) :
94
-	    (($n & 0x7fffffff) >> $s) | 
94
+		(($n & 0x7fffffff) >> $s) | 
95 95
 		(0x40000000 >> ($s - 1));
96
-    }
96
+	}
97 97
 
98
-    public function parse($input) {
98
+	public function parse($input) {
99 99
 	global $globalDebug;
100 100
 	$debug = false;
101 101
 	$result = array();
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 	
108 108
 	/* Check that end was found and body has at least one byte. */
109 109
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
110
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
111
-	    return false;
110
+		if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
111
+		return false;
112 112
 	}
113 113
 	
114 114
 	if ($debug) echo 'input : '.$input."\n";
@@ -122,31 +122,31 @@  discard block
 block discarded – undo
122 122
 	/* Parse source, target and path. */
123 123
 	//FLRDF0A52>APRS,qAS,LSTB
124 124
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
125
-	    $ident = $matches[1];
126
-	    $all_elements = $matches[2];
127
-	    if ($ident == 'AIRCRAFT') {
125
+		$ident = $matches[1];
126
+		$all_elements = $matches[2];
127
+		if ($ident == 'AIRCRAFT') {
128 128
 		$result['format_source'] = 'famaprs';
129 129
 		$result['source_type'] = 'modes';
130
-	    } elseif ($ident == 'MARINE') {
130
+		} elseif ($ident == 'MARINE') {
131 131
 		$result['format_source'] = 'famaprs';
132 132
 		$result['source_type'] = 'ais';
133
-	    } else {
133
+		} else {
134 134
 		if ($debug) echo 'ident : '.$ident."\n";
135 135
 		$result['ident'] = $ident;
136
-	    }
136
+		}
137 137
 	} else return false;
138 138
 	$elements = explode(',',$all_elements);
139 139
 	$source = end($elements);
140 140
 	$result['source'] = $source;
141 141
 	foreach ($elements as $element) {
142
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
143
-	        //echo "ok";
144
-	        //if ($element == 'TCPIP*') return false;
145
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
142
+		if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
143
+			//echo "ok";
144
+			//if ($element == 'TCPIP*') return false;
145
+		} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
146 146
 		if ($debug) echo 'element : '.$element."\n";
147 147
 		return false;
148
-	    }
149
-	    /*
148
+		}
149
+		/*
150 150
 	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) {
151 151
 		//echo "ok";
152 152
 	    } else {
@@ -171,49 +171,49 @@  discard block
 block discarded – undo
171 171
 	$body_parse = substr($body,1);
172 172
 	//echo 'Body : '.$body."\n";
173 173
 	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
174
-	    $body_parse = substr($body_parse,10);
175
-	    $find = true;
176
-	    //echo $body_parse."\n";
174
+		$body_parse = substr($body_parse,10);
175
+		$find = true;
176
+		//echo $body_parse."\n";
177 177
 	}
178 178
 	if (preg_match('/^`(.*)\//',$body,$matches)) {
179
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
180
-	    $find = true;
181
-	    //echo $body_parse."\n";
179
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
180
+		$find = true;
181
+		//echo $body_parse."\n";
182 182
 	}
183 183
 	if (preg_match("/^'(.*)\//",$body,$matches)) {
184
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
185
-	    $find = true;
186
-	    //echo $body_parse."\n";
184
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
185
+		$find = true;
186
+		//echo $body_parse."\n";
187 187
 	}
188 188
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
189
-	    $find = true;
190
-	    //print_r($matches);
191
-	    $timestamp = $matches[0];
192
-	    if ($matches[4] == 'h') {
189
+		$find = true;
190
+		//print_r($matches);
191
+		$timestamp = $matches[0];
192
+		if ($matches[4] == 'h') {
193 193
 		$timestamp = strtotime($matches[1].':'.$matches[2].':'.$matches[3]);
194 194
 		//echo 'timestamp : '.$timestamp.' - now : '.time()."\n";
195 195
 		/*
196 196
 		if (time() + 3900 < $timestamp) $timestamp -= 86400;
197 197
 		elseif (time() - 82500 > $timestamp) $timestamp += 86400;
198 198
 		*/
199
-	    } elseif ($matches[4] == 'z' || $matches[4] == '/') {
199
+		} elseif ($matches[4] == 'z' || $matches[4] == '/') {
200 200
 		// This work or not ?
201 201
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
202
-	    }
203
-	    $body_parse = substr($body_parse,7);
204
-	    $result['timestamp'] = $timestamp;
205
-	    //echo date('Ymd H:i:s',$timestamp);
202
+		}
203
+		$body_parse = substr($body_parse,7);
204
+		$result['timestamp'] = $timestamp;
205
+		//echo date('Ymd H:i:s',$timestamp);
206 206
 	}
207 207
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
208
-	    $find = true;
209
-	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
210
-	    $body_parse = substr($body_parse,8);
211
-	    $result['timestamp'] = $timestamp;
212
-	    //echo date('Ymd H:i:s',$timestamp);
208
+		$find = true;
209
+		$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
210
+		$body_parse = substr($body_parse,8);
211
+		$result['timestamp'] = $timestamp;
212
+		//echo date('Ymd H:i:s',$timestamp);
213 213
 	}
214 214
 	//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)) {
216
-	    $find = true;
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)) {
216
+		$find = true;
217 217
 		// 4658.70N/00707.78Ez
218 218
 		//print_r(str_split($body_parse));
219 219
 		
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 		$lon = intval($lon_deg);
231 231
 		if ($lat > 89 || $lon > 179) return false;
232 232
 	    
233
-	    /*
233
+		/*
234 234
 	    $tmp_5b = str_replace('.','',$lat_min);
235 235
 	    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) {
236 236
 	        print_r($matches);
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
 		$result['longitude'] = $longitude;
245 245
 		$body_parse = substr($body_parse,18);
246 246
 		$body_parse_len = strlen($body_parse);
247
-	    }
248
-	    $body_parse_len = strlen($body_parse);
249
-	    if ($body_parse_len > 0) {
247
+		}
248
+		$body_parse_len = strlen($body_parse);
249
+		if ($body_parse_len > 0) {
250 250
 		/*
251 251
 		if (!isset($result['timestamp']) && !isset($result['latitude'])) {
252 252
 			$body_split = str_split($body);
@@ -276,89 +276,89 @@  discard block
 block discarded – undo
276 276
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
277 277
 			if ($symbol_code != '_') {
278 278
 			}
279
-		    //$body_parse = substr($body_parse,1);
280
-		    //$body_parse = trim($body_parse);
281
-		    //$body_parse_len = strlen($body_parse);
282
-		    if ($body_parse_len >= 7) {
279
+			//$body_parse = substr($body_parse,1);
280
+			//$body_parse = trim($body_parse);
281
+			//$body_parse_len = strlen($body_parse);
282
+			if ($body_parse_len >= 7) {
283 283
 			
284
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
285
-		    	    $course = substr($body_parse,0,3);
286
-		    	    $tmp_s = intval($course);
287
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
288
-		    	    $speed = substr($body_parse,4,3);
289
-		    	    if ($speed != '...') {
290
-		    		//$result['speed'] = round($speed*1.852);
291
-		    		$result['speed'] = intval($speed);
292
-		    	    }
293
-		    	    $body_parse = substr($body_parse,7);
294
-		        }
295
-		        // Check PHGR, PHG, RNG
296
-		    } 
297
-		    /*
284
+				if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
285
+					$course = substr($body_parse,0,3);
286
+					$tmp_s = intval($course);
287
+					if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
288
+					$speed = substr($body_parse,4,3);
289
+					if ($speed != '...') {
290
+					//$result['speed'] = round($speed*1.852);
291
+					$result['speed'] = intval($speed);
292
+					}
293
+					$body_parse = substr($body_parse,7);
294
+				}
295
+				// Check PHGR, PHG, RNG
296
+			} 
297
+			/*
298 298
 		    else if ($body_parse_len > 0) {
299 299
 			$rest = $body_parse;
300 300
 		    }
301 301
 		    */
302
-		    if (strlen($body_parse) > 0) {
303
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
304
-		            $altitude = intval($matches[1]);
305
-		            //$result['altitude'] = round($altitude*0.3048);
306
-		            $result['altitude'] = $altitude;
307
-		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
308
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
309
-		        }
310
-		    }
302
+			if (strlen($body_parse) > 0) {
303
+				if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
304
+					$altitude = intval($matches[1]);
305
+					//$result['altitude'] = round($altitude*0.3048);
306
+					$result['altitude'] = $altitude;
307
+					//$body_parse = trim(substr($body_parse,strlen($matches[0])));
308
+					$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
309
+				}
310
+			}
311 311
 		    
312
-		    // Telemetry
313
-		    /*
312
+			// Telemetry
313
+			/*
314 314
 		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) {
315 315
 		        // Nothing yet...
316 316
 		    }
317 317
 		    */
318
-		    // DAO
318
+			// DAO
319 319
 		    
320
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
320
+			if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
321 321
 			    
322
-			    $dao = $matches[1];
323
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
322
+				$dao = $matches[1];
323
+				if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
324 324
 				$dao_split = str_split($dao);
325
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
326
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
325
+					$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
326
+					$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
327 327
 			    
328 328
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
329 329
 				else $result['latitude'] += $lat_off;
330 330
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
331 331
 				else $result['longitude'] += $lon_off;
332
-			    }
332
+				}
333 333
 			    
334
-		            $body_parse = substr($body_parse,6);
335
-		    }
334
+					$body_parse = substr($body_parse,6);
335
+			}
336 336
 		    
337
-		    if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) {
337
+			if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) {
338 338
 			$result['ident'] = $matches[1];
339
-		    }
340
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
339
+			}
340
+			if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
341 341
 			$result['squawk'] = $matches[1];
342
-		    }
343
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
342
+			}
343
+			if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
344 344
 			$result['aircraft_icao'] = $matches[1];
345
-		    }
346
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
345
+			}
346
+			if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
347 347
 			$result['typeid'] = $matches[1];
348
-		    }
349
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
348
+			}
349
+			if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
350 350
 			$result['imo'] = $matches[1];
351
-		    }
352
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
351
+			}
352
+			if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
353 353
 			$result['arrival_date'] = $matches[1];
354
-		    }
355
-		    if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) {
354
+			}
355
+			if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) {
356 356
 			$result['arrival_code'] = $matches[1];
357
-		    }
358
-		    // OGN comment
357
+			}
358
+			// OGN comment
359 359
 		   // echo "Before OGN : ".$body_parse."\n";
360
-		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
361
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
360
+			//if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
361
+			if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
362 362
 			$id = $matches[1];
363 363
 			//$mode = substr($id,0,2);
364 364
 			$address = substr($id,2);
@@ -388,53 +388,53 @@  discard block
 block discarded – undo
388 388
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
389 389
 			$result['stealth'] = $stealth;
390 390
 			$result['address'] = $address;
391
-		    }
391
+			}
392 392
 		    
393
-		    //Comment
394
-		    $result['comment'] = trim($body_parse);
393
+			//Comment
394
+			$result['comment'] = trim($body_parse);
395 395
 		} else {
396
-		    // parse weather
397
-		    //$body_parse = substr($body_parse,1);
398
-		    //$body_parse_len = strlen($body_parse);
396
+			// parse weather
397
+			//$body_parse = substr($body_parse,1);
398
+			//$body_parse_len = strlen($body_parse);
399 399
 
400
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
401
-			    $result['wind_dir'] = intval($matches[1]);
402
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
403
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
404
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
405
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
406
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
400
+			if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
401
+				$result['wind_dir'] = intval($matches[1]);
402
+				$result['wind_speed'] = round(intval($matches[2])*1.60934,1);
403
+				$result['wind_gust'] = round(intval($matches[3])*1.60934,1);
404
+				$result['temp'] = round(5/9*((intval($matches[4]))-32),1);
405
+					$body_parse = substr($body_parse,strlen($matches[0])+1);
406
+			} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
407 407
 			$result['wind_dir'] = intval($matches[1]);
408 408
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
409 409
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
410 410
 			$result['temp'] = round(5/9*(($matches[4])-32),1);
411
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
412
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
411
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
412
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
413 413
 			$result['wind_dir'] = intval($matches[1]);
414 414
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
415 415
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
416
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
417
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
416
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
417
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
418 418
 			$result['wind_dir'] = intval($matches[1]);
419 419
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
420 420
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
421
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
422
-		    }
423
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
421
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
422
+			}
423
+			if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
424 424
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
425
-		    }
425
+			}
426 426
 		}
427 427
 		} else $result['comment'] = trim($body_parse);
428 428
 
429
-	    }
429
+		}
430 430
 	//}
431 431
 	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
432 432
 	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
433 433
 	if ($debug) print_r($result);
434 434
 	return $result;
435
-    }
435
+	}
436 436
     
437
-    public function connect() {
437
+	public function connect() {
438 438
 	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
439 439
 	$aprs_connect = 0;
440 440
 	$aprs_keep = 120;
@@ -457,32 +457,32 @@  discard block
 block discarded – undo
457 457
 		$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
458 458
 		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
459 459
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
460
-			    echo 'APRS user verified !'."\n";
461
-			    $this->connected = true;
462
-			    return true;
463
-			    break;
460
+				echo 'APRS user verified !'."\n";
461
+				$this->connected = true;
462
+				return true;
463
+				break;
464 464
 			}
465 465
 			if (time()-$authstart > 5) {
466
-			    echo 'APRS timeout'."\n";
467
-			    break;
466
+				echo 'APRS timeout'."\n";
467
+				break;
468 468
 			}
469 469
 		}
470 470
 		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE);
471 471
 	}
472
-    }
472
+	}
473 473
 
474
-    public function disconnect() {
474
+	public function disconnect() {
475 475
 	socket_close($this->socket);
476
-    }
476
+	}
477 477
     
478
-    public function send($data) {
478
+	public function send($data) {
479 479
 	if ($this->connected === false) $this->connect();
480 480
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
481 481
 	if ($send === FALSE) {
482 482
 		socket_close($this->socket);
483 483
 		$this->connect();
484 484
 	}
485
-    }
485
+	}
486 486
 }
487 487
 
488 488
 class APRSSpotter extends APRS {
Please login to merge, or discard this patch.
Spacing   +97 added lines, -98 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,14 +154,14 @@  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'] == 'modes') {
162
-			$result['address'] = trim(substr($body,1,9));
161
+			$result['address'] = trim(substr($body, 1, 9));
163 162
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
164
-			$result['mmsi'] = trim(substr($body,1,9));
165
-		} else $result['ident'] = trim(substr($body,1,9));
163
+			$result['mmsi'] = trim(substr($body, 1, 9));
164
+		} else $result['ident'] = trim(substr($body, 1, 9));
166 165
 	} elseif ($type == ',') {
167 166
 		// Invalid data or test data
168 167
 		return false;
@@ -170,24 +169,24 @@  discard block
 block discarded – undo
170 169
 	
171 170
 	// Check for Timestamp
172 171
 	$find = false;
173
-	$body_parse = substr($body,1);
172
+	$body_parse = substr($body, 1);
174 173
 	//echo 'Body : '.$body."\n";
175
-	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
176
-	    $body_parse = substr($body_parse,10);
174
+	if (preg_match('/^;(.){9}\*/', $body, $matches)) {
175
+	    $body_parse = substr($body_parse, 10);
177 176
 	    $find = true;
178 177
 	    //echo $body_parse."\n";
179 178
 	}
180
-	if (preg_match('/^`(.*)\//',$body,$matches)) {
181
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
179
+	if (preg_match('/^`(.*)\//', $body, $matches)) {
180
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
182 181
 	    $find = true;
183 182
 	    //echo $body_parse."\n";
184 183
 	}
185
-	if (preg_match("/^'(.*)\//",$body,$matches)) {
186
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
184
+	if (preg_match("/^'(.*)\//", $body, $matches)) {
185
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
187 186
 	    $find = true;
188 187
 	    //echo $body_parse."\n";
189 188
 	}
190
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
189
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
191 190
 	    $find = true;
192 191
 	    //print_r($matches);
193 192
 	    $timestamp = $matches[0];
@@ -202,19 +201,19 @@  discard block
 block discarded – undo
202 201
 		// This work or not ?
203 202
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
204 203
 	    }
205
-	    $body_parse = substr($body_parse,7);
204
+	    $body_parse = substr($body_parse, 7);
206 205
 	    $result['timestamp'] = $timestamp;
207 206
 	    //echo date('Ymd H:i:s',$timestamp);
208 207
 	}
209
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
208
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
210 209
 	    $find = true;
211 210
 	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
212
-	    $body_parse = substr($body_parse,8);
211
+	    $body_parse = substr($body_parse, 8);
213 212
 	    $result['timestamp'] = $timestamp;
214 213
 	    //echo date('Ymd H:i:s',$timestamp);
215 214
 	}
216 215
 	//if (strlen($body_parse) > 19) {
217
-	    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
+	    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)) {
218 217
 	    $find = true;
219 218
 		// 4658.70N/00707.78Ez
220 219
 		//print_r(str_split($body_parse));
@@ -240,11 +239,11 @@  discard block
 block discarded – undo
240 239
 	    */
241 240
 		$latitude = $lat + floatval($lat_min)/60;
242 241
 		$longitude = $lon + floatval($lon_min)/60;
243
-		if ($sind == 'S') $latitude = 0-$latitude;
244
-		if ($wind == 'W') $longitude = 0-$longitude;
242
+		if ($sind == 'S') $latitude = 0 - $latitude;
243
+		if ($wind == 'W') $longitude = 0 - $longitude;
245 244
 		$result['latitude'] = $latitude;
246 245
 		$result['longitude'] = $longitude;
247
-		$body_parse = substr($body_parse,18);
246
+		$body_parse = substr($body_parse, 18);
248 247
 		$body_parse_len = strlen($body_parse);
249 248
 	    }
250 249
 	    $body_parse_len = strlen($body_parse);
@@ -272,7 +271,7 @@  discard block
 block discarded – undo
272 271
 		//echo $body_parse;
273 272
 			//if ($type != ';' && $type != '>') {
274 273
 			if ($type != '') {
275
-			$body_parse = substr($body_parse,1);
274
+			$body_parse = substr($body_parse, 1);
276 275
 			$body_parse_len = strlen($body_parse);
277 276
 			$result['symbol_code'] = $symbol_code;
278 277
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
@@ -283,16 +282,16 @@  discard block
 block discarded – undo
283 282
 		    //$body_parse_len = strlen($body_parse);
284 283
 		    if ($body_parse_len >= 7) {
285 284
 			
286
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
287
-		    	    $course = substr($body_parse,0,3);
285
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
286
+		    	    $course = substr($body_parse, 0, 3);
288 287
 		    	    $tmp_s = intval($course);
289 288
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
290
-		    	    $speed = substr($body_parse,4,3);
289
+		    	    $speed = substr($body_parse, 4, 3);
291 290
 		    	    if ($speed != '...') {
292 291
 		    		//$result['speed'] = round($speed*1.852);
293 292
 		    		$result['speed'] = intval($speed);
294 293
 		    	    }
295
-		    	    $body_parse = substr($body_parse,7);
294
+		    	    $body_parse = substr($body_parse, 7);
296 295
 		        }
297 296
 		        // Check PHGR, PHG, RNG
298 297
 		    } 
@@ -302,12 +301,12 @@  discard block
 block discarded – undo
302 301
 		    }
303 302
 		    */
304 303
 		    if (strlen($body_parse) > 0) {
305
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
304
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
306 305
 		            $altitude = intval($matches[1]);
307 306
 		            //$result['altitude'] = round($altitude*0.3048);
308 307
 		            $result['altitude'] = $altitude;
309 308
 		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
310
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
309
+		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse));
311 310
 		        }
312 311
 		    }
313 312
 		    
@@ -319,13 +318,13 @@  discard block
 block discarded – undo
319 318
 		    */
320 319
 		    // DAO
321 320
 		    
322
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
321
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
323 322
 			    
324 323
 			    $dao = $matches[1];
325
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
324
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
326 325
 				$dao_split = str_split($dao);
327
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
328
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
326
+			        $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
327
+			        $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
329 328
 			    
330 329
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
331 330
 				else $result['latitude'] += $lat_off;
@@ -333,44 +332,44 @@  discard block
 block discarded – undo
333 332
 				else $result['longitude'] += $lon_off;
334 333
 			    }
335 334
 			    
336
-		            $body_parse = substr($body_parse,6);
335
+		            $body_parse = substr($body_parse, 6);
337 336
 		    }
338 337
 		    
339
-		    if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) {
338
+		    if (preg_match('/CS=([0-9A-Z]*)/', $body_parse, $matches)) {
340 339
 			$result['ident'] = $matches[1];
341 340
 		    }
342
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
341
+		    if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) {
343 342
 			$result['squawk'] = $matches[1];
344 343
 		    }
345
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
344
+		    if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) {
346 345
 			$result['aircraft_icao'] = $matches[1];
347 346
 		    }
348
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
347
+		    if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) {
349 348
 			$result['typeid'] = $matches[1];
350 349
 		    }
351
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
350
+		    if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) {
352 351
 			$result['imo'] = $matches[1];
353 352
 		    }
354
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
353
+		    if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) {
355 354
 			$result['arrival_date'] = $matches[1];
356 355
 		    }
357
-		    if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) {
356
+		    if (preg_match('/AC=([0-9A-Z]*)/', $body_parse, $matches)) {
358 357
 			$result['arrival_code'] = $matches[1];
359 358
 		    }
360 359
 		    // OGN comment
361 360
 		   // echo "Before OGN : ".$body_parse."\n";
362 361
 		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
363
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
362
+		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
364 363
 			$id = $matches[1];
365 364
 			//$mode = substr($id,0,2);
366
-			$address = substr($id,2);
365
+			$address = substr($id, 2);
367 366
 			//print_r($matches);
368
-			$addressType = (intval(substr($id,0,2),16))&3;
367
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
369 368
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
370 369
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
371 370
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
372 371
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
373
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
372
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
374 373
 			$result['aircrafttype_code'] = $aircraftType;
375 374
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
376 375
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -387,7 +386,7 @@  discard block
 block discarded – undo
387 386
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
388 387
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
389 388
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
390
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
389
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
391 390
 			$result['stealth'] = $stealth;
392 391
 			$result['address'] = $address;
393 392
 		    }
@@ -399,77 +398,77 @@  discard block
 block discarded – undo
399 398
 		    //$body_parse = substr($body_parse,1);
400 399
 		    //$body_parse_len = strlen($body_parse);
401 400
 
402
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
401
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([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(intval($matches[2])*1.60934,1);
405
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
406
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
407
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
408
-		    } 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
+			    $result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
404
+			    $result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
405
+			    $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1);
406
+		    	    $body_parse = substr($body_parse, strlen($matches[0]) + 1);
407
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)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
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
413
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
414
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[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
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
412
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
413
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
415 414
 			$result['wind_dir'] = intval($matches[1]);
416
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
417
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
418
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
419
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
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);
418
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
420 419
 			$result['wind_dir'] = intval($matches[1]);
421
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
422
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
423
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
420
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
421
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
422
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
424 423
 		    }
425
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
426
-			$result['temp'] = round(5/9*(($matches[1])-32),1);
424
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) {
425
+			$result['temp'] = round(5/9*(($matches[1]) - 32), 1);
427 426
 		    }
428 427
 		}
429 428
 		} else $result['comment'] = trim($body_parse);
430 429
 
431 430
 	    }
432 431
 	//}
433
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
434
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
432
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
433
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
435 434
 	if ($debug) print_r($result);
436 435
 	return $result;
437 436
     }
438 437
     
439 438
     public function connect() {
440
-	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
439
+	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport;
441 440
 	$aprs_connect = 0;
442 441
 	$aprs_keep = 120;
443 442
 	$aprs_last_tx = time();
444 443
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
445
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
444
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
446 445
 	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
447
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
446
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
448 447
 	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
449 448
 	else $aprs_pass = '-1';
450 449
 	
451
-	$aprs_filter  = '';
450
+	$aprs_filter = '';
452 451
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
453 452
 	$Common = new Common();
454
-	$s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr);
453
+	$s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr);
455 454
 	if ($s !== false) {
456 455
 		echo 'Connected to APRS server! '."\n";
457 456
 		$authstart = time();
458 457
 		$this->socket = $s;
459
-		$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
460
-		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
458
+		$send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0);
459
+		while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) {
461 460
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
462 461
 			    echo 'APRS user verified !'."\n";
463 462
 			    $this->connected = true;
464 463
 			    return true;
465 464
 			    break;
466 465
 			}
467
-			if (time()-$authstart > 5) {
466
+			if (time() - $authstart > 5) {
468 467
 			    echo 'APRS timeout'."\n";
469 468
 			    break;
470 469
 			}
471 470
 		}
472
-		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE);
471
+		socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE);
473 472
 	}
474 473
     }
475 474
 
@@ -479,7 +478,7 @@  discard block
 block discarded – undo
479 478
     
480 479
     public function send($data) {
481 480
 	if ($this->connected === false) $this->connect();
482
-	$send = socket_send( $this->socket  , $data , strlen($data),0);
481
+	$send = socket_send($this->socket, $data, strlen($data), 0);
483 482
 	if ($send === FALSE) {
484 483
 		socket_close($this->socket);
485 484
 		$this->connect();
@@ -488,14 +487,14 @@  discard block
 block discarded – undo
488 487
 }
489 488
 
490 489
 class APRSSpotter extends APRS {
491
-	public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) {
490
+	public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) {
492 491
 		$Common = new Common();
493 492
 		if ($latitude != '' && $longitude != '') {
494
-			$latitude = $Common->convertDM($latitude,'latitude');
495
-			$longitude = $Common->convertDM($longitude,'longitude');
496
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
497
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
498
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
493
+			$latitude = $Common->convertDM($latitude, 'latitude');
494
+			$longitude = $Common->convertDM($longitude, 'longitude');
495
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
496
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
497
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
499 498
 			$w = $w1.$w2;
500 499
 			//$w = '00';
501 500
 			$custom = '';
@@ -512,19 +511,19 @@  discard block
 block discarded – undo
512 511
 				$custom .= 'AI='.$aircraft_icao;
513 512
 			}
514 513
 			if ($custom != '') $custom = ' '.$custom;
515
-			$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");
514
+			$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");
516 515
 		}
517 516
 	}
518 517
 }
519 518
 class APRSMarine extends APRS {
520
-	public 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) {
519
+	public 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) {
521 520
 		$Common = new Common();
522 521
 		if ($latitude != '' && $longitude != '') {
523
-			$latitude = $Common->convertDM($latitude,'latitude');
524
-			$longitude = $Common->convertDM($longitude,'longitude');
525
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
526
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
527
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
522
+			$latitude = $Common->convertDM($latitude, 'latitude');
523
+			$longitude = $Common->convertDM($longitude, 'longitude');
524
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
525
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
526
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
528 527
 			$w = $w1.$w2;
529 528
 			//$w = '00';
530 529
 			$custom = '';
@@ -550,7 +549,7 @@  discard block
 block discarded – undo
550 549
 			}
551 550
 			if ($custom != '') $custom = ' '.$custom;
552 551
 			$altitude = 0;
553
-			$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");
552
+			$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");
554 553
 		}
555 554
 	}
556 555
 }
Please login to merge, or discard this patch.
Braces   +149 added lines, -57 removed lines patch added patch discarded remove patch
@@ -107,17 +107,23 @@  discard block
 block discarded – undo
107 107
 	
108 108
 	/* Check that end was found and body has at least one byte. */
109 109
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
110
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
110
+	    if ($globalDebug) {
111
+	    	echo '!!! APRS invalid : '.$input."\n";
112
+	    }
111 113
 	    return false;
112 114
 	}
113 115
 	
114
-	if ($debug) echo 'input : '.$input."\n";
116
+	if ($debug) {
117
+		echo 'input : '.$input."\n";
118
+	}
115 119
 	/* Save header and body. */
116 120
 	$body = substr($input,$splitpos+1,$input_len);
117 121
 	$body_len = strlen($body);
118 122
 	$header = substr($input,0,$splitpos);
119 123
 	//$header_len = strlen($header);
120
-	if ($debug) echo 'header : '.$header."\n";
124
+	if ($debug) {
125
+		echo 'header : '.$header."\n";
126
+	}
121 127
 	
122 128
 	/* Parse source, target and path. */
123 129
 	//FLRDF0A52>APRS,qAS,LSTB
@@ -131,10 +137,14 @@  discard block
 block discarded – undo
131 137
 		$result['format_source'] = 'famaprs';
132 138
 		$result['source_type'] = 'ais';
133 139
 	    } else {
134
-		if ($debug) echo 'ident : '.$ident."\n";
140
+		if ($debug) {
141
+			echo 'ident : '.$ident."\n";
142
+		}
135 143
 		$result['ident'] = $ident;
136 144
 	    }
137
-	} else return false;
145
+	} else {
146
+		return false;
147
+	}
138 148
 	$elements = explode(',',$all_elements);
139 149
 	$source = end($elements);
140 150
 	$result['source'] = $source;
@@ -143,7 +153,9 @@  discard block
 block discarded – undo
143 153
 	        //echo "ok";
144 154
 	        //if ($element == 'TCPIP*') return false;
145 155
 	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
146
-		if ($debug) echo 'element : '.$element."\n";
156
+		if ($debug) {
157
+			echo 'element : '.$element."\n";
158
+		}
147 159
 		return false;
148 160
 	    }
149 161
 	    /*
@@ -156,13 +168,17 @@  discard block
 block discarded – undo
156 168
 	}
157 169
 	
158 170
 	$type = substr($body,0,1);
159
-	if ($debug) echo 'type : '.$type."\n";
171
+	if ($debug) {
172
+		echo 'type : '.$type."\n";
173
+	}
160 174
 	if ($type == ';') {
161 175
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
162 176
 			$result['address'] = trim(substr($body,1,9));
163 177
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
164 178
 			$result['mmsi'] = trim(substr($body,1,9));
165
-		} else $result['ident'] = trim(substr($body,1,9));
179
+		} else {
180
+			$result['ident'] = trim(substr($body,1,9));
181
+		}
166 182
 	} elseif ($type == ',') {
167 183
 		// Invalid data or test data
168 184
 		return false;
@@ -230,7 +246,9 @@  discard block
 block discarded – undo
230 246
 		//$symbol_table = $matches[4];
231 247
 		$lat = intval($lat_deg);
232 248
 		$lon = intval($lon_deg);
233
-		if ($lat > 89 || $lon > 179) return false;
249
+		if ($lat > 89 || $lon > 179) {
250
+			return false;
251
+		}
234 252
 	    
235 253
 	    /*
236 254
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -240,8 +258,12 @@  discard block
 block discarded – undo
240 258
 	    */
241 259
 		$latitude = $lat + floatval($lat_min)/60;
242 260
 		$longitude = $lon + floatval($lon_min)/60;
243
-		if ($sind == 'S') $latitude = 0-$latitude;
244
-		if ($wind == 'W') $longitude = 0-$longitude;
261
+		if ($sind == 'S') {
262
+			$latitude = 0-$latitude;
263
+		}
264
+		if ($wind == 'W') {
265
+			$longitude = 0-$longitude;
266
+		}
245 267
 		$result['latitude'] = $latitude;
246 268
 		$result['longitude'] = $longitude;
247 269
 		$body_parse = substr($body_parse,18);
@@ -275,7 +297,9 @@  discard block
 block discarded – undo
275 297
 			$body_parse = substr($body_parse,1);
276 298
 			$body_parse_len = strlen($body_parse);
277 299
 			$result['symbol_code'] = $symbol_code;
278
-			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
300
+			if (isset($this->symbols[$symbol_code])) {
301
+				$result['symbol'] = $this->symbols[$symbol_code];
302
+			}
279 303
 			if ($symbol_code != '_') {
280 304
 			}
281 305
 		    //$body_parse = substr($body_parse,1);
@@ -286,7 +310,9 @@  discard block
 block discarded – undo
286 310
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
287 311
 		    	    $course = substr($body_parse,0,3);
288 312
 		    	    $tmp_s = intval($course);
289
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
313
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
314
+		    	    	$result['heading'] = intval($course);
315
+		    	    }
290 316
 		    	    $speed = substr($body_parse,4,3);
291 317
 		    	    if ($speed != '...') {
292 318
 		    		//$result['speed'] = round($speed*1.852);
@@ -327,10 +353,16 @@  discard block
 block discarded – undo
327 353
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
328 354
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
329 355
 			    
330
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
331
-				else $result['latitude'] += $lat_off;
332
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
333
-				else $result['longitude'] += $lon_off;
356
+				if ($result['latitude'] < 0) {
357
+					$result['latitude'] -= $lat_off;
358
+				} else {
359
+					$result['latitude'] += $lat_off;
360
+				}
361
+				if ($result['longitude'] < 0) {
362
+					$result['longitude'] -= $lon_off;
363
+				} else {
364
+					$result['longitude'] += $lon_off;
365
+				}
334 366
 			    }
335 367
 			    
336 368
 		            $body_parse = substr($body_parse,6);
@@ -366,27 +398,48 @@  discard block
 block discarded – undo
366 398
 			$address = substr($id,2);
367 399
 			//print_r($matches);
368 400
 			$addressType = (intval(substr($id,0,2),16))&3;
369
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
370
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
371
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
372
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
401
+			if ($addressType == 0) {
402
+				$result['addresstype'] = "RANDOM";
403
+			} elseif ($addressType == 1) {
404
+				$result['addresstype'] = "ICAO";
405
+			} elseif ($addressType == 2) {
406
+				$result['addresstype'] = "FLARM";
407
+			} elseif ($addressType == 3) {
408
+				$result['addresstype'] = "OGN";
409
+			}
373 410
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
374 411
 			$result['aircrafttype_code'] = $aircraftType;
375
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
376
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
377
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
378
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
379
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
380
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
381
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
382
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
383
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
384
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
385
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
386
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
387
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
388
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
389
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
412
+			if ($aircraftType == 0) {
413
+				$result['aircrafttype'] = "UNKNOWN";
414
+			} elseif ($aircraftType == 1) {
415
+				$result['aircrafttype'] = "GLIDER";
416
+			} elseif ($aircraftType == 2) {
417
+				$result['aircrafttype'] = "TOW_PLANE";
418
+			} elseif ($aircraftType == 3) {
419
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
420
+			} elseif ($aircraftType == 4) {
421
+				$result['aircrafttype'] = "PARACHUTE";
422
+			} elseif ($aircraftType == 5) {
423
+				$result['aircrafttype'] = "DROP_PLANE";
424
+			} elseif ($aircraftType == 6) {
425
+				$result['aircrafttype'] = "HANG_GLIDER";
426
+			} elseif ($aircraftType == 7) {
427
+				$result['aircrafttype'] = "PARA_GLIDER";
428
+			} elseif ($aircraftType == 8) {
429
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
430
+			} elseif ($aircraftType == 9) {
431
+				$result['aircrafttype'] = "JET_AIRCRAFT";
432
+			} elseif ($aircraftType == 10) {
433
+				$result['aircrafttype'] = "UFO";
434
+			} elseif ($aircraftType == 11) {
435
+				$result['aircrafttype'] = "BALLOON";
436
+			} elseif ($aircraftType == 12) {
437
+				$result['aircrafttype'] = "AIRSHIP";
438
+			} elseif ($aircraftType == 13) {
439
+				$result['aircrafttype'] = "UAV";
440
+			} elseif ($aircraftType == 15) {
441
+				$result['aircrafttype'] = "STATIC_OBJECT";
442
+			}
390 443
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
391 444
 			$result['stealth'] = $stealth;
392 445
 			$result['address'] = $address;
@@ -426,13 +479,21 @@  discard block
 block discarded – undo
426 479
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
427 480
 		    }
428 481
 		}
429
-		} else $result['comment'] = trim($body_parse);
482
+		} else {
483
+			$result['comment'] = trim($body_parse);
484
+		}
430 485
 
431 486
 	    }
432 487
 	//}
433
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
434
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
435
-	if ($debug) print_r($result);
488
+	if (isset($result['latitude'])) {
489
+		$result['latitude'] = round($result['latitude'],4);
490
+	}
491
+	if (isset($result['longitude'])) {
492
+		$result['longitude'] = round($result['longitude'],4);
493
+	}
494
+	if ($debug) {
495
+		print_r($result);
496
+	}
436 497
 	return $result;
437 498
     }
438 499
     
@@ -441,12 +502,21 @@  discard block
 block discarded – undo
441 502
 	$aprs_connect = 0;
442 503
 	$aprs_keep = 120;
443 504
 	$aprs_last_tx = time();
444
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
445
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
446
-	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
447
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
448
-	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
449
-	else $aprs_pass = '-1';
505
+	if (isset($globalAPRSversion)) {
506
+		$aprs_version = $globalAPRSversion;
507
+	} else {
508
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
509
+	}
510
+	if (isset($globalServerAPRSssid)) {
511
+		$aprs_ssid = $globalServerAPRSssid;
512
+	} else {
513
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
514
+	}
515
+	if (isset($globalServerAPRSpass)) {
516
+		$aprs_pass = $globalServerAPRSpass;
517
+	} else {
518
+		$aprs_pass = '-1';
519
+	}
450 520
 	
451 521
 	$aprs_filter  = '';
452 522
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
@@ -478,7 +548,9 @@  discard block
 block discarded – undo
478 548
     }
479 549
     
480 550
     public function send($data) {
481
-	if ($this->connected === false) $this->connect();
551
+	if ($this->connected === false) {
552
+		$this->connect();
553
+	}
482 554
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
483 555
 	if ($send === FALSE) {
484 556
 		socket_close($this->socket);
@@ -500,18 +572,26 @@  discard block
 block discarded – undo
500 572
 			//$w = '00';
501 573
 			$custom = '';
502 574
 			if ($ident != '') {
503
-				if ($custom != '') $custom .= '/';
575
+				if ($custom != '') {
576
+					$custom .= '/';
577
+				}
504 578
 				$custom .= 'CS='.$ident;
505 579
 			}
506 580
 			if ($squawk != '') {
507
-				if ($custom != '') $custom .= '/';
581
+				if ($custom != '') {
582
+					$custom .= '/';
583
+				}
508 584
 				$custom .= 'SQ='.$squawk;
509 585
 			}
510 586
 			if ($aircraft_icao != '' && $aircraft_icao != 'NA') {
511
-				if ($custom != '') $custom .= '/';
587
+				if ($custom != '') {
588
+					$custom .= '/';
589
+				}
512 590
 				$custom .= 'AI='.$aircraft_icao;
513 591
 			}
514
-			if ($custom != '') $custom = ' '.$custom;
592
+			if ($custom != '') {
593
+				$custom = ' '.$custom;
594
+			}
515 595
 			$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");
516 596
 		}
517 597
 	}
@@ -529,26 +609,38 @@  discard block
 block discarded – undo
529 609
 			//$w = '00';
530 610
 			$custom = '';
531 611
 			if ($ident != '') {
532
-				if ($custom != '') $custom .= '/';
612
+				if ($custom != '') {
613
+					$custom .= '/';
614
+				}
533 615
 				$custom .= 'CS='.$ident;
534 616
 			}
535 617
 			if ($typeid != '') {
536
-				if ($custom != '') $custom .= '/';
618
+				if ($custom != '') {
619
+					$custom .= '/';
620
+				}
537 621
 				$custom .= 'TI='.$typeid;
538 622
 			}
539 623
 			if ($imo != '') {
540
-				if ($custom != '') $custom .= '/';
624
+				if ($custom != '') {
625
+					$custom .= '/';
626
+				}
541 627
 				$custom .= 'IMO='.$imo;
542 628
 			}
543 629
 			if ($arrival_date != '') {
544
-				if ($custom != '') $custom .= '/';
630
+				if ($custom != '') {
631
+					$custom .= '/';
632
+				}
545 633
 				$custom .= 'AD='.strtotime($arrival_date);
546 634
 			}
547 635
 			if ($arrival_code != '') {
548
-				if ($custom != '') $custom .= '/';
636
+				if ($custom != '') {
637
+					$custom .= '/';
638
+				}
549 639
 				$custom .= 'AC='.$arrival_code;
550 640
 			}
551
-			if ($custom != '') $custom = ' '.$custom;
641
+			if ($custom != '') {
642
+				$custom = ' '.$custom;
643
+			}
552 644
 			$altitude = 0;
553 645
 			$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");
554 646
 		}
Please login to merge, or discard this patch.
incident.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3
-$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
3
+$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING);
4 4
 if ($date == '') $date = date('Y-m-d');
5 5
 header('Location: '.$globalURL.'/incident/'.$date);
6 6
 ?>
7 7
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
4
-if ($date == '') $date = date('Y-m-d');
4
+if ($date == '') {
5
+	$date = date('Y-m-d');
6
+}
5 7
 header('Location: '.$globalURL.'/incident/'.$date);
6 8
 ?>
7 9
\ No newline at end of file
Please login to merge, or discard this patch.
country-statistics-airline-country.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 if (!isset($_GET['country'])) {
6
-        header('Location: '.$globalURL.'/country');
7
-        die();
6
+		header('Location: '.$globalURL.'/country');
7
+		die();
8 8
 }
9 9
 $Spotter = new Spotter();
10 10
 $country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING)));
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
         die();
8 8
 }
9 9
 $Spotter = new Spotter();
10
-$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING)));
11
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
10
+$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'country', FILTER_SANITIZE_STRING)));
11
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
12 12
 
13 13
 if (isset($_GET['sort'])) {
14 14
 	$spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", $sort);
@@ -18,16 +18,16 @@  discard block
 block discarded – undo
18 18
 
19 19
 if (!empty($spotter_array))
20 20
 {
21
-	$title = sprintf(_("Most Common Airlines by Country of %s"),$country);
21
+	$title = sprintf(_("Most Common Airlines by Country of %s"), $country);
22 22
 	require_once('header.php');
23 23
 	print '<div class="select-item">';
24 24
 	print '<form action="'.$globalURL.'/country" method="post">';
25 25
 	print '<select name="country" class="selectpicker" data-live-search="true">';
26 26
 	print '<option></option>';
27 27
 	$all_countries = $Spotter->getAllCountries();
28
-	foreach($all_countries as $all_country)
28
+	foreach ($all_countries as $all_country)
29 29
 	{
30
-		if($country == $all_country['country'])
30
+		if ($country == $all_country['country'])
31 31
 		{
32 32
 			print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>';
33 33
 		} else {
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	if ($_GET['country'] != "NA")
43 43
 	{
44 44
 		print '<div class="info column">';
45
-		print '<h1>'.sprintf(_("Airports &amp; Airlines from %s"),$country).'</h1>';
45
+		print '<h1>'.sprintf(_("Airports &amp; Airlines from %s"), $country).'</h1>';
46 46
 		print '</div>';
47 47
 	} else {
48 48
 		print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>';
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	include('country-sub-menu.php');
52 52
 	print '<div class="column">';
53 53
 	print '<h2>'._("Most Common Airlines by Country").'</h2>';
54
-	print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights from airports &amp; airlines of <strong>%s</strong>."),$country).'</p>';
54
+	print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights from airports &amp; airlines of <strong>%s</strong>."), $country).'</p>';
55 55
 	$airline_array = $Spotter->countAllAirlineCountriesByCountry($country);
56 56
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
57 57
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
60 60
 	print 'var series = [';
61 61
 	$country_data = '';
62
-	foreach($airline_array as $airline_item)
62
+	foreach ($airline_array as $airline_item)
63 63
 	{
64 64
 		$country_data .= '[ "'.$airline_item['airline_country_iso3'].'",'.$airline_item['airline_country_count'].'],';
65 65
 	}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		print '</thead>';
108 108
 		print '<tbody>';
109 109
 		$i = 1;
110
-		foreach($airline_array as $airline_item)
110
+		foreach ($airline_array as $airline_item)
111 111
 		{
112 112
 			print '<tr>';
113 113
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
country-statistics-arrival-airport-country.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 if (!isset($_GET['country'])) {
6
-        header('Location: '.$globalURL.'/country');
7
-        die();
6
+		header('Location: '.$globalURL.'/country');
7
+		die();
8 8
 }
9 9
 $Spotter = new Spotter();
10 10
 $country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING)));
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	include('country-sub-menu.php');
52 52
 	print '<div class="column">';
53 53
 	print '<h2>'._("Most Common Arrival Airports by Country").'</h2>';
54
-        print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports &amp; airlines from <strong>%s</strong>."),$country).'</p>';
54
+		print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports &amp; airlines from <strong>%s</strong>."),$country).'</p>';
55 55
 
56 56
 	$airport_country_array = $Spotter->countAllArrivalAirportCountriesByCountry($country);
57 57
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
         die();
8 8
 }
9 9
 $Spotter = new Spotter();
10
-$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING)));
11
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
10
+$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'country', FILTER_SANITIZE_STRING)));
11
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
12 12
 
13 13
 if (isset($_GET['sort'])) {
14 14
 	$spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", $sort);
@@ -18,16 +18,16 @@  discard block
 block discarded – undo
18 18
 
19 19
 if (!empty($spotter_array))
20 20
 {
21
-	$title = sprintf(_("Most Common Arrival Airports by Country from %s"),$country);
21
+	$title = sprintf(_("Most Common Arrival Airports by Country from %s"), $country);
22 22
 	require_once('header.php');
23 23
 	print '<div class="select-item">';
24 24
 	print '<form action="'.$globalURL.'/country" method="post">';
25 25
 	print '<select name="country" class="selectpicker" data-live-search="true">';
26 26
 	print '<option></option>';
27 27
 	$all_countries = $Spotter->getAllCountries();
28
-	foreach($all_countries as $all_country)
28
+	foreach ($all_countries as $all_country)
29 29
 	{
30
-		if($country == $all_country['country'])
30
+		if ($country == $all_country['country'])
31 31
 		{
32 32
 			print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>';
33 33
 		} else {
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	if ($_GET['country'] != "NA")
43 43
 	{
44 44
 		print '<div class="info column">';
45
-		print '<h1>'.sprintf(_("Airports &amp; Airlines from %s"),$country).'</h1>';
45
+		print '<h1>'.sprintf(_("Airports &amp; Airlines from %s"), $country).'</h1>';
46 46
 		print '</div>';
47 47
 	} else {
48 48
 		print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>';
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	include('country-sub-menu.php');
52 52
 	print '<div class="column">';
53 53
 	print '<h2>'._("Most Common Arrival Airports by Country").'</h2>';
54
-        print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports &amp; airlines from <strong>%s</strong>."),$country).'</p>';
54
+        print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports &amp; airlines from <strong>%s</strong>."), $country).'</p>';
55 55
 
56 56
 	$airport_country_array = $Spotter->countAllArrivalAirportCountriesByCountry($country);
57 57
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
62 62
 	print 'var series = [';
63 63
 	$country_data = '';
64
-	foreach($airport_country_array as $airport_item)
64
+	foreach ($airport_country_array as $airport_item)
65 65
 	{
66 66
 		$country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],';
67 67
 	}
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		print '</thead>';
110 110
 		print '<tbody>';
111 111
 		$i = 1;
112
-		foreach($airport_country_array as $airport_item)
112
+		foreach ($airport_country_array as $airport_item)
113 113
 		{
114 114
 			print '<tr>';
115 115
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
date-statistics-departure-airport-country.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 $Spotter = new Spotter();
6
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
7
-$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
8
-$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
6
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
7
+$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING);
8
+$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort);
9 9
 
10 10
 if (!empty($spotter_array))
11 11
 {
12
-	$title = sprintf(_("Most Common Departure Airports by Country on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
12
+	$title = sprintf(_("Most Common Departure Airports by Country on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
13 13
 
14 14
 	require_once('header.php');
15 15
 	print '<div class="select-item">';
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
 	print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
28 28
 	print '<br />';
29 29
 	print '<div class="info column">';
30
-	print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
30
+	print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
31 31
 	print '</div>';
32 32
 
33 33
 	include('date-sub-menu.php');
34 34
 	print '<div class="column">';
35 35
 	print '<h2>'._("Most Common Departure Airports by Country").'</h2>';
36
-	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
36
+	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
37 37
 	$airport_country_array = $Spotter->countAllDepartureAirportCountriesByDate($date);
38 38
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
39 39
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
42 42
 	print 'var series = [';
43 43
 	$country_data = '';
44
-	foreach($airport_country_array as $airport_item)
44
+	foreach ($airport_country_array as $airport_item)
45 45
 	{
46 46
 		$country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],';
47 47
 	}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		print '</thead>';
90 90
 		print '<tbody>';
91 91
 		$i = 1;
92
-		foreach($airport_country_array as $airport_item)
92
+		foreach ($airport_country_array as $airport_item)
93 93
 		{
94 94
 			print '<tr>';
95 95
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
date-statistics-arrival-airport-country.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 $Spotter = new Spotter();
6
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
7
-$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
8
-$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
6
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
7
+$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING);
8
+$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort);
9 9
 
10 10
 if (!empty($spotter_array))
11 11
 {
12
-	$title = sprintf(_("Most Common Arrival Airports by Country on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
12
+	$title = sprintf(_("Most Common Arrival Airports by Country on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
13 13
 	require_once('header.php');
14 14
 	print '<div class="select-item">';
15 15
 	print '<form action="'.$globalURL.'/date" method="post" class="form-inline">';
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
 	print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
27 27
 	print '<br />';
28 28
 	print '<div class="info column">';
29
-	print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
29
+	print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
30 30
 	print '</div>';
31 31
 
32 32
 	include('date-sub-menu.php');
33 33
 	print '<div class="column">';
34 34
 	print '<h2>'._("Most Common Arrival Airports by Country").'</h2>';
35
-	print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
35
+	print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
36 36
 
37 37
 	$airport_country_array = $Spotter->countAllArrivalAirportCountriesByDate($date);
38 38
 	//print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>';
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 */
74 74
 	print 'var series = [';
75 75
 	$country_data = '';
76
-	foreach($airport_country_array as $airport_item)
76
+	foreach ($airport_country_array as $airport_item)
77 77
 	{
78 78
 		$country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],';
79 79
 	}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		print '</thead>';
122 122
 		print '<tbody>';
123 123
 		$i = 1;
124
-		foreach($airport_country_array as $airport_item)
124
+		foreach ($airport_country_array as $airport_item)
125 125
 		{
126 126
 			print '<tr>';
127 127
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
manufacturer-sub-menu.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
3 3
 </span>
4 4
 <div class="sub-menu sub-menu-container">
5 5
 	<ul class="nav nav-pills">
6
-		<li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
6
+		<li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
7 7
 		<li class="dropdown">
8
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
8
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration") { print 'active'; } ?>" data-toggle="dropdown" href="#">
9 9
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
10 10
 		    </a>
11 11
 		    <ul class="dropdown-menu" role="menu">
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 		    </ul>
15 15
 		</li>
16 16
 		<li class="dropdown">
17
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
17
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
18 18
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
19 19
 		    </a>
20 20
 		    <ul class="dropdown-menu" role="menu">
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		    </ul>
24 24
 		</li>
25 25
 		<li class="dropdown">
26
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-statistics-arrival-airport-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
26
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-statistics-arrival-airport-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
27 27
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
28 28
 		    </a>
29 29
 		    <ul class="dropdown-menu" role="menu">
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 			  <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/arrival-airport-country/<?php print $manufacturer; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
34 34
 		    </ul>
35 35
 		</li>
36
-		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
37
-		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
36
+		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route") { print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
37
+		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time") { print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
38 38
 	</ul>
39 39
 </div>
40 40
\ No newline at end of file
Please login to merge, or discard this patch.
live-geojson.php 3 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -5,23 +5,23 @@  discard block
 block discarded – undo
5 5
 $marine = false;
6 6
 $usecoord = false;
7 7
 if (isset($_GET['tracker'])) {
8
-    $tracker = true;
8
+	$tracker = true;
9 9
 }
10 10
 if (isset($_GET['marine'])) {
11
-    $marine = true;
11
+	$marine = true;
12 12
 }
13 13
 if ($tracker) {
14
-    require_once('require/class.Tracker.php');
15
-    require_once('require/class.TrackerLive.php');
16
-    //require_once('require/class.TrackerArchive.php');
14
+	require_once('require/class.Tracker.php');
15
+	require_once('require/class.TrackerLive.php');
16
+	//require_once('require/class.TrackerArchive.php');
17 17
 } elseif ($marine) {
18
-    require_once('require/class.Marine.php');
19
-    require_once('require/class.MarineLive.php');
20
-    //require_once('require/class.MarineArchive.php');
18
+	require_once('require/class.Marine.php');
19
+	require_once('require/class.MarineLive.php');
20
+	//require_once('require/class.MarineArchive.php');
21 21
 } else {
22
-    require_once('require/class.Spotter.php');
23
-    require_once('require/class.SpotterLive.php');
24
-    require_once('require/class.SpotterArchive.php');
22
+	require_once('require/class.Spotter.php');
23
+	require_once('require/class.SpotterLive.php');
24
+	require_once('require/class.SpotterArchive.php');
25 25
 }
26 26
 
27 27
 $begintime = microtime(true);
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
 $Common = new Common();
42 42
 
43 43
 if (isset($_GET['download'])) {
44
-    if ($_GET['download'] == "true")
45
-    {
44
+	if ($_GET['download'] == "true")
45
+	{
46 46
 	header('Content-disposition: attachment; filename="flightairmap.json"');
47
-    }
47
+	}
48 48
 }
49 49
 header('Content-Type: text/javascript');
50 50
 
@@ -496,13 +496,13 @@  discard block
 block discarded – undo
496 496
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
497 497
 				
498 498
 				if (
499
-				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
500
-				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
499
+					(isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
500
+					|| ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
501 501
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
502 502
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
503
-				    || (isset($history) && $history != '' && $history != 'NA' && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
504
-				    || (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
505
-				    ) {
503
+					|| (isset($history) && $history != '' && $history != 'NA' && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
504
+					|| (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
505
+					) {
506 506
 					if ($tracker) {
507 507
 						$spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']);
508 508
 					} elseif ($marine) {
@@ -555,26 +555,26 @@  discard block
 block discarded – undo
555 555
 				}
556 556
 				
557 557
 				if (isset($history) && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
558
-				    $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
559
-				    if (isset($spotter_item['departure_airport_latitude'])) {
558
+					$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
559
+					if (isset($spotter_item['departure_airport_latitude'])) {
560 560
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
561
-				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
561
+					} elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
562 562
 					$dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']);
563 563
 					if (isset($dairport[0]['latitude'])) {
564
-					    $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
564
+						$output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
565 565
 					}
566
-				    }
567
-				    if (isset($spotter_item['arrival_airport_latitude'])) {
566
+					}
567
+					if (isset($spotter_item['arrival_airport_latitude'])) {
568 568
 					$output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']';
569
-				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
569
+					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
570 570
 					$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
571 571
 					if (isset($aairport[0]['latitude'])) {
572
-					    $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
572
+						$output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
573 573
 					}
574
-				    }
575
-				    $output_air .= ']}},';
576
-				    $output .= $output_air;
577
-				    unset($output_air);
574
+					}
575
+					$output_air .= ']}},';
576
+					$output .= $output_air;
577
+					unset($output_air);
578 578
 				}
579 579
 			}
580 580
 			$output  = substr($output, 0, -1);
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -55,23 +55,23 @@  discard block
 block discarded – undo
55 55
 $min = true;
56 56
 $allhistory = false;
57 57
 $filter['source'] = array();
58
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
59
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
60
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
61
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
62
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
63
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
64
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
65
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
66
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
67
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
58
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
59
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
60
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
61
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
62
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
63
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
64
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
65
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
66
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
67
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
68 68
 
69 69
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
70 70
 	$min = true;
71 71
 } else $min = false;
72 72
 
73 73
 if (isset($_GET['ident'])) {
74
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
74
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
75 75
 	if ($tracker) {
76 76
 		$spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident);
77 77
 	} elseif ($marine) {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	}
86 86
 	$allhistory = true;
87 87
 } elseif (isset($_GET['flightaware_id'])) {
88
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
88
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
89 89
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
90 90
 	if (empty($spotter_array)) {
91 91
 		$from_archive = true;
@@ -93,44 +93,44 @@  discard block
 block discarded – undo
93 93
 	}
94 94
 	$allhistory = true;
95 95
 } elseif (isset($_GET['famtrack_id'])) {
96
-	$famtrack_id = filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING);
96
+	$famtrack_id = filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING);
97 97
 	$spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id);
98 98
 	$allhistory = true;
99 99
 } elseif (isset($_GET['fammarine_id'])) {
100
-	$fammarine_id = filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING);
100
+	$fammarine_id = filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING);
101 101
 	$spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id);
102 102
 	$allhistory = true;
103 103
 } elseif (isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) {
104 104
 //} elseif (isset($_GET['coord'])) {
105 105
 	$usecoord = true;
106
-	$coord = explode(',',$_GET['coord']);
106
+	$coord = explode(',', $_GET['coord']);
107 107
 	if ($tracker) {
108
-		$spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter);
108
+		$spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord, $filter);
109 109
 	} elseif ($marine) {
110
-		$spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord,$filter);
110
+		$spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord, $filter);
111 111
 	} else {
112
-		$spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter);
112
+		$spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter);
113 113
 	}
114 114
 } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) {
115 115
 	$usecoord = true;
116
-	$coord = explode(',',$_GET['coord']);
116
+	$coord = explode(',', $_GET['coord']);
117 117
 	if ($tracker) {
118
-		$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
118
+		$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter);
119 119
 	} elseif ($marine) {
120
-		$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter);
120
+		$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter);
121 121
 	} else {
122
-		$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter);
122
+		$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter);
123 123
 	}
124 124
 } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) {
125 125
 	$from_archive = true;
126 126
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
127 127
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
128
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
129
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
130
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
131
-	$begindate = date('Y-m-d H:i:s',$begindate);
132
-	$enddate = date('Y-m-d H:i:s',$enddate);
133
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
128
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
129
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
130
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
131
+	$begindate = date('Y-m-d H:i:s', $begindate);
132
+	$enddate = date('Y-m-d H:i:s', $enddate);
133
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
134 134
 } elseif ($min) {
135 135
 	if ($tracker) {
136 136
 		$spotter_array = $TrackerLive->getMinLiveTrackerData($filter);
@@ -142,18 +142,18 @@  discard block
 block discarded – undo
142 142
 #	$min = true;
143 143
 } else {
144 144
 	if ($tracker) {
145
-		$spotter_array = $TrackerLive->getLiveTrackerData('','',$filter);
145
+		$spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter);
146 146
 	} elseif ($marine) {
147
-		$spotter_array = $marineLive->getLiveMarineData('','',$filter);
147
+		$spotter_array = $marineLive->getLiveMarineData('', '', $filter);
148 148
 	} else {
149
-		$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
149
+		$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
150 150
 	}
151 151
 }
152 152
 
153 153
 if (!empty($spotter_array) || $usecoord) {
154 154
 	if ($usecoord) {
155 155
 		if (isset($_GET['archive'])) {
156
-			$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
156
+			$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
157 157
 		} else {
158 158
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
159 159
 		}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	if ($flightcnt == '') $flightcnt = 0;
162 162
 } else $flightcnt = 0;
163 163
 
164
-$sqltime = round(microtime(true)-$begintime,2);
164
+$sqltime = round(microtime(true) - $begintime, 2);
165 165
 
166 166
 if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
167 167
 else $usenextlatlon = true;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		if (!empty($spotter_array) && is_array($spotter_array))
179 179
 		{
180 180
 			$output .= '"features": [';
181
-			foreach($spotter_array as $spotter_item)
181
+			foreach ($spotter_array as $spotter_item)
182 182
 			{
183 183
 				$j++;
184 184
 				date_default_timezone_set('UTC');
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
244 244
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
245 245
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
246
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
246
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
247 247
 						} elseif (isset($spotter_item['aircraft_type'])) {
248 248
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
249 249
 						} elseif (!$min) {
@@ -383,16 +383,16 @@  discard block
 block discarded – undo
383 383
 						else $output .= '"heading": "'.$spotter_item['heading'].'",';
384 384
 						
385 385
 						if (isset($archivespeed)) {
386
-							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
386
+							$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed);
387 387
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
388 388
 						} elseif ($usenextlatlon) {
389
-							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']);
389
+							$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']);
390 390
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
391 391
 						}
392 392
 
393 393
 						if (!$min) $output .= '"image": "'.$image.'",';
394 394
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
395
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
395
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
396 396
 						}
397 397
 						if (isset($spotter_item['image_source_website'])) {
398 398
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
415 415
 						}
416 416
 						if (isset($spotter_item['acars'])) {
417
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
417
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
418 418
 						}
419 419
 						// type when not aircraft ?
420 420
 						if (isset($spotter_item['type'])) {
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
                 
493 493
 			}
494 494
 */
495
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
495
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
496 496
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
497 497
 				
498 498
 				if (
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
501 501
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
502 502
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
503
-				    || (isset($history) && $history != '' && $history != 'NA' && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
503
+				    || (isset($history) && $history != '' && $history != 'NA' && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
504 504
 				    || (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
505 505
 				    ) {
506 506
 					if ($tracker) {
@@ -529,9 +529,9 @@  discard block
 block discarded – undo
529 529
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
530 530
 							}
531 531
 							$output_history .= '[';
532
-							$output_history .=  $spotter_history['longitude'].', ';
533
-							$output_history .=  $spotter_history['latitude'].', ';
534
-							$output_history .=  $spotter_history['altitude']*30.48;
532
+							$output_history .= $spotter_history['longitude'].', ';
533
+							$output_history .= $spotter_history['latitude'].', ';
534
+							$output_history .= $spotter_history['altitude']*30.48;
535 535
 							$output_history .= '],';
536 536
 							$prev_alt = $alt;
537 537
 						} else {
@@ -540,8 +540,8 @@  discard block
 block discarded – undo
540 540
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
541 541
 							} else $d = true;
542 542
 							$output_history .= '[';
543
-							$output_history .=  $spotter_history['longitude'].', ';
544
-							$output_history .=  $spotter_history['latitude'];
543
+							$output_history .= $spotter_history['longitude'].', ';
544
+							$output_history .= $spotter_history['latitude'];
545 545
 							$output_history .= '],';
546 546
 						}
547 547
 					}
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 			$output  = substr($output, 0, -1);
581 581
 			$output .= ']';
582 582
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
583
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
583
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
584 584
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
585 585
 			$output .= '"fc": "'.$j.'"';
586 586
 		} else {
Please login to merge, or discard this patch.
Braces   +273 added lines, -107 removed lines patch added patch discarded remove patch
@@ -48,27 +48,52 @@  discard block
 block discarded – undo
48 48
 }
49 49
 header('Content-Type: text/javascript');
50 50
 
51
-if (!isset($globalJsonCompress)) $compress = true;
52
-else $compress = $globalJsonCompress;
51
+if (!isset($globalJsonCompress)) {
52
+	$compress = true;
53
+} else {
54
+	$compress = $globalJsonCompress;
55
+}
53 56
 
54 57
 $from_archive = false;
55 58
 $min = true;
56 59
 $allhistory = false;
57 60
 $filter['source'] = array();
58
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
59
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
60
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
61
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
62
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
63
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
64
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
65
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
66
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
67
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
61
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
62
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
63
+}
64
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
65
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
66
+}
67
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
68
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
69
+}
70
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
71
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
72
+}
73
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
74
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
75
+}
76
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
77
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
78
+}
79
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
80
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
81
+}
82
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
83
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
84
+}
85
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
86
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
87
+}
88
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
89
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
90
+}
68 91
 
69 92
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
70 93
 	$min = true;
71
-} else $min = false;
94
+} else {
95
+	$min = false;
96
+}
72 97
 
73 98
 if (isset($_GET['ident'])) {
74 99
 	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
@@ -157,21 +182,33 @@  discard block
 block discarded – undo
157 182
 		} else {
158 183
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
159 184
 		}
160
-	} else $flightcnt = count($spotter_array);
161
-	if ($flightcnt == '') $flightcnt = 0;
162
-} else $flightcnt = 0;
185
+	} else {
186
+		$flightcnt = count($spotter_array);
187
+	}
188
+	if ($flightcnt == '') {
189
+		$flightcnt = 0;
190
+	}
191
+	} else {
192
+	$flightcnt = 0;
193
+}
163 194
 
164 195
 $sqltime = round(microtime(true)-$begintime,2);
165 196
 
166
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
167
-else $usenextlatlon = true;
197
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
198
+	$usenextlatlon = false;
199
+} else {
200
+	$usenextlatlon = true;
201
+}
168 202
 $j = 0;
169 203
 $prev_flightaware_id = '';
170 204
 $aircrafts_shadow = array();
171 205
 $output = '{';
172 206
 	$output .= '"type": "FeatureCollection",';
173
-		if ($min) $output .= '"minimal": "true",';
174
-		else $output .= '"minimal": "false",';
207
+		if ($min) {
208
+			$output .= '"minimal": "true",';
209
+		} else {
210
+			$output .= '"minimal": "false",';
211
+		}
175 212
 		$output .= '"fc": "'.$flightcnt.'",';
176 213
 		$output .= '"sqt": "'.$sqltime.'",';
177 214
 
@@ -215,18 +252,29 @@  discard block
 block discarded – undo
215 252
 						}
216 253
 						$output .= '"properties": {';
217 254
 						if (isset($spotter_item['flightaware_id'])) {
218
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
219
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
255
+							if ($compress) {
256
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
257
+							} else {
258
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
259
+							}
220 260
 						} elseif (isset($spotter_item['famtrackid'])) {
221
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
222
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
261
+							if ($compress) {
262
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
263
+							} else {
264
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
265
+							}
223 266
 						} elseif (isset($spotter_item['fammarine_id'])) {
224
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
225
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
267
+							if ($compress) {
268
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
269
+							} else {
270
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
271
+							}
226 272
 						}
227 273
 							$output .= '"fc": "'.$flightcnt.'",';
228 274
 							$output .= '"sqt": "'.$sqltime.'",';
229
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
275
+							if (isset($begindate)) {
276
+								$output .= '"archive_date": "'.$begindate.'",';
277
+							}
230 278
 
231 279
 /*
232 280
 							if ($min) $output .= '"minimal": "true",';
@@ -234,13 +282,21 @@  discard block
 block discarded – undo
234 282
 */
235 283
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
236 284
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
237
-							if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",';
238
-							else $output .= '"callsign": "'.$spotter_item['ident'].'",';
285
+							if ($compress) {
286
+								$output .= '"c": "'.$spotter_item['ident'].'",';
287
+							} else {
288
+								$output .= '"callsign": "'.$spotter_item['ident'].'",';
289
+							}
239 290
 						} else {
240
-							if ($compress) $output .= '"c": "NA",';
241
-							else $output .= '"callsign": "NA",';
291
+							if ($compress) {
292
+								$output .= '"c": "NA",';
293
+							} else {
294
+								$output .= '"callsign": "NA",';
295
+							}
296
+						}
297
+						if (isset($spotter_item['registration'])) {
298
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
242 299
 						}
243
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
244 300
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
245 301
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
246 302
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -253,15 +309,21 @@  discard block
 block discarded – undo
253 309
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
254 310
 						}
255 311
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) {
256
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
257
-							else {
312
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
313
+								$spotter_item['aircraft_shadow'] = '';
314
+							} else {
258 315
 								$aircraft_icao = $spotter_item['aircraft_icao'];
259
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
260
-								else {
316
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
317
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
318
+								} else {
261 319
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
262
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
263
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
264
-									else $spotter_item['aircraft_shadow'] = '';
320
+									if (count($aircraft_info) > 0) {
321
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
322
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
323
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
324
+									} else {
325
+										$spotter_item['aircraft_shadow'] = '';
326
+									}
265 327
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
266 328
 								}
267 329
 							}
@@ -269,73 +331,139 @@  discard block
 block discarded – undo
269 331
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
270 332
 							if ($tracker) {
271 333
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
272
-									if ($compress) $output .= '"as": "ambulance.png",';
273
-									else $output .= '"aircraft_shadow": "ambulance.png",';
334
+									if ($compress) {
335
+										$output .= '"as": "ambulance.png",';
336
+									} else {
337
+										$output .= '"aircraft_shadow": "ambulance.png",';
338
+									}
274 339
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
275
-									if ($compress) $output .= '"as": "police.png",';
276
-									else $output .= '"aircraft_shadow": "police.png",';
340
+									if ($compress) {
341
+										$output .= '"as": "police.png",';
342
+									} else {
343
+										$output .= '"aircraft_shadow": "police.png",';
344
+									}
277 345
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
278
-									if ($compress) $output .= '"as": "ship.png",';
279
-									else $output .= '"aircraft_shadow": "ship.png",';
346
+									if ($compress) {
347
+										$output .= '"as": "ship.png",';
348
+									} else {
349
+										$output .= '"aircraft_shadow": "ship.png",';
350
+									}
280 351
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
281
-									if ($compress) $output .= '"as": "ship.png",';
282
-									else $output .= '"aircraft_shadow": "ship.png",';
352
+									if ($compress) {
353
+										$output .= '"as": "ship.png",';
354
+									} else {
355
+										$output .= '"aircraft_shadow": "ship.png",';
356
+									}
283 357
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
284
-									if ($compress) $output .= '"as": "ship.png",';
285
-									else $output .= '"aircraft_shadow": "ship.png",';
358
+									if ($compress) {
359
+										$output .= '"as": "ship.png",';
360
+									} else {
361
+										$output .= '"aircraft_shadow": "ship.png",';
362
+									}
286 363
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
287
-									if ($compress) $output .= '"as": "truck.png",';
288
-									else $output .= '"aircraft_shadow": "truck.png",';
364
+									if ($compress) {
365
+										$output .= '"as": "truck.png",';
366
+									} else {
367
+										$output .= '"aircraft_shadow": "truck.png",';
368
+									}
289 369
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
290
-									if ($compress) $output .= '"as": "truck.png",';
291
-									else $output .= '"aircraft_shadow": "truck.png",';
370
+									if ($compress) {
371
+										$output .= '"as": "truck.png",';
372
+									} else {
373
+										$output .= '"aircraft_shadow": "truck.png",';
374
+									}
292 375
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
293
-									if ($compress) $output .= '"as": "aircraft.png",';
294
-									else $output .= '"aircraft_shadow": "aircraft.png",';
376
+									if ($compress) {
377
+										$output .= '"as": "aircraft.png",';
378
+									} else {
379
+										$output .= '"aircraft_shadow": "aircraft.png",';
380
+									}
295 381
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
296
-									if ($compress) $output .= '"as": "aircraft.png",';
297
-									else $output .= '"aircraft_shadow": "aircraft.png",';
382
+									if ($compress) {
383
+										$output .= '"as": "aircraft.png",';
384
+									} else {
385
+										$output .= '"aircraft_shadow": "aircraft.png",';
386
+									}
298 387
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
299
-									if ($compress) $output .= '"as": "helico.png",';
300
-									else $output .= '"aircraft_shadow": "helico.png",';
388
+									if ($compress) {
389
+										$output .= '"as": "helico.png",';
390
+									} else {
391
+										$output .= '"aircraft_shadow": "helico.png",';
392
+									}
301 393
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
302
-									if ($compress) $output .= '"as": "rail.png",';
303
-									else $output .= '"aircraft_shadow": "rail.png",';
394
+									if ($compress) {
395
+										$output .= '"as": "rail.png",';
396
+									} else {
397
+										$output .= '"aircraft_shadow": "rail.png",';
398
+									}
304 399
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
305
-									if ($compress) $output .= '"as": "firetruck.png",';
306
-									else $output .= '"aircraft_shadow": "firetruck.png",';
400
+									if ($compress) {
401
+										$output .= '"as": "firetruck.png",';
402
+									} else {
403
+										$output .= '"aircraft_shadow": "firetruck.png",';
404
+									}
307 405
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
308
-									if ($compress) $output .= '"as": "bus.png",';
309
-									else $output .= '"aircraft_shadow": "bus.png",';
406
+									if ($compress) {
407
+										$output .= '"as": "bus.png",';
408
+									} else {
409
+										$output .= '"aircraft_shadow": "bus.png",';
410
+									}
310 411
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
311
-									if ($compress) $output .= '"as": "phone.png",';
312
-									else $output .= '"aircraft_shadow": "phone.png",';
412
+									if ($compress) {
413
+										$output .= '"as": "phone.png",';
414
+									} else {
415
+										$output .= '"aircraft_shadow": "phone.png",';
416
+									}
313 417
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
314
-									if ($compress) $output .= '"as": "jogger.png",';
315
-									else $output .= '"aircraft_shadow": "jogger.png",';
418
+									if ($compress) {
419
+										$output .= '"as": "jogger.png",';
420
+									} else {
421
+										$output .= '"aircraft_shadow": "jogger.png",';
422
+									}
316 423
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
317
-									if ($compress) $output .= '"as": "bike.png",';
318
-									else $output .= '"aircraft_shadow": "bike.png",';
424
+									if ($compress) {
425
+										$output .= '"as": "bike.png",';
426
+									} else {
427
+										$output .= '"aircraft_shadow": "bike.png",';
428
+									}
319 429
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
320
-									if ($compress) $output .= '"as": "motorcycle.png",';
321
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
430
+									if ($compress) {
431
+										$output .= '"as": "motorcycle.png",';
432
+									} else {
433
+										$output .= '"aircraft_shadow": "motorcycle.png",';
434
+									}
322 435
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
323
-									if ($compress) $output .= '"as": "balloon.png",';
324
-									else $output .= '"aircraft_shadow": "balloon.png",';
436
+									if ($compress) {
437
+										$output .= '"as": "balloon.png",';
438
+									} else {
439
+										$output .= '"aircraft_shadow": "balloon.png",';
440
+									}
325 441
 								} else {
326
-									if ($compress) $output .= '"as": "car.png",';
327
-									else $output .= '"aircraft_shadow": "car.png",';
442
+									if ($compress) {
443
+										$output .= '"as": "car.png",';
444
+									} else {
445
+										$output .= '"aircraft_shadow": "car.png",';
446
+									}
328 447
 								}
329 448
 							} elseif ($marine) {
330
-								if ($compress) $output .= '"as": "ship.png",';
331
-								else $output .= '"aircraft_shadow": "ship.png",';
449
+								if ($compress) {
450
+									$output .= '"as": "ship.png",';
451
+								} else {
452
+									$output .= '"aircraft_shadow": "ship.png",';
453
+								}
332 454
 							} else {
333
-								if ($compress) $output .= '"as": "default.png",';
334
-								else $output .= '"aircraft_shadow": "default.png",';
455
+								if ($compress) {
456
+									$output .= '"as": "default.png",';
457
+								} else {
458
+									$output .= '"aircraft_shadow": "default.png",';
459
+								}
335 460
 							}
336 461
 						} else {
337
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
338
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
462
+							if ($compress) {
463
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
464
+							} else {
465
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
466
+							}
339 467
 						}
340 468
 						if (isset($spotter_item['airline_name'])) {
341 469
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -343,8 +471,11 @@  discard block
 block discarded – undo
343 471
 							$output .= '"airline_name": "NA",';
344 472
 						}
345 473
 						if (isset($spotter_item['departure_airport'])) {
346
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
347
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
474
+							if ($compress) {
475
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
476
+							} else {
477
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
478
+							}
348 479
 						}
349 480
 						if (isset($spotter_item['departure_airport_city'])) {
350 481
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -356,8 +487,11 @@  discard block
 block discarded – undo
356 487
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
357 488
 						}
358 489
 						if (isset($spotter_item['arrival_airport'])) {
359
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
360
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
490
+							if ($compress) {
491
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
492
+							} else {
493
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
494
+							}
361 495
 						}
362 496
 						if (isset($spotter_item['arrival_airport_city'])) {
363 497
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -376,11 +510,17 @@  discard block
 block discarded – undo
376 510
 						}
377 511
 						
378 512
 						if (isset($spotter_item['altitude'])) {
379
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
380
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
513
+							if ($compress) {
514
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
515
+							} else {
516
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
517
+							}
518
+						}
519
+						if ($compress) {
520
+							$output .= '"h": "'.$spotter_item['heading'].'",';
521
+						} else {
522
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
381 523
 						}
382
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
383
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
384 524
 						
385 525
 						if (isset($archivespeed)) {
386 526
 							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
@@ -390,7 +530,9 @@  discard block
 block discarded – undo
390 530
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
391 531
 						}
392 532
 
393
-						if (!$min) $output .= '"image": "'.$image.'",';
533
+						if (!$min) {
534
+							$output .= '"image": "'.$image.'",';
535
+						}
394 536
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
395 537
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
396 538
 						}
@@ -398,8 +540,11 @@  discard block
 block discarded – undo
398 540
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
399 541
 						}
400 542
 						if (isset($spotter_item['squawk'])) {
401
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
402
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
543
+							if ($compress) {
544
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
545
+							} else {
546
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
547
+							}
403 548
 						}
404 549
 						if (isset($spotter_item['squawk_usage'])) {
405 550
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -418,14 +563,23 @@  discard block
 block discarded – undo
418 563
 						}
419 564
 						// type when not aircraft ?
420 565
 						if (isset($spotter_item['type'])) {
421
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
422
-							else $output .= '"type": "'.$spotter_item['type'].'"';
566
+							if ($compress) {
567
+								$output .= '"t": "'.$spotter_item['type'].'"';
568
+							} else {
569
+								$output .= '"type": "'.$spotter_item['type'].'"';
570
+							}
423 571
 						} elseif ($marine) {
424
-							if ($compress) $output .= '"t": "ship"';
425
-							else $output .= '"type": "ship"';
572
+							if ($compress) {
573
+								$output .= '"t": "ship"';
574
+							} else {
575
+								$output .= '"type": "ship"';
576
+							}
426 577
 						} else {
427
-							if ($compress) $output .= '"t": "aircraft"';
428
-							else $output .= '"type": "aircraft"';
578
+							if ($compress) {
579
+								$output .= '"t": "aircraft"';
580
+							} else {
581
+								$output .= '"type": "aircraft"';
582
+							}
429 583
 						}
430 584
 						$output .= '},';
431 585
 						$output .= '"geometry": {';
@@ -493,7 +647,9 @@  discard block
 block discarded – undo
493 647
 			}
494 648
 */
495 649
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
496
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
650
+				if ($history == '' && isset($_COOKIE['history'])) {
651
+					$history = $_COOKIE['history'];
652
+				}
497 653
 				
498 654
 				if (
499 655
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -525,8 +681,11 @@  discard block
 block discarded – undo
525 681
 									$output_history .= ']}},';
526 682
 									$output .= $output_history;
527 683
 								}
528
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
529
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
684
+								if ($compress) {
685
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
686
+								} else {
687
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
688
+								}
530 689
 							}
531 690
 							$output_history .= '[';
532 691
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -536,9 +695,14 @@  discard block
 block discarded – undo
536 695
 							$prev_alt = $alt;
537 696
 						} else {
538 697
 							if ($d == false) {
539
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
540
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
541
-							} else $d = true;
698
+								if ($compress) {
699
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
700
+								} else {
701
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
702
+								}
703
+							} else {
704
+								$d = true;
705
+							}
542 706
 							$output_history .= '[';
543 707
 							$output_history .=  $spotter_history['longitude'].', ';
544 708
 							$output_history .=  $spotter_history['latitude'];
@@ -581,7 +745,9 @@  discard block
 block discarded – undo
581 745
 			$output .= ']';
582 746
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
583 747
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
584
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
748
+			if (isset($begindate)) {
749
+				$output .= '"archive_date": "'.$begindate.'",';
750
+			}
585 751
 			$output .= '"fc": "'.$j.'"';
586 752
 		} else {
587 753
 			$output .= '"features": ';
Please login to merge, or discard this patch.
airport-geojson.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		date_default_timezone_set('UTC');
28 28
 		//waypoint plotting
29 29
 		$output .= '{"type": "Feature",';
30
-		    $output .= '"properties": {';
30
+			$output .= '"properties": {';
31 31
 			$output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",';
32 32
 			$output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",';
33 33
 			$output .= '"country": "'.$spotter_item['country'].'",';
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 			$output .= '"homepage": "'.$spotter_item['home_link'].'",';
51 51
 			$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
52 52
 //			$output .= '"photo": "'.$spotter_item['image_thumbnail'].'",';
53
-		    $output .= '},';
54
-		    $output .= '"geometry": {';
53
+			$output .= '},';
54
+			$output .= '"geometry": {';
55 55
 			$output .= '"type": "Point",';
56 56
 			$output .= '"coordinates": [';
57
-			    $output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
57
+				$output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
58 58
 			$output .= ']';
59
-		    $output .= '}';
59
+			$output .= '}';
60 60
 		$output .= '},';
61 61
 	}
62 62
 	$output  = substr($output, 0, -1);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 if (isset($_GET['coord'])) 
13 13
 {
14
-	$coords = explode(',',$_GET['coord']);
14
+	$coords = explode(',', $_GET['coord']);
15 15
 	$spotter_array = $Spotter->getAllAirportInfobyCoord($coords);
16 16
 } else {
17 17
 	$spotter_array = $Spotter->getAllAirportInfo();
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
             
23 23
 if (!empty($spotter_array))
24 24
 {	  
25
-	foreach($spotter_array as $spotter_item)
25
+	foreach ($spotter_array as $spotter_item)
26 26
 	{
27 27
 		date_default_timezone_set('UTC');
28 28
 		//waypoint plotting
29 29
 		$output .= '{"type": "Feature",';
30 30
 		    $output .= '"properties": {';
31
-			$output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",';
32
-			$output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",';
31
+			$output .= '"name": "'.str_replace('"', "'", $spotter_item['name']).'",';
32
+			$output .= '"city": "'.str_replace('"', "'", $spotter_item['city']).'",';
33 33
 			$output .= '"country": "'.$spotter_item['country'].'",';
34 34
 			$output .= '"altitude": "'.$spotter_item['altitude'].'",';
35
-			$output .= '"popupContent": "'.str_replace('"',"'",$spotter_item['name']).' : '.str_replace('"',"'",$spotter_item['city']).', '.$spotter_item['country'].'",';
35
+			$output .= '"popupContent": "'.str_replace('"', "'", $spotter_item['name']).' : '.str_replace('"', "'", $spotter_item['city']).', '.$spotter_item['country'].'",';
36 36
 			if ($spotter_item['type'] == 'large_airport') {
37 37
 				$output .= '"icon": "'.$globalURL.'/images/airport.png",';
38 38
 			} elseif ($spotter_item['type'] == 'heliport') {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		    $output .= '}';
60 60
 		$output .= '},';
61 61
 	}
62
-	$output  = substr($output, 0, -1);
62
+	$output = substr($output, 0, -1);
63 63
 }
64 64
 $output .= ']}';
65 65
 print $output;
Please login to merge, or discard this patch.