Completed
Push — master ( 7b2761...d4dde6 )
by Yannick
29:28
created
require/class.GeoidHeight.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -91,6 +91,10 @@
 block discarded – undo
91 91
 		$this->rlatres = (($this->height - 1) / 180.0);
92 92
 	}
93 93
 
94
+	/**
95
+	 * @param integer $ix
96
+	 * @param integer $iy
97
+	 */
94 98
 	private function _rawval($ix,$iy) {
95 99
 		if (($iy < 0)) {
96 100
 			$iy = -$iy;
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 * Translated to PHP of GeographicLib/src/Geoid.cpp
12 12
 * by Ycarus <[email protected]> in 2017
13 13
 */
14
-class GeoidHeight  {
14
+class GeoidHeight {
15 15
 	private $c0 = 240;
16 16
 	private $c3 = [[9, -18, -88, 0, 96, 90, 0, 0, -60, -20], [-9, 18, 8, 0, -96, 30, 0, 0, 60, -20], [9, -88, -18, 90, 96, 0, -20, -60, 0, 0], [186, -42, -42, -150, -96, -150, 60, 60, 60, 60], [54, 162, -78, 30, -24, -90, -60, 60, -60, 60], [-9, -32, 18, 30, 24, 0, 20, -60, 0, 0], [-9, 8, 18, 30, -96, 0, -20, 60, 0, 0], [54, -78, 162, -90, -24, 30, 60, -60, 60, -60], [-54, 78, 78, 90, 144, 90, -60, -60, -60, -60], [9, -8, -18, -30, -24, 0, 20, 60, 0, 0], [-9, 18, -32, 0, 24, 30, 0, 0, -60, 20], [9, -18, -8, 0, -24, -30, 0, 0, 60, 20]];
17 17
 	private $c0n = 372;
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	private $v10 = null;
35 35
 	private $v11 = null;
36 36
 
37
-	public function __construct($name='') {
37
+	public function __construct($name = '') {
38 38
 		global $globalGeoidSource;
39 39
 		//if ($name == '') $name = dirname(__FILE__).'/../install/tmp/egm2008-1.pgm';
40 40
 		if ($name == '') {
@@ -42,35 +42,35 @@  discard block
 block discarded – undo
42 42
 			else $name = dirname(__FILE__).'/../data/egm96-15.pgm';
43 43
 		}
44 44
 
45
-		$f = @fopen($name,"r");
45
+		$f = @fopen($name, "r");
46 46
 		if ($f === FALSE) {
47 47
 			throw new Exception("Can't open ".$name);
48 48
 		}
49
-		$line = fgets($f,4096);
49
+		$line = fgets($f, 4096);
50 50
 		if (trim($line) != 'P5') {
51 51
 			throw new Exception('No PGM header');
52 52
 		}
53 53
 		$headerlen = strlen($line);
54 54
 		while (true) {
55
-			$line = fgets($f,4096);
55
+			$line = fgets($f, 4096);
56 56
 			if ((strlen($line) == 0)) {
57 57
 				throw new Exception('EOF before end of file header');
58 58
 			}
59 59
 			$headerlen += strlen($line);
60
-			if (strpos($line,'# Offset ') !== FALSE) {
60
+			if (strpos($line, '# Offset ') !== FALSE) {
61 61
 				$this->offset = substr($line, 9);
62
-			} else if (strpos($line,'# Scale ') !== FALSE) {
62
+			} else if (strpos($line, '# Scale ') !== FALSE) {
63 63
 				$this->scale = substr($line, 8);
64
-			} else if ((strpos($line,'#') === FALSE)) {
65
-				list($this->width, $this->height) = preg_split('/\s+/',$line);
64
+			} else if ((strpos($line, '#') === FALSE)) {
65
+				list($this->width, $this->height) = preg_split('/\s+/', $line);
66 66
 				break;
67 67
 			}
68 68
 		}
69
-		$line = fgets($f,4096);
69
+		$line = fgets($f, 4096);
70 70
 		$headerlen += strlen($line);
71
-		$levels = (int)$line;
72
-		$this->width = (int)$this->width;
73
-		$this->height = (int)$this->height;
71
+		$levels = (int) $line;
72
+		$this->width = (int) $this->width;
73
+		$this->height = (int) $this->height;
74 74
 		if (($levels != 65535)) {
75 75
 			throw new Exception('PGM file must have 65535 gray levels ('.$levels.')');
76 76
 		}
@@ -85,42 +85,42 @@  discard block
 block discarded – undo
85 85
 		}
86 86
 
87 87
 		$fullsize = filesize($name);
88
-		if ((($fullsize - $headerlen) != (($this->width * $this->height) * 2))) {
88
+		if ((($fullsize - $headerlen) != (($this->width*$this->height)*2))) {
89 89
 			throw new Exception('File has the wrong length');
90 90
 		}
91 91
 
92 92
 		$this->headerlen = $headerlen;
93
-		$this->raw= $f;
94
-		$this->rlonres = ($this->width / 360.0);
95
-		$this->rlatres = (($this->height - 1) / 180.0);
93
+		$this->raw = $f;
94
+		$this->rlonres = ($this->width/360.0);
95
+		$this->rlatres = (($this->height - 1)/180.0);
96 96
 	}
97 97
 
98
-	private function _rawval($ix,$iy) {
98
+	private function _rawval($ix, $iy) {
99 99
 		if (($iy < 0)) {
100 100
 			$iy = -$iy;
101
-			$ix += ($this->width / 2);
101
+			$ix += ($this->width/2);
102 102
 		} else if (($iy >= $this->height)) {
103
-			$iy = ((2 * ($this->height - 1)) - $iy);
104
-			$ix += ($this->width / 2);
103
+			$iy = ((2*($this->height - 1)) - $iy);
104
+			$ix += ($this->width/2);
105 105
 		}
106 106
 		if (($ix < 0)) {
107 107
 			$ix += $this->width;
108 108
 		} else if (($ix >= $this->width)) {
109 109
 			$ix -= $this->width;
110 110
 		}
111
-		$k = ((($iy * $this->width) + $ix) * 2) + $this->headerlen;
112
-		fseek($this->raw,$k);
113
-		return unpack('n',fread($this->raw,2))[1];
111
+		$k = ((($iy*$this->width) + $ix)*2) + $this->headerlen;
112
+		fseek($this->raw, $k);
113
+		return unpack('n', fread($this->raw, 2))[1];
114 114
 	}
115 115
 
116
-	public function get($lat,$lon,$cubic=true) {
116
+	public function get($lat, $lon, $cubic = true) {
117 117
 		if (($lon < 0)) {
118 118
 			$lon += 360;
119 119
 		}
120
-		$fy = ((90 - $lat) * $this->rlatres);
121
-		$fx = ($lon * $this->rlonres);
122
-		$iy = (int)$fy;
123
-		$ix = (int)$fx;
120
+		$fy = ((90 - $lat)*$this->rlatres);
121
+		$fx = ($lon*$this->rlonres);
122
+		$iy = (int) $fy;
123
+		$ix = (int) $fx;
124 124
 		$fx -= $ix;
125 125
 		$fy -= $iy;
126 126
 		$t = array();
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 					$c3x = $this->c3;
148 148
 					$c0x = $this->c0;
149 149
 				}
150
-				for ($i = 0; $i < 10;++$i) {
150
+				for ($i = 0; $i < 10; ++$i) {
151 151
 					$t[$i] = 0;
152 152
 					for ($j = 0; $j < 12; ++$j) {
153 153
 						$t[$i] += $v[$j]*$c3x[$j][$i];
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
 			$this->t = $t;
159 159
 		} else $t = $this->t;
160 160
 		if (!($cubic)) {
161
-			$a = (((1 - $fx) * $this->v00) + ($fx * $this->v01));
162
-			$b = (((1 - $fx) * $this->v10) + ($fx * $this->v11));
163
-			$h = (((1 - $fy) * $a) + ($fy * $b));
161
+			$a = (((1 - $fx)*$this->v00) + ($fx*$this->v01));
162
+			$b = (((1 - $fx)*$this->v10) + ($fx*$this->v11));
163
+			$h = (((1 - $fy)*$a) + ($fy*$b));
164 164
 		} else {
165
-			$h = (($t[0] + ($fx * ($t[1] + ($fx * ($t[3] + ($fx * $t[6])))))) + ($fy * (($t[2] + ($fx * ($t[4] + ($fx * $t[7])))) + ($fy * (($t[5] + ($fx * $t[8])) + ($fy * $t[9]))))));
165
+			$h = (($t[0] + ($fx*($t[1] + ($fx*($t[3] + ($fx*$t[6])))))) + ($fy*(($t[2] + ($fx*($t[4] + ($fx*$t[7])))) + ($fy*(($t[5] + ($fx*$t[8])) + ($fy*$t[9]))))));
166 166
 		}
167
-		return ((float)$this->offset + ((float)$this->scale * (float)$h));
167
+		return ((float) $this->offset + ((float) $this->scale*(float) $h));
168 168
 	}
169 169
 }
170 170
 /*
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,8 +38,11 @@  discard block
 block discarded – undo
38 38
 		global $globalGeoidSource;
39 39
 		//if ($name == '') $name = dirname(__FILE__).'/../install/tmp/egm2008-1.pgm';
40 40
 		if ($name == '') {
41
-			if (isset($globalGeoidSource) && $globalGeoidSource != '') $name = dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm';
42
-			else $name = dirname(__FILE__).'/../data/egm96-15.pgm';
41
+			if (isset($globalGeoidSource) && $globalGeoidSource != '') {
42
+				$name = dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm';
43
+			} else {
44
+				$name = dirname(__FILE__).'/../data/egm96-15.pgm';
45
+			}
43 46
 		}
44 47
 
45 48
 		$f = @fopen($name,"r");
@@ -156,7 +159,9 @@  discard block
 block discarded – undo
156 159
 				}
157 160
 			}
158 161
 			$this->t = $t;
159
-		} else $t = $this->t;
162
+		} else {
163
+			$t = $this->t;
164
+		}
160 165
 		if (!($cubic)) {
161 166
 			$a = (((1 - $fx) * $this->v00) + ($fx * $this->v01));
162 167
 			$b = (((1 - $fx) * $this->v10) + ($fx * $this->v11));
Please login to merge, or discard this patch.
require/settings.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 $globalLongitudeMin = '1.0'; //the minimum longitude (east)
43 43
 
44 44
 $globalCenterLatitude = '46.38'; //the latitude center of your coverage area
45
-$globalCenterLongitude = '5.29';//the longitude center of your coverage area
45
+$globalCenterLongitude = '5.29'; //the longitude center of your coverage area
46 46
 
47 47
 $globalLiveZoom = '9'; //default zoom on Live Map
48 48
 $globalAirportZoom = '7'; //default zoom to begin to display airports icons
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 $globalACARS = FALSE;
152 152
 $globalACARSHost = '0.0.0.0'; // Local IP to listen
153 153
 $globalACARSPort = '9999';
154
-$globalACARSArchive = array('10','80','81','82','3F'); // labels of messages to archive
154
+$globalACARSArchive = array('10', '80', '81', '82', '3F'); // labels of messages to archive
155 155
 $globalACARSArchiveKeepMonths = '0';
156 156
 
157 157
 //APRS configuration (for glidernet)
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 //Check by aircraft ICAO if image is not found by registration
249 249
 $globalAircraftImageCheckICAO = TRUE;
250 250
 //Sources for Aircraft image
251
-$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters','customsources');
251
+$globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters', 'customsources');
252 252
 // Custom source configuration {registration} will be replaced by aircraft registration (exif get copyright from exif data for each pic)
253 253
 // example of config : $globalAircraftImageCustomSources = array('thumbnail' => 'http://pics.myurl.com/thumbnail/{registration}.jpg','original' => 'http://myurl/original/{registration}.jpg','source_website' => 'https://www.myurl.com', 'source' => 'customsite', 'copyright' => 'myself','exif' => true);
254 254
 // ************************
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 //Retrieve Image from externals sources
258 258
 $globalMarineImageFetch = TRUE;
259 259
 //Sources for Marine image
260
-$globalMarineImageSources = array('wikimedia','flickr','deviantart','bing','customsources');
260
+$globalMarineImageSources = array('wikimedia', 'flickr', 'deviantart', 'bing', 'customsources');
261 261
 // Custom source configuration {mmsi} will be replaced by vessel mmsi, {name} by it's name (exif get copyright from exif data for each pic)
262 262
 // example of config : $globalMarineImageCustomSources = array('thumbnail' => 'http://pics.myurl.com/thumbnail/{name}.jpg','original' => 'http://myurl/original/{name}.jpg','source_website' => 'https://www.myurl.com', 'source' => 'customsite', 'copyright' => 'myself','exif' => true);
263 263
 // ************************
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 //Retrieve schedules from externals sources (set to FALSE for IVAO or if $globalFork = FALSE)
266 266
 $globalSchedulesFetch = TRUE;
267 267
 //Sources for airline schedule if not official airline site
268
-$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
268
+$globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
269 269
 
270 270
 //Retrieve translation from external sources (set to FALSE for IVAO)
271 271
 $globalTranslationFetch = TRUE;
Please login to merge, or discard this patch.
import/callback.php 2 patches
Braces   +39 added lines, -13 removed lines patch added patch discarded remove patch
@@ -27,15 +27,21 @@  discard block
 block discarded – undo
27 27
 		}
28 28
 	}
29 29
 }
30
-if ($authorize === false) die;
30
+if ($authorize === false) {
31
+	die;
32
+}
31 33
 
32
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
34
+if (isset($globalTracker) && $globalTracker) {
35
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
36
+}
33 37
 if (isset($globalMarine) && $globalMarine) {
34 38
 	require_once(dirname(__FILE__).'/../require/class.AIS.php');
35 39
 	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
36 40
 }
37 41
 
38
-if (!isset($globalDebug)) $globalDebug = FALSE;
42
+if (!isset($globalDebug)) {
43
+	$globalDebug = FALSE;
44
+}
39 45
 
40 46
 // Check if schema is at latest version
41 47
 $Connection = new Connection();
@@ -45,10 +51,16 @@  discard block
 block discarded – undo
45 51
 }
46 52
 
47 53
 if (isset($globalServer) && $globalServer) {
48
-	if ($globalDebug) echo "Using Server Mode\n";
54
+	if ($globalDebug) {
55
+		echo "Using Server Mode\n";
56
+	}
49 57
 	$SI=new SpotterServer();
50
-} else $SI=new SpotterImport($Connection->db);
51
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
58
+} else {
59
+	$SI=new SpotterImport($Connection->db);
60
+}
61
+if (isset($globalTracker) && $globalTracker) {
62
+	$TI = new TrackerImport($Connection->db);
63
+}
52 64
 if (isset($globalMarine) && $globalMarine) {
53 65
 	$AIS = new AIS();
54 66
 	$MI = new MarineImport($Connection->db);
@@ -57,7 +69,9 @@  discard block
 block discarded – undo
57 69
 date_default_timezone_set('UTC');
58 70
 
59 71
 $buffer = '';
60
-if (isset($_POST)) $buffer = $_POST;
72
+if (isset($_POST)) {
73
+	$buffer = $_POST;
74
+}
61 75
 $data = array();
62 76
 if (isset($buffer['type_event']) && isset($buffer['lat']) && isset($buffer['lon'])) {
63 77
 	$data['ident'] = $buffer['device_id'];
@@ -68,15 +82,27 @@  discard block
 block discarded – undo
68 82
 	//$data['heading'] = $buffer['cap']; // Only N/S/E/W
69 83
 	$data['datetime'] = date('Y-m-d H:i:s',$buffer['timestamp']);
70 84
 	$data['comment'] = '';
71
-	if (isset($buffer['battery']) && $buffer['battery'] != '') $data['comment'] .= 'Battery: '.$buffer['battery'].'% ';
85
+	if (isset($buffer['battery']) && $buffer['battery'] != '') {
86
+		$data['comment'] .= 'Battery: '.$buffer['battery'].'% ';
87
+	}
72 88
 	//if (isset($buffer['snr']) && $buffer['snr'] != '') $data['comment'] .= 'SNR: '.$buffer['snr'].' ';
73
-	if (isset($buffer['temp']) && $buffer['temp'] != '') $data['comment'] .= 'Temperature: '.$buffer['temp'].'°C ';
74
-	if (isset($buffer['press']) && $buffer['press'] != '') $data['comment'] .= 'Pressure: '.$buffer['press'].'hPa ';
89
+	if (isset($buffer['temp']) && $buffer['temp'] != '') {
90
+		$data['comment'] .= 'Temperature: '.$buffer['temp'].'°C ';
91
+	}
92
+	if (isset($buffer['press']) && $buffer['press'] != '') {
93
+		$data['comment'] .= 'Pressure: '.$buffer['press'].'hPa ';
94
+	}
75 95
 	$TI->add($data);
76 96
 	unset($data);
77 97
 }
78
-if (isset($SI)) $SI->checkAll();
79
-if (isset($MI)) $MI->checkAll();
80
-if (isset($TI)) $TI->checkAll();
98
+if (isset($SI)) {
99
+	$SI->checkAll();
100
+}
101
+if (isset($MI)) {
102
+	$MI->checkAll();
103
+}
104
+if (isset($TI)) {
105
+	$TI->checkAll();
106
+}
81 107
 
82 108
 ?>
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/../require/class.Source.php');
10 10
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
11 11
 require_once(dirname(__FILE__).'/../require/class.Common.php');
12
-$Common=new Common();
12
+$Common = new Common();
13 13
 $authorize = false;
14 14
 $params = array();
15 15
 $userip = $Common->getUserIP();
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 			$authorize = true;
21 21
 			break;
22 22
 		}
23
-		if ($userip != '' && isset($cb['host']) && in_array($userip,explode(',',$cb['host']))) {
23
+		if ($userip != '' && isset($cb['host']) && in_array($userip, explode(',', $cb['host']))) {
24 24
 			$params = $globalSources[$key];
25 25
 			$authorize = true;
26 26
 			break;
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 
47 47
 if (isset($globalServer) && $globalServer) {
48 48
 	if ($globalDebug) echo "Using Server Mode\n";
49
-	$SI=new SpotterServer();
50
-} else $SI=new SpotterImport($Connection->db);
49
+	$SI = new SpotterServer();
50
+} else $SI = new SpotterImport($Connection->db);
51 51
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
52 52
 if (isset($globalMarine) && $globalMarine) {
53 53
 	$AIS = new AIS();
54 54
 	$MI = new MarineImport($Connection->db);
55 55
 }
56
-$Source=new Source($Connection->db);
56
+$Source = new Source($Connection->db);
57 57
 date_default_timezone_set('UTC');
58 58
 
59 59
 $buffer = '';
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	$data['altitude'] = round($buffer['altitude']*3.28084);
67 67
 	$data['speed'] = $buffer['speed'];
68 68
 	//$data['heading'] = $buffer['cap']; // Only N/S/E/W
69
-	$data['datetime'] = date('Y-m-d H:i:s',$buffer['timestamp']);
69
+	$data['datetime'] = date('Y-m-d H:i:s', $buffer['timestamp']);
70 70
 	$data['comment'] = '';
71 71
 	if (isset($buffer['battery']) && $buffer['battery'] != '') $data['comment'] .= 'Battery: '.$buffer['battery'].'% ';
72 72
 	//if (isset($buffer['snr']) && $buffer['snr'] != '') $data['comment'] .= 'SNR: '.$buffer['snr'].' ';
Please login to merge, or discard this patch.
require/class.APRS.php 4 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -165,6 +165,10 @@  discard block
 block discarded – undo
165 165
 	'\~' => 'TNC Stream SW');
166 166
 	
167 167
 
168
+    /**
169
+     * @param integer $n
170
+     * @param integer $s
171
+     */
168 172
     private function urshift($n, $s) {
169 173
 	return ($n >= 0) ? ($n >> $s) :
170 174
 	    (($n & 0x7fffffff) >> $s) | 
@@ -565,6 +569,9 @@  discard block
 block discarded – undo
565 569
 	socket_close($this->socket);
566 570
     }
567 571
     
572
+    /**
573
+     * @param string $data
574
+     */
568 575
     public function send($data) {
569 576
 	global $globalDebug;
570 577
 	if ($this->connected === false) $this->connect();
Please login to merge, or discard this patch.
Braces   +307 added lines, -110 removed lines patch added patch discarded remove patch
@@ -184,17 +184,23 @@  discard block
 block discarded – undo
184 184
 	
185 185
 	/* Check that end was found and body has at least one byte. */
186 186
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
187
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
187
+	    if ($globalDebug) {
188
+	    	echo '!!! APRS invalid : '.$input."\n";
189
+	    }
188 190
 	    return false;
189 191
 	}
190 192
 	
191
-	if ($debug) echo 'input : '.$input."\n";
193
+	if ($debug) {
194
+		echo 'input : '.$input."\n";
195
+	}
192 196
 	/* Save header and body. */
193 197
 	$body = substr($input,$splitpos+1,$input_len);
194 198
 	$body_len = strlen($body);
195 199
 	$header = substr($input,0,$splitpos);
196 200
 	//$header_len = strlen($header);
197
-	if ($debug) echo 'header : '.$header."\n";
201
+	if ($debug) {
202
+		echo 'header : '.$header."\n";
203
+	}
198 204
 	
199 205
 	/* Parse source, target and path. */
200 206
 	//FLRDF0A52>APRS,qAS,LSTB
@@ -208,11 +214,15 @@  discard block
 block discarded – undo
208 214
 		$result['format_source'] = 'famaprs';
209 215
 		$result['source_type'] = 'ais';
210 216
 	    } else {
211
-		if ($debug) echo 'ident : '.$ident."\n";
217
+		if ($debug) {
218
+			echo 'ident : '.$ident."\n";
219
+		}
212 220
 		$result['ident'] = $ident;
213 221
 	    }
214 222
 	} else {
215
-	    if ($debug) 'No ident'."\n";
223
+	    if ($debug) {
224
+	    	'No ident'."\n";
225
+	    }
216 226
 	    return false;
217 227
 	}
218 228
 	$elements = explode(',',$all_elements);
@@ -223,7 +233,9 @@  discard block
 block discarded – undo
223 233
 	        //echo "ok";
224 234
 	        //if ($element == 'TCPIP*') return false;
225 235
 	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
226
-		if ($debug) echo 'element : '.$element."\n";
236
+		if ($debug) {
237
+			echo 'element : '.$element."\n";
238
+		}
227 239
 		return false;
228 240
 	    }
229 241
 	    /*
@@ -236,13 +248,17 @@  discard block
 block discarded – undo
236 248
 	}
237 249
 	
238 250
 	$type = substr($body,0,1);
239
-	if ($debug) echo 'type : '.$type."\n";
251
+	if ($debug) {
252
+		echo 'type : '.$type."\n";
253
+	}
240 254
 	if ($type == ';') {
241 255
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
242 256
 			$result['address'] = trim(substr($body,1,9));
243 257
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
244 258
 			$result['mmsi'] = trim(substr($body,1,9));
245
-		} else $result['ident'] = trim(substr($body,1,9));
259
+		} else {
260
+			$result['ident'] = trim(substr($body,1,9));
261
+		}
246 262
 	} elseif ($type == ',') {
247 263
 		// Invalid data or test data
248 264
 		return false;
@@ -311,7 +327,9 @@  discard block
 block discarded – undo
311 327
 		//$symbol_table = $matches[4];
312 328
 		$lat = intval($lat_deg);
313 329
 		$lon = intval($lon_deg);
314
-		if ($lat > 89 || $lon > 179) return false;
330
+		if ($lat > 89 || $lon > 179) {
331
+			return false;
332
+		}
315 333
 	    
316 334
 	    /*
317 335
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -321,8 +339,12 @@  discard block
 block discarded – undo
321 339
 	    */
322 340
 		$latitude = $lat + floatval($lat_min)/60;
323 341
 		$longitude = $lon + floatval($lon_min)/60;
324
-		if ($sind == 'S') $latitude = 0-$latitude;
325
-		if ($wind == 'W') $longitude = 0-$longitude;
342
+		if ($sind == 'S') {
343
+			$latitude = 0-$latitude;
344
+		}
345
+		if ($wind == 'W') {
346
+			$longitude = 0-$longitude;
347
+		}
326 348
 		$result['latitude'] = $latitude;
327 349
 		$result['longitude'] = $longitude;
328 350
 		$body_parse = substr($body_parse,18);
@@ -350,8 +372,11 @@  discard block
 block discarded – undo
350 372
 			//echo 'find'."\n";
351 373
 			$body_split = str_split($body_parse);
352 374
 			$symbol_code = $body_split[0];
353
-			if (!isset($symbolll) || $symbolll == '/') $symbol_code = '/'.$symbol_code;
354
-			else $symbol_code = '\\'.$symbol_code;
375
+			if (!isset($symbolll) || $symbolll == '/') {
376
+				$symbol_code = '/'.$symbol_code;
377
+			} else {
378
+				$symbol_code = '\\'.$symbol_code;
379
+			}
355 380
 		//'
356 381
 		//}
357 382
 		//echo $body_parse;
@@ -360,7 +385,9 @@  discard block
 block discarded – undo
360 385
 			$body_parse = substr($body_parse,1);
361 386
 			$body_parse_len = strlen($body_parse);
362 387
 			$result['symbol_code'] = $symbol_code;
363
-			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
388
+			if (isset($this->symbols[$symbol_code])) {
389
+				$result['symbol'] = $this->symbols[$symbol_code];
390
+			}
364 391
 			if ($symbol_code != '_') {
365 392
 			}
366 393
 		    //$body_parse = substr($body_parse,1);
@@ -371,7 +398,9 @@  discard block
 block discarded – undo
371 398
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
372 399
 		    	    $course = substr($body_parse,0,3);
373 400
 		    	    $tmp_s = intval($course);
374
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
401
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
402
+		    	    	$result['heading'] = intval($course);
403
+		    	    }
375 404
 		    	    $speed = substr($body_parse,4,3);
376 405
 		    	    if ($speed != '...') {
377 406
 		    		//$result['speed'] = round($speed*1.852);
@@ -412,10 +441,16 @@  discard block
 block discarded – undo
412 441
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
413 442
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
414 443
 			    
415
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
416
-				else $result['latitude'] += $lat_off;
417
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
418
-				else $result['longitude'] += $lon_off;
444
+				if ($result['latitude'] < 0) {
445
+					$result['latitude'] -= $lat_off;
446
+				} else {
447
+					$result['latitude'] += $lat_off;
448
+				}
449
+				if ($result['longitude'] < 0) {
450
+					$result['longitude'] -= $lon_off;
451
+				} else {
452
+					$result['longitude'] += $lon_off;
453
+				}
419 454
 			    }
420 455
 			    
421 456
 		            $body_parse = substr($body_parse,6);
@@ -457,27 +492,48 @@  discard block
 block discarded – undo
457 492
 			$address = substr($id,2);
458 493
 			//print_r($matches);
459 494
 			$addressType = (intval(substr($id,0,2),16))&3;
460
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
461
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
462
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
463
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
495
+			if ($addressType == 0) {
496
+				$result['addresstype'] = "RANDOM";
497
+			} elseif ($addressType == 1) {
498
+				$result['addresstype'] = "ICAO";
499
+			} elseif ($addressType == 2) {
500
+				$result['addresstype'] = "FLARM";
501
+			} elseif ($addressType == 3) {
502
+				$result['addresstype'] = "OGN";
503
+			}
464 504
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
465 505
 			$result['aircrafttype_code'] = $aircraftType;
466
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
467
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
468
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
469
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
470
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
471
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
472
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
473
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
474
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
475
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
476
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
477
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
478
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
479
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
480
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
506
+			if ($aircraftType == 0) {
507
+				$result['aircrafttype'] = "UNKNOWN";
508
+			} elseif ($aircraftType == 1) {
509
+				$result['aircrafttype'] = "GLIDER";
510
+			} elseif ($aircraftType == 2) {
511
+				$result['aircrafttype'] = "TOW_PLANE";
512
+			} elseif ($aircraftType == 3) {
513
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
514
+			} elseif ($aircraftType == 4) {
515
+				$result['aircrafttype'] = "PARACHUTE";
516
+			} elseif ($aircraftType == 5) {
517
+				$result['aircrafttype'] = "DROP_PLANE";
518
+			} elseif ($aircraftType == 6) {
519
+				$result['aircrafttype'] = "HANG_GLIDER";
520
+			} elseif ($aircraftType == 7) {
521
+				$result['aircrafttype'] = "PARA_GLIDER";
522
+			} elseif ($aircraftType == 8) {
523
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
524
+			} elseif ($aircraftType == 9) {
525
+				$result['aircrafttype'] = "JET_AIRCRAFT";
526
+			} elseif ($aircraftType == 10) {
527
+				$result['aircrafttype'] = "UFO";
528
+			} elseif ($aircraftType == 11) {
529
+				$result['aircrafttype'] = "BALLOON";
530
+			} elseif ($aircraftType == 12) {
531
+				$result['aircrafttype'] = "AIRSHIP";
532
+			} elseif ($aircraftType == 13) {
533
+				$result['aircrafttype'] = "UAV";
534
+			} elseif ($aircraftType == 15) {
535
+				$result['aircrafttype'] = "STATIC_OBJECT";
536
+			}
481 537
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
482 538
 			$result['stealth'] = $stealth;
483 539
 			$result['address'] = $address;
@@ -517,79 +573,183 @@  discard block
 block discarded – undo
517 573
 		    //g012t088r000p000P000h38b10110
518 574
 		    //g011t086r000p000P000h29b10198
519 575
 		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
520
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
521
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
522
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
523
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
524
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
525
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
526
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
576
+			if ($matches[1] != '...') {
577
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
578
+			}
579
+			if ($matches[2] != '...') {
580
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
581
+			}
582
+			if ($matches[3] != '...') {
583
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
584
+			}
585
+			if ($matches[4] != '...') {
586
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
587
+			}
588
+			if ($matches[5] != '...') {
589
+				$result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
590
+			}
591
+			if ($matches[6] != '...') {
592
+				$result['humidity'] = intval($matches[6]);
593
+			}
594
+			if ($matches[7] != '...') {
595
+				$result['pressure'] = round((intval($matches[7])/10),1);
596
+			}
527 597
 		        $body_parse = substr($body_parse,strlen($matches[0]));
528 598
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
529
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
530
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
531
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
532
-			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
533
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
534
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
535
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
599
+			if ($matches[1] != '...') {
600
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
601
+			}
602
+			if ($matches[2] != '...') {
603
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
604
+			}
605
+			if ($matches[3] != '...') {
606
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
607
+			}
608
+			if ($matches[5] != '...') {
609
+				$result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
610
+			}
611
+			if ($matches[4] != '...') {
612
+				$result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
613
+			}
614
+			if ($matches[6] != '...') {
615
+				$result['humidity'] = intval($matches[6]);
616
+			}
617
+			if ($matches[7] != '...') {
618
+				$result['pressure'] = round((intval($matches[7])/10),1);
619
+			}
536 620
 		        $body_parse = substr($body_parse,strlen($matches[0]));
537 621
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
538
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
539
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
540
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
541
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
542
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
543
-			if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
544
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
622
+			if ($matches[1] != '...') {
623
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
624
+			}
625
+			if ($matches[2] != '...') {
626
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
627
+			}
628
+			if ($matches[3] != '...') {
629
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
630
+			}
631
+			if ($matches[4] != '...') {
632
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
633
+			}
634
+			if ($matches[5] != '...') {
635
+				$result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
636
+			}
637
+			if ($matches[7] != '...') {
638
+				$result['humidity'] = intval($matches[7]);
639
+			}
640
+			if ($matches[6] != '...') {
641
+				$result['pressure'] = round((intval($matches[6])/10),1);
642
+			}
545 643
 		        $body_parse = substr($body_parse,strlen($matches[0]));
546 644
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
547
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
548
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
549
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
550
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
551
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
552
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
645
+			if ($matches[1] != '...') {
646
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
647
+			}
648
+			if ($matches[2] != '...') {
649
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
650
+			}
651
+			if ($matches[3] != '...') {
652
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
653
+			}
654
+			if ($matches[4] != '...') {
655
+				$result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
656
+			}
657
+			if ($matches[6] != '...') {
658
+				$result['humidity'] = intval($matches[6]);
659
+			}
660
+			if ($matches[5] != '...') {
661
+				$result['pressure'] = round((intval($matches[5])/10),1);
662
+			}
553 663
 		        $body_parse = substr($body_parse,strlen($matches[0]));
554 664
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
555
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
556
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
557
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
558
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
559
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
560
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
665
+			if ($matches[1] != '...') {
666
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
667
+			}
668
+			if ($matches[2] != '...') {
669
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
670
+			}
671
+			if ($matches[3] != '...') {
672
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
673
+			}
674
+			if ($matches[4] != '...') {
675
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
676
+			}
677
+			if ($matches[6] != '...') {
678
+				$result['humidity'] = intval($matches[6]);
679
+			}
680
+			if ($matches[5] != '...') {
681
+				$result['pressure'] = round((intval($matches[5])/10),1);
682
+			}
561 683
 		        $body_parse = substr($body_parse,strlen($matches[0]));
562 684
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
563
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
564
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
565
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
566
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
567
-			if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
568
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
685
+			if ($matches[1] != '...') {
686
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
687
+			}
688
+			if ($matches[2] != '...') {
689
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
690
+			}
691
+			if ($matches[3] != '...') {
692
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
693
+			}
694
+			if ($matches[4] != '...') {
695
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
696
+			}
697
+			if ($matches[5] != '...') {
698
+				$result['humidity'] = intval($matches[5]);
699
+			}
700
+			if ($matches[6] != '...') {
701
+				$result['pressure'] = round((intval($matches[6])/10),1);
702
+			}
569 703
 		        $body_parse = substr($body_parse,strlen($matches[0]));
570 704
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
571
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
572
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
573
-			if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
574
-			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
705
+			if ($matches[1] != '...') {
706
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
707
+			}
708
+			if ($matches[2] != '...') {
709
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
710
+			}
711
+			if ($matches[2] != '...') {
712
+				$result['humidity'] = intval($matches[3]);
713
+			}
714
+			if ($matches[4] != '...') {
715
+				$result['pressure'] = round((intval($matches[4])/10),1);
716
+			}
575 717
 		        $body_parse = substr($body_parse,strlen($matches[0]));
576 718
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
577
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
578
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
579
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
580
-			if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
581
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
719
+			if ($matches[1] != '...') {
720
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
721
+			}
722
+			if ($matches[2] != '...') {
723
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
724
+			}
725
+			if ($matches[3] != '...') {
726
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
727
+			}
728
+			if ($matches[4] != '...') {
729
+				$result['humidity'] = intval($matches[4]);
730
+			}
731
+			if ($matches[5] != '...') {
732
+				$result['pressure'] = round((intval($matches[5])/10),1);
733
+			}
582 734
 		        $body_parse = substr($body_parse,strlen($matches[0]));
583 735
 		    }
584 736
 		    $result['comment'] = trim($body_parse);
585 737
 		}
586
-		} else $result['comment'] = trim($body_parse);
738
+		} else {
739
+			$result['comment'] = trim($body_parse);
740
+		}
587 741
 
588 742
 	    }
589 743
 	//}
590
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
591
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
592
-	if ($debug) print_r($result);
744
+	if (isset($result['latitude'])) {
745
+		$result['latitude'] = round($result['latitude'],4);
746
+	}
747
+	if (isset($result['longitude'])) {
748
+		$result['longitude'] = round($result['longitude'],4);
749
+	}
750
+	if ($debug) {
751
+		print_r($result);
752
+	}
593 753
 	return $result;
594 754
     }
595 755
     
@@ -598,12 +758,21 @@  discard block
 block discarded – undo
598 758
 	$aprs_connect = 0;
599 759
 	$aprs_keep = 120;
600 760
 	$aprs_last_tx = time();
601
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
602
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
603
-	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
604
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
605
-	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
606
-	else $aprs_pass = '-1';
761
+	if (isset($globalAPRSversion)) {
762
+		$aprs_version = $globalAPRSversion;
763
+	} else {
764
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
765
+	}
766
+	if (isset($globalServerAPRSssid)) {
767
+		$aprs_ssid = $globalServerAPRSssid;
768
+	} else {
769
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
770
+	}
771
+	if (isset($globalServerAPRSpass)) {
772
+		$aprs_pass = $globalServerAPRSpass;
773
+	} else {
774
+		$aprs_pass = '-1';
775
+	}
607 776
 	
608 777
 	$aprs_filter  = '';
609 778
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
@@ -636,10 +805,14 @@  discard block
 block discarded – undo
636 805
     
637 806
     public function send($data) {
638 807
 	global $globalDebug;
639
-	if ($this->connected === false) $this->connect();
808
+	if ($this->connected === false) {
809
+		$this->connect();
810
+	}
640 811
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
641 812
 	if ($send === FALSE) {
642
-		if ($globalDebug) echo 'Reconnect...';
813
+		if ($globalDebug) {
814
+			echo 'Reconnect...';
815
+		}
643 816
 		socket_close($this->socket);
644 817
 		$this->connect();
645 818
 	}
@@ -661,22 +834,32 @@  discard block
 block discarded – undo
661 834
 			//$w = '00';
662 835
 			$custom = '';
663 836
 			if ($ident != '') {
664
-				if ($custom != '') $custom .= '/';
837
+				if ($custom != '') {
838
+					$custom .= '/';
839
+				}
665 840
 				$custom .= 'CS='.$ident;
666 841
 			}
667 842
 			if ($squawk != '') {
668
-				if ($custom != '') $custom .= '/';
843
+				if ($custom != '') {
844
+					$custom .= '/';
845
+				}
669 846
 				$custom .= 'SQ='.$squawk;
670 847
 			}
671 848
 			if ($verticalrate != '') {
672
-				if ($custom != '') $custom .= '/';
849
+				if ($custom != '') {
850
+					$custom .= '/';
851
+				}
673 852
 				$custom .= 'VR='.$verticalrate;
674 853
 			}
675 854
 			if ($aircraft_icao != '' && $aircraft_icao != 'NA') {
676
-				if ($custom != '') $custom .= '/';
855
+				if ($custom != '') {
856
+					$custom .= '/';
857
+				}
677 858
 				$custom .= 'AI='.$aircraft_icao;
678 859
 			}
679
-			if ($custom != '') $custom = ' '.$custom;
860
+			if ($custom != '') {
861
+				$custom = ' '.$custom;
862
+			}
680 863
 			/*
681 864
 			// Use AMSL altitude
682 865
 			$GeoidClass = new GeoidHeight();
@@ -700,30 +883,44 @@  discard block
 block discarded – undo
700 883
 			//$w = '00';
701 884
 			$custom = '';
702 885
 			if ($ident != '') {
703
-				if ($custom != '') $custom .= '/';
886
+				if ($custom != '') {
887
+					$custom .= '/';
888
+				}
704 889
 				$custom .= 'CS='.str_replace(' ','_',$ident);
705 890
 			}
706 891
 			if ($typeid != '') {
707
-				if ($custom != '') $custom .= '/';
892
+				if ($custom != '') {
893
+					$custom .= '/';
894
+				}
708 895
 				$custom .= 'TI='.$typeid;
709 896
 			}
710 897
 			if ($statusid != '') {
711
-				if ($custom != '') $custom .= '/';
898
+				if ($custom != '') {
899
+					$custom .= '/';
900
+				}
712 901
 				$custom .= 'SI='.$statusid;
713 902
 			}
714 903
 			if ($imo != '') {
715
-				if ($custom != '') $custom .= '/';
904
+				if ($custom != '') {
905
+					$custom .= '/';
906
+				}
716 907
 				$custom .= 'IMO='.$imo;
717 908
 			}
718 909
 			if ($arrival_date != '') {
719
-				if ($custom != '') $custom .= '/';
910
+				if ($custom != '') {
911
+					$custom .= '/';
912
+				}
720 913
 				$custom .= 'AD='.strtotime($arrival_date);
721 914
 			}
722 915
 			if ($arrival_code != '') {
723
-				if ($custom != '') $custom .= '/';
916
+				if ($custom != '') {
917
+					$custom .= '/';
918
+				}
724 919
 				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
725 920
 			}
726
-			if ($custom != '') $custom = ' '.$custom;
921
+			if ($custom != '') {
922
+				$custom = ' '.$custom;
923
+			}
727 924
 			$altitude = 0;
728 925
 			$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");
729 926
 		}
Please login to merge, or discard this patch.
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -3,10 +3,10 @@  discard block
 block discarded – undo
3 3
 require_once(dirname(__FILE__).'/class.Common.php');
4 4
 require_once(dirname(__FILE__).'/class.GeoidHeight.php');
5 5
 class aprs {
6
-    private $socket;
7
-    private $connected = false;
6
+	private $socket;
7
+	private $connected = false;
8 8
 
9
-    protected $symbols = array('/!' => 'Police',
9
+	protected $symbols = array('/!' => 'Police',
10 10
 	'/#' => 'DIGI',
11 11
 	'/$' => 'Phone',
12 12
 	'/%' => 'DX Cluster',
@@ -166,13 +166,13 @@  discard block
 block discarded – undo
166 166
 	'\~' => 'TNC Stream SW');
167 167
 	
168 168
 
169
-    private function urshift($n, $s) {
169
+	private function urshift($n, $s) {
170 170
 	return ($n >= 0) ? ($n >> $s) :
171
-	    (($n & 0x7fffffff) >> $s) | 
171
+		(($n & 0x7fffffff) >> $s) | 
172 172
 		(0x40000000 >> ($s - 1));
173
-    }
173
+	}
174 174
 
175
-    public function parse($input) {
175
+	public function parse($input) {
176 176
 	global $globalDebug;
177 177
 	$debug = false;
178 178
 	$result = array();
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	
185 185
 	/* Check that end was found and body has at least one byte. */
186 186
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
187
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
188
-	    return false;
187
+		if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
188
+		return false;
189 189
 	}
190 190
 	
191 191
 	if ($debug) echo 'input : '.$input."\n";
@@ -199,34 +199,34 @@  discard block
 block discarded – undo
199 199
 	/* Parse source, target and path. */
200 200
 	//FLRDF0A52>APRS,qAS,LSTB
201 201
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
202
-	    $ident = $matches[1];
203
-	    $all_elements = $matches[2];
204
-	    if ($ident == 'AIRCRAFT') {
202
+		$ident = $matches[1];
203
+		$all_elements = $matches[2];
204
+		if ($ident == 'AIRCRAFT') {
205 205
 		$result['format_source'] = 'famaprs';
206 206
 		$result['source_type'] = 'modes';
207
-	    } elseif ($ident == 'MARINE') {
207
+		} elseif ($ident == 'MARINE') {
208 208
 		$result['format_source'] = 'famaprs';
209 209
 		$result['source_type'] = 'ais';
210
-	    } else {
210
+		} else {
211 211
 		if ($debug) echo 'ident : '.$ident."\n";
212 212
 		$result['ident'] = $ident;
213
-	    }
213
+		}
214 214
 	} else {
215
-	    if ($debug) 'No ident'."\n";
216
-	    return false;
215
+		if ($debug) 'No ident'."\n";
216
+		return false;
217 217
 	}
218 218
 	$elements = explode(',',$all_elements);
219 219
 	$source = end($elements);
220 220
 	$result['source'] = $source;
221 221
 	foreach ($elements as $element) {
222
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
223
-	        //echo "ok";
224
-	        //if ($element == 'TCPIP*') return false;
225
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
222
+		if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
223
+			//echo "ok";
224
+			//if ($element == 'TCPIP*') return false;
225
+		} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
226 226
 		if ($debug) echo 'element : '.$element."\n";
227 227
 		return false;
228
-	    }
229
-	    /*
228
+		}
229
+		/*
230 230
 	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) {
231 231
 		//echo "ok";
232 232
 	    } else {
@@ -253,48 +253,48 @@  discard block
 block discarded – undo
253 253
 	$body_parse = substr($body,1);
254 254
 	//echo 'Body : '.$body."\n";
255 255
 	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
256
-	    $body_parse = substr($body_parse,10);
257
-	    $find = true;
258
-	    //echo $body_parse."\n";
256
+		$body_parse = substr($body_parse,10);
257
+		$find = true;
258
+		//echo $body_parse."\n";
259 259
 	}
260 260
 	if (preg_match('/^`(.*)\//',$body,$matches)) {
261
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
262
-	    $find = true;
263
-	    //echo $body_parse."\n";
261
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
262
+		$find = true;
263
+		//echo $body_parse."\n";
264 264
 	}
265 265
 	if (preg_match("/^'(.*)\//",$body,$matches)) {
266
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
267
-	    $find = true;
268
-	    //echo $body_parse."\n";
266
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
267
+		$find = true;
268
+		//echo $body_parse."\n";
269 269
 	}
270 270
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
271
-	    $find = true;
272
-	    //print_r($matches);
273
-	    $timestamp = $matches[0];
274
-	    if ($matches[4] == 'h') {
271
+		$find = true;
272
+		//print_r($matches);
273
+		$timestamp = $matches[0];
274
+		if ($matches[4] == 'h') {
275 275
 		$timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]);
276 276
 		//echo 'timestamp : '.$timestamp.' - now : '.time()."\n";
277 277
 		/*
278 278
 		if (time() + 3900 < $timestamp) $timestamp -= 86400;
279 279
 		elseif (time() - 82500 > $timestamp) $timestamp += 86400;
280 280
 		*/
281
-	    } elseif ($matches[4] == 'z' || $matches[4] == '/') {
281
+		} elseif ($matches[4] == 'z' || $matches[4] == '/') {
282 282
 		// This work or not ?
283 283
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
284
-	    }
285
-	    $body_parse = substr($body_parse,7);
286
-	    $result['timestamp'] = $timestamp;
287
-	    //echo date('Ymd H:i:s',$timestamp);
284
+		}
285
+		$body_parse = substr($body_parse,7);
286
+		$result['timestamp'] = $timestamp;
287
+		//echo date('Ymd H:i:s',$timestamp);
288 288
 	}
289 289
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
290
-	    $find = true;
291
-	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
292
-	    $body_parse = substr($body_parse,8);
293
-	    $result['timestamp'] = $timestamp;
294
-	    //echo date('Ymd H:i:s',$timestamp);
290
+		$find = true;
291
+		$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
292
+		$body_parse = substr($body_parse,8);
293
+		$result['timestamp'] = $timestamp;
294
+		//echo date('Ymd H:i:s',$timestamp);
295 295
 	}
296 296
 	//if (strlen($body_parse) > 19) {
297
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
297
+		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
298 298
 		$find = true;
299 299
 		// 4658.70N/00707.78Ez
300 300
 		//print_r(str_split($body_parse));
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 		$lon = intval($lon_deg);
314 314
 		if ($lat > 89 || $lon > 179) return false;
315 315
 	    
316
-	    /*
316
+		/*
317 317
 	    $tmp_5b = str_replace('.','',$lat_min);
318 318
 	    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) {
319 319
 	        print_r($matches);
@@ -327,9 +327,9 @@  discard block
 block discarded – undo
327 327
 		$result['longitude'] = $longitude;
328 328
 		$body_parse = substr($body_parse,18);
329 329
 		$body_parse_len = strlen($body_parse);
330
-	    }
331
-	    $body_parse_len = strlen($body_parse);
332
-	    if ($body_parse_len > 0) {
330
+		}
331
+		$body_parse_len = strlen($body_parse);
332
+		if ($body_parse_len > 0) {
333 333
 		/*
334 334
 		if (!isset($result['timestamp']) && !isset($result['latitude'])) {
335 335
 			$body_split = str_split($body);
@@ -363,95 +363,95 @@  discard block
 block discarded – undo
363 363
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
364 364
 			if ($symbol_code != '_') {
365 365
 			}
366
-		    //$body_parse = substr($body_parse,1);
367
-		    //$body_parse = trim($body_parse);
368
-		    //$body_parse_len = strlen($body_parse);
369
-		    if ($body_parse_len >= 7) {
366
+			//$body_parse = substr($body_parse,1);
367
+			//$body_parse = trim($body_parse);
368
+			//$body_parse_len = strlen($body_parse);
369
+			if ($body_parse_len >= 7) {
370 370
 			
371
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
372
-		    	    $course = substr($body_parse,0,3);
373
-		    	    $tmp_s = intval($course);
374
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
375
-		    	    $speed = substr($body_parse,4,3);
376
-		    	    if ($speed != '...') {
377
-		    		//$result['speed'] = round($speed*1.852);
378
-		    		$result['speed'] = intval($speed);
379
-		    	    }
380
-		    	    $body_parse = substr($body_parse,7);
381
-		        }
382
-		        // Check PHGR, PHG, RNG
383
-		    } 
384
-		    /*
371
+				if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
372
+					$course = substr($body_parse,0,3);
373
+					$tmp_s = intval($course);
374
+					if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
375
+					$speed = substr($body_parse,4,3);
376
+					if ($speed != '...') {
377
+					//$result['speed'] = round($speed*1.852);
378
+					$result['speed'] = intval($speed);
379
+					}
380
+					$body_parse = substr($body_parse,7);
381
+				}
382
+				// Check PHGR, PHG, RNG
383
+			} 
384
+			/*
385 385
 		    else if ($body_parse_len > 0) {
386 386
 			$rest = $body_parse;
387 387
 		    }
388 388
 		    */
389
-		    if (strlen($body_parse) > 0) {
390
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
391
-		            $altitude = intval($matches[1]);
392
-		            //$result['altitude'] = round($altitude*0.3048);
393
-		            $result['altitude'] = $altitude;
394
-		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
395
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
396
-		        }
397
-		    }
389
+			if (strlen($body_parse) > 0) {
390
+				if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
391
+					$altitude = intval($matches[1]);
392
+					//$result['altitude'] = round($altitude*0.3048);
393
+					$result['altitude'] = $altitude;
394
+					//$body_parse = trim(substr($body_parse,strlen($matches[0])));
395
+					$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
396
+				}
397
+			}
398 398
 		    
399
-		    // Telemetry
400
-		    /*
399
+			// Telemetry
400
+			/*
401 401
 		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) {
402 402
 		        // Nothing yet...
403 403
 		    }
404 404
 		    */
405
-		    // DAO
405
+			// DAO
406 406
 		    
407
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
407
+			if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
408 408
 			    
409
-			    $dao = $matches[1];
410
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
409
+				$dao = $matches[1];
410
+				if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
411 411
 				$dao_split = str_split($dao);
412
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
413
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
412
+					$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
413
+					$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
414 414
 			    
415 415
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
416 416
 				else $result['latitude'] += $lat_off;
417 417
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
418 418
 				else $result['longitude'] += $lon_off;
419
-			    }
419
+				}
420 420
 			    
421
-		            $body_parse = substr($body_parse,6);
422
-		    }
423
-		    //echo 'bodyparse : '.$body_parse."\n";
424
-		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
421
+					$body_parse = substr($body_parse,6);
422
+			}
423
+			//echo 'bodyparse : '.$body_parse."\n";
424
+			if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
425 425
 			$result['ident'] = str_replace('_',' ',$matches[1]);
426
-		    }
427
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
426
+			}
427
+			if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
428 428
 			$result['squawk'] = $matches[1];
429
-		    }
430
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
429
+			}
430
+			if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
431 431
 			$result['aircraft_icao'] = $matches[1];
432
-		    }
433
-		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
432
+			}
433
+			if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
434 434
 			$result['verticalrate'] = $matches[1];
435
-		    }
436
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
435
+			}
436
+			if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
437 437
 			$result['typeid'] = $matches[1];
438
-		    }
439
-		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
438
+			}
439
+			if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
440 440
 			$result['statusid'] = $matches[1];
441
-		    }
442
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
441
+			}
442
+			if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
443 443
 			$result['imo'] = $matches[1];
444
-		    }
445
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
444
+			}
445
+			if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
446 446
 			$result['arrival_date'] = $matches[1];
447
-		    }
448
-		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
447
+			}
448
+			if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
449 449
 			$result['arrival_code'] = str_replace('_',' ',$matches[1]);
450
-		    }
451
-		    // OGN comment
450
+			}
451
+			// OGN comment
452 452
 		   // echo "Before OGN : ".$body_parse."\n";
453
-		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
454
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
453
+			//if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
454
+			if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
455 455
 			$id = $matches[1];
456 456
 			//$mode = substr($id,0,2);
457 457
 			$address = substr($id,2);
@@ -481,42 +481,42 @@  discard block
 block discarded – undo
481 481
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
482 482
 			$result['stealth'] = $stealth;
483 483
 			$result['address'] = $address;
484
-		    }
484
+			}
485 485
 		    
486
-		    //Comment
487
-		    $result['comment'] = trim($body_parse);
486
+			//Comment
487
+			$result['comment'] = trim($body_parse);
488 488
 		//} else {
489
-		    // parse weather
490
-		    //$body_parse = substr($body_parse,1);
491
-		    //$body_parse_len = strlen($body_parse);
492
-		    //echo 'weather'."\n";
493
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
494
-			    $result['wind_dir'] = intval($matches[1]);
495
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
496
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
497
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
498
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
499
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
489
+			// parse weather
490
+			//$body_parse = substr($body_parse,1);
491
+			//$body_parse_len = strlen($body_parse);
492
+			//echo 'weather'."\n";
493
+			if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
494
+				$result['wind_dir'] = intval($matches[1]);
495
+				$result['wind_speed'] = round(intval($matches[2])*1.60934,1);
496
+				$result['wind_gust'] = round(intval($matches[3])*1.60934,1);
497
+				$result['temp'] = round(5/9*((intval($matches[4]))-32),1);
498
+					$body_parse = substr($body_parse,strlen($matches[0])+1);
499
+			} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
500 500
 			$result['wind_dir'] = intval($matches[1]);
501 501
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
502 502
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
503 503
 			$result['temp'] = round(5/9*(($matches[4])-32),1);
504
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
505
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
504
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
505
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
506 506
 			$result['wind_dir'] = intval($matches[1]);
507 507
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
508 508
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
509
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
510
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
509
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
510
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
511 511
 			$result['wind_dir'] = intval($matches[1]);
512 512
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
513 513
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
514
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
515
-		    }
516
-		    //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
517
-		    //g012t088r000p000P000h38b10110
518
-		    //g011t086r000p000P000h29b10198
519
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
514
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
515
+			}
516
+			//if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
517
+			//g012t088r000p000P000h38b10110
518
+			//g011t086r000p000P000h29b10198
519
+			if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
520 520
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
521 521
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
522 522
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
 			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
525 525
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
526 526
 			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
527
-		        $body_parse = substr($body_parse,strlen($matches[0]));
528
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
527
+				$body_parse = substr($body_parse,strlen($matches[0]));
528
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
529 529
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
530 530
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
531 531
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
@@ -533,8 +533,8 @@  discard block
 block discarded – undo
533 533
 			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
534 534
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
535 535
 			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
536
-		        $body_parse = substr($body_parse,strlen($matches[0]));
537
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
536
+				$body_parse = substr($body_parse,strlen($matches[0]));
537
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
538 538
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
539 539
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
540 540
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
@@ -542,58 +542,58 @@  discard block
 block discarded – undo
542 542
 			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
543 543
 			if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
544 544
 			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
545
-		        $body_parse = substr($body_parse,strlen($matches[0]));
546
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
545
+				$body_parse = substr($body_parse,strlen($matches[0]));
546
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
547 547
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
548 548
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
549 549
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
550 550
 			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
551 551
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
552 552
 			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
553
-		        $body_parse = substr($body_parse,strlen($matches[0]));
554
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
553
+				$body_parse = substr($body_parse,strlen($matches[0]));
554
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
555 555
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
556 556
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
557 557
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
558 558
 			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
559 559
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
560 560
 			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
561
-		        $body_parse = substr($body_parse,strlen($matches[0]));
562
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
561
+				$body_parse = substr($body_parse,strlen($matches[0]));
562
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
563 563
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
564 564
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
565 565
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
566 566
 			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
567 567
 			if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
568 568
 			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
569
-		        $body_parse = substr($body_parse,strlen($matches[0]));
570
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
569
+				$body_parse = substr($body_parse,strlen($matches[0]));
570
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
571 571
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
572 572
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
573 573
 			if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
574 574
 			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
575
-		        $body_parse = substr($body_parse,strlen($matches[0]));
576
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
575
+				$body_parse = substr($body_parse,strlen($matches[0]));
576
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
577 577
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
578 578
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
579 579
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
580 580
 			if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
581 581
 			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
582
-		        $body_parse = substr($body_parse,strlen($matches[0]));
583
-		    }
584
-		    $result['comment'] = trim($body_parse);
582
+				$body_parse = substr($body_parse,strlen($matches[0]));
583
+			}
584
+			$result['comment'] = trim($body_parse);
585 585
 		}
586 586
 		} else $result['comment'] = trim($body_parse);
587 587
 
588
-	    }
588
+		}
589 589
 	//}
590 590
 	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
591 591
 	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
592 592
 	if ($debug) print_r($result);
593 593
 	return $result;
594
-    }
594
+	}
595 595
     
596
-    public function connect() {
596
+	public function connect() {
597 597
 	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
598 598
 	$aprs_connect = 0;
599 599
 	$aprs_keep = 120;
@@ -617,24 +617,24 @@  discard block
 block discarded – undo
617 617
 		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1);
618 618
 		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
619 619
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
620
-			    echo 'APRS user verified !'."\n";
621
-			    $this->connected = true;
622
-			    return true;
623
-			    break;
620
+				echo 'APRS user verified !'."\n";
621
+				$this->connected = true;
622
+				return true;
623
+				break;
624 624
 			}
625 625
 			if (time()-$authstart > 5) {
626
-			    echo 'APRS timeout'."\n";
627
-			    break;
626
+				echo 'APRS timeout'."\n";
627
+				break;
628 628
 			}
629 629
 		}
630 630
 	}
631
-    }
631
+	}
632 632
 
633
-    public function disconnect() {
633
+	public function disconnect() {
634 634
 	socket_close($this->socket);
635
-    }
635
+	}
636 636
     
637
-    public function send($data) {
637
+	public function send($data) {
638 638
 	global $globalDebug;
639 639
 	if ($this->connected === false) $this->connect();
640 640
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 		socket_close($this->socket);
644 644
 		$this->connect();
645 645
 	}
646
-    }
646
+	}
647 647
 }
648 648
 
649 649
 class APRSSpotter extends APRS {
Please login to merge, or discard this patch.
Spacing   +157 added lines, -158 removed lines patch added patch discarded remove patch
@@ -167,8 +167,7 @@  discard block
 block discarded – undo
167 167
 	
168 168
 
169 169
     private function urshift($n, $s) {
170
-	return ($n >= 0) ? ($n >> $s) :
171
-	    (($n & 0x7fffffff) >> $s) | 
170
+	return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
172 171
 		(0x40000000 >> ($s - 1));
173 172
     }
174 173
 
@@ -180,7 +179,7 @@  discard block
 block discarded – undo
180 179
 	//$split_input = str_split($input);
181 180
 
182 181
 	/* Find the end of header checking for NULL bytes while doing it. */
183
-	$splitpos = strpos($input,':');
182
+	$splitpos = strpos($input, ':');
184 183
 	
185 184
 	/* Check that end was found and body has at least one byte. */
186 185
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -190,15 +189,15 @@  discard block
 block discarded – undo
190 189
 	
191 190
 	if ($debug) echo 'input : '.$input."\n";
192 191
 	/* Save header and body. */
193
-	$body = substr($input,$splitpos+1,$input_len);
192
+	$body = substr($input, $splitpos + 1, $input_len);
194 193
 	$body_len = strlen($body);
195
-	$header = substr($input,0,$splitpos);
194
+	$header = substr($input, 0, $splitpos);
196 195
 	//$header_len = strlen($header);
197 196
 	if ($debug) echo 'header : '.$header."\n";
198 197
 	
199 198
 	/* Parse source, target and path. */
200 199
 	//FLRDF0A52>APRS,qAS,LSTB
201
-	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
200
+	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
202 201
 	    $ident = $matches[1];
203 202
 	    $all_elements = $matches[2];
204 203
 	    if ($ident == 'AIRCRAFT') {
@@ -215,14 +214,14 @@  discard block
 block discarded – undo
215 214
 	    if ($debug) 'No ident'."\n";
216 215
 	    return false;
217 216
 	}
218
-	$elements = explode(',',$all_elements);
217
+	$elements = explode(',', $all_elements);
219 218
 	$source = end($elements);
220 219
 	$result['source'] = $source;
221 220
 	foreach ($elements as $element) {
222
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
221
+	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
223 222
 	        //echo "ok";
224 223
 	        //if ($element == 'TCPIP*') return false;
225
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
224
+	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
226 225
 		if ($debug) echo 'element : '.$element."\n";
227 226
 		return false;
228 227
 	    }
@@ -235,14 +234,14 @@  discard block
 block discarded – undo
235 234
 	    */
236 235
 	}
237 236
 	
238
-	$type = substr($body,0,1);
237
+	$type = substr($body, 0, 1);
239 238
 	if ($debug) echo 'type : '.$type."\n";
240 239
 	if ($type == ';') {
241 240
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
242
-			$result['address'] = trim(substr($body,1,9));
241
+			$result['address'] = trim(substr($body, 1, 9));
243 242
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
244
-			$result['mmsi'] = trim(substr($body,1,9));
245
-		} else $result['ident'] = trim(substr($body,1,9));
243
+			$result['mmsi'] = trim(substr($body, 1, 9));
244
+		} else $result['ident'] = trim(substr($body, 1, 9));
246 245
 	} elseif ($type == ',') {
247 246
 		// Invalid data or test data
248 247
 		return false;
@@ -250,24 +249,24 @@  discard block
 block discarded – undo
250 249
 	
251 250
 	// Check for Timestamp
252 251
 	$find = false;
253
-	$body_parse = substr($body,1);
252
+	$body_parse = substr($body, 1);
254 253
 	//echo 'Body : '.$body."\n";
255
-	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
256
-	    $body_parse = substr($body_parse,10);
254
+	if (preg_match('/^;(.){9}\*/', $body, $matches)) {
255
+	    $body_parse = substr($body_parse, 10);
257 256
 	    $find = true;
258 257
 	    //echo $body_parse."\n";
259 258
 	}
260
-	if (preg_match('/^`(.*)\//',$body,$matches)) {
261
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
259
+	if (preg_match('/^`(.*)\//', $body, $matches)) {
260
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
262 261
 	    $find = true;
263 262
 	    //echo $body_parse."\n";
264 263
 	}
265
-	if (preg_match("/^'(.*)\//",$body,$matches)) {
266
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
264
+	if (preg_match("/^'(.*)\//", $body, $matches)) {
265
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
267 266
 	    $find = true;
268 267
 	    //echo $body_parse."\n";
269 268
 	}
270
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
269
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
271 270
 	    $find = true;
272 271
 	    //print_r($matches);
273 272
 	    $timestamp = $matches[0];
@@ -282,19 +281,19 @@  discard block
 block discarded – undo
282 281
 		// This work or not ?
283 282
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
284 283
 	    }
285
-	    $body_parse = substr($body_parse,7);
284
+	    $body_parse = substr($body_parse, 7);
286 285
 	    $result['timestamp'] = $timestamp;
287 286
 	    //echo date('Ymd H:i:s',$timestamp);
288 287
 	}
289
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
288
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
290 289
 	    $find = true;
291 290
 	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
292
-	    $body_parse = substr($body_parse,8);
291
+	    $body_parse = substr($body_parse, 8);
293 292
 	    $result['timestamp'] = $timestamp;
294 293
 	    //echo date('Ymd H:i:s',$timestamp);
295 294
 	}
296 295
 	//if (strlen($body_parse) > 19) {
297
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
296
+	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
298 297
 		$find = true;
299 298
 		// 4658.70N/00707.78Ez
300 299
 		//print_r(str_split($body_parse));
@@ -321,11 +320,11 @@  discard block
 block discarded – undo
321 320
 	    */
322 321
 		$latitude = $lat + floatval($lat_min)/60;
323 322
 		$longitude = $lon + floatval($lon_min)/60;
324
-		if ($sind == 'S') $latitude = 0-$latitude;
325
-		if ($wind == 'W') $longitude = 0-$longitude;
323
+		if ($sind == 'S') $latitude = 0 - $latitude;
324
+		if ($wind == 'W') $longitude = 0 - $longitude;
326 325
 		$result['latitude'] = $latitude;
327 326
 		$result['longitude'] = $longitude;
328
-		$body_parse = substr($body_parse,18);
327
+		$body_parse = substr($body_parse, 18);
329 328
 		$body_parse_len = strlen($body_parse);
330 329
 	    }
331 330
 	    $body_parse_len = strlen($body_parse);
@@ -357,7 +356,7 @@  discard block
 block discarded – undo
357 356
 		//echo $body_parse;
358 357
 			//if ($type != ';' && $type != '>') {
359 358
 			if ($type != '') {
360
-			$body_parse = substr($body_parse,1);
359
+			$body_parse = substr($body_parse, 1);
361 360
 			$body_parse_len = strlen($body_parse);
362 361
 			$result['symbol_code'] = $symbol_code;
363 362
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
@@ -368,16 +367,16 @@  discard block
 block discarded – undo
368 367
 		    //$body_parse_len = strlen($body_parse);
369 368
 		    if ($body_parse_len >= 7) {
370 369
 			
371
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
372
-		    	    $course = substr($body_parse,0,3);
370
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
371
+		    	    $course = substr($body_parse, 0, 3);
373 372
 		    	    $tmp_s = intval($course);
374 373
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
375
-		    	    $speed = substr($body_parse,4,3);
374
+		    	    $speed = substr($body_parse, 4, 3);
376 375
 		    	    if ($speed != '...') {
377 376
 		    		//$result['speed'] = round($speed*1.852);
378 377
 		    		$result['speed'] = intval($speed);
379 378
 		    	    }
380
-		    	    $body_parse = substr($body_parse,7);
379
+		    	    $body_parse = substr($body_parse, 7);
381 380
 		        }
382 381
 		        // Check PHGR, PHG, RNG
383 382
 		    } 
@@ -387,12 +386,12 @@  discard block
 block discarded – undo
387 386
 		    }
388 387
 		    */
389 388
 		    if (strlen($body_parse) > 0) {
390
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
389
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
391 390
 		            $altitude = intval($matches[1]);
392 391
 		            //$result['altitude'] = round($altitude*0.3048);
393 392
 		            $result['altitude'] = $altitude;
394 393
 		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
395
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
394
+		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse));
396 395
 		        }
397 396
 		    }
398 397
 		    
@@ -404,13 +403,13 @@  discard block
 block discarded – undo
404 403
 		    */
405 404
 		    // DAO
406 405
 		    
407
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
406
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
408 407
 			    
409 408
 			    $dao = $matches[1];
410
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
409
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
411 410
 				$dao_split = str_split($dao);
412
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
413
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
411
+			        $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
412
+			        $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
414 413
 			    
415 414
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
416 415
 				else $result['latitude'] += $lat_off;
@@ -418,50 +417,50 @@  discard block
 block discarded – undo
418 417
 				else $result['longitude'] += $lon_off;
419 418
 			    }
420 419
 			    
421
-		            $body_parse = substr($body_parse,6);
420
+		            $body_parse = substr($body_parse, 6);
422 421
 		    }
423 422
 		    //echo 'bodyparse : '.$body_parse."\n";
424
-		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
425
-			$result['ident'] = str_replace('_',' ',$matches[1]);
423
+		    if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) {
424
+			$result['ident'] = str_replace('_', ' ', $matches[1]);
426 425
 		    }
427
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
426
+		    if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) {
428 427
 			$result['squawk'] = $matches[1];
429 428
 		    }
430
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
429
+		    if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) {
431 430
 			$result['aircraft_icao'] = $matches[1];
432 431
 		    }
433
-		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
432
+		    if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) {
434 433
 			$result['verticalrate'] = $matches[1];
435 434
 		    }
436
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
435
+		    if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) {
437 436
 			$result['typeid'] = $matches[1];
438 437
 		    }
439
-		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
438
+		    if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) {
440 439
 			$result['statusid'] = $matches[1];
441 440
 		    }
442
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
441
+		    if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) {
443 442
 			$result['imo'] = $matches[1];
444 443
 		    }
445
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
444
+		    if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) {
446 445
 			$result['arrival_date'] = $matches[1];
447 446
 		    }
448
-		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
449
-			$result['arrival_code'] = str_replace('_',' ',$matches[1]);
447
+		    if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) {
448
+			$result['arrival_code'] = str_replace('_', ' ', $matches[1]);
450 449
 		    }
451 450
 		    // OGN comment
452 451
 		   // echo "Before OGN : ".$body_parse."\n";
453 452
 		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
454
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
453
+		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
455 454
 			$id = $matches[1];
456 455
 			//$mode = substr($id,0,2);
457
-			$address = substr($id,2);
456
+			$address = substr($id, 2);
458 457
 			//print_r($matches);
459
-			$addressType = (intval(substr($id,0,2),16))&3;
458
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
460 459
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
461 460
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
462 461
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
463 462
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
464
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
463
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
465 464
 			$result['aircrafttype_code'] = $aircraftType;
466 465
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
467 466
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -478,7 +477,7 @@  discard block
 block discarded – undo
478 477
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
479 478
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
480 479
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
481
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
480
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
482 481
 			$result['stealth'] = $stealth;
483 482
 			$result['address'] = $address;
484 483
 		    }
@@ -490,96 +489,96 @@  discard block
 block discarded – undo
490 489
 		    //$body_parse = substr($body_parse,1);
491 490
 		    //$body_parse_len = strlen($body_parse);
492 491
 		    //echo 'weather'."\n";
493
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
492
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
494 493
 			    $result['wind_dir'] = intval($matches[1]);
495
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
496
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
497
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
498
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
499
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
494
+			    $result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
495
+			    $result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
496
+			    $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1);
497
+		    	    $body_parse = substr($body_parse, strlen($matches[0]) + 1);
498
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
500 499
 			$result['wind_dir'] = intval($matches[1]);
501
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
502
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
503
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
504
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
505
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
500
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
501
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
502
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
503
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
504
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
506 505
 			$result['wind_dir'] = intval($matches[1]);
507
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
508
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
509
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
510
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
506
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
507
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
508
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
509
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
511 510
 			$result['wind_dir'] = intval($matches[1]);
512
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
513
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
514
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
511
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
512
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
513
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
515 514
 		    }
516 515
 		    //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
517 516
 		    //g012t088r000p000P000h38b10110
518 517
 		    //g011t086r000p000P000h29b10198
519
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
520
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
521
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
522
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
523
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
524
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
518
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
519
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
520
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
521
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
522
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
523
+			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
525 524
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
526
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
527
-		        $body_parse = substr($body_parse,strlen($matches[0]));
528
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
529
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
530
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
531
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
532
-			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
533
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
525
+			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
526
+		        $body_parse = substr($body_parse, strlen($matches[0]));
527
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
528
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
529
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
530
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
531
+			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1);
532
+			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
534 533
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
535
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
536
-		        $body_parse = substr($body_parse,strlen($matches[0]));
537
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
538
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
539
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
540
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
541
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
542
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
534
+			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
535
+		        $body_parse = substr($body_parse, strlen($matches[0]));
536
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
537
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
538
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
539
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
540
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
541
+			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
543 542
 			if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
544
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
545
-		        $body_parse = substr($body_parse,strlen($matches[0]));
546
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
547
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
548
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
549
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
550
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
543
+			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
544
+		        $body_parse = substr($body_parse, strlen($matches[0]));
545
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
546
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
547
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
548
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
549
+			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
551 550
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
552
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
553
-		        $body_parse = substr($body_parse,strlen($matches[0]));
554
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
555
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
556
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
557
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
558
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
551
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
552
+		        $body_parse = substr($body_parse, strlen($matches[0]));
553
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
554
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
555
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
556
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
557
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
559 558
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
560
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
561
-		        $body_parse = substr($body_parse,strlen($matches[0]));
562
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
563
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
564
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
565
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
566
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
559
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
560
+		        $body_parse = substr($body_parse, strlen($matches[0]));
561
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
562
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
563
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
564
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
565
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
567 566
 			if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
568
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
569
-		        $body_parse = substr($body_parse,strlen($matches[0]));
570
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
571
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
572
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
567
+			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
568
+		        $body_parse = substr($body_parse, strlen($matches[0]));
569
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
570
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
571
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
573 572
 			if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
574
-			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
575
-		        $body_parse = substr($body_parse,strlen($matches[0]));
576
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
577
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
578
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
579
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
573
+			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1);
574
+		        $body_parse = substr($body_parse, strlen($matches[0]));
575
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
576
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
577
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
578
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
580 579
 			if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
581
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
582
-		        $body_parse = substr($body_parse,strlen($matches[0]));
580
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
581
+		        $body_parse = substr($body_parse, strlen($matches[0]));
583 582
 		    }
584 583
 		    $result['comment'] = trim($body_parse);
585 584
 		}
@@ -587,42 +586,42 @@  discard block
 block discarded – undo
587 586
 
588 587
 	    }
589 588
 	//}
590
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
591
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
589
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
590
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
592 591
 	if ($debug) print_r($result);
593 592
 	return $result;
594 593
     }
595 594
     
596 595
     public function connect() {
597
-	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
596
+	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport;
598 597
 	$aprs_connect = 0;
599 598
 	$aprs_keep = 120;
600 599
 	$aprs_last_tx = time();
601 600
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
602
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
601
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
603 602
 	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
604
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
603
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
605 604
 	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
606 605
 	else $aprs_pass = '-1';
607 606
 	
608
-	$aprs_filter  = '';
607
+	$aprs_filter = '';
609 608
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
610 609
 	$Common = new Common();
611
-	$s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr);
610
+	$s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr);
612 611
 	if ($s !== false) {
613 612
 		echo 'Connected to APRS server! '."\n";
614 613
 		$authstart = time();
615 614
 		$this->socket = $s;
616
-		$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
617
-		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1);
618
-		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
615
+		$send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0);
616
+		socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1);
617
+		while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) {
619 618
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
620 619
 			    echo 'APRS user verified !'."\n";
621 620
 			    $this->connected = true;
622 621
 			    return true;
623 622
 			    break;
624 623
 			}
625
-			if (time()-$authstart > 5) {
624
+			if (time() - $authstart > 5) {
626 625
 			    echo 'APRS timeout'."\n";
627 626
 			    break;
628 627
 			}
@@ -637,7 +636,7 @@  discard block
 block discarded – undo
637 636
     public function send($data) {
638 637
 	global $globalDebug;
639 638
 	if ($this->connected === false) $this->connect();
640
-	$send = socket_send( $this->socket  , $data , strlen($data),0);
639
+	$send = socket_send($this->socket, $data, strlen($data), 0);
641 640
 	if ($send === FALSE) {
642 641
 		if ($globalDebug) echo 'Reconnect...';
643 642
 		socket_close($this->socket);
@@ -647,17 +646,17 @@  discard block
 block discarded – undo
647 646
 }
648 647
 
649 648
 class APRSSpotter extends APRS {
650
-	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) {
649
+	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) {
651 650
 		$Common = new Common();
652 651
 		date_default_timezone_set('UTC');
653 652
 		if ($latitude != '' && $longitude != '') {
654 653
 			$lat = $latitude;
655 654
 			$long = $longitude;
656
-			$latitude = $Common->convertDM($latitude,'latitude');
657
-			$longitude = $Common->convertDM($longitude,'longitude');
658
-			$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'];
659
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
660
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
655
+			$latitude = $Common->convertDM($latitude, 'latitude');
656
+			$longitude = $Common->convertDM($longitude, 'longitude');
657
+			$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'];
658
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
659
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
661 660
 			$w = $w1.$w2;
662 661
 			//$w = '00';
663 662
 			$custom = '';
@@ -684,26 +683,26 @@  discard block
 block discarded – undo
684 683
 			$geoid= round($GeoidClass->get($lat,$long)*3.28084,2);
685 684
 			$altitude_real = round($altitude_real + $geoid);
686 685
 			*/
687
-			$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");
686
+			$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");
688 687
 		}
689 688
 	}
690 689
 }
691 690
 class APRSMarine extends APRS {
692
-	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) {
691
+	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) {
693 692
 		$Common = new Common();
694 693
 		date_default_timezone_set('UTC');
695 694
 		if ($latitude != '' && $longitude != '') {
696
-			$latitude = $Common->convertDM($latitude,'latitude');
697
-			$longitude = $Common->convertDM($longitude,'longitude');
698
-			$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'];
699
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
700
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
695
+			$latitude = $Common->convertDM($latitude, 'latitude');
696
+			$longitude = $Common->convertDM($longitude, 'longitude');
697
+			$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'];
698
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
699
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
701 700
 			$w = $w1.$w2;
702 701
 			//$w = '00';
703 702
 			$custom = '';
704 703
 			if ($ident != '') {
705 704
 				if ($custom != '') $custom .= '/';
706
-				$custom .= 'CS='.str_replace(' ','_',$ident);
705
+				$custom .= 'CS='.str_replace(' ', '_', $ident);
707 706
 			}
708 707
 			if ($typeid != '') {
709 708
 				if ($custom != '') $custom .= '/';
@@ -723,11 +722,11 @@  discard block
 block discarded – undo
723 722
 			}
724 723
 			if ($arrival_code != '') {
725 724
 				if ($custom != '') $custom .= '/';
726
-				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
725
+				$custom .= 'AC='.str_replace(' ', '_', $arrival_code);
727 726
 			}
728 727
 			if ($custom != '') $custom = ' '.$custom;
729 728
 			$altitude = 0;
730
-			$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");
729
+			$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");
731 730
 		}
732 731
 	}
733 732
 }
Please login to merge, or discard this patch.
require/class.ATC.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 	/**
15 15
 	* Get SQL query part for filter used
16 16
 	* @param Array $filter the filter
17
-	* @return Array the SQL part
17
+	* @return string the SQL part
18 18
 	*/
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName;
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@
 block discarded – undo
10 10
 	}
11 11
 
12 12
 	/**
13
-	* Get SQL query part for filter used
14
-	* @param Array $filter the filter
15
-	* @return Array the SQL part
16
-	*/
13
+	 * Get SQL query part for filter used
14
+	 * @param Array $filter the filter
15
+	 * @return Array the SQL part
16
+	 */
17 17
 	public function getFilter($filter = array(),$where = false,$and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName;
19 19
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -14,22 +14,22 @@  discard block
 block discarded – undo
14 14
 	* @param Array $filter the filter
15 15
 	* @return Array the SQL part
16 16
 	*/
17
-	public function getFilter($filter = array(),$where = false,$and = false) {
17
+	public function getFilter($filter = array(), $where = false, $and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName;
19 19
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
20 20
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
21
-				foreach($globalStatsFilters[$globalFilterName] as $source) {
21
+				foreach ($globalStatsFilters[$globalFilterName] as $source) {
22 22
 					if (isset($source['source'])) $filter['source'][] = $source['source'];
23 23
 				}
24 24
 			} else {
25 25
 				$filter = $globalStatsFilters[$globalFilterName];
26 26
 			}
27 27
 		}
28
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
28
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
29 29
 		$filter_query_join = '';
30 30
 		$filter_query_where = '';
31 31
 		if (isset($filter['source']) && !empty($filter['source'])) {
32
-			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
32
+			$filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
33 33
 		}
34 34
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
35 35
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		try {
45 45
 			$sth = $this->db->prepare($query);
46 46
 			$sth->execute($query_values);
47
-		} catch(PDOException $e) {
47
+		} catch (PDOException $e) {
48 48
 			return "error : ".$e->getMessage();
49 49
 		}
50 50
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -52,66 +52,66 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 	public function getById($id) {
55
-		$filter_query = $this->getFilter(array(),true);
55
+		$filter_query = $this->getFilter(array(), true);
56 56
 		$query = "SELECT * FROM atc".$filter_query." atc_id = :id";
57 57
 		$query_values = array(':id' => $id);
58 58
 		try {
59 59
 			$sth = $this->db->prepare($query);
60 60
 			$sth->execute($query_values);
61
-		} catch(PDOException $e) {
61
+		} catch (PDOException $e) {
62 62
 			return "error : ".$e->getMessage();
63 63
 		}
64 64
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
65 65
 		return $all;
66 66
 	}
67 67
 
68
-	public function getByIdent($ident,$format_source = '') {
69
-		$filter_query = $this->getFilter(array(),true);
68
+	public function getByIdent($ident, $format_source = '') {
69
+		$filter_query = $this->getFilter(array(), true);
70 70
 		if ($format_source == '') {
71 71
 			$query = "SELECT * FROM atc".$filter_query." ident = :ident";
72 72
 			$query_values = array(':ident' => $ident);
73 73
 		} else {
74 74
 			$query = "SELECT * FROM atc".$filter_query." ident = :ident AND format_source = :format_source";
75
-			$query_values = array(':ident' => $ident,':format_source' => $format_source);
75
+			$query_values = array(':ident' => $ident, ':format_source' => $format_source);
76 76
 		}
77 77
 		try {
78 78
 			$sth = $this->db->prepare($query);
79 79
 			$sth->execute($query_values);
80
-		} catch(PDOException $e) {
80
+		} catch (PDOException $e) {
81 81
 			return "error : ".$e->getMessage();
82 82
 		}
83 83
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
84 84
 		return $all;
85 85
 	}
86 86
 
87
-	public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
88
-		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
89
-		$info = str_replace('^','<br />',$info);
90
-		$info = str_replace('&amp;sect;','',$info);
91
-		$info = str_replace('"','',$info);
87
+	public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
88
+		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
89
+		$info = str_replace('^', '<br />', $info);
90
+		$info = str_replace('&amp;sect;', '', $info);
91
+		$info = str_replace('"', '', $info);
92 92
 		if ($type == '') $type = NULL;
93 93
 		$query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
94
-		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
94
+		$query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name);
95 95
 		try {
96 96
 			$sth = $this->db->prepare($query);
97 97
 			$sth->execute($query_values);
98
-		} catch(PDOException $e) {
98
+		} catch (PDOException $e) {
99 99
 			return "error : ".$e->getMessage();
100 100
 		}
101 101
 	}
102 102
 
103
-	public function update($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
104
-		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
105
-		$info = str_replace('^','<br />',$info);
106
-		$info = str_replace('&amp;sect;','',$info);
107
-		$info = str_replace('"','',$info);
103
+	public function update($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
104
+		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
105
+		$info = str_replace('^', '<br />', $info);
106
+		$info = str_replace('&amp;sect;', '', $info);
107
+		$info = str_replace('"', '', $info);
108 108
 		if ($type == '') $type = NULL;
109 109
 		$query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name";
110
-		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
110
+		$query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name);
111 111
 		try {
112 112
 			$sth = $this->db->prepare($query);
113 113
 			$sth->execute($query_values);
114
-		} catch(PDOException $e) {
114
+		} catch (PDOException $e) {
115 115
 			return "error : ".$e->getMessage();
116 116
 		}
117 117
 	}
@@ -122,18 +122,18 @@  discard block
 block discarded – undo
122 122
 		try {
123 123
 			$sth = $this->db->prepare($query);
124 124
 			$sth->execute($query_values);
125
-		} catch(PDOException $e) {
125
+		} catch (PDOException $e) {
126 126
 			return "error : ".$e->getMessage();
127 127
 		}
128 128
 	}
129 129
 
130
-	public function deleteByIdent($ident,$format_source) {
130
+	public function deleteByIdent($ident, $format_source) {
131 131
 		$query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source";
132
-		$query_values = array(':ident' => $ident,':format_source' => $format_source);
132
+		$query_values = array(':ident' => $ident, ':format_source' => $format_source);
133 133
 		try {
134 134
 			$sth = $this->db->prepare($query);
135 135
 			$sth->execute($query_values);
136
-		} catch(PDOException $e) {
136
+		} catch (PDOException $e) {
137 137
 			return "error : ".$e->getMessage();
138 138
 		}
139 139
 	}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		try {
145 145
 			$sth = $this->db->prepare($query);
146 146
 			$sth->execute($query_values);
147
-		} catch(PDOException $e) {
147
+		} catch (PDOException $e) {
148 148
 			return "error : ".$e->getMessage();
149 149
 		}
150 150
 	}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		try {
160 160
 			$sth = $this->db->prepare($query);
161 161
 			$sth->execute();
162
-		} catch(PDOException $e) {
162
+		} catch (PDOException $e) {
163 163
 			return "error";
164 164
 		}
165 165
 		return "success";
Please login to merge, or discard this patch.
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,7 +7,9 @@  discard block
 block discarded – undo
7 7
 	public function __construct($dbc = null) {
8 8
 		$Connection = new Connection($dbc);
9 9
 		$this->db = $Connection->db;
10
-		if ($this->db === null) die('Error: No DB connection. (ATC)');
10
+		if ($this->db === null) {
11
+			die('Error: No DB connection. (ATC)');
12
+		}
11 13
 	}
12 14
 
13 15
 	/**
@@ -20,20 +22,27 @@  discard block
 block discarded – undo
20 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 24
 				foreach($globalStatsFilters[$globalFilterName] as $source) {
23
-					if (isset($source['source'])) $filter['source'][] = $source['source'];
25
+					if (isset($source['source'])) {
26
+						$filter['source'][] = $source['source'];
27
+					}
24 28
 				}
25 29
 			} else {
26 30
 				$filter = $globalStatsFilters[$globalFilterName];
27 31
 			}
28 32
 		}
29
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) {
34
+			$filter = array_merge($filter,$globalFilter);
35
+		}
30 36
 		$filter_query_join = '';
31 37
 		$filter_query_where = '';
32 38
 		if (isset($filter['source']) && !empty($filter['source'])) {
33 39
 			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
34 40
 		}
35
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
36
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
41
+		if ($filter_query_where == '' && $where) {
42
+			$filter_query_where = ' WHERE';
43
+		} elseif ($filter_query_where != '' && $and) {
44
+			$filter_query_where .= ' AND';
45
+		}
37 46
 		$filter_query = $filter_query_join.$filter_query_where;
38 47
 		return $filter_query;
39 48
 	}
@@ -90,7 +99,9 @@  discard block
 block discarded – undo
90 99
 		$info = str_replace('^','<br />',$info);
91 100
 		$info = str_replace('&amp;sect;','',$info);
92 101
 		$info = str_replace('"','',$info);
93
-		if ($type == '') $type = NULL;
102
+		if ($type == '') {
103
+			$type = NULL;
104
+		}
94 105
 		$query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
95 106
 		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
96 107
 		try {
@@ -106,7 +117,9 @@  discard block
 block discarded – undo
106 117
 		$info = str_replace('^','<br />',$info);
107 118
 		$info = str_replace('&amp;sect;','',$info);
108 119
 		$info = str_replace('"','',$info);
109
-		if ($type == '') $type = NULL;
120
+		if ($type == '') {
121
+			$type = NULL;
122
+		}
110 123
 		$query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name";
111 124
 		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
112 125
 		try {
Please login to merge, or discard this patch.
tools-geoid.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 try {
6 6
 $GeoidHeight = new GeoidHeight();
7 7
 } catch (Exception $e) {
8
-    echo $e;
8
+	echo $e;
9 9
 }
10 10
 $title = _("Geoid Height Calculator");
11 11
 require_once('header.php');
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
 
13 13
 $page_url = $globalURL.'/tools-geoid';
14 14
 
15
-$latitude = filter_input(INPUT_POST,'latitude',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
16
-$longitude = filter_input(INPUT_POST,'longitude',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
17
-$altitude = filter_input(INPUT_POST,'altitude',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
15
+$latitude = filter_input(INPUT_POST, 'latitude', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
16
+$longitude = filter_input(INPUT_POST, 'longitude', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
17
+$altitude = filter_input(INPUT_POST, 'altitude', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
18 18
 
19 19
 print '<div class="info column">';
20 20
 print '<h1>'._("Geoid Height Calculator").'</h1>';
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 
52 52
 if ($latitude != '' && $longitude != '') {
53 53
 	$globalDebug = FALSE;
54
-	$geoid = $GeoidHeight->get($latitude,$longitude);
54
+	$geoid = $GeoidHeight->get($latitude, $longitude);
55 55
 	print '<div class="row">';
56 56
 	print '<div class="col-md-3 col-md-offset-5">';
57 57
 	print '<div class="col-sm-6"><b>Geoid</b></div>';
58 58
 	print '<div class="col-sm-6">'.$geoid.'</div>';
59 59
 	if ($altitude != '') {
60 60
 		print '<div class="col-sm-6"><b>AMSL Elevation</b></div>';
61
-		print '<div class="col-sm-6">'.round($altitude-$geoid,3).'</div>';
61
+		print '<div class="col-sm-6">'.round($altitude - $geoid, 3).'</div>';
62 62
 	}
63 63
 	print '<div class="col-sm-6"><b>Earth Gravity Model</b></div>';
64 64
 	if (isset($globalGeoidSource) && $globalGeoidSource != '') $geoidsource = $globalGeoidSource;
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,8 +61,11 @@
 block discarded – undo
61 61
 		print '<div class="col-sm-6">'.round($altitude-$geoid,3).'</div>';
62 62
 	}
63 63
 	print '<div class="col-sm-6"><b>Earth Gravity Model</b></div>';
64
-	if (isset($globalGeoidSource) && $globalGeoidSource != '') $geoidsource = $globalGeoidSource;
65
-	else $geoidsource = 'EGM96-15';
64
+	if (isset($globalGeoidSource) && $globalGeoidSource != '') {
65
+		$geoidsource = $globalGeoidSource;
66
+	} else {
67
+		$geoidsource = 'EGM96-15';
68
+	}
66 69
 	print '<div class="col-sm-6">'.$geoidsource.'</div>';
67 70
 	print '</div>';
68 71
 }
Please login to merge, or discard this patch.
require/class.METAR.php 3 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -7,35 +7,35 @@  discard block
 block discarded – undo
7 7
 	public $db;
8 8
 	
9 9
 	protected $texts = Array(
10
-	    'MI' => 'Shallow',
11
-	    'PR' => 'Partial',
12
-	    'BC' => 'Low drifting',
13
-	    'BL' => 'Blowing',
14
-	    'SH' => 'Showers',
15
-	    'TS' => 'Thunderstorm',
16
-	    'FZ' => 'Freezing',
17
-	    'DZ' => 'Drizzle',
18
-	    'RA' => 'Rain',
19
-	    'SN' => 'Snow',
20
-	    'SG' => 'Snow Grains',
21
-	    'IC' => 'Ice crystals',
22
-	    'PL' => 'Ice pellets',
23
-	    'GR' => 'Hail',
24
-	    'GS' => 'Small hail',
25
-	    'UP' => 'Unknown',
26
-	    'BR' => 'Mist',
27
-	    'FG' => 'Fog',
28
-	    'FU' => 'Smoke',
29
-	    'VA' => 'Volcanic ash',
30
-	    'DU' => 'Widespread dust',
31
-	    'SA' => 'Sand',
32
-	    'HZ' => 'Haze',
33
-	    'PY' => 'Spray',
34
-	    'PO' => 'Well developed dust / sand whirls',
35
-	    'SQ' => 'Squalls',
36
-	    'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
-	    'SS' => 'Sandstorm',
38
-	    'DS' => 'Duststorm'
10
+		'MI' => 'Shallow',
11
+		'PR' => 'Partial',
12
+		'BC' => 'Low drifting',
13
+		'BL' => 'Blowing',
14
+		'SH' => 'Showers',
15
+		'TS' => 'Thunderstorm',
16
+		'FZ' => 'Freezing',
17
+		'DZ' => 'Drizzle',
18
+		'RA' => 'Rain',
19
+		'SN' => 'Snow',
20
+		'SG' => 'Snow Grains',
21
+		'IC' => 'Ice crystals',
22
+		'PL' => 'Ice pellets',
23
+		'GR' => 'Hail',
24
+		'GS' => 'Small hail',
25
+		'UP' => 'Unknown',
26
+		'BR' => 'Mist',
27
+		'FG' => 'Fog',
28
+		'FU' => 'Smoke',
29
+		'VA' => 'Volcanic ash',
30
+		'DU' => 'Widespread dust',
31
+		'SA' => 'Sand',
32
+		'HZ' => 'Haze',
33
+		'PY' => 'Spray',
34
+		'PO' => 'Well developed dust / sand whirls',
35
+		'SQ' => 'Squalls',
36
+		'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
+		'SS' => 'Sandstorm',
38
+		'DS' => 'Duststorm'
39 39
 	);
40 40
 
41 41
 	public function __construct($dbc = null) {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     				$result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg';
154 154
     				*/
155 155
 			}
156
-                     /*
156
+					 /*
157 157
     			// Wind Direction
158 158
     			if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) {
159 159
     				$result['wind_direction'] = $matches[1];
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
     				$result['speed_variable'] = $matches[1];
165 165
     			}
166 166
     			*/
167
-    			// Visibility
167
+				// Visibility
168 168
 			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
169 169
 				if (isset($matches[3]) && strlen($matches[3]) > 0) {
170 170
 					$result['visibility'] = (float)$matches[3] * 1609.34;
@@ -222,9 +222,9 @@  discard block
 block discarded – undo
222 222
 				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
223 223
 				if (isset($matches[3])) {
224 224
 					$range = Array(
225
-					    'from' => (float)$matches[2],
226
-					    'to'   => (float)$matches[4],
227
-					    'unit' => $matches[5] ? 'FT' : 'M'
225
+						'from' => (float)$matches[2],
226
+						'to'   => (float)$matches[4],
227
+						'unit' => $matches[5] ? 'FT' : 'M'
228 228
 					);
229 229
 				}
230 230
 				$result['RVR'] = $matches[1];
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 			}
258 258
 		}
259 259
 		return $result;
260
-        }
260
+		}
261 261
 
262 262
 	public function getMETAR($icao) {
263 263
 		global $globalMETARcycle, $globalDBdriver;
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 			$Connection = new Connection();
55 55
 			$sth = $Connection->db->prepare($query);
56 56
 			$sth->execute();
57
-		} catch(PDOException $e) {
57
+		} catch (PDOException $e) {
58 58
 			return "error : ".$e->getMessage();
59 59
 		}
60 60
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 			$Connection = new Connection();
71 71
 			$sth = $Connection->db->prepare($query);
72 72
 			$sth->execute();
73
-		} catch(PDOException $e) {
73
+		} catch (PDOException $e) {
74 74
 			return "error : ".$e->getMessage();
75 75
 		}
76 76
 	}
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 	public function parse($data) {
79 79
 		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
80 80
 		$codes = implode('|', array_keys($this->texts));
81
-		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
81
+		$regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#';
82 82
 		//$pieces = explode(' ',$data);
83
-		$pieces = preg_split('/\s/',$data);
83
+		$pieces = preg_split('/\s/', $data);
84 84
 		$pos = 0;
85 85
 		if ($pieces[0] == 'METAR') $pos++;
86 86
 		elseif ($pieces[0] == 'SPECI') $pos++;
@@ -88,25 +88,25 @@  discard block
 block discarded – undo
88 88
 		$result = array();
89 89
 		$result['location'] = $pieces[$pos];
90 90
 		$pos++;
91
-		$result['dayofmonth'] = substr($pieces[$pos],0,2);
92
-		$result['time'] = substr($pieces[$pos],2,4);
91
+		$result['dayofmonth'] = substr($pieces[$pos], 0, 2);
92
+		$result['time'] = substr($pieces[$pos], 2, 4);
93 93
 		$c = count($pieces);
94
-		for($pos++; $pos < $c; $pos++) {
94
+		for ($pos++; $pos < $c; $pos++) {
95 95
 			$piece = $pieces[$pos];
96 96
 			if ($piece == 'RMK') break;
97 97
 			if ($piece == 'AUTO') $result['auto'] = true;
98 98
 			if ($piece == 'COR') $result['correction'] = true;
99 99
 			// Wind Speed
100 100
 			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
101
-				$result['wind']['direction'] = (float)$matches[1];
101
+				$result['wind']['direction'] = (float) $matches[1];
102 102
 				$result['wind']['unit'] = $matches[4];
103
-				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
104
-				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
105
-				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
106
-				$result['wind']['gust'] = (float)$matches[3];
103
+				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2);
104
+				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2);
105
+				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2);
106
+				$result['wind']['gust'] = (float) $matches[3];
107 107
 				$result['wind']['unit'] = $matches[4];
108
-				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
109
-				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
108
+				$result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0;
109
+				$result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0;
110 110
 			}
111 111
 
112 112
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
 
128 128
 			// Temperature
129 129
 			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
130
-				$temp = (float)$matches[1];
130
+				$temp = (float) $matches[1];
131 131
 				if ($matches[1]{0} == 'M') {
132
-					$temp = ((float)substr($matches[1], 1)) * -1;
132
+					$temp = ((float) substr($matches[1], 1))*-1;
133 133
 				}
134 134
 				$result['temperature'] = $temp;
135
-				$dew = (float)$matches[2];
135
+				$dew = (float) $matches[2];
136 136
 				if ($matches[2]{0} == 'M') {
137
-					$dew = ((float)substr($matches[2], 1)) * -1;
137
+					$dew = ((float) substr($matches[2], 1))*-1;
138 138
 				}
139 139
 				$result['dew'] = $dew;
140 140
 			}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 					$result['QNH'] = $matches[2];
147 147
 				} else {
148 148
 					// inHg
149
-					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
149
+					$result['QNH'] = round(($matches[2]/100)*33.86389, 2);
150 150
 				}
151 151
 				/*
152 152
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
@@ -167,12 +167,12 @@  discard block
 block discarded – undo
167 167
     			// Visibility
168 168
 			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
169 169
 				if (isset($matches[3]) && strlen($matches[3]) > 0) {
170
-					$result['visibility'] = (float)$matches[3] * 1609.34;
170
+					$result['visibility'] = (float) $matches[3]*1609.34;
171 171
 				} else {
172 172
 					if ($matches[1] == '9999') {
173 173
 						$result['visibility'] = '> 10000';
174 174
 					} else {
175
-						$result['visibility'] = (float)$matches[1];
175
+						$result['visibility'] = (float) $matches[1];
176 176
 					}
177 177
 				}
178 178
 				if (preg_match('#^CAVOK$#', $piece, $matches)) {
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
195 195
 				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
196 196
 				$cloud['type_code'] = $type;
197
-				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
197
+				$cloud['level'] = round(((float) $matches[2])*100*0.3048);
198 198
 				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
199 199
 				$result['cloud'][] = $cloud;
200 200
 			}
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 				$rvr['runway'] = $matches[1];
205 205
 				$rvr['assessment'] = $matches[2];
206 206
 				$rvr['rvr'] = $matches[3];
207
-				$rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0;
208
-				$rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : '';
207
+				$rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0;
208
+				$rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : '';
209 209
 				$result['RVR'] = $rvr;
210 210
 			}
211 211
 			//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
 				$result['RVR']['friction'] = $matches[5];
219 219
 			}
220 220
 			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
221
-				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
222
-				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
221
+				if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
222
+				else $range = array('exact' => (float) $matches[2], 'unit' => 'M');
223 223
 				if (isset($matches[3])) {
224 224
 					$range = Array(
225
-					    'from' => (float)$matches[2],
226
-					    'to'   => (float)$matches[4],
225
+					    'from' => (float) $matches[2],
226
+					    'to'   => (float) $matches[4],
227 227
 					    'unit' => $matches[5] ? 'FT' : 'M'
228 228
 					);
229 229
 				}
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 		try {
272 272
 			$sth = $this->db->prepare($query);
273 273
 			$sth->execute($query_values);
274
-		} catch(PDOException $e) {
274
+		} catch (PDOException $e) {
275 275
 			return "error : ".$e->getMessage();
276 276
 		}
277 277
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -281,19 +281,19 @@  discard block
 block discarded – undo
281 281
 		return $all;
282 282
 	}
283 283
 
284
-	public function addMETAR($location,$metar,$date) {
284
+	public function addMETAR($location, $metar, $date) {
285 285
 		global $globalDBdriver;
286
-		$date = date('Y-m-d H:i:s',strtotime($date));
286
+		$date = date('Y-m-d H:i:s', strtotime($date));
287 287
 		if ($globalDBdriver == 'mysql') {
288 288
 			$query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar";
289 289
 		} else {
290 290
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
291 291
 		}
292
-		$query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
292
+		$query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar));
293 293
 		try {
294 294
 			$sth = $this->db->prepare($query);
295 295
 			$sth->execute($query_values);
296
-		} catch(PDOException $e) {
296
+		} catch (PDOException $e) {
297 297
 			return "error : ".$e->getMessage();
298 298
 		}
299 299
 	}
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 		try {
305 305
 			$sth = $this->db->prepare($query);
306 306
 			$sth->execute($query_values);
307
-		} catch(PDOException $e) {
307
+		} catch (PDOException $e) {
308 308
 			return "error : ".$e->getMessage();
309 309
 		}
310 310
 	}
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		try {
315 315
 			$sth = $this->db->prepare($query);
316 316
 			$sth->execute();
317
-		} catch(PDOException $e) {
317
+		} catch (PDOException $e) {
318 318
 			return "error : ".$e->getMessage();
319 319
 		}
320 320
 	}
@@ -325,27 +325,27 @@  discard block
 block discarded – undo
325 325
 		date_default_timezone_set("UTC");
326 326
 		$Common = new Common();
327 327
 		if (isset($globalIVAO) && $globalIVAO) {
328
-			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
329
-			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
328
+			$Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt');
329
+			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r");
330 330
 		} else {
331
-			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
332
-			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
331
+			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
332
+			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r");
333 333
 		}
334 334
 		if ($handle) {
335 335
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
336 336
 			$date = '';
337 337
 			if ($globalTransaction) $this->db->beginTransaction();
338
-			while(($line = fgets($handle,4096)) !== false) {
339
-				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
338
+			while (($line = fgets($handle, 4096)) !== false) {
339
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
340 340
 					$date = $line;
341 341
 				} elseif ($line != '') {
342 342
 					if ($date == '') $date = date('Y/m/d H:m');
343 343
 					$pos = 0;
344
-					$pieces = preg_split('/\s/',$line);
344
+					$pieces = preg_split('/\s/', $line);
345 345
 					if ($pieces[0] == 'METAR') $pos++;
346 346
 					if (strlen($pieces[$pos]) != 4) $pos++;
347 347
 					$location = $pieces[$pos];
348
-					echo $this->addMETAR($location,$line,$date);
348
+					echo $this->addMETAR($location, $line, $date);
349 349
 				}
350 350
 			}
351 351
 			fclose($handle);
@@ -359,22 +359,22 @@  discard block
 block discarded – undo
359 359
 		if ($globalMETARurl == '') return array();
360 360
 		date_default_timezone_set("UTC");
361 361
 		$Common = new Common();
362
-		$url = str_replace('{icao}',$icao,$globalMETARurl);
362
+		$url = str_replace('{icao}', $icao, $globalMETARurl);
363 363
 		$cycle = $Common->getData($url);
364 364
 		$date = '';
365
-		foreach(explode("\n",$cycle) as $line) {
366
-			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
365
+		foreach (explode("\n", $cycle) as $line) {
366
+			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
367 367
 				$date = $line;
368 368
 			} 
369 369
 			if ($line != '') {
370 370
 				if ($date == '') $date = date('Y/m/d H:m');
371 371
 				$pos = 0;
372
-				$pieces = preg_split('/\s/',$line);
372
+				$pieces = preg_split('/\s/', $line);
373 373
 				if ($pieces[0] == 'METAR') $pos++;
374 374
 				if (strlen($pieces[$pos]) != 4) $pos++;
375 375
 				$location = $pieces[$pos];
376 376
 				if (strlen($location == 4)) {
377
-					$this->addMETAR($location,$line,$date);
377
+					$this->addMETAR($location, $line, $date);
378 378
 					return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
379 379
 				} else return array();
380 380
 			}
Please login to merge, or discard this patch.
Braces   +100 added lines, -38 removed lines patch added patch discarded remove patch
@@ -59,8 +59,11 @@  discard block
 block discarded – undo
59 59
 		}
60 60
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
61 61
 		$sth->closeCursor();
62
-		if ($row['nb'] > 0) return false;
63
-		else return true;
62
+		if ($row['nb'] > 0) {
63
+			return false;
64
+		} else {
65
+			return true;
66
+		}
64 67
 	}
65 68
 
66 69
 	public static function insert_last_update() {
@@ -82,9 +85,14 @@  discard block
 block discarded – undo
82 85
 		//$pieces = explode(' ',$data);
83 86
 		$pieces = preg_split('/\s/',$data);
84 87
 		$pos = 0;
85
-		if ($pieces[0] == 'METAR') $pos++;
86
-		elseif ($pieces[0] == 'SPECI') $pos++;
87
-		if (strlen($pieces[$pos]) != 4) $pos++;
88
+		if ($pieces[0] == 'METAR') {
89
+			$pos++;
90
+		} elseif ($pieces[0] == 'SPECI') {
91
+			$pos++;
92
+		}
93
+		if (strlen($pieces[$pos]) != 4) {
94
+			$pos++;
95
+		}
88 96
 		$result = array();
89 97
 		$result['location'] = $pieces[$pos];
90 98
 		$pos++;
@@ -93,16 +101,26 @@  discard block
 block discarded – undo
93 101
 		$c = count($pieces);
94 102
 		for($pos++; $pos < $c; $pos++) {
95 103
 			$piece = $pieces[$pos];
96
-			if ($piece == 'RMK') break;
97
-			if ($piece == 'AUTO') $result['auto'] = true;
98
-			if ($piece == 'COR') $result['correction'] = true;
104
+			if ($piece == 'RMK') {
105
+				break;
106
+			}
107
+			if ($piece == 'AUTO') {
108
+				$result['auto'] = true;
109
+			}
110
+			if ($piece == 'COR') {
111
+				$result['correction'] = true;
112
+			}
99 113
 			// Wind Speed
100 114
 			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
101 115
 				$result['wind']['direction'] = (float)$matches[1];
102 116
 				$result['wind']['unit'] = $matches[4];
103
-				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
104
-				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
105
-				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
117
+				if ($result['wind']['unit'] == 'KT') {
118
+					$result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
119
+				} elseif ($result['wind']['unit'] == 'KPH') {
120
+					$result['wind']['speed'] = round(((float)$matches[2])*1000,2);
121
+				} elseif ($result['wind']['unit'] == 'MPS') {
122
+					$result['wind']['speed'] = round(((float)$matches[2]),2);
123
+				}
106 124
 				$result['wind']['gust'] = (float)$matches[3];
107 125
 				$result['wind']['unit'] = $matches[4];
108 126
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
@@ -185,14 +203,23 @@  discard block
 block discarded – undo
185 203
 				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
186 204
 				$type = $matches[1];
187 205
 				$cloud = array();
188
-				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
189
-				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
190
-				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
191
-				elseif ($type == 'FEW') $cloud['type'] = 'Few';
192
-				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
193
-				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
194
-				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
195
-				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
206
+				if ($type == 'SKC') {
207
+					$cloud['type'] = 'No cloud/Sky clear';
208
+				} elseif ($type == 'CLR') {
209
+					$cloud['type'] = 'No cloud below 12,000ft (3700m)';
210
+				} elseif ($type == 'NSC') {
211
+					$cloud['type'] = 'No significant cloud';
212
+				} elseif ($type == 'FEW') {
213
+					$cloud['type'] = 'Few';
214
+				} elseif ($type == 'SCT') {
215
+					$cloud['type'] = 'Scattered';
216
+				} elseif ($type == 'BKN') {
217
+					$cloud['type'] = 'Broken';
218
+				} elseif ($type == 'OVC') {
219
+					$cloud['type'] = 'Overcast/Full cloud coverage';
220
+				} elseif ($type == 'VV') {
221
+					$cloud['type'] = 'Vertical visibility';
222
+				}
196 223
 				$cloud['type_code'] = $type;
197 224
 				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
198 225
 				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
@@ -218,8 +245,11 @@  discard block
 block discarded – undo
218 245
 				$result['RVR']['friction'] = $matches[5];
219 246
 			}
220 247
 			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
221
-				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
222
-				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
248
+				if (isset($matches[5])) {
249
+					$range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
250
+				} else {
251
+					$range = array('exact' => (float)$matches[2], 'unit' => 'M');
252
+				}
223 253
 				if (isset($matches[3])) {
224 254
 					$range = Array(
225 255
 					    'from' => (float)$matches[2],
@@ -252,8 +282,11 @@  discard block
 block discarded – undo
252 282
 				if (isset($matches[3])) {
253 283
 					$text[] = $this->texts[$matches[3]];
254 284
 				}
255
-				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
256
-				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
285
+				if (!isset($result['weather'])) {
286
+					$result['weather'] = implode(' ', $text);
287
+				} else {
288
+					$result['weather'] = $result['weather'].' / '.implode(' ', $text);
289
+				}
257 290
 			}
258 291
 		}
259 292
 		return $result;
@@ -264,8 +297,11 @@  discard block
 block discarded – undo
264 297
 		if (isset($globalMETARcycle) && $globalMETARcycle) {
265 298
 			$query = "SELECT * FROM metar WHERE metar_location = :icao";
266 299
 		} else {
267
-			if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
268
-			else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
300
+			if ($globalDBdriver == 'mysql') {
301
+				$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
302
+			} else {
303
+				$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
304
+			}
269 305
 		}
270 306
 		$query_values = array(':icao' => $icao);
271 307
 		try {
@@ -321,7 +357,9 @@  discard block
 block discarded – undo
321 357
 
322 358
 	public function addMETARCycle() {
323 359
 		global $globalDebug, $globalIVAO, $globalTransaction;
324
-		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
360
+		if (isset($globalDebug) && $globalDebug) {
361
+			echo "Downloading METAR cycle...";
362
+		}
325 363
 		date_default_timezone_set("UTC");
326 364
 		$Common = new Common();
327 365
 		if (isset($globalIVAO) && $globalIVAO) {
@@ -332,31 +370,47 @@  discard block
 block discarded – undo
332 370
 			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
333 371
 		}
334 372
 		if ($handle) {
335
-			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
373
+			if (isset($globalDebug) && $globalDebug) {
374
+				echo "Done - Updating DB...";
375
+			}
336 376
 			$date = '';
337
-			if ($globalTransaction) $this->db->beginTransaction();
377
+			if ($globalTransaction) {
378
+				$this->db->beginTransaction();
379
+			}
338 380
 			while(($line = fgets($handle,4096)) !== false) {
339 381
 				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
340 382
 					$date = $line;
341 383
 				} elseif ($line != '') {
342
-					if ($date == '') $date = date('Y/m/d H:m');
384
+					if ($date == '') {
385
+						$date = date('Y/m/d H:m');
386
+					}
343 387
 					$pos = 0;
344 388
 					$pieces = preg_split('/\s/',$line);
345
-					if ($pieces[0] == 'METAR') $pos++;
346
-					if (strlen($pieces[$pos]) != 4) $pos++;
389
+					if ($pieces[0] == 'METAR') {
390
+						$pos++;
391
+					}
392
+					if (strlen($pieces[$pos]) != 4) {
393
+						$pos++;
394
+					}
347 395
 					$location = $pieces[$pos];
348 396
 					echo $this->addMETAR($location,$line,$date);
349 397
 				}
350 398
 			}
351 399
 			fclose($handle);
352
-			if ($globalTransaction) $this->db->commit();
400
+			if ($globalTransaction) {
401
+				$this->db->commit();
402
+			}
403
+		}
404
+		if (isset($globalDebug) && $globalDebug) {
405
+			echo "Done\n";
353 406
 		}
354
-		if (isset($globalDebug) && $globalDebug) echo "Done\n";
355 407
 	}
356 408
 
357 409
 	public function downloadMETAR($icao) {
358 410
 		global $globalMETARurl;
359
-		if ($globalMETARurl == '') return array();
411
+		if ($globalMETARurl == '') {
412
+			return array();
413
+		}
360 414
 		date_default_timezone_set("UTC");
361 415
 		$Common = new Common();
362 416
 		$url = str_replace('{icao}',$icao,$globalMETARurl);
@@ -367,16 +421,24 @@  discard block
 block discarded – undo
367 421
 				$date = $line;
368 422
 			} 
369 423
 			if ($line != '') {
370
-				if ($date == '') $date = date('Y/m/d H:m');
424
+				if ($date == '') {
425
+					$date = date('Y/m/d H:m');
426
+				}
371 427
 				$pos = 0;
372 428
 				$pieces = preg_split('/\s/',$line);
373
-				if ($pieces[0] == 'METAR') $pos++;
374
-				if (strlen($pieces[$pos]) != 4) $pos++;
429
+				if ($pieces[0] == 'METAR') {
430
+					$pos++;
431
+				}
432
+				if (strlen($pieces[$pos]) != 4) {
433
+					$pos++;
434
+				}
375 435
 				$location = $pieces[$pos];
376 436
 				if (strlen($location == 4)) {
377 437
 					$this->addMETAR($location,$line,$date);
378 438
 					return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
379
-				} else return array();
439
+				} else {
440
+					return array();
441
+				}
380 442
 			}
381 443
 		}
382 444
 		return array();
Please login to merge, or discard this patch.
flightid-overview.php 2 patches
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -48,7 +48,9 @@  discard block
 block discarded – undo
48 48
 		$all_data = $SpotterArchive->getAltitudeSpeedArchiveSpotterDataById($spotter_array[0]['flightaware_id']);
49 49
 		if (isset($globalTimezone)) {
50 50
 			date_default_timezone_set($globalTimezone);
51
-		} else date_default_timezone_set('UTC');
51
+		} else {
52
+			date_default_timezone_set('UTC');
53
+		}
52 54
 		
53 55
 		if (is_array($all_data) && count($all_data) > 1) {
54 56
 			print '<br/>';
@@ -327,9 +329,13 @@  discard block
 block discarded – undo
327 329
 			print '<div>';
328 330
 			if (isset($spotter_item['pilot_id']) && $spotter_item['pilot_id'] != "")
329 331
 			{
330
-				if ($spotter_item['format_source'] == 'whazzup') print '<a href="https://www.ivao.aero/Member.aspx?ID='.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>';
331
-				elseif ($spotter_item['format_source'] == 'vatsimtxt') print '<a href="http://www.vataware.com/pilot/'.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>';
332
-				else print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
332
+				if ($spotter_item['format_source'] == 'whazzup') {
333
+					print '<a href="https://www.ivao.aero/Member.aspx?ID='.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>';
334
+				} elseif ($spotter_item['format_source'] == 'vatsimtxt') {
335
+					print '<a href="http://www.vataware.com/pilot/'.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>';
336
+				} else {
337
+					print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
338
+				}
333 339
 			} else {
334 340
 				if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != "")
335 341
 				{
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-$id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_STRING);
2
+$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_STRING);
3 3
 if ($id == "")
4 4
 {
5 5
 	header('Location: /');
@@ -16,30 +16,30 @@  discard block
 block discarded – undo
16 16
 
17 17
 if (!empty($spotter_array))
18 18
 {
19
-	if(isset($spotter_array[0]['flightaware_id'])) {
19
+	if (isset($spotter_array[0]['flightaware_id'])) {
20 20
 		$flightaware_id = $spotter_array[0]['flightaware_id'];
21 21
 	}
22
-	if(isset($spotter_array[0]['last_latitude']) && $spotter_array[0]['last_latitude'] != '') {
22
+	if (isset($spotter_array[0]['last_latitude']) && $spotter_array[0]['last_latitude'] != '') {
23 23
 		$latitude = $spotter_array[0]['last_latitude'];
24
-	} elseif(isset($spotter_array[0]['latitude'])) {
24
+	} elseif (isset($spotter_array[0]['latitude'])) {
25 25
 		$latitude = $spotter_array[0]['latitude'];
26 26
 	}
27
-	if(isset($spotter_array[0]['last_longitude']) && $spotter_array[0]['last_longitude'] != '') {
27
+	if (isset($spotter_array[0]['last_longitude']) && $spotter_array[0]['last_longitude'] != '') {
28 28
 		$longitude = $spotter_array[0]['last_longitude'];
29
-	} elseif(isset($spotter_array[0]['longitude'])) {
29
+	} elseif (isset($spotter_array[0]['longitude'])) {
30 30
 		$longitude = $spotter_array[0]['longitude'];
31 31
 	}
32 32
 	$title = '';
33
-	if(isset($spotter_array[0]['ident'])) {
33
+	if (isset($spotter_array[0]['ident'])) {
34 34
 		$title .= $spotter_array[0]['ident'];
35 35
 	}
36
-	if(isset($spotter_array[0]['airline_name'])) {
36
+	if (isset($spotter_array[0]['airline_name'])) {
37 37
 		$title .= ' - '.$spotter_array[0]['airline_name'];
38 38
 	}
39
-	if(isset($spotter_array[0]['aircraft_name']) && $spotter_array[0]['aircraft_name'] != 'Not Available') {
39
+	if (isset($spotter_array[0]['aircraft_name']) && $spotter_array[0]['aircraft_name'] != 'Not Available') {
40 40
 		$title .= ' - '.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')';
41 41
 	}
42
-	if(isset($spotter_array[0]['registration']) && $spotter_array[0]['registration'] != 'NA' && $spotter_array[0]['registration'] != 'N/A') {
42
+	if (isset($spotter_array[0]['registration']) && $spotter_array[0]['registration'] != 'NA' && $spotter_array[0]['registration'] != 'N/A') {
43 43
 		$title .= ' - '.$spotter_array[0]['registration'];
44 44
 	}
45 45
 	//$facebook_meta_image = $spotter_array[0]['image'];
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 			$altitude_data = '';
60 60
 			$hour_data = '';
61 61
 			$speed_data = '';
62
-			foreach($all_data as $data)
62
+			foreach ($all_data as $data)
63 63
 			{
64 64
 				$hour_data .= '"'.$data['date'].'",';
65 65
 				if (isset($data['real_altitude']) && $data['real_altitude'] != '') {
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 				$speed_data .= $speed.',';
88 88
 			}
89 89
 			$hour_data = "['x',".substr($hour_data, 0, -1)."]";
90
-			$altitude_data = "['altitude',".substr($altitude_data,0,-1)."]";
91
-			$speed_data = "['speed',".substr($speed_data,0,-1)."]";
90
+			$altitude_data = "['altitude',".substr($altitude_data, 0, -1)."]";
91
+			$speed_data = "['speed',".substr($speed_data, 0, -1)."]";
92 92
 			print 'c3.generate({
93 93
 			    bindto: "#chart",
94 94
 			    data: {
@@ -134,16 +134,16 @@  discard block
 block discarded – undo
134 134
 			print '<a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a> ';
135 135
 		}
136 136
 	}
137
-	if(isset($spotter_array[0]['ident'])) {
137
+	if (isset($spotter_array[0]['ident'])) {
138 138
 		print $spotter_array[0]['ident'];
139 139
 	}
140
-	if(isset($spotter_array[0]['airline_name'])) {
140
+	if (isset($spotter_array[0]['airline_name'])) {
141 141
 		print ' - '.$spotter_array[0]['airline_name'];
142 142
 	}
143
-	if(isset($spotter_array[0]['aircraft_name']) && $spotter_array[0]['aircraft_name'] != 'Not Available') {
143
+	if (isset($spotter_array[0]['aircraft_name']) && $spotter_array[0]['aircraft_name'] != 'Not Available') {
144 144
 		print ' - '.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')';
145 145
 	}
146
-	if(isset($spotter_array[0]['registration']) && $spotter_array[0]['registration'] != 'NA') {
146
+	if (isset($spotter_array[0]['registration']) && $spotter_array[0]['registration'] != 'NA') {
147 147
 		print ' - '.$spotter_array[0]['registration'];
148 148
 	}
149 149
 	print '</h1>';
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 print '</div>';
298 298
 */
299 299
 
300
-	foreach($spotter_array as $spotter_item)
300
+	foreach ($spotter_array as $spotter_item)
301 301
 	{
302 302
 		print '<div class="details">';
303 303
 		print '<h3>'._("Flight Information").'</h3>';
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 			if (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != '') {
398 398
 				if ($spotter_item['departure_airport_time'] > 2460) {
399 399
 					print '<div class="time">';
400
-					print 'at '.date('H:m',$spotter_item['departure_airport_time']);
400
+					print 'at '.date('H:m', $spotter_item['departure_airport_time']);
401 401
 					print '</div>';
402 402
 				} else {
403 403
 					print '<div class="time">';
@@ -547,19 +547,19 @@  discard block
 block discarded – undo
547 547
 			if (count($departure_airport_info) > 0) {
548 548
 				if (isset($spotter_item['last_latitude']) && $spotter_item['last_latitude'] != '') {
549 549
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
550
-						print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'nm').' nm';
550
+						print $Common->distance($spotter_item['last_latitude'], $spotter_item['last_longitude'], $departure_airport_info[0]['latitude'], $departure_airport_info[0]['longitude'], 'nm').' nm';
551 551
 					} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
552
-						print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'mi').' mi';
552
+						print $Common->distance($spotter_item['last_latitude'], $spotter_item['last_longitude'], $departure_airport_info[0]['latitude'], $departure_airport_info[0]['longitude'], 'mi').' mi';
553 553
 					} else {
554
-						print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'km').' km';
554
+						print $Common->distance($spotter_item['last_latitude'], $spotter_item['last_longitude'], $departure_airport_info[0]['latitude'], $departure_airport_info[0]['longitude'], 'km').' km';
555 555
 					}
556 556
 				} else {
557 557
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
558
-						print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'nm').' nm';
558
+						print $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $departure_airport_info[0]['latitude'], $departure_airport_info[0]['longitude'], 'nm').' nm';
559 559
 					} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
560
-						print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'mi').' mi';
560
+						print $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $departure_airport_info[0]['latitude'], $departure_airport_info[0]['longitude'], 'mi').' mi';
561 561
 					} else {
562
-						print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'km').' km';
562
+						print $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $departure_airport_info[0]['latitude'], $departure_airport_info[0]['longitude'], 'km').' km';
563 563
 					}
564 564
 				}
565 565
 			}
@@ -575,19 +575,19 @@  discard block
 block discarded – undo
575 575
 			if (count($arrival_airport_info) > 0) {
576 576
 				if (isset($spotter_item['last_latitude']) && $spotter_item['last_latitude'] != '') {
577 577
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
578
-						print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'nm').' nm';
578
+						print $Common->distance($spotter_item['last_latitude'], $spotter_item['last_longitude'], $arrival_airport_info[0]['latitude'], $arrival_airport_info[0]['longitude'], 'nm').' nm';
579 579
 					} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
580
-						print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'mi').' mi';
580
+						print $Common->distance($spotter_item['last_latitude'], $spotter_item['last_longitude'], $arrival_airport_info[0]['latitude'], $arrival_airport_info[0]['longitude'], 'mi').' mi';
581 581
 					} else {
582
-						print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'km').' km';
582
+						print $Common->distance($spotter_item['last_latitude'], $spotter_item['last_longitude'], $arrival_airport_info[0]['latitude'], $arrival_airport_info[0]['longitude'], 'km').' km';
583 583
 					}
584 584
 				} else {
585 585
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
586
-						print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'nm').' nm';
586
+						print $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $arrival_airport_info[0]['latitude'], $arrival_airport_info[0]['longitude'], 'nm').' nm';
587 587
 					} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
588
-						print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'mi').' mi';
588
+						print $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $arrival_airport_info[0]['latitude'], $arrival_airport_info[0]['longitude'], 'mi').' mi';
589 589
 					} else {
590
-						print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'km').' km';
590
+						print $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $arrival_airport_info[0]['latitude'], $arrival_airport_info[0]['longitude'], 'km').' km';
591 591
 					}
592 592
 				}
593 593
 			}
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 		print '<div class="last-flights">';
607 607
 		print '<h3>'._("Last 5 Flights of this Aircraft").' ('.$registration.')</h3>';
608 608
 		$hide_th_links = true;
609
-		$spotter_array = $Spotter->getSpotterDataByRegistration($registration,"0,5", "");
609
+		$spotter_array = $Spotter->getSpotterDataByRegistration($registration, "0,5", "");
610 610
 		include('table-output.php'); 
611 611
 		print '<div class="more">';
612 612
 		print '<a href="'.$globalURL.'/registration/'.$registration.'" class="btn btn-default btn" role="button">See all Flights&raquo;</a>';
Please login to merge, or discard this patch.
ident-detailed.php 2 patches
Braces   +22 added lines, -8 removed lines patch added patch discarded remove patch
@@ -118,8 +118,12 @@  discard block
 block discarded – undo
118 118
 	{
119 119
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['ident']);
120 120
 		$ident = $spotter_array[0]['ident'];
121
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
122
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
121
+		if (isset($spotter_array[0]['latitude'])) {
122
+			$latitude = $spotter_array[0]['latitude'];
123
+		}
124
+		if (isset($spotter_array[0]['longitude'])) {
125
+			$longitude = $spotter_array[0]['longitude'];
126
+		}
123 127
 		require_once('header.php');
124 128
 		if (isset($globalArchive) && $globalArchive && $type == 'aircraft') {
125 129
 			// Requirement for altitude graph
@@ -127,7 +131,9 @@  discard block
 block discarded – undo
127 131
 			$all_data = $SpotterArchive->getAltitudeSpeedArchiveSpotterDataById($spotter_array[0]['flightaware_id']);
128 132
 			if (isset($globalTimezone)) {
129 133
 				date_default_timezone_set($globalTimezone);
130
-			} else date_default_timezone_set('UTC');
134
+			} else {
135
+				date_default_timezone_set('UTC');
136
+			}
131 137
 			if (is_array($all_data) && count($all_data) > 1) {
132 138
 				print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">';
133 139
 				print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
@@ -204,14 +210,22 @@  discard block
 block discarded – undo
204 210
 		if (isset($spotter_array[0]['airline_icao'])) {
205 211
 			print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>'; 
206 212
 		}
207
-		if ($type == 'aircraft') print '<div><span class="label">'._("Flight History").'</span><a href="http://flightaware.com/live/flight/'.$spotter_array[0]['ident'].'" target="_blank">'._("View the Flight History of this callsign").'</a></div>';
213
+		if ($type == 'aircraft') {
214
+			print '<div><span class="label">'._("Flight History").'</span><a href="http://flightaware.com/live/flight/'.$spotter_array[0]['ident'].'" target="_blank">'._("View the Flight History of this callsign").'</a></div>';
215
+		}
208 216
 		print '</div>';
209 217
 	
210
-		if ($type == 'aircraft') include('ident-sub-menu.php');
218
+		if ($type == 'aircraft') {
219
+			include('ident-sub-menu.php');
220
+		}
211 221
 		print '<div class="table column">';
212
-		if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
213
-		elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
214
-		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
222
+		if ($type == 'aircraft') {
223
+			print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
224
+		} elseif ($type == 'marine') {
225
+			print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
226
+		} elseif ($type == 'tracker') {
227
+			print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
228
+		}
215 229
 
216 230
 		include('table-output.php'); 
217 231
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Language.php');
4 4
 require_once('require/class.Translation.php');
5 5
 $type = '';
6
-$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
6
+$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
7 7
 if (isset($_GET['marine'])) {
8 8
 	require_once('require/class.Marine.php');
9 9
 	require_once('require/class.MarineLive.php');
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 	$page_url = $globalURL.'/ident/'.$_GET['ident'];
31 31
 }
32 32
 
33
-if (!isset($_GET['ident'])){
33
+if (!isset($_GET['ident'])) {
34 34
 	header('Location: '.$globalURL.'');
35 35
 } else {
36 36
 	$Translation = new Translation();
37 37
 	//calculuation for the pagination
38
-	if(!isset($_GET['limit']))
38
+	if (!isset($_GET['limit']))
39 39
 	{
40 40
 		$limit_start = 0;
41 41
 		$limit_end = 25;
@@ -54,18 +54,18 @@  discard block
 block discarded – undo
54 54
 	$limit_previous_1 = $limit_start - $absolute_difference;
55 55
 	$limit_previous_2 = $limit_end - $absolute_difference;
56 56
 	
57
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
57
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
58 58
 	if ($type == 'aircraft') {
59 59
 		if ($sort != '') 
60 60
 		{
61
-			$spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
61
+			$spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
62 62
 			if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
63
-				$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
63
+				$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
64 64
 			}
65 65
 		} else {
66
-			$spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference);
66
+			$spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference);
67 67
 			if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
68
-				$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference);
68
+				$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference);
69 69
 			}
70 70
 		}
71 71
 		if (empty($spotter_array)) {
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 				$ident = $new_ident;
75 75
 				if ($sort != '') 
76 76
 				{
77
-					$spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
77
+					$spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
78 78
 					if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
79
-						$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
79
+						$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
80 80
 					}
81 81
 				} else {
82
-					$spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference);
82
+					$spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference);
83 83
 					if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
84
-						$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference);
84
+						$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference);
85 85
 					}
86 86
 				}
87 87
 			}
@@ -89,34 +89,34 @@  discard block
 block discarded – undo
89 89
 	} elseif ($type == 'marine') {
90 90
 		if ($sort != '') 
91 91
 		{
92
-			$spotter_array = $Marine->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
92
+			$spotter_array = $Marine->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
93 93
 			if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
94
-				$spotter_array = $MarineArchive->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
94
+				$spotter_array = $MarineArchive->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
95 95
 			}
96 96
 		} else {
97
-			$spotter_array = $Marine->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference);
97
+			$spotter_array = $Marine->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference);
98 98
 			if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
99
-				$spotter_array = $MarineArchive->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference);
99
+				$spotter_array = $MarineArchive->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference);
100 100
 			}
101 101
 		}
102 102
 	} elseif ($type == 'tracker') {
103 103
 		if ($sort != '') 
104 104
 		{
105
-			$spotter_array = $Tracker->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
105
+			$spotter_array = $Tracker->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
106 106
 			if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
107
-				$spotter_array = $TrackerArchive->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
107
+				$spotter_array = $TrackerArchive->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
108 108
 			}
109 109
 		} else {
110
-			$spotter_array = $Tracker->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference);
110
+			$spotter_array = $Tracker->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference);
111 111
 			if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
112
-				$spotter_array = $TrackerArchive->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference);
112
+				$spotter_array = $TrackerArchive->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference);
113 113
 			}
114 114
 		}
115 115
 	}
116 116
 
117 117
 	if (!empty($spotter_array))
118 118
 	{
119
-		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['ident']);
119
+		$title = sprintf(_("Detailed View for %s"), $spotter_array[0]['ident']);
120 120
 		$ident = $spotter_array[0]['ident'];
121 121
 		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
122 122
 		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 				$altitude_data = '';
136 136
 				$hour_data = '';
137 137
 				$speed_data = '';
138
-				foreach($all_data as $data)
138
+				foreach ($all_data as $data)
139 139
 				{
140 140
 					$hour_data .= '"'.$data['date'].'",';
141 141
 					if (isset($data['real_altitude']) && $data['real_altitude'] != '') {
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 					$speed_data .= $speed.',';
164 164
 				}
165 165
 				$hour_data = "['x',".substr($hour_data, 0, -1)."]";
166
-				$altitude_data = "['altitude',".substr($altitude_data,0,-1)."]";
167
-				$speed_data = "['speed',".substr($speed_data,0,-1)."]";
166
+				$altitude_data = "['altitude',".substr($altitude_data, 0, -1)."]";
167
+				$speed_data = "['speed',".substr($speed_data, 0, -1)."]";
168 168
 				print 'c3.generate({
169 169
 				    bindto: "#chart",
170 170
 				    data: {
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
 	
209 209
 		if ($type == 'aircraft') include('ident-sub-menu.php');
210 210
 		print '<div class="table column">';
211
-		if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
212
-		elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
213
-		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
211
+		if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>';
212
+		elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>';
213
+		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>';
214 214
 
215 215
 		include('table-output.php'); 
216 216
 		print '<div class="pagination">';
Please login to merge, or discard this patch.