Completed
Push — master ( e14a40...cfb98e )
by Yannick
54:46 queued 27:34
created
require/class.METAR.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 			$Connection = new Connection();
69 69
 			$sth = $Connection->db->prepare($query);
70 70
 			$sth->execute();
71
-		} catch(PDOException $e) {
71
+		} catch (PDOException $e) {
72 72
 			return "error : ".$e->getMessage();
73 73
 		}
74 74
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 			$Connection = new Connection();
88 88
 			$sth = $Connection->db->prepare($query);
89 89
 			$sth->execute();
90
-		} catch(PDOException $e) {
90
+		} catch (PDOException $e) {
91 91
 			return "error : ".$e->getMessage();
92 92
 		}
93 93
 	}
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 	public function parse($data) {
101 101
 		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
102 102
 		$codes = implode('|', array_keys($this->texts));
103
-		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
103
+		$regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#';
104 104
 		//$pieces = explode(' ',$data);
105
-		$pieces = preg_split('/\s/',$data);
105
+		$pieces = preg_split('/\s/', $data);
106 106
 		$pos = 0;
107 107
 		if ($pieces[0] == 'METAR') $pos++;
108 108
 		elseif ($pieces[0] == 'SPECI') $pos++;
@@ -112,25 +112,25 @@  discard block
 block discarded – undo
112 112
 		$result['location'] = $pieces[$pos];
113 113
 		$pos++;
114 114
 		if (!isset($pieces[$pos])) return $result;
115
-		$result['dayofmonth'] = substr($pieces[$pos],0,2);
116
-		$result['time'] = substr($pieces[$pos],2,4);
115
+		$result['dayofmonth'] = substr($pieces[$pos], 0, 2);
116
+		$result['time'] = substr($pieces[$pos], 2, 4);
117 117
 		$c = count($pieces);
118
-		for($pos++; $pos < $c; $pos++) {
118
+		for ($pos++; $pos < $c; $pos++) {
119 119
 			$piece = $pieces[$pos];
120 120
 			if ($piece == 'RMK') break;
121 121
 			if ($piece == 'AUTO') $result['auto'] = true;
122 122
 			if ($piece == 'COR') $result['correction'] = true;
123 123
 			// Wind Speed
124 124
 			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
125
-				$result['wind']['direction'] = (float)$matches[1];
125
+				$result['wind']['direction'] = (float) $matches[1];
126 126
 				$result['wind']['unit'] = $matches[4];
127
-				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
128
-				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
129
-				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
130
-				$result['wind']['gust'] = (float)$matches[3];
127
+				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2);
128
+				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2);
129
+				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2);
130
+				$result['wind']['gust'] = (float) $matches[3];
131 131
 				$result['wind']['unit'] = $matches[4];
132
-				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
133
-				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
132
+				$result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0;
133
+				$result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0;
134 134
 			}
135 135
 
136 136
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
 
152 152
 			// Temperature
153 153
 			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
154
-				$temp = (float)$matches[1];
154
+				$temp = (float) $matches[1];
155 155
 				if ($matches[1]{0} == 'M') {
156
-					$temp = ((float)substr($matches[1], 1)) * -1;
156
+					$temp = ((float) substr($matches[1], 1))*-1;
157 157
 				}
158 158
 				$result['temperature'] = $temp;
159
-				$dew = (float)$matches[2];
159
+				$dew = (float) $matches[2];
160 160
 				if ($matches[2]{0} == 'M') {
161
-					$dew = ((float)substr($matches[2], 1)) * -1;
161
+					$dew = ((float) substr($matches[2], 1))*-1;
162 162
 				}
163 163
 				$result['dew'] = $dew;
164 164
 			}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 					$result['QNH'] = $matches[2];
171 171
 				} else {
172 172
 					// inHg
173
-					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
173
+					$result['QNH'] = round(($matches[2]/100)*33.86389, 2);
174 174
 				}
175 175
 				/*
176 176
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
     			// Visibility
192 192
 			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
193 193
 				if (isset($matches[3]) && strlen($matches[3]) > 0) {
194
-					$result['visibility'] = (float)$matches[3] * 1609.34;
194
+					$result['visibility'] = (float) $matches[3]*1609.34;
195 195
 				} else {
196 196
 					if ($matches[1] == '9999') {
197 197
 						$result['visibility'] = '> 10000';
198 198
 					} else {
199
-						$result['visibility'] = (float)$matches[1];
199
+						$result['visibility'] = (float) $matches[1];
200 200
 					}
201 201
 				}
202 202
 				if (preg_match('#^CAVOK$#', $piece, $matches)) {
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
219 219
 				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
220 220
 				$cloud['type_code'] = $type;
221
-				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
221
+				$cloud['level'] = round(((float) $matches[2])*100*0.3048);
222 222
 				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
223 223
 				$result['cloud'][] = $cloud;
224 224
 			}
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
 				$rvr['runway'] = $matches[1];
229 229
 				$rvr['assessment'] = $matches[2];
230 230
 				$rvr['rvr'] = $matches[3];
231
-				$rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0;
232
-				$rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : '';
231
+				$rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0;
232
+				$rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : '';
233 233
 				$result['RVR'] = $rvr;
234 234
 			}
235 235
 			//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
 				$result['RVR']['friction'] = $matches[5];
243 243
 			}
244 244
 			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
245
-				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
246
-				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
245
+				if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
246
+				else $range = array('exact' => (float) $matches[2], 'unit' => 'M');
247 247
 				if (isset($matches[3])) {
248 248
 					$range = Array(
249
-					    'from' => (float)$matches[2],
250
-					    'to'   => (float)$matches[4],
249
+					    'from' => (float) $matches[2],
250
+					    'to'   => (float) $matches[4],
251 251
 					    'unit' => $matches[5] ? 'FT' : 'M'
252 252
 					);
253 253
 				}
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 		try {
301 301
 			$sth = $this->db->prepare($query);
302 302
 			$sth->execute($query_values);
303
-		} catch(PDOException $e) {
303
+		} catch (PDOException $e) {
304 304
 			return "error : ".$e->getMessage();
305 305
 		}
306 306
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -316,19 +316,19 @@  discard block
 block discarded – undo
316 316
 	 * @param String $metar METAR text
317 317
 	 * @param String $date date of the METAR
318 318
 	*/
319
-	public function addMETAR($location,$metar,$date) {
319
+	public function addMETAR($location, $metar, $date) {
320 320
 		global $globalDBdriver;
321
-		$date = date('Y-m-d H:i:s',strtotime($date));
321
+		$date = date('Y-m-d H:i:s', strtotime($date));
322 322
 		if ($globalDBdriver == 'mysql') {
323 323
 			$query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar";
324 324
 		} else {
325 325
 			$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);";
326 326
 		}
327
-		$query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
327
+		$query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar));
328 328
 		try {
329 329
 			$sth = $this->db->prepare($query);
330 330
 			$sth->execute($query_values);
331
-		} catch(PDOException $e) {
331
+		} catch (PDOException $e) {
332 332
 			return "error : ".$e->getMessage();
333 333
 		}
334 334
 	}
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 		try {
344 344
 			$sth = $this->db->prepare($query);
345 345
 			$sth->execute($query_values);
346
-		} catch(PDOException $e) {
346
+		} catch (PDOException $e) {
347 347
 			return "error : ".$e->getMessage();
348 348
 		}
349 349
 	}
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 		try {
357 357
 			$sth = $this->db->prepare($query);
358 358
 			$sth->execute();
359
-		} catch(PDOException $e) {
359
+		} catch (PDOException $e) {
360 360
 			return "error : ".$e->getMessage();
361 361
 		}
362 362
 	}
@@ -370,27 +370,27 @@  discard block
 block discarded – undo
370 370
 		date_default_timezone_set("UTC");
371 371
 		$Common = new Common();
372 372
 		if (isset($globalIVAO) && $globalIVAO) {
373
-			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
374
-			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
373
+			$Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt');
374
+			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r");
375 375
 		} else {
376
-			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
377
-			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
376
+			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
377
+			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r");
378 378
 		}
379 379
 		if ($handle) {
380 380
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
381 381
 			$date = '';
382 382
 			if ($globalTransaction) $this->db->beginTransaction();
383
-			while(($line = fgets($handle,4096)) !== false) {
384
-				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
383
+			while (($line = fgets($handle, 4096)) !== false) {
384
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
385 385
 					$date = $line;
386 386
 				} elseif ($line != '') {
387 387
 					if ($date == '') $date = date('Y/m/d H:m');
388 388
 					$pos = 0;
389
-					$pieces = preg_split('/\s/',$line);
389
+					$pieces = preg_split('/\s/', $line);
390 390
 					if ($pieces[0] == 'METAR') $pos++;
391 391
 					if (strlen($pieces[$pos]) != 4) $pos++;
392 392
 					$location = $pieces[$pos];
393
-					echo $this->addMETAR($location,$line,$date);
393
+					echo $this->addMETAR($location, $line, $date);
394 394
 				}
395 395
 			}
396 396
 			fclose($handle);
@@ -409,22 +409,22 @@  discard block
 block discarded – undo
409 409
 		if ($globalMETARurl == '') return array();
410 410
 		date_default_timezone_set("UTC");
411 411
 		$Common = new Common();
412
-		$url = str_replace('{icao}',$icao,$globalMETARurl);
412
+		$url = str_replace('{icao}', $icao, $globalMETARurl);
413 413
 		$cycle = $Common->getData($url);
414 414
 		$date = '';
415
-		foreach(explode("\n",$cycle) as $line) {
416
-			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
415
+		foreach (explode("\n", $cycle) as $line) {
416
+			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
417 417
 				$date = $line;
418 418
 			} 
419 419
 			if ($line != '') {
420 420
 				if ($date == '') $date = date('Y/m/d H:m');
421 421
 				$pos = 0;
422
-				$pieces = preg_split('/\s/',$line);
422
+				$pieces = preg_split('/\s/', $line);
423 423
 				if ($pieces[0] == 'METAR') $pos++;
424 424
 				if (strlen($pieces[$pos]) != 4) $pos++;
425 425
 				$location = $pieces[$pos];
426 426
 				if (strlen($location == 4)) {
427
-					$this->addMETAR($location,$line,$date);
427
+					$this->addMETAR($location, $line, $date);
428 428
 					return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
429 429
 				} else return array();
430 430
 			}
Please login to merge, or discard this patch.
require/class.TSK.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 	*/
16 16
 	public function parse_xml($url) {
17 17
 		$Common = new Common();
18
-		$filedata = $Common->getData($url,'get','','','','','','',true);
18
+		$filedata = $Common->getData($url, 'get', '', '', '', '', '', '', true);
19 19
 		if ($filedata != '' && $filedata !== false) {
20 20
 			$xml = simplexml_load_string($filedata);
21 21
 			if ($xml !== false) {
Please login to merge, or discard this patch.
require/class.APRS.php 1 patch
Spacing   +157 added lines, -158 removed lines patch added patch discarded remove patch
@@ -175,8 +175,7 @@  discard block
 block discarded – undo
175 175
 		'\~' => 'TNC Stream SW');
176 176
 
177 177
 	private function urshift($n, $s) {
178
-		return ($n >= 0) ? ($n >> $s) :
179
-		    (($n & 0x7fffffff) >> $s) | 
178
+		return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
180 179
 		    (0x40000000 >> ($s - 1));
181 180
 	}
182 181
 
@@ -192,7 +191,7 @@  discard block
 block discarded – undo
192 191
 		$input_len = strlen($input);
193 192
 		
194 193
 		/* Find the end of header checking for NULL bytes while doing it. */
195
-		$splitpos = strpos($input,':');
194
+		$splitpos = strpos($input, ':');
196 195
 		
197 196
 		/* Check that end was found and body has at least one byte. */
198 197
 		if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -202,14 +201,14 @@  discard block
 block discarded – undo
202 201
 		
203 202
 		if ($debug) echo 'input : '.$input."\n";
204 203
 		/* Save header and body. */
205
-		$body = substr($input,$splitpos+1,$input_len);
204
+		$body = substr($input, $splitpos + 1, $input_len);
206 205
 		$body_len = strlen($body);
207
-		$header = substr($input,0,$splitpos);
206
+		$header = substr($input, 0, $splitpos);
208 207
 		if ($debug) echo 'header : '.$header."\n";
209 208
 		
210 209
 		/* Parse source, target and path. */
211 210
 		//FLRDF0A52>APRS,qAS,LSTB
212
-		if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
211
+		if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
213 212
 			$ident = $matches[1];
214 213
 			$all_elements = $matches[2];
215 214
 			if ($ident == 'AIRCRAFT') {
@@ -226,13 +225,13 @@  discard block
 block discarded – undo
226 225
 			if ($debug) 'No ident'."\n";
227 226
 			return false;
228 227
 		}
229
-		$elements = explode(',',$all_elements);
228
+		$elements = explode(',', $all_elements);
230 229
 		$source = end($elements);
231 230
 		$result['source'] = $source;
232 231
 		foreach ($elements as $element) {
233
-			if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
232
+			if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
234 233
 			//if ($element == 'TCPIP*') return false;
235
-			} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
234
+			} elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
236 235
 				if ($debug) echo 'element : '.$element."\n";
237 236
 				return false;
238 237
 			}
@@ -245,14 +244,14 @@  discard block
 block discarded – undo
245 244
 			*/
246 245
 		}
247 246
 		
248
-		$type = substr($body,0,1);
247
+		$type = substr($body, 0, 1);
249 248
 		if ($debug) echo 'type : '.$type."\n";
250 249
 		if ($type == ';') {
251 250
 			if (isset($result['source_type']) && $result['source_type'] == 'modes') {
252
-				$result['address'] = trim(substr($body,1,9));
251
+				$result['address'] = trim(substr($body, 1, 9));
253 252
 			} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
254
-				$result['mmsi'] = trim(substr($body,1,9));
255
-			} else $result['ident'] = trim(substr($body,1,9));
253
+				$result['mmsi'] = trim(substr($body, 1, 9));
254
+			} else $result['ident'] = trim(substr($body, 1, 9));
256 255
 		} elseif ($type == ',') {
257 256
 			// Invalid data or test data
258 257
 			return false;
@@ -260,20 +259,20 @@  discard block
 block discarded – undo
260 259
 		
261 260
 		// Check for Timestamp
262 261
 		$find = false;
263
-		$body_parse = substr($body,1);
264
-		if (preg_match('/^;(.){9}\*/',$body,$matches)) {
265
-			$body_parse = substr($body_parse,10);
262
+		$body_parse = substr($body, 1);
263
+		if (preg_match('/^;(.){9}\*/', $body, $matches)) {
264
+			$body_parse = substr($body_parse, 10);
266 265
 			$find = true;
267 266
 		}
268
-		if (preg_match('/^`(.*)\//',$body,$matches)) {
269
-			$body_parse = substr($body_parse,strlen($matches[1])-1);
267
+		if (preg_match('/^`(.*)\//', $body, $matches)) {
268
+			$body_parse = substr($body_parse, strlen($matches[1]) - 1);
270 269
 			$find = true;
271 270
 		}
272
-		if (preg_match("/^'(.*)\//",$body,$matches)) {
273
-			$body_parse = substr($body_parse,strlen($matches[1])-1);
271
+		if (preg_match("/^'(.*)\//", $body, $matches)) {
272
+			$body_parse = substr($body_parse, strlen($matches[1]) - 1);
274 273
 			$find = true;
275 274
 		}
276
-		if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
275
+		if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
277 276
 			$find = true;
278 277
 			$timestamp = $matches[0];
279 278
 			if ($matches[4] == 'h') {
@@ -286,17 +285,17 @@  discard block
 block discarded – undo
286 285
 				// This work or not ?
287 286
 				$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
288 287
 			}
289
-			$body_parse = substr($body_parse,7);
288
+			$body_parse = substr($body_parse, 7);
290 289
 			$result['timestamp'] = $timestamp;
291 290
 		}
292
-		if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
291
+		if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
293 292
 			$find = true;
294 293
 			$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
295
-			$body_parse = substr($body_parse,8);
294
+			$body_parse = substr($body_parse, 8);
296 295
 			$result['timestamp'] = $timestamp;
297 296
 		}
298 297
 		//if (strlen($body_parse) > 19) {
299
-		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
+		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)) {
300 299
 			$find = true;
301 300
 			// 4658.70N/00707.78Ez
302 301
 			$sind = strtoupper($matches[3]);
@@ -318,11 +317,11 @@  discard block
 block discarded – undo
318 317
 			    */
319 318
 			$latitude = $lat + floatval($lat_min)/60;
320 319
 			$longitude = $lon + floatval($lon_min)/60;
321
-			if ($sind == 'S') $latitude = 0-$latitude;
322
-			if ($wind == 'W') $longitude = 0-$longitude;
320
+			if ($sind == 'S') $latitude = 0 - $latitude;
321
+			if ($wind == 'W') $longitude = 0 - $longitude;
323 322
 			$result['latitude'] = $latitude;
324 323
 			$result['longitude'] = $longitude;
325
-			$body_parse = substr($body_parse,18);
324
+			$body_parse = substr($body_parse, 18);
326 325
 			$body_parse_len = strlen($body_parse);
327 326
 		}
328 327
 		$body_parse_len = strlen($body_parse);
@@ -349,22 +348,22 @@  discard block
 block discarded – undo
349 348
 				//'
350 349
 				//if ($type != ';' && $type != '>') {
351 350
 				if ($type != '') {
352
-					$body_parse = substr($body_parse,1);
351
+					$body_parse = substr($body_parse, 1);
353 352
 					$body_parse_len = strlen($body_parse);
354 353
 					$result['symbol_code'] = $symbol_code;
355 354
 					if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
356 355
 					if ($symbol_code != '_') {
357 356
 					}
358 357
 					if ($body_parse_len >= 7) {
359
-						if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
360
-							$course = substr($body_parse,0,3);
358
+						if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
359
+							$course = substr($body_parse, 0, 3);
361 360
 							$tmp_s = intval($course);
362 361
 							if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
363
-							$speed = substr($body_parse,4,3);
362
+							$speed = substr($body_parse, 4, 3);
364 363
 							if ($speed != '...') {
365 364
 								$result['speed'] = intval($speed);
366 365
 							}
367
-							$body_parse = substr($body_parse,7);
366
+							$body_parse = substr($body_parse, 7);
368 367
 						}
369 368
 						// Check PHGR, PHG, RNG
370 369
 					} 
@@ -374,11 +373,11 @@  discard block
 block discarded – undo
374 373
 					}
375 374
 					*/
376 375
 					if (strlen($body_parse) > 0) {
377
-						if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
376
+						if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
378 377
 							$altitude = intval($matches[1]);
379 378
 							$result['altitude'] = $altitude;
380 379
 							//$body_parse = trim(substr($body_parse,strlen($matches[0])));
381
-							$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
380
+							$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse));
382 381
 						}
383 382
 					}
384 383
 					// Telemetry
@@ -388,58 +387,58 @@  discard block
 block discarded – undo
388 387
 					}
389 388
 					*/
390 389
 					// DAO
391
-					if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
390
+					if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
392 391
 						$dao = $matches[1];
393
-						if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
392
+						if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
394 393
 							$dao_split = str_split($dao);
395
-							$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
396
-							$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
394
+							$lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
395
+							$lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
397 396
 							if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
398 397
 							else $result['latitude'] += $lat_off;
399 398
 							if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
400 399
 							else $result['longitude'] += $lon_off;
401 400
 						}
402
-						$body_parse = substr($body_parse,6);
401
+						$body_parse = substr($body_parse, 6);
403 402
 					}
404
-					if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
405
-						$result['ident'] = str_replace('_',' ',$matches[1]);
403
+					if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) {
404
+						$result['ident'] = str_replace('_', ' ', $matches[1]);
406 405
 					}
407
-					if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
406
+					if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) {
408 407
 						$result['squawk'] = $matches[1];
409 408
 					}
410
-					if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
409
+					if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) {
411 410
 						$result['aircraft_icao'] = $matches[1];
412 411
 					}
413
-					if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
412
+					if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) {
414 413
 						$result['verticalrate'] = $matches[1];
415 414
 					}
416
-					if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
415
+					if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) {
417 416
 						$result['typeid'] = $matches[1];
418 417
 					}
419
-					if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
418
+					if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) {
420 419
 						$result['statusid'] = $matches[1];
421 420
 					}
422
-					if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
421
+					if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) {
423 422
 						$result['imo'] = $matches[1];
424 423
 					}
425
-					if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
424
+					if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) {
426 425
 						$result['arrival_date'] = $matches[1];
427 426
 					}
428
-					if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
429
-						$result['arrival_code'] = str_replace('_',' ',$matches[1]);
427
+					if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) {
428
+						$result['arrival_code'] = str_replace('_', ' ', $matches[1]);
430 429
 					}
431 430
 					// OGN comment
432 431
 					//if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
433
-					if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
432
+					if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
434 433
 						$id = $matches[1];
435 434
 						//$mode = substr($id,0,2);
436
-						$address = substr($id,2);
437
-						$addressType = (intval(substr($id,0,2),16))&3;
435
+						$address = substr($id, 2);
436
+						$addressType = (intval(substr($id, 0, 2), 16))&3;
438 437
 						if ($addressType == 0) $result['addresstype'] = "RANDOM";
439 438
 						elseif ($addressType == 1) $result['addresstype'] = "ICAO";
440 439
 						elseif ($addressType == 2) $result['addresstype'] = "FLARM";
441 440
 						elseif ($addressType == 3) $result['addresstype'] = "OGN";
442
-						$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
441
+						$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
443 442
 						$result['aircrafttype_code'] = $aircraftType;
444 443
 						if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
445 444
 						elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -456,110 +455,110 @@  discard block
 block discarded – undo
456 455
 						elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
457 456
 						elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
458 457
 						elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
459
-						$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
458
+						$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
460 459
 						$result['stealth'] = $stealth;
461 460
 						$result['address'] = $address;
462 461
 					}
463 462
 					//Comment
464 463
 					$result['comment'] = trim($body_parse);
465 464
 					// parse weather
466
-					if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
465
+					if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
467 466
 						$result['wind_dir'] = intval($matches[1]);
468
-						$result['wind_speed'] = round(intval($matches[2])*1.60934,1);
469
-						$result['wind_gust'] = round(intval($matches[3])*1.60934,1);
470
-						$result['temp'] = round(5/9*((intval($matches[4]))-32),1);
471
-						$body_parse = substr($body_parse,strlen($matches[0])+1);
472
-					} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
467
+						$result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
468
+						$result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
469
+						$result['temp'] = round(5/9*((intval($matches[4])) - 32), 1);
470
+						$body_parse = substr($body_parse, strlen($matches[0]) + 1);
471
+					} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
473 472
 						$result['wind_dir'] = intval($matches[1]);
474
-						$result['wind_speed'] = round($matches[2]*1.60934,1);
475
-						$result['wind_gust'] = round($matches[3]*1.60934,1);
476
-						$result['temp'] = round(5/9*(($matches[4])-32),1);
477
-						$body_parse = substr($body_parse,strlen($matches[0])+1);
478
-					} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
473
+						$result['wind_speed'] = round($matches[2]*1.60934, 1);
474
+						$result['wind_gust'] = round($matches[3]*1.60934, 1);
475
+						$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
476
+						$body_parse = substr($body_parse, strlen($matches[0]) + 1);
477
+					} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
479 478
 						$result['wind_dir'] = intval($matches[1]);
480
-						$result['wind_speed'] = round($matches[2]*1.60934,1);
481
-						$result['wind_gust'] = round($matches[3]*1.60934,1);
482
-						$body_parse = substr($body_parse,strlen($matches[0])+1);
483
-					} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
479
+						$result['wind_speed'] = round($matches[2]*1.60934, 1);
480
+						$result['wind_gust'] = round($matches[3]*1.60934, 1);
481
+						$body_parse = substr($body_parse, strlen($matches[0]) + 1);
482
+					} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
484 483
 						$result['wind_dir'] = intval($matches[1]);
485
-						$result['wind_speed'] = round($matches[2]*1.60934,1);
486
-						$result['wind_gust'] = round($matches[3]*1.60934,1);
487
-						$body_parse = substr($body_parse,strlen($matches[0])+1);
484
+						$result['wind_speed'] = round($matches[2]*1.60934, 1);
485
+						$result['wind_gust'] = round($matches[3]*1.60934, 1);
486
+						$body_parse = substr($body_parse, strlen($matches[0]) + 1);
488 487
 					}
489 488
 					// temperature
490 489
 					//g012t088r000p000P000h38b10110
491 490
 					//g011t086r000p000P000h29b10198
492
-					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)) {
493
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
494
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
495
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
496
-						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
497
-						if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
491
+					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)) {
492
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
493
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
494
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
495
+						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
496
+						if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
498 497
 						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
499
-						if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
500
-						$body_parse = substr($body_parse,strlen($matches[0]));
501
-					} 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)) {
502
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
503
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
504
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
505
-						if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
506
-						if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
498
+						if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
499
+						$body_parse = substr($body_parse, strlen($matches[0]));
500
+					} 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)) {
501
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
502
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
503
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
504
+						if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1);
505
+						if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
507 506
 						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
508
-						if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
509
-						$body_parse = substr($body_parse,strlen($matches[0]));
510
-					} 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)) {
511
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
512
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
513
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
514
-						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
515
-						if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
507
+						if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
508
+						$body_parse = substr($body_parse, strlen($matches[0]));
509
+					} 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)) {
510
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
511
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
512
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
513
+						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
514
+						if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
516 515
 						if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
517
-						if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
518
-						$body_parse = substr($body_parse,strlen($matches[0]));
519
-					} 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)) {
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['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
516
+						if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
517
+						$body_parse = substr($body_parse, strlen($matches[0]));
518
+					} 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)) {
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['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
524 523
 						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
525
-						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/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})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$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[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
524
+						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
525
+						$body_parse = substr($body_parse, strlen($matches[0]));
526
+					} 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)) {
527
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
528
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
529
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
530
+						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
532 531
 						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
533
-						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
534
-						$body_parse = substr($body_parse,strlen($matches[0]));
535
-					} 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)) {
536
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
537
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
538
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
539
-						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
532
+						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
533
+						$body_parse = substr($body_parse, strlen($matches[0]));
534
+					} 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)) {
535
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
536
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
537
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
538
+						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
540 539
 						if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
541
-						if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
542
-						$body_parse = substr($body_parse,strlen($matches[0]));
543
-					} 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)) {
544
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
545
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
540
+						if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
541
+						$body_parse = substr($body_parse, strlen($matches[0]));
542
+					} 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)) {
543
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
544
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
546 545
 						if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
547
-						if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
548
-						$body_parse = substr($body_parse,strlen($matches[0]));
549
-					} 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)) {
550
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
551
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
552
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
546
+						if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1);
547
+						$body_parse = substr($body_parse, strlen($matches[0]));
548
+					} 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)) {
549
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
550
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
551
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
553 552
 						if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
554
-						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
555
-						$body_parse = substr($body_parse,strlen($matches[0]));
553
+						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
554
+						$body_parse = substr($body_parse, strlen($matches[0]));
556 555
 					}
557 556
 					$result['comment'] = trim($body_parse);
558 557
 				}
559 558
 			} else $result['comment'] = trim($body_parse);
560 559
 		}
561
-		if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
562
-		if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
560
+		if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
561
+		if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
563 562
 		if ($debug) print_r($result);
564 563
 		return $result;
565 564
 	}
@@ -568,34 +567,34 @@  discard block
 block discarded – undo
568 567
 	 * Connect to APRS server
569 568
 	*/
570 569
 	public function connect() {
571
-		global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
570
+		global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport;
572 571
 		$aprs_connect = 0;
573 572
 		$aprs_keep = 120;
574 573
 		$aprs_last_tx = time();
575 574
 		if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
576
-		else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
575
+		else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
577 576
 		if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
578
-		else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
577
+		else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
579 578
 		if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
580 579
 		else $aprs_pass = '-1';
581
-		$aprs_filter  = '';
580
+		$aprs_filter = '';
582 581
 		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
583 582
 		$Common = new Common();
584
-		$s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr);
583
+		$s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr);
585 584
 		if ($s !== false) {
586 585
 			echo 'Connected to APRS server! '."\n";
587 586
 			$authstart = time();
588 587
 			$this->socket = $s;
589
-			$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
590
-			socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1);
591
-			while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
588
+			$send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0);
589
+			socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1);
590
+			while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) {
592 591
 				if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
593 592
 					echo 'APRS user verified !'."\n";
594 593
 					$this->connected = true;
595 594
 					return true;
596 595
 					break;
597 596
 				}
598
-				if (time()-$authstart > 5) {
597
+				if (time() - $authstart > 5) {
599 598
 					echo 'APRS timeout'."\n";
600 599
 					break;
601 600
 				}
@@ -617,7 +616,7 @@  discard block
 block discarded – undo
617 616
 	public function send($data) {
618 617
 		global $globalDebug;
619 618
 		if ($this->connected === false) $this->connect();
620
-		$send = socket_send( $this->socket  , $data , strlen($data),0);
619
+		$send = socket_send($this->socket, $data, strlen($data), 0);
621 620
 		if ($send === FALSE) {
622 621
 			if ($globalDebug) echo 'Reconnect...';
623 622
 			socket_close($this->socket);
@@ -627,17 +626,17 @@  discard block
 block discarded – undo
627 626
 }
628 627
 
629 628
 class APRSSpotter extends APRS {
630
-	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) {
629
+	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) {
631 630
 		$Common = new Common();
632 631
 		date_default_timezone_set('UTC');
633 632
 		if ($latitude != '' && $longitude != '') {
634 633
 			$lat = $latitude;
635 634
 			$long = $longitude;
636
-			$latitude = $Common->convertDM($latitude,'latitude');
637
-			$longitude = $Common->convertDM($longitude,'longitude');
638
-			$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'];
639
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
640
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
635
+			$latitude = $Common->convertDM($latitude, 'latitude');
636
+			$longitude = $Common->convertDM($longitude, 'longitude');
637
+			$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'];
638
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
639
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
641 640
 			$w = $w1.$w2;
642 641
 			//$w = '00';
643 642
 			$custom = '';
@@ -664,26 +663,26 @@  discard block
 block discarded – undo
664 663
 			$geoid= round($GeoidClass->get($lat,$long)*3.28084,2);
665 664
 			$altitude_real = round($altitude_real + $geoid);
666 665
 			*/
667
-			$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");
666
+			$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");
668 667
 		}
669 668
 	}
670 669
 }
671 670
 class APRSMarine extends APRS {
672
-	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) {
671
+	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) {
673 672
 		$Common = new Common();
674 673
 		date_default_timezone_set('UTC');
675 674
 		if ($latitude != '' && $longitude != '') {
676
-			$latitude = $Common->convertDM($latitude,'latitude');
677
-			$longitude = $Common->convertDM($longitude,'longitude');
678
-			$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'];
679
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
680
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
675
+			$latitude = $Common->convertDM($latitude, 'latitude');
676
+			$longitude = $Common->convertDM($longitude, 'longitude');
677
+			$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'];
678
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
679
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
681 680
 			$w = $w1.$w2;
682 681
 			//$w = '00';
683 682
 			$custom = '';
684 683
 			if ($ident != '') {
685 684
 				if ($custom != '') $custom .= '/';
686
-				$custom .= 'CS='.str_replace(' ','_',$ident);
685
+				$custom .= 'CS='.str_replace(' ', '_', $ident);
687 686
 			}
688 687
 			if ($typeid != '') {
689 688
 				if ($custom != '') $custom .= '/';
@@ -703,11 +702,11 @@  discard block
 block discarded – undo
703 702
 			}
704 703
 			if ($arrival_code != '') {
705 704
 				if ($custom != '') $custom .= '/';
706
-				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
705
+				$custom .= 'AC='.str_replace(' ', '_', $arrival_code);
707 706
 			}
708 707
 			if ($custom != '') $custom = ' '.$custom;
709 708
 			$altitude = 0;
710
-			$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");
709
+			$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");
711 710
 		}
712 711
 	}
713 712
 }
Please login to merge, or discard this patch.
require/class.ATC.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -26,22 +26,22 @@  discard block
 block discarded – undo
26 26
 	* @param Array $filter the filter
27 27
 	* @return Array the SQL part
28 28
 	*/
29
-	public function getFilter($filter = array(),$where = false,$and = false) {
29
+	public function getFilter($filter = array(), $where = false, $and = false) {
30 30
 		global $globalFilter, $globalStatsFilters, $globalFilterName;
31 31
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
32 32
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
33
-				foreach($globalStatsFilters[$globalFilterName] as $source) {
33
+				foreach ($globalStatsFilters[$globalFilterName] as $source) {
34 34
 					if (isset($source['source'])) $filter['source'][] = $source['source'];
35 35
 				}
36 36
 			} else {
37 37
 				$filter = $globalStatsFilters[$globalFilterName];
38 38
 			}
39 39
 		}
40
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
40
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
41 41
 		$filter_query_join = '';
42 42
 		$filter_query_where = '';
43 43
 		if (isset($filter['source']) && !empty($filter['source'])) {
44
-			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
44
+			$filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
45 45
 		}
46 46
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
47 47
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 		try {
61 61
 			$sth = $this->db->prepare($query);
62 62
 			$sth->execute($query_values);
63
-		} catch(PDOException $e) {
63
+		} catch (PDOException $e) {
64 64
 			return "error : ".$e->getMessage();
65 65
 		}
66 66
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
 	 * @return Array Return ATC
74 74
 	*/
75 75
 	public function getById($id) {
76
-		$filter_query = $this->getFilter(array(),true,true);
76
+		$filter_query = $this->getFilter(array(), true, true);
77 77
 		$query = "SELECT * FROM atc".$filter_query." atc_id = :id";
78 78
 		$query_values = array(':id' => $id);
79 79
 		try {
80 80
 			$sth = $this->db->prepare($query);
81 81
 			$sth->execute($query_values);
82
-		} catch(PDOException $e) {
82
+		} catch (PDOException $e) {
83 83
 			return "error : ".$e->getMessage();
84 84
 		}
85 85
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -92,19 +92,19 @@  discard block
 block discarded – undo
92 92
 	 * @param String $format_source Format source
93 93
 	 * @return Array Return ATC
94 94
 	*/
95
-	public function getByIdent($ident,$format_source = '') {
96
-		$filter_query = $this->getFilter(array(),true,true);
95
+	public function getByIdent($ident, $format_source = '') {
96
+		$filter_query = $this->getFilter(array(), true, true);
97 97
 		if ($format_source == '') {
98 98
 			$query = "SELECT * FROM atc".$filter_query." ident = :ident";
99 99
 			$query_values = array(':ident' => $ident);
100 100
 		} else {
101 101
 			$query = "SELECT * FROM atc".$filter_query." ident = :ident AND format_source = :format_source";
102
-			$query_values = array(':ident' => $ident,':format_source' => $format_source);
102
+			$query_values = array(':ident' => $ident, ':format_source' => $format_source);
103 103
 		}
104 104
 		try {
105 105
 			$sth = $this->db->prepare($query);
106 106
 			$sth->execute($query_values);
107
-		} catch(PDOException $e) {
107
+		} catch (PDOException $e) {
108 108
 			return "error : ".$e->getMessage();
109 109
 		}
110 110
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -126,18 +126,18 @@  discard block
 block discarded – undo
126 126
 	 * @param String $format_source Format source
127 127
 	 * @param String $source_name Source name
128 128
 	*/
129
-	public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
130
-		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
131
-		$info = str_replace('^','<br />',$info);
132
-		$info = str_replace('&amp;sect;','',$info);
133
-		$info = str_replace('"','',$info);
129
+	public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
130
+		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
131
+		$info = str_replace('^', '<br />', $info);
132
+		$info = str_replace('&amp;sect;', '', $info);
133
+		$info = str_replace('"', '', $info);
134 134
 		if ($type == '') $type = NULL;
135 135
 		$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)";
136
-		$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);
136
+		$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);
137 137
 		try {
138 138
 			$sth = $this->db->prepare($query);
139 139
 			$sth->execute($query_values);
140
-		} catch(PDOException $e) {
140
+		} catch (PDOException $e) {
141 141
 			return "error : ".$e->getMessage();
142 142
 		}
143 143
 	}
@@ -157,18 +157,18 @@  discard block
 block discarded – undo
157 157
 	 * @param String $format_source Format source
158 158
 	 * @param String $source_name Source name
159 159
 	*/
160
-	public function update($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
161
-		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
162
-		$info = str_replace('^','<br />',$info);
163
-		$info = str_replace('&amp;sect;','',$info);
164
-		$info = str_replace('"','',$info);
160
+	public function update($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
161
+		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
162
+		$info = str_replace('^', '<br />', $info);
163
+		$info = str_replace('&amp;sect;', '', $info);
164
+		$info = str_replace('"', '', $info);
165 165
 		if ($type == '') $type = NULL;
166 166
 		$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";
167
-		$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);
167
+		$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);
168 168
 		try {
169 169
 			$sth = $this->db->prepare($query);
170 170
 			$sth->execute($query_values);
171
-		} catch(PDOException $e) {
171
+		} catch (PDOException $e) {
172 172
 			return "error : ".$e->getMessage();
173 173
 		}
174 174
 	}
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		try {
184 184
 			$sth = $this->db->prepare($query);
185 185
 			$sth->execute($query_values);
186
-		} catch(PDOException $e) {
186
+		} catch (PDOException $e) {
187 187
 			return "error : ".$e->getMessage();
188 188
 		}
189 189
 	}
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 	 * @param String $ident Flight ident
194 194
 	 * @param String $format_source Format source
195 195
 	*/
196
-	public function deleteByIdent($ident,$format_source) {
196
+	public function deleteByIdent($ident, $format_source) {
197 197
 		$query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source";
198
-		$query_values = array(':ident' => $ident,':format_source' => $format_source);
198
+		$query_values = array(':ident' => $ident, ':format_source' => $format_source);
199 199
 		try {
200 200
 			$sth = $this->db->prepare($query);
201 201
 			$sth->execute($query_values);
202
-		} catch(PDOException $e) {
202
+		} catch (PDOException $e) {
203 203
 			return "error : ".$e->getMessage();
204 204
 		}
205 205
 	}
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 		try {
214 214
 			$sth = $this->db->prepare($query);
215 215
 			$sth->execute($query_values);
216
-		} catch(PDOException $e) {
216
+		} catch (PDOException $e) {
217 217
 			return "error : ".$e->getMessage();
218 218
 		}
219 219
 	}
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 		try {
232 232
 			$sth = $this->db->prepare($query);
233 233
 			$sth->execute();
234
-		} catch(PDOException $e) {
234
+		} catch (PDOException $e) {
235 235
 			return "error";
236 236
 		}
237 237
 		return "success";
Please login to merge, or discard this patch.
require/class.NOTAM.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 		try {
989 989
 			$sth = $this->db->prepare($query);
990 990
 			$sth->execute($query_values);
991
-		} catch(PDOException $e) {
991
+		} catch (PDOException $e) {
992 992
 			echo "error : ".$e->getMessage();
993 993
 		}
994 994
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1005,19 +1005,19 @@  discard block
 block discarded – undo
1005 1005
 		try {
1006 1006
 			$sth = $this->db->prepare($query);
1007 1007
 			$sth->execute($query_values);
1008
-		} catch(PDOException $e) {
1008
+		} catch (PDOException $e) {
1009 1009
 			echo "error : ".$e->getMessage();
1010 1010
 		}
1011 1011
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1012 1012
 		return $all;
1013 1013
 	}
1014 1014
 	public function getAllNOTAMtext() {
1015
-		$query  = 'SELECT full_notam FROM notam';
1015
+		$query = 'SELECT full_notam FROM notam';
1016 1016
 		$query_values = array();
1017 1017
 		try {
1018 1018
 			$sth = $this->db->prepare($query);
1019 1019
 			$sth->execute($query_values);
1020
-		} catch(PDOException $e) {
1020
+		} catch (PDOException $e) {
1021 1021
 			echo "error : ".$e->getMessage();
1022 1022
 		}
1023 1023
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1026,12 +1026,12 @@  discard block
 block discarded – undo
1026 1026
 	public function createNOTAMtextFile($filename) {
1027 1027
 		$allnotam_result = $this->getAllNOTAMtext();
1028 1028
 		$notamtext = '';
1029
-		foreach($allnotam_result as $notam) {
1029
+		foreach ($allnotam_result as $notam) {
1030 1030
 			$notamtext .= '%%'."\n";
1031 1031
 			$notamtext .= $notam['full_notam'];
1032 1032
 			$notamtext .= "\n".'%%'."\n";
1033 1033
 		}
1034
-		file_put_contents($filename,$notamtext);
1034
+		file_put_contents($filename, $notamtext);
1035 1035
 	}
1036 1036
 	public function parseNOTAMtextFile($filename) {
1037 1037
 		$data = file_get_contents($filename);
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
 		try {
1051 1051
 			$sth = $this->db->prepare($query);
1052 1052
 			$sth->execute($query_values);
1053
-		} catch(PDOException $e) {
1053
+		} catch (PDOException $e) {
1054 1054
 			echo "error : ".$e->getMessage();
1055 1055
 		}
1056 1056
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1059,10 +1059,10 @@  discard block
 block discarded – undo
1059 1059
 	public function getAllNOTAMbyCoord($coord) {
1060 1060
 		global $globalDBdriver;
1061 1061
 		if (is_array($coord)) {
1062
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1063
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1064
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1065
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1062
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1063
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1064
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1065
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1066 1066
 			if ($minlat > $maxlat) {
1067 1067
 				$tmplat = $minlat;
1068 1068
 				$minlat = $maxlat;
@@ -1083,19 +1083,19 @@  discard block
 block discarded – undo
1083 1083
 		try {
1084 1084
 			$sth = $this->db->prepare($query);
1085 1085
 			$sth->execute($query_values);
1086
-		} catch(PDOException $e) {
1086
+		} catch (PDOException $e) {
1087 1087
 			echo "error : ".$e->getMessage();
1088 1088
 		}
1089 1089
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1090 1090
 		return $all;
1091 1091
 	}
1092
-	public function getAllNOTAMbyCoordScope($coord,$scope) {
1092
+	public function getAllNOTAMbyCoordScope($coord, $scope) {
1093 1093
 		global $globalDBdriver;
1094 1094
 		if (is_array($coord)) {
1095
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1096
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1097
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1098
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1095
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1096
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1097
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1098
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1099 1099
 		} else return array();
1100 1100
 		if ($globalDBdriver == 'mysql') {
1101 1101
 			$query  = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope';
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 		try {
1107 1107
 			$sth = $this->db->prepare($query);
1108 1108
 			$sth->execute($query_values);
1109
-		} catch(PDOException $e) {
1109
+		} catch (PDOException $e) {
1110 1110
 			echo "error : ".$e->getMessage();
1111 1111
 		}
1112 1112
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 		try {
1119 1119
 			$sth = $this->db->prepare($query);
1120 1120
 			$sth->execute($query_values);
1121
-		} catch(PDOException $e) {
1121
+		} catch (PDOException $e) {
1122 1122
 			return "error : ".$e->getMessage();
1123 1123
 		}
1124 1124
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1126,13 +1126,13 @@  discard block
 block discarded – undo
1126 1126
 		else return array();
1127 1127
 	}
1128 1128
 
1129
-	public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) {
1129
+	public function addNOTAM($ref, $title, $type, $fir, $code, $rules, $scope, $lower_limit, $upper_limit, $center_latitude, $center_longitude, $radius, $date_begin, $date_end, $permanent, $text, $full_notam) {
1130 1130
 		$query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)";
1131
-		$query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam);
1131
+		$query_values = array(':ref' => $ref, ':title' => $title, ':type' => $type, ':fir' => $fir, ':code' => $code, ':rules' => $rules, ':scope' => $scope, ':lower_limit' => $lower_limit, ':upper_limit' => $upper_limit, ':center_latitude' => $center_latitude, ':center_longitude' => $center_longitude, ':radius' => $radius, ':date_begin' => $date_begin, ':date_end' => $date_end, ':permanent' => $permanent, ':text' => $text, ':full_notam' => $full_notam);
1132 1132
 		try {
1133 1133
 			$sth = $this->db->prepare($query);
1134 1134
 			$sth->execute($query_values);
1135
-		} catch(PDOException $e) {
1135
+		} catch (PDOException $e) {
1136 1136
 			return "error : ".$e->getMessage();
1137 1137
 		}
1138 1138
 	}
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 		try {
1144 1144
 			$sth = $this->db->prepare($query);
1145 1145
 			$sth->execute($query_values);
1146
-		} catch(PDOException $e) {
1146
+		} catch (PDOException $e) {
1147 1147
 			return "error : ".$e->getMessage();
1148 1148
 		}
1149 1149
 	}
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
 		try {
1159 1159
 			$sth = $this->db->prepare($query);
1160 1160
 			$sth->execute($query_values);
1161
-		} catch(PDOException $e) {
1161
+		} catch (PDOException $e) {
1162 1162
 			return "error : ".$e->getMessage();
1163 1163
 		}
1164 1164
 	}
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 		try {
1169 1169
 			$sth = $this->db->prepare($query);
1170 1170
 			$sth->execute($query_values);
1171
-		} catch(PDOException $e) {
1171
+		} catch (PDOException $e) {
1172 1172
 			return "error : ".$e->getMessage();
1173 1173
 		}
1174 1174
 	}
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 		try {
1178 1178
 			$sth = $this->db->prepare($query);
1179 1179
 			$sth->execute();
1180
-		} catch(PDOException $e) {
1180
+		} catch (PDOException $e) {
1181 1181
 			return "error : ".$e->getMessage();
1182 1182
 		}
1183 1183
 	}
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 		try {
1187 1187
 			$sth = $this->db->prepare($query);
1188 1188
 			$sth->execute();
1189
-		} catch(PDOException $e) {
1189
+		} catch (PDOException $e) {
1190 1190
 			return "error : ".$e->getMessage();
1191 1191
 		}
1192 1192
 	}
@@ -1194,14 +1194,14 @@  discard block
 block discarded – undo
1194 1194
 	public function updateNOTAM() {
1195 1195
 		global $globalNOTAMAirports;
1196 1196
 		if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) {
1197
-			foreach (array_chunk($globalNOTAMAirports,10) as $airport) {
1198
-				$airport_icao = implode(',',$airport);
1197
+			foreach (array_chunk($globalNOTAMAirports, 10) as $airport) {
1198
+				$airport_icao = implode(',', $airport);
1199 1199
 				$alldata = $this->downloadNOTAM($airport_icao);
1200 1200
 				if (count($alldata) > 0) {
1201 1201
 					foreach ($alldata as $initial_data) {
1202 1202
 						$data = $this->parse($initial_data);
1203 1203
 						$notamref = $this->getNOTAMbyRef($data['ref']);
1204
-						if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1204
+						if (count($notamref) == 0) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1205 1205
 					}
1206 1206
 				}
1207 1207
 			}
@@ -1214,7 +1214,7 @@  discard block
 block discarded – undo
1214 1214
 			foreach ($alldata as $initial_data) {
1215 1215
 				$data = $this->parse($initial_data);
1216 1216
 				$notamref = $this->getNOTAMbyRef($data['ref']);
1217
-				if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1217
+				if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1218 1218
 			}
1219 1219
 		}
1220 1220
 	}
@@ -1223,12 +1223,12 @@  discard block
 block discarded – undo
1223 1223
 		global $globalTransaction;
1224 1224
 		$Spotter = new Spotter($this->db);
1225 1225
 		$allairports = $Spotter->getAllAirportInfo();
1226
-		foreach (array_chunk($allairports,20) as $airport) {
1226
+		foreach (array_chunk($allairports, 20) as $airport) {
1227 1227
 			$airports_icao = array();
1228
-			foreach($airport as $icao) {
1228
+			foreach ($airport as $icao) {
1229 1229
 				if (isset($icao['icao'])) $airports_icao[] = $icao['icao'];
1230 1230
 			}
1231
-			$airport_icao = implode(',',$airports_icao);
1231
+			$airport_icao = implode(',', $airports_icao);
1232 1232
 			$alldata = $this->downloadNOTAM($airport_icao);
1233 1233
 			if ($globalTransaction) $this->db->beginTransaction();
1234 1234
 			if (count($alldata) > 0) {
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 						if (count($notamref) == 0) {
1242 1242
 							if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']);
1243 1243
 							if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']);
1244
-							elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1244
+							elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'], '', '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1245 1245
 						}
1246 1246
 					}
1247 1247
 				}
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 		date_default_timezone_set("UTC");
1256 1256
 		$Common = new Common();
1257 1257
 		//$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1258
-		$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1258
+		$url = str_replace('{icao}', $icao, 'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1259 1259
 		$data = $Common->getData($url);
1260 1260
 		preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches);
1261 1261
 		//print_r($matches);
@@ -1272,8 +1272,8 @@  discard block
 block discarded – undo
1272 1272
 		$result['permanent'] = '';
1273 1273
 		$result['date_begin'] = NULL;
1274 1274
 		$result['date_end'] = NULL;
1275
-		$data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data);
1276
-		$data = preg_split('#\s(?=([A-Z]\)\s))#',$data);
1275
+		$data = str_ireplace(array("\r", "\n", '\r', '\n'), ' ', $data);
1276
+		$data = preg_split('#\s(?=([A-Z]\)\s))#', $data);
1277 1277
 		$q = false;
1278 1278
 		$a = false;
1279 1279
 		$b = false;
@@ -1281,9 +1281,9 @@  discard block
 block discarded – undo
1281 1281
 		$e = false;
1282 1282
 		foreach ($data as $line) {
1283 1283
 			$line = trim($line);
1284
-			if (preg_match('#(^|\s)Q\) (.*)#',$line,$matches) && $q === false) {
1285
-				$line = str_replace(' ','',$line);
1286
-				if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#',$line,$matches)) {
1284
+			if (preg_match('#(^|\s)Q\) (.*)#', $line, $matches) && $q === false) {
1285
+				$line = str_replace(' ', '', $line);
1286
+				if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#', $line, $matches)) {
1287 1287
 				//if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) {
1288 1288
 					$result['fir'] = $matches[1];
1289 1289
 					$result['code'] = $matches[2];
@@ -1328,9 +1328,9 @@  discard block
 block discarded – undo
1328 1328
 					elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning';
1329 1329
 					$result['lower_limit'] = $matches[6];
1330 1330
 					$result['upper_limit'] = $matches[7];
1331
-					$latitude = $Common->convertDec($matches[8],'latitude');
1331
+					$latitude = $Common->convertDec($matches[8], 'latitude');
1332 1332
 					if ($matches[9] == 'S') $latitude = -$latitude;
1333
-					$longitude = $Common->convertDec($matches[10],'longitude');
1333
+					$longitude = $Common->convertDec($matches[10], 'longitude');
1334 1334
 					if ($matches[11] == 'W') $longitude = -$longitude;
1335 1335
 					$result['latitude'] = $latitude;
1336 1336
 					$result['longitude'] = $longitude;
@@ -1342,24 +1342,24 @@  discard block
 block discarded – undo
1342 1342
 					echo "Can't parse : ".$line."\n";
1343 1343
 				}
1344 1344
 			}
1345
-			elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) {
1345
+			elseif (preg_match('#(^|\s)A\) (.*)#', $line, $matches) && $a === false) {
1346 1346
 				$result['icao'] = $matches[2];
1347 1347
 				$a = true;
1348 1348
 			}
1349
-			elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) {
1349
+			elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#', $line, $matches) && $b === false) {
1350 1350
 				if ($matches[1] > 50) $year = '19'.$matches[2];
1351 1351
 				else $year = '20'.$matches[2];
1352 1352
 				$result['date_begin'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6];
1353 1353
 				$b = true;
1354 1354
 			}
1355
-			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) {
1355
+			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $line, $matches) && $c === false) {
1356 1356
 				if ($matches[2] > 50) $year = '19'.$matches[2];
1357 1357
 				else $year = '20'.$matches[2];
1358 1358
 				$result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6];
1359 1359
 				$result['permanent'] = 0;
1360 1360
 				$c = true;
1361 1361
 			}
1362
-			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) {
1362
+			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#', $line, $matches) && $c === false) {
1363 1363
 				if ($matches[2] > 50) $year = '19'.$matches[2];
1364 1364
 				else $year = '20'.$matches[2];
1365 1365
 				$result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6];
@@ -1369,7 +1369,7 @@  discard block
 block discarded – undo
1369 1369
 				else $result['permanent'] = 0;
1370 1370
 				$c = true;
1371 1371
 			}
1372
-			elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) {
1372
+			elseif (preg_match('#(^|\s)C\) (EST|PERM)$#', $line, $matches) && $c === false) {
1373 1373
 				$result['date_end'] = '2030/12/20 12:00';
1374 1374
 				if ($matches[2] == 'EST') $result['estimated'] = 1;
1375 1375
 				else $result['estimated'] = 0;
@@ -1377,20 +1377,20 @@  discard block
 block discarded – undo
1377 1377
 				else $result['permanent'] = 0;
1378 1378
 				$c = true;
1379 1379
 			}
1380
-			elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) {
1380
+			elseif (preg_match('#(^|\s)E\) (.*)#', $line, $matches) && $e === false) {
1381 1381
 				$rtext = array();
1382
-				$text = explode(' ',$matches[2]);
1382
+				$text = explode(' ', $matches[2]);
1383 1383
 				foreach ($text as $word) {
1384 1384
 					if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]);
1385
-					elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3);
1385
+					elseif (ctype_digit(strval(substr($word, 3))) && isset($this->abbr[substr($word, 0, 3)])) $rtext[] = strtoupper($this->abbr[substr($word, 0, 3)]).' '.substr($word, 3);
1386 1386
 					else $rtext[] = $word;
1387 1387
 				}
1388
-				$result['text'] = implode(' ',$rtext);
1388
+				$result['text'] = implode(' ', $rtext);
1389 1389
 				$e = true;
1390 1390
 			//} elseif (preg_match('#F\) (.*)#',$line,$matches)) {
1391 1391
 			//} elseif (preg_match('#G\) (.*)#',$line,$matches)) {
1392
-			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) {
1393
-				$text = explode(' ',$line);
1392
+			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#', $line, $matches)) {
1393
+				$text = explode(' ', $line);
1394 1394
 				$result['ref'] = $text[0];
1395 1395
 				if ($matches[1] == 'NOTAMN') $result['type'] = 'new';
1396 1396
 				if ($matches[1] == 'NOTAMC') {
Please login to merge, or discard this patch.
require/class.ACARS.php 1 patch
Spacing   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	/*
22 22
 	 * Initialize DB connection
23 23
 	*/
24
-	public function __construct($dbc = null,$fromACARSscript = false) {
24
+	public function __construct($dbc = null, $fromACARSscript = false) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27 27
 		if ($this->db === null) die('Error: No DB connection. (ACARS)');
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 	* @return String the icao
39 39
 	*/
40 40
 	public function ident2icao($ident) {
41
-		if (substr($ident,0,2) == 'AF') {
42
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
41
+		if (substr($ident, 0, 2) == 'AF') {
42
+			if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
+			else $icao = 'AFR'.ltrim(substr($ident, 2), '0');
44 44
 		} else {
45 45
 			$Spotter = new Spotter($this->db);
46
-			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
46
+			$identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2));
47 47
 			if (isset($identicao[0])) {
48
-				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
48
+				$icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0');
49 49
 			} else $icao = $ident;
50 50
 		}
51 51
 		return $icao;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
 			$sth = $this->db->prepare($query);
71 71
 			$sth->execute();
72
-		} catch(PDOException $e) {
72
+		} catch (PDOException $e) {
73 73
 			return "error";
74 74
 		}
75 75
 		return "success";
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
 			$sth = $this->db->prepare($query);
95 95
 			$sth->execute();
96
-		} catch(PDOException $e) {
96
+		} catch (PDOException $e) {
97 97
 			return "error";
98 98
 		}
99 99
 		return "success";
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
 		$ident = '';
119 119
 		$message = '';
120 120
 		$result = array();
121
-		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
122
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
123
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
124
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
121
+		$n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
122
+		if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
123
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
124
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
125 125
 		if ($n != 0) {
126
-			$registration = str_replace('.','',$registration);
127
-			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
126
+			$registration = str_replace('.', '', $registration);
127
+			$result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message);
128 128
 			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
129 129
 		} else $message = $data;
130 130
 		$decode = array();
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 				$temp = '';
145 145
 				$n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp);
146 146
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
147
-					$latitude = $la / 10000.0;
148
-					$longitude = $ln / 10000.0;
147
+					$latitude = $la/10000.0;
148
+					$longitude = $ln/10000.0;
149 149
 					if ($lac == 'S') $latitude = '-'.$latitude;
150 150
 					if ($lnc == 'W') $longitude = '-'.$longitude;
151 151
 					// Temp not always available
152 152
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
153
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
154
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
153
+					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt);
154
+					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C');
155 155
 
156 156
 					//$icao = $Translation->checkTranslation($ident);
157 157
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -163,19 +163,19 @@  discard block
 block discarded – undo
163 163
 				$dhour = '';
164 164
 				$darr = '';
165 165
 				$ahour = '';
166
-				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
166
+				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour);
167 167
 				if ($n == 4 && strlen($darr) == 4) {
168
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
169
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
170
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
168
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
169
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
170
+					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n";
171 171
 					//$icao = ACARS->ident2icao($ident);
172 172
 					//$icao = $Translation->checkTranslation($ident);
173 173
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
174 174
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
175 175
 					$found = true;
176 176
 				}
177
-				elseif ($n == 2 || $n  == 4) {
178
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
177
+				elseif ($n == 2 || $n == 4) {
178
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
179 179
 					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
180 180
 					//$icao = ACARS->ident2icao($ident);
181 181
 					//$icao = $Translation->checkTranslation($ident);
@@ -233,11 +233,11 @@  discard block
 block discarded – undo
233 233
 				$ahour = '';
234 234
 				$aair = '';
235 235
 				$apiste = '';
236
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
236
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste);
237 237
 				if ($n > 8) {
238
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
239
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
240
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
238
+					if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
239
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
240
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
241 241
 					$icao = trim($aident);
242 242
 
243 243
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
 				if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
263 263
 					$las = $las.'.'.$lass;
264 264
 					$lns = $lns.'.'.$lns;
265
-					$latitude = $las / 1000.0;
266
-					$longitude = $lns / 1000.0;
265
+					$latitude = $las/1000.0;
266
+					$longitude = $lns/1000.0;
267 267
 					if ($lac == 'S') $latitude = '-'.$latitude;
268 268
 					if ($lnc == 'W') $longitude = '-'.$longitude;
269 269
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
@@ -358,17 +358,17 @@  discard block
 block discarded – undo
358 358
 				$alt = '';
359 359
 				$fuel = '';
360 360
 				$speed = '';
361
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
361
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
362 362
 				if ($n == 9) {
363 363
 					//if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
364 364
 					$icao = trim($aident);
365 365
 					$decode['icao'] = $icao;
366
-					$latitude = $las / 100.0;
367
-					$longitude = $lns / 100.0;
366
+					$latitude = $las/100.0;
367
+					$longitude = $lns/100.0;
368 368
 					if ($lac == 'S') $latitude = '-'.$latitude;
369 369
 					if ($lnc == 'W') $longitude = '-'.$longitude;
370 370
 
371
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
371
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed);
372 372
 					$found = true;
373 373
 				}
374 374
 			}
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 					if ($lac == 'S') $latitude = '-'.$latitude;
388 388
 					if ($lnc == 'W') $longitude = '-'.$longitude;
389 389
 
390
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
390
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
391 391
 					$found = true;
392 392
 				}
393 393
 			}
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 				$dair = '';
421 421
 				$darr = '';
422 422
 				$aident = '';
423
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
423
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
424 424
 				if ($n == 8) {
425 425
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
426 426
 					$icao = trim($aident);
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 				*/
453 453
 				$dair = '';
454 454
 				$darr = '';
455
-				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
455
+				$n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr);
456 456
 				if ($n == 3) {
457 457
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
458 458
 					//$icao = $Translation->checkTranslation($ident);
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 				*/
468 468
 				$dair = '';
469 469
 				$darr = '';
470
-				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
470
+				$n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr);
471 471
 				if ($n == 3) {
472 472
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
473 473
 					//$icao = $Translation->checkTranslation($ident);
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 				}
478 478
 			}
479 479
 			if (!$found) {
480
-				$n = sscanf($message,'MET01%4c',$airport);
480
+				$n = sscanf($message, 'MET01%4c', $airport);
481 481
 				if ($n == 1) {
482 482
 					if ($globalDebug) echo 'airport name : '.$airport;
483 483
 					$decode = array('Airport/Waypoint name' => $airport);
@@ -485,241 +485,241 @@  discard block
 block discarded – undo
485 485
 				}
486 486
 			}
487 487
 			if ($label == 'H1') {
488
-				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
489
-					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
488
+				if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) {
489
+					$decode = array_merge(array('Message nature' => 'Equipment failure'), $decode);
490 490
 				}
491
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
492
-					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
491
+				elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) {
492
+					$decode = array_merge(array('Message nature' => 'Take off performance data'), $decode);
493 493
 				}
494
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
495
-					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
494
+				elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) {
495
+					$decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode);
496 496
 				}
497
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
498
-					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
497
+				elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) {
498
+					$decode = array_merge(array('Message nature' => 'Weather observation'), $decode);
499 499
 				}
500
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
501
-					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
500
+				elseif (preg_match(':^#DFB/PIREP:', $message)) {
501
+					$decode = array_merge(array('Message nature' => 'Pilot Report'), $decode);
502 502
 				}
503
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
504
-					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
503
+				elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) {
504
+					$decode = array_merge(array('Message nature' => 'Engine Data'), $decode);
505 505
 				}
506
-				elseif (preg_match(':^#M1AAEP:',$message)) {
507
-					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
506
+				elseif (preg_match(':^#M1AAEP:', $message)) {
507
+					$decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode);
508 508
 				}
509
-				elseif (preg_match(':^#M2APWD:',$message)) {
510
-					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
509
+				elseif (preg_match(':^#M2APWD:', $message)) {
510
+					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode);
511 511
 				}
512
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
513
-					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
512
+				elseif (preg_match(':^#M1BREQPWI:', $message)) {
513
+					$decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode);
514 514
 				}
515
-				elseif (preg_match(':^#CF:',$message)) {
516
-					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
515
+				elseif (preg_match(':^#CF:', $message)) {
516
+					$decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode);
517 517
 				}
518
-				elseif (preg_match(':^#DF:',$message)) {
519
-					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
518
+				elseif (preg_match(':^#DF:', $message)) {
519
+					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode);
520 520
 				}
521
-				elseif (preg_match(':^#EC:',$message)) {
522
-					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
521
+				elseif (preg_match(':^#EC:', $message)) {
522
+					$decode = array_merge(array('Message nature' => 'Engine Display System'), $decode);
523 523
 				}
524
-				elseif (preg_match(':^#EI:',$message)) {
525
-					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
524
+				elseif (preg_match(':^#EI:', $message)) {
525
+					$decode = array_merge(array('Message nature' => 'Engine Report'), $decode);
526 526
 				}
527
-				elseif (preg_match(':^#H1:',$message)) {
528
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
527
+				elseif (preg_match(':^#H1:', $message)) {
528
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode);
529 529
 				}
530
-				elseif (preg_match(':^#H2:',$message)) {
531
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
530
+				elseif (preg_match(':^#H2:', $message)) {
531
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode);
532 532
 				}
533
-				elseif (preg_match(':^#HD:',$message)) {
534
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
533
+				elseif (preg_match(':^#HD:', $message)) {
534
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode);
535 535
 				}
536
-				elseif (preg_match(':^#M1:',$message)) {
537
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
536
+				elseif (preg_match(':^#M1:', $message)) {
537
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode);
538 538
 				}
539
-				elseif (preg_match(':^#M2:',$message)) {
540
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
539
+				elseif (preg_match(':^#M2:', $message)) {
540
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode);
541 541
 				}
542
-				elseif (preg_match(':^#M3:',$message)) {
543
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
542
+				elseif (preg_match(':^#M3:', $message)) {
543
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode);
544 544
 				}
545
-				elseif (preg_match(':^#MD:',$message)) {
546
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
545
+				elseif (preg_match(':^#MD:', $message)) {
546
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode);
547 547
 				}
548
-				elseif (preg_match(':^#PS:',$message)) {
549
-					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
548
+				elseif (preg_match(':^#PS:', $message)) {
549
+					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode);
550 550
 				}
551
-				elseif (preg_match(':^#S1:',$message)) {
552
-					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
551
+				elseif (preg_match(':^#S1:', $message)) {
552
+					$decode = array_merge(array('Message nature' => 'SDU - Left'), $decode);
553 553
 				}
554
-				elseif (preg_match(':^#S2:',$message)) {
555
-					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
554
+				elseif (preg_match(':^#S2:', $message)) {
555
+					$decode = array_merge(array('Message nature' => 'SDU - Right'), $decode);
556 556
 				}
557
-				elseif (preg_match(':^#SD:',$message)) {
558
-					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
557
+				elseif (preg_match(':^#SD:', $message)) {
558
+					$decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode);
559 559
 				}
560
-				elseif (preg_match(':^#T[0-8]:',$message)) {
561
-					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
560
+				elseif (preg_match(':^#T[0-8]:', $message)) {
561
+					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode);
562 562
 				}
563
-				elseif (preg_match(':^#WO:',$message)) {
564
-					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
563
+				elseif (preg_match(':^#WO:', $message)) {
564
+					$decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode);
565 565
 				}
566
-				elseif (preg_match(':^#A1:',$message)) {
567
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
566
+				elseif (preg_match(':^#A1:', $message)) {
567
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode);
568 568
 				}
569
-				elseif (preg_match(':^#A3:',$message)) {
570
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
569
+				elseif (preg_match(':^#A3:', $message)) {
570
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode);
571 571
 				}
572
-				elseif (preg_match(':^#A4:',$message)) {
573
-					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
572
+				elseif (preg_match(':^#A4:', $message)) {
573
+					$decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode);
574 574
 				}
575
-				elseif (preg_match(':^#A6:',$message)) {
576
-					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
575
+				elseif (preg_match(':^#A6:', $message)) {
576
+					$decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode);
577 577
 				}
578
-				elseif (preg_match(':^#A8:',$message)) {
579
-					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
578
+				elseif (preg_match(':^#A8:', $message)) {
579
+					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode);
580 580
 				}
581
-				elseif (preg_match(':^#A9:',$message)) {
582
-					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
581
+				elseif (preg_match(':^#A9:', $message)) {
582
+					$decode = array_merge(array('Message nature' => 'ATIS report'), $decode);
583 583
 				}
584
-				elseif (preg_match(':^#A0:',$message)) {
585
-					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
584
+				elseif (preg_match(':^#A0:', $message)) {
585
+					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode);
586 586
 				}
587
-				elseif (preg_match(':^#AA:',$message)) {
588
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
587
+				elseif (preg_match(':^#AA:', $message)) {
588
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
589 589
 				}
590
-				elseif (preg_match(':^#AB:',$message)) {
591
-					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
590
+				elseif (preg_match(':^#AB:', $message)) {
591
+					$decode = array_merge(array('Message nature' => 'TWIP Report'), $decode);
592 592
 				}
593
-				elseif (preg_match(':^#AC:',$message)) {
594
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
593
+				elseif (preg_match(':^#AC:', $message)) {
594
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode);
595 595
 				}
596
-				elseif (preg_match(':^#AD:',$message)) {
597
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
596
+				elseif (preg_match(':^#AD:', $message)) {
597
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode);
598 598
 				}
599
-				elseif (preg_match(':^#AF:',$message)) {
600
-					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
599
+				elseif (preg_match(':^#AF:', $message)) {
600
+					$decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode);
601 601
 				}
602
-				elseif (preg_match(':^#B1:',$message)) {
603
-					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
602
+				elseif (preg_match(':^#B1:', $message)) {
603
+					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode);
604 604
 				}
605
-				elseif (preg_match(':^#B2:',$message)) {
606
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
605
+				elseif (preg_match(':^#B2:', $message)) {
606
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode);
607 607
 				}
608
-				elseif (preg_match(':^#B3:',$message)) {
609
-					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
608
+				elseif (preg_match(':^#B3:', $message)) {
609
+					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode);
610 610
 				}
611
-				elseif (preg_match(':^#B4:',$message)) {
612
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
611
+				elseif (preg_match(':^#B4:', $message)) {
612
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode);
613 613
 				}
614
-				elseif (preg_match(':^#B6:',$message)) {
615
-					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
614
+				elseif (preg_match(':^#B6:', $message)) {
615
+					$decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode);
616 616
 				}
617
-				elseif (preg_match(':^#B8:',$message)) {
618
-					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
617
+				elseif (preg_match(':^#B8:', $message)) {
618
+					$decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode);
619 619
 				}
620
-				elseif (preg_match(':^#B9:',$message)) {
621
-					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
620
+				elseif (preg_match(':^#B9:', $message)) {
621
+					$decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode);
622 622
 				}
623
-				elseif (preg_match(':^#B0:',$message)) {
624
-					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
623
+				elseif (preg_match(':^#B0:', $message)) {
624
+					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode);
625 625
 				}
626
-				elseif (preg_match(':^#BA:',$message)) {
627
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
626
+				elseif (preg_match(':^#BA:', $message)) {
627
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
628 628
 				}
629
-				elseif (preg_match(':^#BB:',$message)) {
630
-					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
629
+				elseif (preg_match(':^#BB:', $message)) {
630
+					$decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode);
631 631
 				}
632
-				elseif (preg_match(':^#BC:',$message)) {
633
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
632
+				elseif (preg_match(':^#BC:', $message)) {
633
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode);
634 634
 				}
635
-				elseif (preg_match(':^#BD:',$message)) {
636
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
635
+				elseif (preg_match(':^#BD:', $message)) {
636
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode);
637 637
 				}
638
-				elseif (preg_match(':^#BE:',$message)) {
639
-					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
638
+				elseif (preg_match(':^#BE:', $message)) {
639
+					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode);
640 640
 				}
641
-				elseif (preg_match(':^#BF:',$message)) {
642
-					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
641
+				elseif (preg_match(':^#BF:', $message)) {
642
+					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode);
643 643
 				}
644
-				elseif (preg_match(':^#H3:',$message)) {
645
-					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
644
+				elseif (preg_match(':^#H3:', $message)) {
645
+					$decode = array_merge(array('Message nature' => 'Icing Report'), $decode);
646 646
 				}
647 647
 			}
648 648
 			if ($label == '10') {
649
-				if (preg_match(':^DTO01:',$message)) {
650
-					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
649
+				if (preg_match(':^DTO01:', $message)) {
650
+					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode);
651 651
 				}
652
-				elseif (preg_match(':^AIS01:',$message)) {
653
-					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
652
+				elseif (preg_match(':^AIS01:', $message)) {
653
+					$decode = array_merge(array('Message nature' => 'AIS Request'), $decode);
654 654
 				}
655
-				elseif (preg_match(':^FTX01:',$message)) {
656
-					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
655
+				elseif (preg_match(':^FTX01:', $message)) {
656
+					$decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode);
657 657
 				}
658
-				elseif (preg_match(':^FPL01:',$message)) {
659
-					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
658
+				elseif (preg_match(':^FPL01:', $message)) {
659
+					$decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode);
660 660
 				}
661
-				elseif (preg_match(':^WAB01:',$message)) {
662
-					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
661
+				elseif (preg_match(':^WAB01:', $message)) {
662
+					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode);
663 663
 				}
664
-				elseif (preg_match(':^MET01:',$message)) {
665
-					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
664
+				elseif (preg_match(':^MET01:', $message)) {
665
+					$decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode);
666 666
 				}
667
-				elseif (preg_match(':^WAB02:',$message)) {
668
-					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
667
+				elseif (preg_match(':^WAB02:', $message)) {
668
+					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode);
669 669
 				}
670 670
 			}
671 671
 			if ($label == '15') {
672
-				if (preg_match(':^FST01:',$message)) {
673
-					$decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode);
672
+				if (preg_match(':^FST01:', $message)) {
673
+					$decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode);
674 674
 				}
675 675
 			}
676 676
 			if (!$found && $label == 'SA') {
677
-				$n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at);
677
+				$n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at);
678 678
 				if ($n == 4) {
679 679
 					$vsta = array('Version' => $version);
680 680
 					if ($state == 'E') {
681
-						$vsta = array_merge($vsta,array('Link state' => 'Established'));
681
+						$vsta = array_merge($vsta, array('Link state' => 'Established'));
682 682
 					}
683 683
 					elseif ($state == 'L') {
684
-						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
684
+						$vsta = array_merge($vsta, array('Link state' => 'Lost'));
685 685
 					}
686 686
 					else {
687
-						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
687
+						$vsta = array_merge($vsta, array('Link state' => 'Unknown'));
688 688
 					}
689 689
 					if ($type == 'V') {
690
-						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
690
+						$vsta = array_merge($vsta, array('Link type' => 'VHF ACARS'));
691 691
 					}
692 692
 					elseif ($type == 'S') {
693
-						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
693
+						$vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM'));
694 694
 					}
695 695
 					elseif ($type == 'H') {
696
-						$vsta = array_merge($vsta,array('Link type' => 'HF'));
696
+						$vsta = array_merge($vsta, array('Link type' => 'HF'));
697 697
 					}
698 698
 					elseif ($type == 'G') {
699
-						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
699
+						$vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM'));
700 700
 					}
701 701
 					elseif ($type == 'C') {
702
-						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
702
+						$vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM'));
703 703
 					}
704 704
 					elseif ($type == '2') {
705
-						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
705
+						$vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2'));
706 706
 					}
707 707
 					elseif ($type == 'X') {
708
-						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
708
+						$vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero'));
709 709
 					}
710 710
 					elseif ($type == 'I') {
711
-						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
711
+						$vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM'));
712 712
 					}
713 713
 					else {
714
-						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
714
+						$vsta = array_merge($vsta, array('Link type' => 'Unknown'));
715 715
 					}
716
-					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
717
-					$decode = array_merge($vsta,$decode);
716
+					$vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2))));
717
+					$decode = array_merge($vsta, $decode);
718 718
 				}
719 719
 			}
720 720
 
721 721
 			$title = $this->getTitlefromLabel($label);
722
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
722
+			if ($title != '') $decode = array_merge(array('Message title' => $title), $decode);
723 723
 			/*
724 724
 			// Business jets always use GS0001
725 725
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -747,13 +747,13 @@  discard block
 block discarded – undo
747 747
 		$Translation = new Translation($this->db);
748 748
 		$message = $this->parse($data);
749 749
 		if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') {
750
-			$ident = (string)$message['ident'];
750
+			$ident = (string) $message['ident'];
751 751
 			$label = $message['label'];
752 752
 			$block_id = $message['block_id'];
753 753
 			$msg_no = $message['msg_no'];
754 754
 			$msg = $message['message'];
755 755
 			$decode = $message['decode'];
756
-			$registration = (string)$message['registration'];
756
+			$registration = (string) $message['registration'];
757 757
 			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
758 758
 			else $latitude = '';
759 759
 			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
@@ -767,20 +767,20 @@  discard block
 block discarded – undo
767 767
 				$Image->addSpotterImage($registration);
768 768
 			}
769 769
 			// Business jets always use GS0001
770
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
770
+			if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude);
771 771
 			if ($globalDebug && isset($info) && $info != '') echo $info;
772 772
 			if (count($decode) > 0) $decode_json = json_encode($decode);
773 773
 			else $decode_json = '';
774 774
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
775
-				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
775
+				$Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS');
776 776
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
777
-				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
777
+				$Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS');
778 778
 			}
779
-			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
780
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
781
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
779
+			$result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
780
+			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F');
781
+			if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
782 782
 			if ($globalDebug && count($decode) > 0) {
783
-				echo "Human readable data : ".implode(' - ',$decode)."\n";
783
+				echo "Human readable data : ".implode(' - ', $decode)."\n";
784 784
 			}
785 785
 		}
786 786
 	}
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 	* @param String $msg_no Number of the ACARS message
796 796
 	* @param String $message ACARS message
797 797
 	*/
798
-	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
798
+	public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
799 799
 		global $globalDebug;
800 800
 		date_default_timezone_set('UTC');
801 801
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
@@ -803,21 +803,21 @@  discard block
 block discarded – undo
803 803
 			$this->db = $Connection->db;
804 804
 			if ($globalDebug) echo "Test if not already in Live ACARS table...";
805 805
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
806
-			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
806
+			$query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message);
807 807
 			try {
808 808
 				$stht = $this->db->prepare($query_test);
809 809
 				$stht->execute($query_test_values);
810
-			} catch(PDOException $e) {
810
+			} catch (PDOException $e) {
811 811
 				return "error : ".$e->getMessage();
812 812
 			}
813 813
 			if ($stht->fetchColumn() == 0) {
814 814
 				if ($globalDebug) echo "Add Live ACARS data...";
815 815
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
816
-				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
816
+				$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s"));
817 817
 				try {
818 818
 					$sth = $this->db->prepare($query);
819 819
 					$sth->execute($query_values);
820
-				} catch(PDOException $e) {
820
+				} catch (PDOException $e) {
821 821
 					return "error : ".$e->getMessage();
822 822
 				}
823 823
 			} else {
@@ -839,10 +839,10 @@  discard block
 block discarded – undo
839 839
 	* @param String $msg_no Number of the ACARS message
840 840
 	* @param String $message ACARS message
841 841
 	*/
842
-	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
842
+	public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
843 843
 		global $globalDebug;
844 844
 		date_default_timezone_set('UTC');
845
-		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) {
845
+		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) {
846 846
 			/*
847 847
 				    if ($globalDebug) echo "Test if not already in Archive ACARS table...";
848 848
 			    	    $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message";
@@ -857,11 +857,11 @@  discard block
 block discarded – undo
857 857
 			*/
858 858
 			if ($globalDebug) echo "Add Live ACARS data...";
859 859
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
860
-			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
860
+			$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
861 861
 			try {
862 862
 				$sth = $this->db->prepare($query);
863 863
 				$sth->execute($query_values);
864
-			} catch(PDOException $e) {
864
+			} catch (PDOException $e) {
865 865
 				return "error : ".$e->getMessage();
866 866
 			}
867 867
 			if ($globalDebug) echo "Done\n";
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 		try {
883 883
 			$sth = $this->db->prepare($query);
884 884
 			$sth->execute($query_values);
885
-		} catch(PDOException $e) {
885
+		} catch (PDOException $e) {
886 886
 			echo "error : ".$e->getMessage();
887 887
 			return '';
888 888
 		}
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 		try {
903 903
 			$sth = $this->db->prepare($query);
904 904
 			$sth->execute($query_values);
905
-		} catch(PDOException $e) {
905
+		} catch (PDOException $e) {
906 906
 			echo "error : ".$e->getMessage();
907 907
 			return array();
908 908
 		}
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
 		try {
924 924
 			$sth = $this->db->prepare($query);
925 925
 			$sth->execute($query_values);
926
-		} catch(PDOException $e) {
926
+		} catch (PDOException $e) {
927 927
 			echo "error : ".$e->getMessage();
928 928
 			return array();
929 929
 		}
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 	*
938 938
 	* @return Array Return ACARS data in array
939 939
 	*/
940
-	public function getLatestAcarsData($limit = '',$label = '') {
940
+	public function getLatestAcarsData($limit = '', $label = '') {
941 941
 		global $globalURL, $globalDBdriver;
942 942
 		$Image = new Image($this->db);
943 943
 		$Spotter = new Spotter($this->db);
@@ -948,8 +948,8 @@  discard block
 block discarded – undo
948 948
 		if ($limit != "")
949 949
 		{
950 950
 			$limit_array = explode(",", $limit);
951
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
952
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
951
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
952
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
953 953
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
954 954
 			{
955 955
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -965,46 +965,46 @@  discard block
 block discarded – undo
965 965
 		try {
966 966
 			$sth = $this->db->prepare($query);
967 967
 			$sth->execute($query_values);
968
-		} catch(PDOException $e) {
968
+		} catch (PDOException $e) {
969 969
 			return "error : ".$e->getMessage();
970 970
 		}
971 971
 		$i = 0;
972 972
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
973 973
 			$data = array();
974 974
 			if ($row['registration'] != '') {
975
-				$row['registration'] = str_replace('.','',$row['registration']);
975
+				$row['registration'] = str_replace('.', '', $row['registration']);
976 976
 				$image_array = $Image->getSpotterImage($row['registration']);
977
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
978
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
979
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
977
+				if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
978
+				else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
979
+			} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
980 980
 			if ($row['registration'] == '') $row['registration'] = 'NA';
981 981
 			if ($row['ident'] == '') $row['ident'] = 'NA';
982
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
982
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
983 983
 			if (isset($identicao[0])) {
984
-				if (substr($row['ident'],0,2) == 'AF') {
985
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
986
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
987
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
988
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
984
+				if (substr($row['ident'], 0, 2) == 'AF') {
985
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
986
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
987
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
988
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
989 989
 			} else $icao = $row['ident'];
990
-			$icao = $Translation->checkTranslation($icao,false);
991
-			$decode = json_decode($row['decode'],true);
990
+			$icao = $Translation->checkTranslation($icao, false);
991
+			$decode = json_decode($row['decode'], true);
992 992
 			$found = false;
993
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
993
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
994 994
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
995 995
 				if (isset($airport_info[0]['icao'])) {
996 996
 					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
997 997
 					$found = true;
998 998
 				}
999 999
 			}
1000
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1000
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1001 1001
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1002 1002
 				if (isset($airport_info[0]['icao'])) {
1003 1003
 					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1004 1004
 					$found = true;
1005 1005
 				}
1006 1006
 			}
1007
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1007
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1008 1008
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1009 1009
 				if (isset($airport_info[0]['icao'])) {
1010 1010
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 				}
1013 1013
 			}
1014 1014
 			if ($found) $row['decode'] = json_encode($decode);
1015
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1015
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1016 1016
 			$result[] = $data;
1017 1017
 			$i++;
1018 1018
 		}
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 	*
1029 1029
 	* @return Array Return ACARS data in array
1030 1030
 	*/
1031
-	public function getArchiveAcarsData($limit = '',$label = '') {
1031
+	public function getArchiveAcarsData($limit = '', $label = '') {
1032 1032
 		global $globalURL, $globalDBdriver;
1033 1033
 		$Image = new Image($this->db);
1034 1034
 		$Spotter = new Spotter($this->db);
@@ -1038,8 +1038,8 @@  discard block
 block discarded – undo
1038 1038
 		if ($limit != "")
1039 1039
 		{
1040 1040
 			$limit_array = explode(",", $limit);
1041
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1041
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1042
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1043 1043
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1044 1044
 			{
1045 1045
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -1060,43 +1060,43 @@  discard block
 block discarded – undo
1060 1060
 		try {
1061 1061
 			$sth = $this->db->prepare($query);
1062 1062
 			$sth->execute($query_values);
1063
-		} catch(PDOException $e) {
1063
+		} catch (PDOException $e) {
1064 1064
 			return "error : ".$e->getMessage();
1065 1065
 		}
1066
-		$i=0;
1066
+		$i = 0;
1067 1067
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1068 1068
 			$data = array();
1069 1069
 			if ($row['registration'] != '') {
1070
-				$row['registration'] = str_replace('.','',$row['registration']);
1070
+				$row['registration'] = str_replace('.', '', $row['registration']);
1071 1071
 				$image_array = $Image->getSpotterImage($row['registration']);
1072
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1073
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1074
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1072
+				if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
1073
+				else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1074
+			} else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1075 1075
 			$icao = '';
1076 1076
 			if ($row['registration'] == '') $row['registration'] = 'NA';
1077 1077
 			if ($row['ident'] == '') $row['ident'] = 'NA';
1078
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1078
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
1079 1079
 			if (isset($identicao[0])) {
1080
-				if (substr($row['ident'],0,2) == 'AF') {
1081
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1082
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1083
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1084
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1080
+				if (substr($row['ident'], 0, 2) == 'AF') {
1081
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1082
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1083
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1084
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1085 1085
 			} else $icao = $row['ident'];
1086 1086
 			$icao = $Translation->checkTranslation($icao);
1087
-			$decode = json_decode($row['decode'],true);
1087
+			$decode = json_decode($row['decode'], true);
1088 1088
 			$found = false;
1089
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1089
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1090 1090
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1091 1091
 				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1092 1092
 				$found = true;
1093 1093
 			}
1094
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1094
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1095 1095
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1096 1096
 				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1097 1097
 				$found = true;
1098 1098
 			}
1099
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1099
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1100 1100
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1101 1101
 				if (isset($airport_info[0]['icao'])) {
1102 1102
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 				}
1105 1105
 			}
1106 1106
 			if ($found) $row['decode'] = json_encode($decode);
1107
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1107
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1108 1108
 			$result[] = $data;
1109 1109
 			$i++;
1110 1110
 		}
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
 	* @param String $icao
1123 1123
 	* @param String $ICAOTypeCode
1124 1124
 	*/
1125
-	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1125
+	public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') {
1126 1126
 		global $globalDebug, $globalDBdriver;
1127 1127
 		$ident = trim($ident);
1128 1128
 		$Translation = new Translation($this->db);
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
 			if ($globalDebug) echo "Ident or registration null, exit\n";
1136 1136
 			return '';
1137 1137
 		}
1138
-		$registration = str_replace('.','',$registration);
1138
+		$registration = str_replace('.', '', $registration);
1139 1139
 		$ident = $Translation->ident2icao($ident);
1140 1140
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1141 1141
 		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 		try {
1145 1145
 			$sthsi = $this->db->prepare($querysi);
1146 1146
 			$sthsi->execute($querysi_values);
1147
-		} catch(PDOException $e) {
1147
+		} catch (PDOException $e) {
1148 1148
 			if ($globalDebug) echo $e->getMessage();
1149 1149
 			return "error : ".$e->getMessage();
1150 1150
 		}
@@ -1154,8 +1154,8 @@  discard block
 block discarded – undo
1154 1154
 			$Translation = new Translation($this->db);
1155 1155
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1156 1156
 			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1157
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1158
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1157
+			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS');
1158
+			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS');
1159 1159
 		} else {
1160 1160
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1161 1161
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 				try {
1164 1164
 					$sth = $this->db->prepare($query);
1165 1165
 					$sth->execute($query_values);
1166
-				} catch(PDOException $e) {
1166
+				} catch (PDOException $e) {
1167 1167
 					if ($globalDebug) echo $e->getMessage();
1168 1168
 					return "error : ".$e->getMessage();
1169 1169
 				}
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
 				$sth->closeCursor();
1172 1172
 				if (isset($result['modes'])) $hex = $result['modes'];
1173 1173
 				else $hex = '';
1174
-				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1174
+				$SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS');
1175 1175
 				if ($this->fromACARSscript) $this->SI->add($SI_data);
1176 1176
 			}
1177 1177
 		}
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 		try {
1182 1182
 			$sth = $this->db->prepare($query);
1183 1183
 			$sth->execute($query_values);
1184
-		} catch(PDOException $e) {
1184
+		} catch (PDOException $e) {
1185 1185
 			if ($globalDebug) echo $e->getMessage();
1186 1186
 			return "error : ".$e->getMessage();
1187 1187
 		}
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1192 1192
 			else $ModeS = '';
1193 1193
 			if ($ModeS == '') {
1194
-				$id = explode('-',$result['flightaware_id']);
1194
+				$id = explode('-', $result['flightaware_id']);
1195 1195
 				$ModeS = $id[0];
1196 1196
 			}
1197 1197
 			if ($ModeS != '') {
@@ -1201,20 +1201,20 @@  discard block
 block discarded – undo
1201 1201
 				try {
1202 1202
 					$sthc = $this->db->prepare($queryc);
1203 1203
 					$sthc->execute($queryc_values);
1204
-				} catch(PDOException $e) {
1204
+				} catch (PDOException $e) {
1205 1205
 					if ($globalDebug) echo $e->getMessage();
1206 1206
 					return "error : ".$e->getMessage();
1207 1207
 				}
1208 1208
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1209 1209
 				$sthc->closeCursor();
1210
-				if (count($row) ==  0) {
1210
+				if (count($row) == 0) {
1211 1211
 					if ($globalDebug) echo " Add to ModeS table - ";
1212 1212
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1213
-					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1213
+					$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1214 1214
 					try {
1215 1215
 						$sthi = $this->db->prepare($queryi);
1216 1216
 						$sthi->execute($queryi_values);
1217
-					} catch(PDOException $e) {
1217
+					} catch (PDOException $e) {
1218 1218
 						if ($globalDebug) echo $e->getMessage();
1219 1219
 						return "error : ".$e->getMessage();
1220 1220
 					}
@@ -1222,15 +1222,15 @@  discard block
 block discarded – undo
1222 1222
 					if ($globalDebug) echo " Update ModeS table - ";
1223 1223
 					if ($ICAOTypeCode != '') {
1224 1224
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1225
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1225
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1226 1226
 					} else {
1227 1227
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1228
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration);
1228
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration);
1229 1229
 					}
1230 1230
 					try {
1231 1231
 						$sthi = $this->db->prepare($queryi);
1232 1232
 						$sthi->execute($queryi_values);
1233
-					} catch(PDOException $e) {
1233
+					} catch (PDOException $e) {
1234 1234
 						if ($globalDebug) echo $e->getMessage();
1235 1235
 						return "error : ".$e->getMessage();
1236 1236
 					}
@@ -1267,12 +1267,12 @@  discard block
 block discarded – undo
1267 1267
 					elseif ($globalDBdriver == 'pgsql') {
1268 1268
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1269 1269
 					}
1270
-					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
1270
+					$queryi_values = array(':Registration' => $registration, ':ident' => $icao);
1271 1271
 				}
1272 1272
 				try {
1273 1273
 					$sthi = $this->db->prepare($queryi);
1274 1274
 					$sthi->execute($queryi_values);
1275
-				} catch(PDOException $e) {
1275
+				} catch (PDOException $e) {
1276 1276
 					if ($globalDebug) echo $e->getMessage();
1277 1277
 					return "error : ".$e->getMessage();
1278 1278
 				}
Please login to merge, or discard this patch.
require/class.Connection.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/settings.php');
3 3
 
4
-class Connection{
4
+class Connection {
5 5
 	public $db = null;
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 50;
8 8
 
9
-	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
9
+	public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) {
10 10
 		global $globalNoDB;
11 11
 		if (isset($globalNoDB) && $globalNoDB === TRUE) {
12 12
 			$this->db = null;
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 					if ($user === null && $pass === null) {
17 17
 						$this->createDBConnection();
18 18
 					} else {
19
-						$this->createDBConnection(null,$user,$pass);
19
+						$this->createDBConnection(null, $user, $pass);
20 20
 					}
21 21
 				} else {
22 22
 					$this->createDBConnection($dbname);
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 		while (true) {
101 101
 			try {
102 102
 				if ($globalDBSdriver == 'mysql') {
103
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser,  $globalDBSpass);
103
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass);
104 104
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
105 105
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
106
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
107
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
108
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
109
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
110
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
106
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
107
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500);
108
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
109
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
110
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
111 111
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
112 112
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
113 113
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -117,19 +117,19 @@  discard block
 block discarded – undo
117 117
 					$this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"');
118 118
 					//$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"');
119 119
 				} else {
120
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser,  $globalDBSpass);
120
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass);
121 121
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
122 122
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
123
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
124
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
125
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
126
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
127
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
123
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
124
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200);
125
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
126
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
127
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
128 128
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
129 129
 					$this->dbs[$DBname]->exec('SET timezone="UTC"');
130 130
 				}
131 131
 				break;
132
-			} catch(PDOException $e) {
132
+			} catch (PDOException $e) {
133 133
 				$i++;
134 134
 				if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
135 135
 				//exit;
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
 		try {
155 155
 			//$Connection = new Connection();
156 156
 			$results = $this->db->query($query);
157
-		} catch(PDOException $e) {
157
+		} catch (PDOException $e) {
158 158
 			return false;
159 159
 		}
160
-		if($results->rowCount()>0) {
160
+		if ($results->rowCount() > 0) {
161 161
 		    return true; 
162 162
 		}
163 163
 		else return false;
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 			     return false;
180 180
 			}
181 181
 			
182
-		} catch(PDOException $e) {
183
-			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
182
+		} catch (PDOException $e) {
183
+			if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
184 184
             			throw $e;
185 185
 	                }
186 186
 	                //echo 'error ! '.$e->getMessage();
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	/*
193 193
 	* Check if index exist
194 194
 	*/
195
-	public function indexExists($table,$index)
195
+	public function indexExists($table, $index)
196 196
 	{
197 197
 		global $globalDBdriver, $globalDBname;
198 198
 		if ($globalDBdriver == 'mysql') {
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
 		try {
204 204
 			//$Connection = new Connection();
205 205
 			$results = $this->db->query($query);
206
-		} catch(PDOException $e) {
206
+		} catch (PDOException $e) {
207 207
 			return false;
208 208
 		}
209 209
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
210
-		if($nb[0]['nb'] > 0) {
210
+		if ($nb[0]['nb'] > 0) {
211 211
 			return true; 
212 212
 		}
213 213
 		else return false;
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		$query = "SELECT * FROM ".$table." LIMIT 0";
223 223
 		try {
224 224
 			$results = $this->db->query($query);
225
-		} catch(PDOException $e) {
225
+		} catch (PDOException $e) {
226 226
 			return "error : ".$e->getMessage()."\n";
227 227
 		}
228 228
 		$columns = array();
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		return $columns;
235 235
 	}
236 236
 
237
-	public function getColumnType($table,$column) {
237
+	public function getColumnType($table, $column) {
238 238
 		$select = $this->db->query('SELECT '.$column.' FROM '.$table);
239 239
 		$tomet = $select->getColumnMeta(0);
240 240
 		return $tomet['native_type'];
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	* Check if a column name exist in a table
245 245
 	* @return Boolean column exist or not
246 246
 	*/
247
-	public function checkColumnName($table,$name)
247
+	public function checkColumnName($table, $name)
248 248
 	{
249 249
 		global $globalDBdriver, $globalDBname;
250 250
 		if ($globalDBdriver == 'mysql') {
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 		}
255 255
 			try {
256 256
 				$sth = $this->db()->prepare($query);
257
-				$sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name));
258
-			} catch(PDOException $e) {
257
+				$sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name));
258
+			} catch (PDOException $e) {
259 259
 				echo "error : ".$e->getMessage()."\n";
260 260
 			}
261 261
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 				try {
295 295
 					$sth = $this->db->prepare($query);
296 296
 					$sth->execute();
297
-				} catch(PDOException $e) {
297
+				} catch (PDOException $e) {
298 298
 					return "error : ".$e->getMessage()."\n";
299 299
 				}
300 300
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
require/class.Scheduler.php 1 patch
Spacing   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	* @param String $arrival_airport_time arrival airport time
36 36
 	/ @param String $source source of data
37 37
 	*/
38
-	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
38
+	public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') {
39 39
 		date_default_timezone_set('UTC');
40
-		$date = date("Y-m-d H:i:s",time());
40
+		$date = date("Y-m-d H:i:s", time());
41 41
 		//if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
42 42
 		//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
43 43
 		$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
@@ -45,69 +45,69 @@  discard block
 block discarded – undo
45 45
 		 try {
46 46
 			$sth = $this->db->prepare($query);
47 47
 			$sth->execute($query_values);
48
-		} catch(PDOException $e) {
48
+		} catch (PDOException $e) {
49 49
 			return "error : ".$e->getMessage();
50 50
 		}
51 51
 		if ($sth->fetchColumn() > 0) {
52 52
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
53 53
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
54
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
54
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao);
55 55
 			} elseif ($arrival_airport_time == '') {
56 56
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
57
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
57
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao);
58 58
 			} elseif ($departure_airport_time == '') {
59 59
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
60
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
60
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
61 61
 			} else {
62 62
 			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
63 63
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
64
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
64
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
65 65
 			}
66 66
 			try {
67 67
 				$sth = $this->db->prepare($query);
68 68
 				$sth->execute($query_values);
69
-			} catch(PDOException $e) {
69
+			} catch (PDOException $e) {
70 70
 				return "error : ".$e->getMessage();
71 71
 			}
72 72
 			if ($sth->fetchColumn() == 0) {
73 73
 				//$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident';
74 74
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
75 75
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
76
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
76
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
77 77
 				} elseif ($arrival_airport_time == '') {
78 78
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
79
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
79
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
80 80
 				} elseif ($departure_airport_time == '') {
81 81
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
82
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
82
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
83 83
 				} else {
84 84
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
85
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
85
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
86 86
 				}
87 87
 				try {
88 88
 					$sth = $this->db->prepare($query);
89 89
 					$sth->execute($query_values);
90
-				} catch(PDOException $e) {
90
+				} catch (PDOException $e) {
91 91
 					return "error : ".$e->getMessage();
92 92
 				}
93 93
 			} else {
94 94
 				//$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident';
95 95
 				$query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident';
96
-				$query_values = array(':ident' => $ident,':date' => $date);
96
+				$query_values = array(':ident' => $ident, ':date' => $date);
97 97
 				try {
98 98
 					$sth = $this->db->prepare($query);
99 99
 					$sth->execute($query_values);
100
-				} catch(PDOException $e) {
100
+				} catch (PDOException $e) {
101 101
 					return "error : ".$e->getMessage();
102 102
 				}
103 103
 			}
104 104
 		} else {
105 105
 			$query = 'INSERT INTO  routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source)  VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)';
106
-			$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
106
+			$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
107 107
 			 try {
108 108
 				$sth = $this->db->prepare($query);
109 109
 				$sth->execute($query_values);
110
-			} catch(PDOException $e) {
110
+			} catch (PDOException $e) {
111 111
 				return "error : ".$e->getMessage();
112 112
 			}
113 113
 		}
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 	*/
121 121
 	public function getSchedule($ident) {
122 122
 		$Translation = new Translation($this->db);
123
-		$operator = $Translation->checkTranslation($ident,false);
123
+		$operator = $Translation->checkTranslation($ident, false);
124 124
 		if ($ident != $operator) {
125 125
 			$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1";
126
-			$query_values = array(':ident' => $ident,'operator' => $operator);
126
+			$query_values = array(':ident' => $ident, 'operator' => $operator);
127 127
 		} else {
128 128
 			$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1";
129 129
 			$query_values = array(':ident' => $ident);
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		 try {
132 132
 			$sth = $this->db->prepare($query);
133 133
 			$sth->execute($query_values);
134
-		} catch(PDOException $e) {
134
+		} catch (PDOException $e) {
135 135
 			return "error : ".$e->getMessage();
136 136
 		}
137 137
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		 try {
161 161
 			$sth = $this->db->prepare($query);
162 162
 			$sth->execute($query_values);
163
-		} catch(PDOException $e) {
163
+		} catch (PDOException $e) {
164 164
 			return "error : ".$e->getMessage();
165 165
 		}
166 166
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -175,16 +175,16 @@  discard block
 block discarded – undo
175 175
 	* @param String $carrier IATA code
176 176
 	* @return Flight departure and arrival airports and time
177 177
 	*/
178
-	private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
178
+	private function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') {
179 179
 		$Common = new Common();
180 180
 		$check_date = new Datetime($date);
181
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
182
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
181
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
182
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
183 183
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
184 184
 		$json = $Common->getData($url);
185 185
 	
186 186
 		$parsed_json = json_decode($json);
187
-		if (property_exists($parsed_json,'errors') === false) {
187
+		if (property_exists($parsed_json, 'errors') === false) {
188 188
 			//$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'};
189 189
 			$originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'};
190 190
 			//$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'};
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
 			//$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'};
195 195
 			$arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'};
196 196
 
197
-			preg_match('/\((.*?)\)/',$originShort,$originiata);
197
+			preg_match('/\((.*?)\)/', $originShort, $originiata);
198 198
 			$DepartureAirportIata = $originiata[1];
199
-			preg_match('/\((.*?)\)/',$destinationShort,$destinationiata);
199
+			preg_match('/\((.*?)\)/', $destinationShort, $destinationiata);
200 200
 			$ArrivalAirportIata = $destinationiata[1];
201 201
 
202 202
 			/*
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 			$arrivalTime = gmdate('H:i',strtotime($arrivalTime));
206 206
 			*/
207 207
 		
208
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
208
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance');
209 209
 		} else return array();
210 210
 	}
211 211
 
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
 		$Common = new Common();
221 221
 		date_default_timezone_set($globalTimezone);
222 222
 		$check_date = new Datetime($date);
223
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
224
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
223
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
224
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
225 225
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
226 226
 		$json = $Common->getData($url);
227 227
 		$parsed_json = json_decode($json);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 			$departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'};
234 234
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
235 235
 
236
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
236
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet');
237 237
 		} else return array();
238 238
 	}
239 239
 
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 	*/
245 245
 	private function getRyanair($callsign) {
246 246
 		$Common = new Common();
247
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
248
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
247
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
248
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
249 249
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
250 250
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
251
-		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
252
-		$json = $Common->getData($url,'post',$post,$headers);
251
+		$headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post));
252
+		$json = $Common->getData($url, 'post', $post, $headers);
253 253
 		$parsed_json = json_decode($json);
254 254
 		if (isset($parsed_json->{'flightInfo'})) {
255 255
 			$flights = $parsed_json->{'flightInfo'};
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 				$ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name
259 259
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
260 260
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
261
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
261
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
262 262
 			} else return array();
263 263
 		} else return array();
264 264
 	}
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	*/
271 271
 	private function getSwiss($callsign) {
272 272
 		$Common = new Common();
273
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
274
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
273
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
274
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
275 275
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
276 276
 		$json = $Common->getData($url);
277 277
 		$parsed_json = json_decode($json);
@@ -285,12 +285,12 @@  discard block
 block discarded – undo
285 285
 				if ($flight->{'no'} == "Vol LX ".$numvol) {
286 286
 					$DepartureAirportIata = $flight->{'from'}->{'code'}; //city
287 287
 					$ArrivalAirportIata = $flight->{'to'}->{'code'}; //city
288
-					$departureTime = substr($flight->{'from'}->{'hour'},0,5);
289
-					$arrivalTime = substr($flight->{'to'}->{'hour'},0,5);
288
+					$departureTime = substr($flight->{'from'}->{'hour'},0, 5);
289
+					$arrivalTime = substr($flight->{'to'}->{'hour'},0, 5);
290 290
 				}
291 291
 			}
292 292
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
293
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
293
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss');
294 294
 			} else return array();
295 295
 		} else return array();
296 296
 	}
@@ -305,21 +305,21 @@  discard block
 block discarded – undo
305 305
 		global $globalBritishAirwaysKey;
306 306
 		$Common = new Common();
307 307
 		$check_date = new Datetime($date);
308
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
309
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
308
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
309
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
310 310
 		if ($globalBritishAirwaysKey == '') return array();
311 311
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
312 312
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
313
-		$json = $Common->getData($url,'get','',$headers);
313
+		$json = $Common->getData($url, 'get', '', $headers);
314 314
 		if ($json == '') return array();
315 315
 		$parsed_json = json_decode($json);
316 316
 		$flights = $parsed_json->{'FlightsResponse'};
317 317
 		if (count($flights) > 0) {
318 318
 			$DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'};
319 319
 			$ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'};
320
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
321
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
322
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
320
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
321
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
322
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways');
323 323
 		} else return array();
324 324
 	}
325 325
 
@@ -333,27 +333,27 @@  discard block
 block discarded – undo
333 333
 		global $globalLufthansaKey;
334 334
 		$Common = new Common();
335 335
 		$check_date = new Datetime($date);
336
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
337
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
336
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
337
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
338 338
 		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
339 339
 		$url = "https://api.lufthansa.com/v1/oauth/token";
340
-		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
341
-		$data = $Common->getData($url,'post',$post);
340
+		$post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials');
341
+		$data = $Common->getData($url, 'post', $post);
342 342
 		$parsed_data = json_decode($data);
343 343
 		if (!isset($parsed_data->{'access_token'})) return array();
344 344
 		$token = $parsed_data->{'access_token'};
345 345
 		
346 346
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
347
-		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
348
-		$json = $Common->getData($url,'get','',$headers);
347
+		$headers = array('Authorization: Bearer '.$token, 'Accept: application/json');
348
+		$json = $Common->getData($url, 'get', '', $headers);
349 349
 		if ($json == '') return array();
350 350
 		$parsed_json = json_decode($json);
351 351
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
352 352
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
353
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
353
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
354 354
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
355
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
356
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
355
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
356
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa');
357 357
 		} else return array();
358 358
 	}
359 359
 
@@ -367,23 +367,23 @@  discard block
 block discarded – undo
367 367
 		global $globalTransaviaKey;
368 368
 		$Common = new Common();
369 369
 		$check_date = new Datetime($date);
370
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
371
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
370
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
371
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
372 372
 		if ($globalTransaviaKey == '') return array();
373 373
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
374 374
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
375 375
 		$headers = array('apikey: '.$globalTransaviaKey);
376
-		$json = $Common->getData($url,'get','',$headers);
376
+		$json = $Common->getData($url, 'get', '', $headers);
377 377
 		//echo 'result : '.$json;
378 378
 		if ($json == '') return array();
379 379
 		$parsed_json = json_decode($json);
380 380
 		
381 381
 		if (isset($parsed_json->{'data'}[0])) {
382 382
 			$DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'};
383
-			$departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
383
+			$departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
384 384
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
385
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
386
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
385
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
386
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia');
387 387
 		} else return array();
388 388
 	}
389 389
 
@@ -394,14 +394,14 @@  discard block
 block discarded – undo
394 394
 	*/
395 395
 	public function getTunisair($callsign) {
396 396
 		$Common = new Common();
397
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
398
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
397
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
398
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
399 399
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
400 400
 		$data = $Common->getData($url);
401 401
 		$table = $Common->table2array($data);
402 402
 		foreach ($table as $flight) {
403
-			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) {
404
-				return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair');
403
+			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) {
404
+				return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair');
405 405
 			}
406 406
 		}
407 407
 		return array();
@@ -412,21 +412,21 @@  discard block
 block discarded – undo
412 412
 	* @param String $callsign The callsign
413 413
 	* @return Flight departure and arrival airports and time
414 414
 	*/
415
-	public function getVueling($callsign,$date = 'NOW') {
415
+	public function getVueling($callsign, $date = 'NOW') {
416 416
 		$Common = new Common();
417 417
 		$check_date = new Datetime($date);
418
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
419
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
420
-		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
418
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
419
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
420
+		$final_date = str_replace('/', '%2F', $check_date->format('d/m/Y'));
421 421
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
422 422
 		$data = $Common->getData($url);
423
-		$data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data));
423
+		$data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data));
424 424
 		if ($data != '') {
425
-			preg_match('/flightOri=[A-Z]{3}/',$data,$result);
426
-			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
427
-			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
428
-			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
429
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
425
+			preg_match('/flightOri=[A-Z]{3}/', $data, $result);
426
+			$DepartureAirportIata = str_replace('flightOri=', '', $result[0]);
427
+			preg_match('/flightDest=[A-Z]{3}/', $data, $result);
428
+			$ArrivalAirportIata = str_replace('flightDest=', '', $result[0]);
429
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling');
430 430
 			else return array();
431 431
 		}
432 432
 		return array();
@@ -440,27 +440,27 @@  discard block
 block discarded – undo
440 440
 	*/
441 441
 	public function getIberia($callsign, $date = 'NOW') {
442 442
 		$Common = new Common();
443
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
443
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
444 444
 		$check_date = new Datetime($date);
445
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
445
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
446 446
 		$url = "https://www.iberia.com/web/flightDetail.do";
447
-		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
448
-		$data = $Common->getData($url,'post',$post);
447
+		$post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB');
448
+		$data = $Common->getData($url, 'post', $post);
449 449
 		if ($data != '') {
450 450
 			$table = $Common->table2array($data);
451 451
 			//print_r($table);
452 452
 			if (count($table) > 0) {
453 453
 				$flight = $table;
454
-				preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
455
-				preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch);
454
+				preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
455
+				preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch);
456 456
 				$DepartureAirportIata = $DepartureAirportIataMatch[0];
457 457
 				$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
458
-				$departureTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[3][2]))),0,5);
459
-				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
458
+				$departureTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[3][2]))), 0, 5);
459
+				$arrivalTime = trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][1])));
460 460
 				if ($arrivalTime == 'Hora estimada de llegada') {
461
-					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
462
-				} else $arrivalTime = substr($arrivalTime,0,5);
463
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
461
+					$arrivalTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][2]))), 0, 5);
462
+				} else $arrivalTime = substr($arrivalTime, 0, 5);
463
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia');
464 464
 			}
465 465
 		}
466 466
 		return array();
@@ -473,11 +473,11 @@  discard block
 block discarded – undo
473 473
 	* @return Flight departure and arrival airports and time
474 474
 	*/
475 475
 
476
-	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
476
+	private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') {
477 477
 		$Common = new Common();
478
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
478
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
479 479
 		$check_date = new Datetime($date);
480
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
480
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
481 481
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
482 482
 		$data = $Common->getData($url);
483 483
 		if ($data != '') {
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
 				$flight = $table;
487 487
 				//print_r($table);
488 488
 				if (isset($flight[25]) && isset($flight[29])) {
489
-					preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch);
490
-					preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch);
489
+					preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch);
490
+					preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch);
491 491
 					$DepartureAirportIata = $DepartureAirportIataMatch[0];
492 492
 					$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
493
-					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
494
-					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
495
-					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
493
+					$departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5);
494
+					$arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5);
495
+					return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance');
496 496
 				} else return array();
497 497
 			}
498 498
 			
@@ -510,10 +510,10 @@  discard block
 block discarded – undo
510 510
 	*/
511 511
 	private function getAlitalia($callsign, $date = 'NOW') {
512 512
 		$Common = new Common();
513
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
513
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
514 514
 		$check_date = new Datetime($date);
515
-		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
516
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
515
+		$url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
516
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
517 517
 		$data = $Common->getData($url);
518 518
 		if ($data != '') {
519 519
 			$table = $Common->text2array($data);
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 			$ArrivalAirportIata = '';
522 522
 			$departureTime = $table[4];
523 523
 			$arrivalTime = $table[5];
524
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia');
524
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia');
525 525
 		}
526 526
 	}
527 527
 
@@ -533,21 +533,21 @@  discard block
 block discarded – undo
533 533
 	*/
534 534
 	private function getBrussels($callsign, $date = 'NOW') {
535 535
 		$Common = new Common();
536
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
536
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
537 537
 		$check_date = new Datetime($date);
538
-		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
538
+		$url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
539 539
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
540
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
540
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
541 541
 		$data = $Common->getData($url);
542 542
 		if ($data != '') {
543 543
 		    //echo $data;
544
-		    $parsed_json = json_decode($data,true);
544
+		    $parsed_json = json_decode($data, true);
545 545
 		    if (isset($parsed_json[0]['FromAirportCode'])) {
546 546
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
547 547
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
548
-			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
549
-			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
550
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
548
+			$departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate']));
549
+			$arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate']));
550
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels');
551 551
 		    }
552 552
 		}
553 553
 	}
@@ -624,21 +624,21 @@  discard block
 block discarded – undo
624 624
 	*/
625 625
 	private function getFlyTap($callsign) {
626 626
 		$Common = new Common();
627
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
628
-		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
627
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
628
+		$url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
629 629
 		//$check_date = new Datetime($date);
630
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
631
-		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
632
-		$data = $Common->getData($url,'post',$post);
630
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
631
+		$post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1');
632
+		$data = $Common->getData($url, 'post', $post);
633 633
 		if ($data != '') {
634 634
 			$table = $Common->table2array($data);
635
-			$departureTime = trim(substr($table[15][0],0,5));
636
-			$arrivalTime = trim(substr($table[35][0],0,5));
637
-			preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch);
638
-			preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch);
635
+			$departureTime = trim(substr($table[15][0], 0, 5));
636
+			$arrivalTime = trim(substr($table[35][0], 0, 5));
637
+			preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch);
638
+			preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch);
639 639
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
640 640
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
641
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap');
641
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap');
642 642
 		}
643 643
 		return array();
644 644
 	}
@@ -660,10 +660,10 @@  discard block
 block discarded – undo
660 660
 			} 
661 661
 		}
662 662
 		if ($airline_icao == '') return array();
663
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
664
-		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
663
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
664
+		$url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
665 665
 		//$check_date = new Datetime($date);
666
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
666
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
667 667
 		$data = $Common->getData($url);
668 668
 		if ($data != '') {
669 669
 			$table = $Common->table2array($data);
@@ -673,13 +673,13 @@  discard block
 block discarded – undo
673 673
 				$darr = '';
674 674
 				$ahour = '';
675 675
 				$aarr = '';
676
-				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
676
+				$n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr);
677 677
 				if ($n == 7) {
678 678
 				    $departureTime = $dhour;
679 679
 				    $arrivalTime = $ahour;
680
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
681
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
682
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
680
+				    $DepartureAirportIata = str_replace(array('(', ')'), '', $darr);
681
+				    $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr);
682
+				    return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper');
683 683
 				}
684 684
 			}
685 685
 		}
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 			$url = 'http://'.$globalFlightAwareUsername.':'.$globalFlightAwarePassword.'@flightxml.flightaware.com/json/FlightXML3/FlightInfoStatus?ident='.$callsign;
712 712
 			$data = $Common->getData($url);
713 713
 			if ($data != '') {
714
-				$result = json_decode($data,true);
714
+				$result = json_decode($data, true);
715 715
 				$flight = $result['FlightInfoStatusResult']['flights'][0];
716 716
 				if (isset($flight['origin'])) {
717 717
 					return array(
@@ -724,18 +724,18 @@  discard block
 block discarded – undo
724 724
 			}
725 725
 		}
726 726
 		
727
-		$url= "http://flightaware.com/live/flight/".$callsign;
727
+		$url = "http://flightaware.com/live/flight/".$callsign;
728 728
 		$data = $Common->getData($url);
729 729
 		if ($data != '') {
730
-			preg_match(':<script>var trackpollBootstrap = (.*?);</script>:',$data,$result);
731
-			$flights = json_decode($result[1],true);
730
+			preg_match(':<script>var trackpollBootstrap = (.*?);</script>:', $data, $result);
731
+			$flights = json_decode($result[1], true);
732 732
 			$flight = reset($flights['flights']);
733 733
 			if (isset($flight['activityLog']['flights'][0]['origin'])) {
734 734
 				return array(
735 735
 				    'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
736
-				    'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
736
+				    'DepartureTime' => date('H:i', $flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
737 737
 				    'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
738
-				    'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
738
+				    'ArrivalTime' => date('H:i', $flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
739 739
 				    'Source' => 'website_flightaware');
740 740
 			}
741 741
 		}
@@ -749,20 +749,20 @@  discard block
 block discarded – undo
749 749
 	*/
750 750
 	public function getCostToTravel($callsign) {
751 751
 		$Common = new Common();
752
-		$url= "http://www.costtotravel.com/flight-number/".$callsign;
752
+		$url = "http://www.costtotravel.com/flight-number/".$callsign;
753 753
 		//$check_date = new Datetime($date);
754 754
 		//if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
755 755
 		$data = $Common->getData($url);
756 756
 		if ($data != '') {
757 757
 			$table = $Common->table2array($data);
758 758
 			if (isset($table[11][1])) {
759
-				if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5);
759
+				if (is_numeric(substr($table[11][1], 0, 1))) $departureTime = substr($table[11][1], 0, 5);
760 760
 				else $departureTime = '';
761
-				if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5);
761
+				if (is_numeric(substr($table[17][1], 0, 1))) $arrivalTime = substr($table[17][1], 0, 5);
762 762
 				else $arrivalTime = '';
763
-				$DepartureAirportIata = substr($table[13][1],0,3);
764
-				$ArrivalAirportIata = substr($table[15][1],0,3);
765
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
763
+				$DepartureAirportIata = substr($table[13][1], 0, 3);
764
+				$ArrivalAirportIata = substr($table[15][1], 0, 3);
765
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel');
766 766
 			}
767 767
 		}
768 768
 		return array();
@@ -774,14 +774,14 @@  discard block
 block discarded – undo
774 774
 	* @param String $date date we want flight number info
775 775
 	* @return Flight departure and arrival airports and time
776 776
 	*/
777
-	private function getAirCanada($callsign,$date = 'NOW') {
777
+	private function getAirCanada($callsign, $date = 'NOW') {
778 778
 		$Common = new Common();
779 779
 		if (class_exists("DomDocument") === FALSE) return array();
780 780
 		date_default_timezone_set('UTC');
781 781
 		$check_date = new Datetime($date);
782
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
783
-		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
784
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
782
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
783
+		$url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
784
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
785 785
 		$data = $Common->getData($url);
786 786
 		$dom = new DomDocument();
787 787
 		$dom->loadXML($data);
@@ -789,11 +789,11 @@  discard block
 block discarded – undo
789 789
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
790 790
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
791 791
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
792
-			$departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
792
+			$departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
793 793
 			$arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0);
794 794
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
795
-			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
796
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
795
+			$arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
796
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada');
797 797
 		} else return array();
798 798
 	}
799 799
 
@@ -805,21 +805,21 @@  discard block
 block discarded – undo
805 805
 	*/
806 806
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
807 807
 		$Common = new Common();
808
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
808
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
809 809
 		$check_date = new Datetime($date);
810
-		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
811
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
810
+		$url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
811
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
812 812
 		$data = $Common->getData($url);
813 813
 		if ($data != '') {
814 814
 			$table = $Common->table2array($data);
815 815
 			$flight = $table;
816
-			preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
817
-			preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch);
816
+			preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
817
+			preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch);
818 818
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
819 819
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
820 820
 			$departureTime = $flight[5][1];
821 821
 			$arrivalTime = $flight[23][1];
822
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines');
822
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines');
823 823
 		}
824 824
 	}
825 825
 
@@ -830,16 +830,16 @@  discard block
 block discarded – undo
830 830
 	* @param String $carrier airline code
831 831
 	* @return Flight departure and arrival airports and time
832 832
 	*/
833
-	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
833
+	private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') {
834 834
 		$Common = new Common();
835 835
 		date_default_timezone_set('UTC');
836 836
 		//AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair 
837
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
837
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
838 838
 		$check_date = new Datetime($date);
839
-		$url= "http://www.airberlin.com/en-US/site/aims.php";
840
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
841
-		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
842
-		$data = $Common->getData($url,'post',$post);
839
+		$url = "http://www.airberlin.com/en-US/site/aims.php";
840
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
841
+		$post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier);
842
+		$data = $Common->getData($url, 'post', $post);
843 843
 		//echo $data;
844 844
 		$DepartureAirportIata = '';
845 845
 		$ArrivalAirportIata = '';
@@ -852,8 +852,8 @@  discard block
 block discarded – undo
852 852
 			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
853 853
 			else $departureAirport = '';
854 854
 		} else return array();
855
-		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
856
-		$data = $Common->getData($url,'post',$post);
855
+		$post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB');
856
+		$data = $Common->getData($url, 'post', $post);
857 857
 		if ($data != '') {
858 858
 			$table = $Common->table2array($data);
859 859
 			$flight = $table;
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 			}
882 882
 		}
883 883
 		if (isset($DepartureAirportIata)) {
884
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
884
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin');
885 885
 		} else return array();
886 886
 	}
887 887
 
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 	 * @param String $date Date
892 892
 	 * @return Array Schedules info
893 893
 	*/
894
-	public function fetchSchedule($ident,$date = 'NOW') {
894
+	public function fetchSchedule($ident, $date = 'NOW') {
895 895
 		global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline;
896 896
 		//$Common = new Common();
897 897
 		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array();
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
 				// Brussels Airlines
962 962
 				case "BEL":
963 963
 				case "SN":
964
-					return $this->getBrussels($ident,$date);
964
+					return $this->getBrussels($ident, $date);
965 965
 /*
966 966
 				// Copa Airlines
967 967
 				case "CMP":
@@ -1046,17 +1046,17 @@  discard block
 block discarded – undo
1046 1046
 				// Air France
1047 1047
 				case "AF":
1048 1048
 				case "AFR":
1049
-					return $this->getAirFrance($ident,$date,'AF');
1049
+					return $this->getAirFrance($ident, $date, 'AF');
1050 1050
 				// HOP
1051 1051
 				case "A5":
1052 1052
 				case "HOP":
1053
-					return $this->getAirFrance($ident,$date,'A5');
1053
+					return $this->getAirFrance($ident, $date, 'A5');
1054 1054
 				// EasyJet
1055 1055
 				case "U2":
1056 1056
 				case "DS":
1057 1057
 				case "EZY":
1058 1058
 				case "EZS":
1059
-					return $this->getEasyJet($ident,$date);
1059
+					return $this->getEasyJet($ident, $date);
1060 1060
 				// Ryanair
1061 1061
 				case "FR":
1062 1062
 				case "RYR":
@@ -1106,25 +1106,25 @@  discard block
 block discarded – undo
1106 1106
 					return $this->getIberia($ident);
1107 1107
 				// Vietnam Airlines
1108 1108
 				case "HVN":
1109
-					return $this->getVietnamAirlines($ident,$date);
1109
+					return $this->getVietnamAirlines($ident, $date);
1110 1110
 				// Air Berlin
1111 1111
 				case "AB":
1112 1112
 				case "BER":
1113
-					return $this->getAirBerlin($ident,$date,'AB');
1113
+					return $this->getAirBerlin($ident, $date, 'AB');
1114 1114
 				// NIKI
1115 1115
 				case "HG":
1116 1116
 				case "NLY":
1117
-					return $this->getAirBerlin($ident,$date,'HG');
1117
+					return $this->getAirBerlin($ident, $date, 'HG');
1118 1118
 				// BelAir
1119 1119
 				case "4T":
1120 1120
 				case "BHP":
1121
-					return $this->getAirBerlin($ident,$date,'4T');
1121
+					return $this->getAirBerlin($ident, $date, '4T');
1122 1122
 				default:
1123 1123
 					// Randomly use a generic function to get hours
1124 1124
 					if (strlen($airline_icao) == 2) {
1125
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1125
+						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1126 1126
 						if (count($globalSchedulesSources) > 0) {
1127
-							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1127
+							$rand = mt_rand(0, count($globalSchedulesSources) - 1);
1128 1128
 							$source = $globalSchedulesSources[$rand];
1129 1129
 							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1130 1130
 							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
Please login to merge, or discard this patch.
require/class.SBS.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -18,82 +18,82 @@  discard block
 block discarded – undo
18 18
 	public function parse($buffer) {
19 19
 		// Not yet finished, no CRC checks
20 20
 		$data = array();
21
-		$typehex = substr($buffer,0,1);
22
-		if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1);
23
-		elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13);
24
-		else $hex = substr($buffer,1,-1);
25
-		$bin = gmp_strval( gmp_init($hex,16), 2);
21
+		$typehex = substr($buffer, 0, 1);
22
+		if ($typehex == '*' || $typehex == ':') $hex = substr($buffer, 1, -1);
23
+		elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer, 13, -13);
24
+		else $hex = substr($buffer, 1, -1);
25
+		$bin = gmp_strval(gmp_init($hex, 16), 2);
26 26
 		//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
27 27
 		if (strlen($hex) == 28) {
28
-			$df = intval(substr($bin,0,5),2);
28
+			$df = intval(substr($bin, 0, 5), 2);
29 29
 			//$ca = intval(substr($bin,5,3),2);
30 30
 			// Only support DF17 for now
31 31
 			//if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) {
32
-			if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) {
33
-				$icao = substr($hex,2,6);
32
+			if (($df == 17 || $df == 18) && ($this->parityCheck($hex, $bin) || $typehex == '@')) {
33
+				$icao = substr($hex, 2, 6);
34 34
 				$data['hex'] = $icao;
35
-				$tc = intval(substr($bin,32,5),2);
35
+				$tc = intval(substr($bin, 32, 5), 2);
36 36
 				if ($tc >= 1 && $tc <= 4) {
37 37
 					//callsign
38
-					$csbin = substr($bin,40,56);
38
+					$csbin = substr($bin, 40, 56);
39 39
 					$charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######');
40 40
 					$cs = '';
41
-					$cs .= $charset[intval(substr($csbin,0,6),2)];
42
-					$cs .= $charset[intval(substr($csbin,6,6),2)];
43
-					$cs .= $charset[intval(substr($csbin,12,6),2)];
44
-					$cs .= $charset[intval(substr($csbin,18,6),2)];
45
-					$cs .= $charset[intval(substr($csbin,24,6),2)];
46
-					$cs .= $charset[intval(substr($csbin,30,6),2)];
47
-					$cs .= $charset[intval(substr($csbin,36,6),2)];
48
-					$cs .= $charset[intval(substr($csbin,42,6),2)];
49
-					$cs = str_replace('_','',$cs);
50
-					$cs = str_replace('#','',$cs);
41
+					$cs .= $charset[intval(substr($csbin, 0, 6), 2)];
42
+					$cs .= $charset[intval(substr($csbin, 6, 6), 2)];
43
+					$cs .= $charset[intval(substr($csbin, 12, 6), 2)];
44
+					$cs .= $charset[intval(substr($csbin, 18, 6), 2)];
45
+					$cs .= $charset[intval(substr($csbin, 24, 6), 2)];
46
+					$cs .= $charset[intval(substr($csbin, 30, 6), 2)];
47
+					$cs .= $charset[intval(substr($csbin, 36, 6), 2)];
48
+					$cs .= $charset[intval(substr($csbin, 42, 6), 2)];
49
+					$cs = str_replace('_', '', $cs);
50
+					$cs = str_replace('#', '', $cs);
51 51
 					$callsign = $cs;
52 52
 					$data['ident'] = $callsign;
53 53
 				} elseif ($tc >= 9 && $tc <= 18) {
54 54
 					// Check Q-bit
55
-					$q = substr($bin,47,1);
55
+					$q = substr($bin, 47, 1);
56 56
 					if ($q) {
57
-						$n = intval(substr($bin,40,7).substr($bin,48,4),2);
58
-						$alt = $n*25-1000;
57
+						$n = intval(substr($bin, 40, 7).substr($bin, 48, 4), 2);
58
+						$alt = $n*25 - 1000;
59 59
 						$data['altitude'] = $alt;
60 60
 					}
61 61
 					// Check odd/even flag
62
-					$oe = substr($bin,53,1);
62
+					$oe = substr($bin, 53, 1);
63 63
 					//if ($oe) => odd else even
64 64
 					//  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
65
-					$cprlat = intval(substr($bin,54,17),2)/131072.0;
66
-					$cprlon = intval(substr($bin,71,17),2)/131072.0;
67
-					if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
65
+					$cprlat = intval(substr($bin, 54, 17), 2)/131072.0;
66
+					$cprlon = intval(substr($bin, 71, 17), 2)/131072.0;
67
+					if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat, 'longitude' => $cprlon, 'created' => time());
68 68
 					elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
69 69
 						$cprlat_odd = $cprlat;
70 70
 						$cprlon_odd = $cprlon;
71 71
 						$cprlat_even = $this::$latlon[$icao]['latitude'];
72 72
 						$cprlon_even = $this::$latlon[$icao]['longitude'];
73
-						$j = 59*$cprlat_even-60*$cprlat_odd+0.5;
74
-						$lat_even = (360.0/60)*($j%60+$cprlat_even);
75
-						$lat_odd = (360.0/59)*($j%59+$cprlat_odd);
73
+						$j = 59*$cprlat_even - 60*$cprlat_odd + 0.5;
74
+						$lat_even = (360.0/60)*($j%60 + $cprlat_even);
75
+						$lat_odd = (360.0/59)*($j%59 + $cprlat_odd);
76 76
 						if ($lat_even >= 270) $lat_even = $lat_even - 360;
77 77
 						if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
78 78
 						// check latitude zone
79 79
 						if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
80 80
 							if ($this::$latlon[$icao]['created'] > time()) {
81
-								$ni = $this->cprN($lat_even,0);
82
-								$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
83
-								$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
81
+								$ni = $this->cprN($lat_even, 0);
82
+								$m = floor($cprlon_even*($this->cprNL($lat_even) - 1) - $cprlon_odd*$this->cprNL($lat_even) + 0.5);
83
+								$lon = (360.0/$ni)*($m%$ni + $cprlon_even);
84 84
 								$lat = $lat_even;
85
-								if ($lon > 180) $lon = $lon -360;
85
+								if ($lon > 180) $lon = $lon - 360;
86 86
 								if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
87 87
 									//if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
88 88
 									$data['latitude'] = $lat;
89 89
 									$data['longitude'] = $lon;
90 90
 								}
91 91
 							} else {
92
-								$ni = $this->cprN($lat_odd,1);
93
-								$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
94
-								$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
92
+								$ni = $this->cprN($lat_odd, 1);
93
+								$m = floor($cprlon_even*($this->cprNL($lat_odd) - 1) - $cprlon_odd*$this->cprNL($lat_odd) + 0.5);
94
+								$lon = (360.0/$ni)*($m%$ni + $cprlon_odd);
95 95
 								$lat = $lat_odd;
96
-								if ($lon > 180) $lon = $lon -360;
96
+								if ($lon > 180) $lon = $lon - 360;
97 97
 								if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
98 98
 									//if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
99 99
 									$data['latitude'] = $lat;
@@ -105,15 +105,15 @@  discard block
 block discarded – undo
105 105
 					}
106 106
 				} elseif ($tc == 19) {
107 107
 					// speed & heading
108
-					$v_ew_dir = intval(substr($bin,45,1));
109
-					$v_ew = intval(substr($bin,46,10),2);
110
-					$v_ns_dir = intval(substr($bin,56,1));
111
-					$v_ns = intval(substr($bin,57,10),2);
108
+					$v_ew_dir = intval(substr($bin, 45, 1));
109
+					$v_ew = intval(substr($bin, 46, 10), 2);
110
+					$v_ns_dir = intval(substr($bin, 56, 1));
111
+					$v_ns = intval(substr($bin, 57, 10), 2);
112 112
 					if ($v_ew_dir) $v_ew = -1*$v_ew;
113 113
 					if ($v_ns_dir) $v_ns = -1*$v_ns;
114
-					$speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
115
-					$heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
116
-					if ($heading <0) $heading = $heading+360;
114
+					$speed = sqrt($v_ns*$v_ns + $v_ew*$v_ew);
115
+					$heading = atan2($v_ew, $v_ns)*360.0/(2*pi());
116
+					if ($heading < 0) $heading = $heading + 360;
117 117
 					$data['speed'] = $speed;
118 118
 					$data['heading'] = $heading;
119 119
 				}
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * Lookup table to convert the latitude to index.
129 129
 	*/
130 130
 	private function cprNL($lat) {
131
-		if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
131
+		if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator.
132 132
 		if ($lat < 10.47047130) return 59;
133 133
 		if ($lat < 14.82817437) return 58;
134 134
 		if ($lat < 18.18626357) return 57;
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		return 1;
191 191
 	}
192 192
 
193
-	private function cprN($lat,$isodd) {
193
+	private function cprN($lat, $isodd) {
194 194
 		$nl = $this->cprNL($lat) - $isodd;
195 195
 		if ($nl > 1) return $nl;
196 196
 		else return 1;
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
 		    0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000
215 215
 		);
216 216
 		$crc = 0;
217
-		$checksum = intval(substr($msg,22,6),16);
217
+		$checksum = intval(substr($msg, 22, 6), 16);
218 218
 		for ($j = 0; $j < strlen($bin); $j++) {
219
-			if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
219
+			if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j], 0);
220 220
 		}
221 221
 		if ($crc == $checksum) return true;
222 222
 		else {
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
 			$msg['aircraftid'] = hexdec($data['address']);
239 239
 			$msg['hex'] = $data['address'];
240 240
 			$msg['flightid'] = hexdec($data['address']);
241
-			$msg['date_gen'] = date('Y/m/d',$data['timestamp']);
242
-			$msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
243
-			$msg['date_log'] = date('Y/m/d',$data['timestamp']);
244
-			$msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
241
+			$msg['date_gen'] = date('Y/m/d', $data['timestamp']);
242
+			$msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180';
243
+			$msg['date_log'] = date('Y/m/d', $data['timestamp']);
244
+			$msg['time_log'] = date('H:i:s', $data['timestamp']).'.180';
245 245
 			$msg['callsign'] = $data['ident'];
246 246
 			$msg['altitude'] = '';
247 247
 			$msg['speed'] = '';
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 			$msg['emergency'] = '';
255 255
 			$msg['SPI'] = '';
256 256
 			$msg['ground'] = '';
257
-			$result[] = implode(',',$msg);
257
+			$result[] = implode(',', $msg);
258 258
 		}
259 259
 		if (isset($data['latitude']) && $data['latitude'] != 0) {
260 260
 			$msg = array();
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
 			$msg['aircraftid'] = hexdec($data['address']);
265 265
 			$msg['hex'] = $data['address'];
266 266
 			$msg['flightid'] = hexdec($data['address']);
267
-			$msg['date_gen'] = date('Y/m/d',$data['timestamp']);
268
-			$msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
269
-			$msg['date_log'] = date('Y/m/d',$data['timestamp']);
270
-			$msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
267
+			$msg['date_gen'] = date('Y/m/d', $data['timestamp']);
268
+			$msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180';
269
+			$msg['date_log'] = date('Y/m/d', $data['timestamp']);
270
+			$msg['time_log'] = date('H:i:s', $data['timestamp']).'.180';
271 271
 			$msg['callsign'] = '';
272 272
 			if (isset($data['altitude'])) $msg['altitude'] = $data['altitude'];
273 273
 			else $msg['altitude'] = '';
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 			$msg['SPI'] = 0;
286 286
 			if (isset($data['ground'])) $msg['ground'] = 1;
287 287
 			else $msg['ground'] = 0;
288
-			$result[] = implode(',',$msg);
288
+			$result[] = implode(',', $msg);
289 289
 		}
290 290
 		return $result;
291 291
 	}
Please login to merge, or discard this patch.