Completed
Push — master ( 6c0d65...2769c1 )
by Yannick
47:12
created
scripts/daemon-spotter.php 1 patch
Spacing   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
 	    die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
62
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
63 63
     }
64 64
 }
65 65
 
66
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
66
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70 70
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
71
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
72 72
     else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74 74
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
76 76
     else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115 115
     if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
116
+    $SI = new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
120 120
     $SI->connect();
121 121
 */
122
-} else $SI=new SpotterImport($Connection->db);
122
+} else $SI = new SpotterImport($Connection->db);
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
     $MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136
-$SBS=new SBS();
136
+$SBS = new SBS();
137 137
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
138
-	$ACARS=new ACARS($Connection->db,true);
139
-	$Source=new Source($Connection->db);
138
+	$ACARS = new ACARS($Connection->db, true);
139
+	$Source = new Source($Connection->db);
140 140
 }
141
-$Common=new Common();
141
+$Common = new Common();
142 142
 date_default_timezone_set('UTC');
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
146
+    pcntl_signal(SIGINT, function() {
147 147
         global $sockets;
148 148
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149 149
         die("Bye!\n");
@@ -159,40 +159,40 @@  discard block
 block discarded – undo
159 159
 
160 160
 function connect_all($hosts) {
161 161
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
162
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
163 163
     $reset++;
164 164
     if ($globalDebug) echo 'Connect to all...'."\n";
165 165
     foreach ($hosts as $id => $value) {
166 166
 	$host = $value['host'];
167 167
 	$globalSources[$id]['last_exec'] = 0;
168 168
 	// Here we check type of source(s)
169
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
170
-            if (preg_match('/deltadb.txt$/i',$host)) {
169
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
170
+            if (preg_match('/deltadb.txt$/i', $host)) {
171 171
         	//$formats[$id] = 'deltadbtxt';
172 172
         	$globalSources[$id]['format'] = 'deltadbtxt';
173 173
         	//$last_exec['deltadbtxt'] = 0;
174 174
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
175
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
175
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
176 176
         	//$formats[$id] = 'vatsimtxt';
177 177
         	$globalSources[$id]['format'] = 'vatsimtxt';
178 178
         	//$last_exec['vatsimtxt'] = 0;
179 179
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
180
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
180
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
181 181
         	//$formats[$id] = 'aircraftlistjson';
182 182
         	$globalSources[$id]['format'] = 'aircraftlistjson';
183 183
         	//$last_exec['aircraftlistjson'] = 0;
184 184
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
185
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
185
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
186 186
         	//$formats[$id] = 'aircraftjson';
187 187
         	$globalSources[$id]['format'] = 'aircraftjson';
188 188
         	//$last_exec['aircraftlistjson'] = 0;
189 189
         	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
190
-    	    } else if (preg_match('/aircraft$/i',$host)) {
190
+    	    } else if (preg_match('/aircraft$/i', $host)) {
191 191
         	//$formats[$id] = 'planefinderclient';
192 192
         	$globalSources[$id]['format'] = 'planefinderclient';
193 193
         	//$last_exec['aircraftlistjson'] = 0;
194 194
         	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
195
-    	    } else if (preg_match('/opensky/i',$host)) {
195
+    	    } else if (preg_match('/opensky/i', $host)) {
196 196
         	//$formats[$id] = 'aircraftlistjson';
197 197
         	$globalSources[$id]['format'] = 'opensky';
198 198
         	//$last_exec['aircraftlistjson'] = 0;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         	    exit(0);
210 210
         	}
211 211
     	    */
212
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
212
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
213 213
         	//$formats[$id] = 'planeupdatefaa';
214 214
         	$globalSources[$id]['format'] = 'planeupdatefaa';
215 215
         	//$last_exec['planeupdatefaa'] = 0;
@@ -218,37 +218,37 @@  discard block
 block discarded – undo
218 218
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
219 219
         	    exit(0);
220 220
         	}
221
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
221
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
222 222
         	//$formats[$id] = 'phpvmacars';
223 223
         	$globalSources[$id]['format'] = 'phpvmacars';
224 224
         	//$last_exec['phpvmacars'] = 0;
225 225
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
226
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
226
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
227 227
         	//$formats[$id] = 'phpvmacars';
228 228
         	$globalSources[$id]['format'] = 'vaos';
229 229
         	//$last_exec['phpvmacars'] = 0;
230 230
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
231
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
231
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
232 232
         	//$formats[$id] = 'phpvmacars';
233 233
         	$globalSources[$id]['format'] = 'vam';
234 234
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
235
-            } else if (preg_match('/whazzup/i',$host)) {
235
+            } else if (preg_match('/whazzup/i', $host)) {
236 236
         	//$formats[$id] = 'whazzup';
237 237
         	$globalSources[$id]['format'] = 'whazzup';
238 238
         	//$last_exec['whazzup'] = 0;
239 239
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
240
-            } else if (preg_match('/blitzortung/i',$host)) {
240
+            } else if (preg_match('/blitzortung/i', $host)) {
241 241
         	$globalSources[$id]['format'] = 'blitzortung';
242 242
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
243
-            } else if (preg_match('/airwhere/i',$host)) {
243
+            } else if (preg_match('/airwhere/i', $host)) {
244 244
         	$globalSources[$id]['format'] = 'airwhere';
245 245
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
246
-            } else if (preg_match('/recentpireps/i',$host)) {
246
+            } else if (preg_match('/recentpireps/i', $host)) {
247 247
         	//$formats[$id] = 'pirepsjson';
248 248
         	$globalSources[$id]['format'] = 'pirepsjson';
249 249
         	//$last_exec['pirepsjson'] = 0;
250 250
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
251
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
251
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
252 252
         	//$formats[$id] = 'fr24json';
253 253
         	$globalSources[$id]['format'] = 'fr24json';
254 254
         	//$last_exec['fr24json'] = 0;
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258 258
         	    exit(0);
259 259
         	}
260
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
260
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
261 261
         	//$formats[$id] = 'fr24json';
262 262
         	$globalSources[$id]['format'] = 'myshiptracking';
263 263
         	//$last_exec['fr24json'] = 0;
@@ -267,22 +267,22 @@  discard block
 block discarded – undo
267 267
         	    exit(0);
268 268
         	}
269 269
             //} else if (preg_match('/10001/',$host)) {
270
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
270
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271 271
         	//$formats[$id] = 'tsv';
272 272
         	$globalSources[$id]['format'] = 'tsv';
273 273
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
274 274
             }
275
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
275
+        } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276 276
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
277
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
277
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
278 278
     		    if ($idf !== false) {
279 279
     			$httpfeeds[$id] = $idf;
280 280
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
281 281
     		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
282 282
     		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
283 283
     		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
284
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
285
-	    $hostport = explode(':',$host);
284
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
285
+	    $hostport = explode(':', $host);
286 286
 	    if (isset($hostport[1])) {
287 287
 		$port = $hostport[1];
288 288
 		$hostn = $hostport[0];
@@ -292,19 +292,19 @@  discard block
 block discarded – undo
292 292
 	    }
293 293
 	    $Common = new Common();
294 294
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
295
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
295
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
296 296
     	    } else {
297
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
297
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
298 298
 	    }
299 299
 	    if ($s) {
300 300
     	        $sockets[$id] = $s;
301 301
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
302
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
302
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
303 303
 			//$formats[$id] = 'aprs';
304 304
 			$globalSources[$id]['format'] = 'aprs';
305 305
 			//$aprs_connect = 0;
306 306
 			//$use_aprs = true;
307
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
307
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
308 308
 			$globalSources[$id]['format'] = 'vrstcp';
309 309
     		    } elseif ($port == '10001') {
310 310
         		//$formats[$id] = 'tsv';
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
346 346
 else $timeout = 20;
347 347
 $errno = '';
348
-$errstr='';
348
+$errstr = '';
349 349
 
350 350
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
351 351
 /* Initiate connections to all the hosts simultaneously */
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 //connect_all($globalSources);
354 354
 
355 355
 if (isset($globalProxy) && $globalProxy) {
356
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
356
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
357 357
 } else {
358 358
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
359 359
 }
@@ -383,16 +383,16 @@  discard block
 block discarded – undo
383 383
 
384 384
 if ($use_aprs) {
385 385
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
386
-	$APRS=new APRS();
386
+	$APRS = new APRS();
387 387
 	$aprs_connect = 0;
388 388
 	$aprs_keep = 120;
389 389
 	$aprs_last_tx = time();
390 390
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
391
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
391
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
392 392
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
393
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
393
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
394 394
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
395
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
395
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
396 396
 	if ($aprs_full) $aprs_filter = '';
397 397
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
398 398
 	else $aprs_pass = '-1';
@@ -406,12 +406,12 @@  discard block
 block discarded – undo
406 406
 sleep(1);
407 407
 if ($globalDebug) echo "SCAN MODE \n\n";
408 408
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
409
-$endtime = time()+$globalCronEnd;
409
+$endtime = time() + $globalCronEnd;
410 410
 $i = 1;
411 411
 $tt = array();
412 412
 // Delete all ATC
413 413
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
414
-	$ATC=new ATC($Connection->db);
414
+	$ATC = new ATC($Connection->db);
415 415
 }
416 416
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
417 417
 	$ATC->deleteAll();
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 while ($i > 0) {
422 422
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
423 423
 
424
-    if (!$globalDaemon) $i = $endtime-time();
424
+    if (!$globalDaemon) $i = $endtime - time();
425 425
     // Delete old ATC
426 426
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
427 427
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	}
436 436
 	if ($max < $globalMinFetch) {
437 437
 	    if ($globalDebug) echo 'Sleeping...'."\n";
438
-	    sleep($globalMinFetch-$max+2);
438
+	    sleep($globalMinFetch - $max + 2);
439 439
 	}
440 440
     }
441 441
 
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 	    //$buffer = $Common->getData($hosts[$id]);
455 455
 	    $buffer = $Common->getData($value['host']);
456 456
 	    if ($buffer != '') $reset = 0;
457
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
458
-	    $buffer = explode('\n',$buffer);
457
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
458
+	    $buffer = explode('\n', $buffer);
459 459
 	    foreach ($buffer as $line) {
460 460
     		if ($line != '' && count($line) > 7) {
461 461
     		    $line = explode(',', $line);
@@ -488,11 +488,11 @@  discard block
 block discarded – undo
488 488
 	    )
489 489
 	) {
490 490
 	    date_default_timezone_set('CET');
491
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
491
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
492 492
 	    date_default_timezone_set('UTC');
493 493
 	    if ($buffer != '') $reset = 0;
494
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
495
-	    $buffer = explode('\n',$buffer);
494
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
495
+	    $buffer = explode('\n', $buffer);
496 496
 	    foreach ($buffer as $line) {
497 497
 		if ($line != '') {
498 498
 		    //echo "'".$line."'\n";
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 		    $ais_data = $AIS->parse_line(trim($line));
501 501
 		    $data = array();
502 502
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
503
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
503
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
504 504
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
505 505
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
506 506
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
513 513
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
514 514
 		    if (isset($ais_data['timestamp'])) {
515
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
515
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
516 516
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
517 517
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
518 518
 			    $add = true;
@@ -535,21 +535,21 @@  discard block
 block discarded – undo
535 535
 	    $w = $e = null;
536 536
 	    
537 537
 	    if (isset($arr[$id])) {
538
-		$nn = stream_select($arr,$w,$e,$timeout);
538
+		$nn = stream_select($arr, $w, $e, $timeout);
539 539
 		if ($nn > 0) {
540 540
 		    foreach ($httpfeeds as $feed) {
541
-			$buffer = stream_get_line($feed,2000,"\n");
541
+			$buffer = stream_get_line($feed, 2000, "\n");
542 542
 			if ($buffer === FALSE) {
543 543
 			    connect_all($globalSources);
544 544
 			}
545
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
546
-			$buffer = explode('\n',$buffer);
545
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
546
+			$buffer = explode('\n', $buffer);
547 547
 			foreach ($buffer as $line) {
548 548
 			    if ($line != '') {
549 549
 				$ais_data = $AIS->parse_line(trim($line));
550 550
 				$data = array();
551 551
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
552
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
552
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
553 553
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
554 554
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
555 555
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -561,9 +561,9 @@  discard block
 block discarded – undo
561 561
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
562 562
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
563 563
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
564
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
564
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
565 565
 				if (isset($ais_data['timestamp'])) {
566
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
566
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
567 567
 				} else {
568 568
 				    $data['datetime'] = date('Y-m-d H:i:s');
569 569
 				}
@@ -595,10 +595,10 @@  discard block
 block discarded – undo
595 595
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
596 596
 	    )
597 597
 	) {
598
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
598
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
599 599
 	    if ($buffer != '') {
600 600
 		//echo $buffer;
601
-		$all_data = json_decode($buffer,true);
601
+		$all_data = json_decode($buffer, true);
602 602
 		//print_r($all_data);
603 603
 		if (isset($all_data[0]['DATA'])) {
604 604
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 			    $data['ident'] = $line['NAME'];
608 608
 			    $data['mmsi'] = $line['MMSI'];
609 609
 			    if (strlen($data['mmsi']) > 9) {
610
-				$data['mmsi'] = substr($data['mmsi'],-9);
610
+				$data['mmsi'] = substr($data['mmsi'], -9);
611 611
 			    }
612 612
 			    $data['speed'] = $line['SOG'];
613 613
 			    $data['heading'] = $line['COG'];
@@ -617,8 +617,8 @@  discard block
 block discarded – undo
617 617
 			    //$data['type_id'] = $line['TYPE'];
618 618
 			    $data['imo'] = $line['IMO'];
619 619
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
620
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
621
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
620
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
621
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
622 622
 			    $data['format_source'] = 'myshiptracking';
623 623
 			    $data['id_source'] = $id_source;
624 624
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -635,16 +635,16 @@  discard block
 block discarded – undo
635 635
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
636 636
 	    )
637 637
 	) {
638
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
638
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
639 639
 	    if ($buffer != '') {
640
-		$all_data = json_decode($buffer,true);
640
+		$all_data = json_decode($buffer, true);
641 641
 		if (isset($all_data[0]['mmsi'])) {
642 642
 		    foreach ($all_data as $line) {
643 643
 			if ($line != '') {
644 644
 			    $data = array();
645 645
 			    $data['ident'] = $line['shipname'];
646 646
 			    $data['callsign'] = $line['callsign'];
647
-			    $data['mmsi'] = substr($line['mmsi'],-9);
647
+			    $data['mmsi'] = substr($line['mmsi'], -9);
648 648
 			    $data['speed'] = $line['sog'];
649 649
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
650 650
 			    $data['latitude'] = $line['latitude'];
@@ -671,14 +671,14 @@  discard block
 block discarded – undo
671 671
 	) {
672 672
 	    $buffer = $Common->getData($value['host']);
673 673
 	    if ($buffer != '') {
674
-		$all_data = json_decode($buffer,true);
674
+		$all_data = json_decode($buffer, true);
675 675
 		if (isset($all_data['features'][0]['id'])) {
676 676
 		    foreach ($all_data['features'] as $line) {
677 677
 			print_r($line);
678 678
 			$data = array();
679 679
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
680 680
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
681
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
681
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
682 682
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
683 683
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
684 684
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -705,31 +705,31 @@  discard block
 block discarded – undo
705 705
 	    )
706 706
 	) {
707 707
 	    if ($globalDebug) echo 'download...';
708
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
708
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
709 709
 	    if ($globalDebug) echo 'done !'."\n";
710 710
 	    // FIXME: Need more work
711 711
 	    if ($buffer != '') $reset = 0;
712
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
713
-	    $buffer = explode('\n',$buffer);
712
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
713
+	    $buffer = explode('\n', $buffer);
714 714
 	    foreach ($buffer as $line) {
715 715
 		if ($line != '') {
716 716
 		    $data = array();
717 717
 		    //echo $line."\n";
718
-		    $data['mmsi'] = (int)substr($line,0,9);
719
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
720
-		    $data['status_id'] = substr($line,21,2);
721
-		    $data['type_id'] = substr($line,24,3);
722
-		    $data['latitude'] = substr($line,29,9);
723
-		    $data['longitude'] = substr($line,41,9);
724
-		    $data['speed'] = round(substr($line,51,5));
718
+		    $data['mmsi'] = (int) substr($line, 0, 9);
719
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
720
+		    $data['status_id'] = substr($line, 21, 2);
721
+		    $data['type_id'] = substr($line, 24, 3);
722
+		    $data['latitude'] = substr($line, 29, 9);
723
+		    $data['longitude'] = substr($line, 41, 9);
724
+		    $data['speed'] = round(substr($line, 51, 5));
725 725
 		    //$data['course'] = substr($line,57,5);
726
-		    $data['heading'] = round(substr($line,63,3));
726
+		    $data['heading'] = round(substr($line, 63, 3));
727 727
 		    //$data['draft'] = substr($line,67,4);
728 728
 		    //$data['length'] = substr($line,72,3);
729 729
 		    //$data['beam'] = substr($line,76,2);
730
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
730
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
731 731
 		    //$data['callsign'] = trim(substr($line,100,7);
732
-		    $data['arrival_code'] = substr($line,108,20);
732
+		    $data['arrival_code'] = substr($line, 108, 20);
733 733
 		    //$data['etaDate'] = substr($line,129,5);
734 734
 		    //$data['etaTime'] = substr($line,135,5);
735 735
 		    $data['format_source'] = 'shipplotter';
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 	    )
750 750
 	) {
751 751
 	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
752
-		$authsailaway = $Common->getData('https://sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
752
+		$authsailaway = $Common->getData('https://sailaway.world/cgi-bin/sailaway/weblogin.pl', 'post', array('submitlogin' => 'Login', 'email' => $globalSailaway['email'], 'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'), '', '', '', '', '', false, false, true);
753 753
 		//echo $authsailaway;
754 754
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
755 755
 		if (isset($setcookie[1][0])) {
@@ -758,18 +758,18 @@  discard block
 block discarded – undo
758 758
 	    }
759 759
 
760 760
 	    if ($globalDebug) echo '! Download... ';
761
-	    for ($i =0; $i <= 1; $i++) {
761
+	    for ($i = 0; $i <= 1; $i++) {
762 762
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
763 763
 		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
764 764
 	    if ($globalDebug) echo 'done'."\n";
765 765
 	    if ($buffer != '') {
766
-		$all_data = json_decode($buffer,true);
766
+		$all_data = json_decode($buffer, true);
767 767
 		if (isset($all_data['missions'])) {
768 768
 			foreach ($all_data['missions'] as $mission) {
769 769
 				$mission_user = $mission['usrname'];
770
-				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
771
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
772
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
770
+				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']));
771
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
772
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie);
773 773
 					else $racebuffer = '';
774 774
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
775 775
 				} else {
@@ -777,19 +777,19 @@  discard block
 block discarded – undo
777 777
 					$racebuffer = '';
778 778
 				}
779 779
 				if ($racebuffer != '') {
780
-					$race_data = json_decode($racebuffer,true);
780
+					$race_data = json_decode($racebuffer, true);
781 781
 					//print_r($race_data);
782 782
 					unset($racebuffer);
783 783
 					if (isset($race_data['mission'])) {
784 784
 					    $datar = array();
785 785
 					    $datar['id'] = $mission['misnr'];
786 786
 					    $datar['desc'] = $race_data['mission']['misdescr'];
787
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
788
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
787
+					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname'])));
788
+					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle'])));
789 789
 					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
790 790
 					    $markers = array();
791 791
 					    foreach ($race_data['mission']['course'] as $course) {
792
-						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
792
+						$markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']);
793 793
 					    }
794 794
 					    $datar['markers'] = json_encode($markers);
795 795
 					    //print_r($datar);
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
 					}
798 798
 				}
799 799
 				if ($bufferm != '') {
800
-					$mission_data = json_decode($bufferm,true);
800
+					$mission_data = json_decode($bufferm, true);
801 801
 					unset($bufferm);
802 802
 					if (isset($mission_data['leaderboard'][0]['results'])) {
803 803
 						foreach ($mission_data['leaderboard'][0]['results'] as $sail) {
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 								//$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr'];
811 811
 								$data['id'] = $sail['misnr'].'-'.$sail['usrnr'];
812 812
 								$data['datetime'] = date('Y-m-d H:i:s');
813
-								$data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart']));
813
+								$data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart']));
814 814
 								$data['last_update'] = date('Y-m-d H:i:s');
815 815
 								$data['status'] = $sail['status'];
816 816
 								$data['type'] = $sail['btptype'];
@@ -821,16 +821,16 @@  discard block
 block discarded – undo
821 821
 									$data['longitude'] = $pos['longitude'];
822 822
 								}
823 823
 								if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') {
824
-									$resultdescr = explode(',',$sail['resultdescr']);
824
+									$resultdescr = explode(',', $sail['resultdescr']);
825 825
 									if (count($resultdescr) > 2) {
826
-										$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2);
827
-										$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1]));
826
+										$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2);
827
+										$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1]));
828 828
 										if (isset($resultdescr[3])) {
829
-											$data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3);
829
+											$data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3);
830 830
 										}
831 831
 									}
832 832
 								}
833
-								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
833
+								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
834 834
 								$data['captain_id'] = $sail['usrnr'];
835 835
 								$data['captain_name'] = $sail['usrname'];
836 836
 								$data['race_id'] = $sail['misnr'];
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
 	) {
879 879
 	    //$buffer = $Common->getData($hosts[$id]);
880 880
 	    $buffer = $Common->getData($value['host']);
881
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
882
-	    $buffer = explode('\n',$buffer);
881
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
882
+	    $buffer = explode('\n', $buffer);
883 883
 	    $reset = 0;
884 884
 	    foreach ($buffer as $line) {
885 885
     		if ($line != '') {
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
891 891
 			$data['pilot_id'] = $line[1];
892 892
 			$data['pilot_name'] = $line[2];
893
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
893
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
894 894
 			$data['ident'] = $line[0]; // ident
895 895
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
896 896
 			$data['speed'] = $line[8]; // speed
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
907 907
 			//if (isset($line[37])) $data['last_update'] = $line[37];
908 908
 		        $data['departure_airport_icao'] = $line[11];
909
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
909
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
910 910
 		        $data['arrival_airport_icao'] = $line[13];
911 911
 			$data['frequency'] = $line[4];
912 912
 			$data['type'] = $line[18];
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
     			$data['id_source'] = $id_source;
916 916
 	    		//$data['arrival_airport_time'] = ;
917 917
 	    		if ($line[9] != '') {
918
-	    		    $aircraft_data = explode('/',$line[9]);
918
+	    		    $aircraft_data = explode('/', $line[9]);
919 919
 	    		    if (isset($aircraft_data[1])) {
920 920
 	    			$data['aircraft_icao'] = $aircraft_data[1];
921 921
 	    		    }
@@ -930,9 +930,9 @@  discard block
 block discarded – undo
930 930
     			if ($line[3] === 'PILOT') $SI->add($data);
931 931
 			elseif ($line[3] === 'ATC') {
932 932
 				//print_r($data);
933
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
934
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
935
-				$typec = substr($data['ident'],-3);
933
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
934
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
935
+				$typec = substr($data['ident'], -3);
936 936
 				if ($typec === 'APP') $data['type'] = 'Approach';
937 937
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
938 938
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -944,8 +944,8 @@  discard block
 block discarded – undo
944 944
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
945 945
 				if (!isset($data['source_name'])) $data['source_name'] = '';
946 946
 				if (isset($ATC)) {
947
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
948
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
947
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
948
+					else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
949 949
 				}
950 950
 			}
951 951
     			unset($data);
@@ -961,24 +961,24 @@  discard block
 block discarded – undo
961 961
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
962 962
     	    )
963 963
     	) {
964
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
964
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
965 965
 	    if ($buffer != '') {
966 966
 		$all_data = simplexml_load_string($buffer);
967
-		foreach($all_data->children() as $childdata) {
967
+		foreach ($all_data->children() as $childdata) {
968 968
 			$data = array();
969 969
 			$line = $childdata;
970 970
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
971
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
972
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
973
-			$data['latitude'] = (float)$line['pktLatitude'];
974
-			$data['longitude'] = (float)$line['pktLongitude'];
975
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
976
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
977
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
971
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
972
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
973
+			$data['latitude'] = (float) $line['pktLatitude'];
974
+			$data['longitude'] = (float) $line['pktLongitude'];
975
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
976
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
977
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
978 978
 			$data['altitude_relative'] = 'AMSL';
979
-			$data['pilot_id'] = (int)$line['pktPilotID'];
979
+			$data['pilot_id'] = (int) $line['pktPilotID'];
980 980
 			$data['aircraft_icao'] = 'PARAGLIDER';
981
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
981
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
982 982
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
983 983
 			$data['format_source'] = $value['format'];
984 984
 			$SI->add($data);
@@ -986,22 +986,22 @@  discard block
 block discarded – undo
986 986
 		}
987 987
 	    }
988 988
 	    $Source->deleteOldLocationByType('gs');
989
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
989
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
990 990
 	    if ($buffer != '') {
991 991
 		$all_data = simplexml_load_string($buffer);
992
-		foreach($all_data->children() as $childdata) {
992
+		foreach ($all_data->children() as $childdata) {
993 993
 			$data = array();
994 994
 			$line = $childdata;
995
-			$data['id'] = (int)$line['gsID'];
996
-			$data['latitude'] = (float)$line['gsLatitude'];
997
-			$data['longitude'] = (float)$line['gsLongitude'];
998
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
995
+			$data['id'] = (int) $line['gsID'];
996
+			$data['latitude'] = (float) $line['gsLatitude'];
997
+			$data['longitude'] = (float) $line['gsLongitude'];
998
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
999 999
 			$data['altitude_relative'] = 'AMSL';
1000
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
1000
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
1001 1001
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
1002
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1002
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1003 1003
 			} else {
1004
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1004
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1005 1005
 			}
1006 1006
 			unset($data);
1007 1007
 		}
@@ -1019,9 +1019,9 @@  discard block
 block discarded – undo
1019 1019
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1020 1020
 	    )
1021 1021
 	) {
1022
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1022
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1023 1023
 	    if ($buffer != '') {
1024
-	        $all_data = json_decode($buffer,true);
1024
+	        $all_data = json_decode($buffer, true);
1025 1025
 		if (isset($all_data['acList'])) {
1026 1026
 		    $reset = 0;
1027 1027
 		    foreach ($all_data['acList'] as $line) {
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1038 1038
 			$data['emergency'] = ''; // emergency
1039 1039
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1040
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1040
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1041 1041
 			else $data['datetime'] = date('Y-m-d H:i:s');
1042 1042
 			//$data['datetime'] = date('Y-m-d H:i:s');
1043 1043
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1063 1063
 			$data['squawk'] = $line['squawk']; // squawk
1064 1064
 			$data['emergency'] = ''; // emergency
1065
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1065
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1066 1066
 			else $data['datetime'] = date('Y-m-d H:i:s');
1067 1067
 			$data['format_source'] = 'aircraftlistjson';
1068 1068
 			$data['id_source'] = $id_source;
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
     	    )
1084 1084
     	) {
1085 1085
 	    $buffer = $Common->getData($value['host']);
1086
-	    $all_data = json_decode($buffer,true);
1086
+	    $all_data = json_decode($buffer, true);
1087 1087
 	    if (isset($all_data['planes'])) {
1088 1088
 		$reset = 0;
1089 1089
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1100,12 +1100,12 @@  discard block
 block discarded – undo
1100 1100
 		    $data['emergency'] = ''; // emergency
1101 1101
 		    $data['registration'] = $line[2];
1102 1102
 		    $data['aircraft_icao'] = $line[0];
1103
-		    $deparr = explode('-',$line[1]);
1103
+		    $deparr = explode('-', $line[1]);
1104 1104
 		    if (count($deparr) === 2) {
1105 1105
 			$data['departure_airport_icao'] = $deparr[0];
1106 1106
 			$data['arrival_airport_icao'] = $deparr[1];
1107 1107
 		    }
1108
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1108
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1109 1109
 	    	    $data['format_source'] = 'planeupdatefaa';
1110 1110
     		    $data['id_source'] = $id_source;
1111 1111
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 	    )
1124 1124
 	) {
1125 1125
 	    $buffer = $Common->getData($value['host']);
1126
-	    $all_data = json_decode($buffer,true);
1126
+	    $all_data = json_decode($buffer, true);
1127 1127
 	    if (isset($all_data['states'])) {
1128 1128
 		$reset = 0;
1129 1129
 		foreach ($all_data['states'] as $key => $line) {
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 		    //$data['emergency'] = ''; // emergency
1141 1141
 		    //$data['registration'] = $line[2];
1142 1142
 		    //$data['aircraft_icao'] = $line[0];
1143
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1143
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1144 1144
 		    $data['format_source'] = 'opensky';
1145 1145
 		    $data['id_source'] = $id_source;
1146 1146
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1157,8 +1157,8 @@  discard block
 block discarded – undo
1157 1157
 	    )
1158 1158
 	) {
1159 1159
 	    $buffer = $Common->getData($value['host']);
1160
-	    $all_data = json_decode($buffer,true);
1161
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1160
+	    $all_data = json_decode($buffer, true);
1161
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1162 1162
 		$reset = 0;
1163 1163
 		foreach ($all_data['aircraft'] as $key => $line) {
1164 1164
 		    $data = array();
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 	    )
1197 1197
 	) {
1198 1198
 	    $buffer = $Common->getData($value['host']);
1199
-	    $all_data = json_decode($buffer,true);
1199
+	    $all_data = json_decode($buffer, true);
1200 1200
 	    if (isset($all_data['aircraft'])) {
1201 1201
 		$reset = 0;
1202 1202
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
 		    //$data['emergency'] = ''; // emergency
1214 1214
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1215 1215
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1216
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1216
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1217 1217
 		    $data['format_source'] = 'planefinderclient';
1218 1218
 		    $data['id_source'] = $id_source;
1219 1219
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
 	) {
1233 1233
 	    //$buffer = $Common->getData($hosts[$id]);
1234 1234
 	    $buffer = $Common->getData($value['host']);
1235
-	    $all_data = json_decode($buffer,true);
1235
+	    $all_data = json_decode($buffer, true);
1236 1236
 	    if (!empty($all_data)) $reset = 0;
1237 1237
 	    foreach ($all_data as $key => $line) {
1238 1238
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1270,11 +1270,11 @@  discard block
 block discarded – undo
1270 1270
 	    )
1271 1271
 	) {
1272 1272
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1273
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1273
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1274 1274
 	    //echo $buffer;
1275
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1276
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1277
-	    $all_data = json_decode($buffer,true);
1275
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1276
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1277
+	    $all_data = json_decode($buffer, true);
1278 1278
 	    if (json_last_error() != JSON_ERROR_NONE) {
1279 1279
 		die(json_last_error_msg());
1280 1280
 	    }
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 			//$data['departure_airport_iata'] = $line[11];
1298 1298
 			//$data['arrival_airport_iata'] = $line[12];
1299 1299
 	    		//$data['emergency'] = ''; // emergency
1300
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1300
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1301 1301
 	    		$data['format_source'] = 'radarvirtueljson';
1302 1302
     			$data['id_source'] = $id_source;
1303 1303
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1318,14 +1318,14 @@  discard block
 block discarded – undo
1318 1318
 	) {
1319 1319
 	    //$buffer = $Common->getData($hosts[$id]);
1320 1320
 	    $buffer = $Common->getData($value['host'].'?'.time());
1321
-	    $all_data = json_decode(utf8_encode($buffer),true);
1321
+	    $all_data = json_decode(utf8_encode($buffer), true);
1322 1322
 	    
1323 1323
 	    if (isset($all_data['pireps'])) {
1324 1324
 		$reset = 0;
1325 1325
 	        foreach ($all_data['pireps'] as $line) {
1326 1326
 		    $data = array();
1327 1327
 		    $data['id'] = $line['id'];
1328
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1328
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1329 1329
 		    $data['ident'] = $line['callsign']; // ident
1330 1330
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1331 1331
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1355,9 +1355,9 @@  discard block
 block discarded – undo
1355 1355
 			$SI->add($data);
1356 1356
 		    //    print_r($data);
1357 1357
     		    } elseif ($line['icon'] === 'ct') {
1358
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1359
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1360
-			$typec = substr($data['ident'],-3);
1358
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1359
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1360
+			$typec = substr($data['ident'], -3);
1361 1361
 			$data['type'] = '';
1362 1362
 			if ($typec === 'APP') $data['type'] = 'Approach';
1363 1363
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1368,7 +1368,7 @@  discard block
 block discarded – undo
1368 1368
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1369 1369
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1370 1370
 			else $data['type'] = 'Observer';
1371
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1371
+			if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
1372 1372
 		    }
1373 1373
 		    unset($data);
1374 1374
 		}
@@ -1385,14 +1385,14 @@  discard block
 block discarded – undo
1385 1385
 	    //$buffer = $Common->getData($hosts[$id]);
1386 1386
 	    if ($globalDebug) echo 'Get Data...'."\n";
1387 1387
 	    $buffer = $Common->getData($value['host']);
1388
-	    $all_data = json_decode($buffer,true);
1388
+	    $all_data = json_decode($buffer, true);
1389 1389
 	    if ($buffer != '' && is_array($all_data)) {
1390 1390
 		$reset = 0;
1391 1391
 		foreach ($all_data as $line) {
1392 1392
 	    	    $data = array();
1393 1393
 	    	    //$data['id'] = $line['id']; // id not usable
1394 1394
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1395
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1395
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1396 1396
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1397 1397
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1398 1398
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 	    	    //$data['datetime'] = $line['lastupdate'];
1408 1408
 	    	    //$data['last_update'] = $line['lastupdate'];
1409 1409
 	    	    if (isset($value['timezone'])) {
1410
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1410
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1411 1411
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1412 1412
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1413 1413
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1423,14 +1423,14 @@  discard block
 block discarded – undo
1423 1423
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1424 1424
 		    if (isset($line['aircraftname'])) {
1425 1425
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1426
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1427
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1426
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1427
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1428 1428
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1429 1429
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1430 1430
 	    		else {
1431
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1432
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1433
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1431
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1432
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1433
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1434 1434
 	    		}
1435 1435
 	    	    }
1436 1436
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 	    //$buffer = $Common->getData($hosts[$id]);
1456 1456
 	    if ($globalDebug) echo 'Get Data...'."\n";
1457 1457
 	    $buffer = $Common->getData($value['host']);
1458
-	    $all_data = json_decode($buffer,true);
1458
+	    $all_data = json_decode($buffer, true);
1459 1459
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1460 1460
 		$reset = 0;
1461 1461
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1466,7 +1466,7 @@  discard block
 block discarded – undo
1466 1466
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1467 1467
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1468 1468
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1469
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1469
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1470 1470
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1471 1471
 	    	    $data['altitude'] = $line['altitude']; // altitude
1472 1472
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
 	    	    //$data['squawk'] = ''; // squawk
1478 1478
 	    	    //$data['emergency'] = ''; // emergency
1479 1479
 	    	    if (isset($value['timezone'])) {
1480
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1480
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1481 1481
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1482 1482
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1483 1483
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1513,14 +1513,14 @@  discard block
 block discarded – undo
1513 1513
 	    //$buffer = $Common->getData($hosts[$id]);
1514 1514
 	    if ($globalDebug) echo 'Get Data...'."\n";
1515 1515
 	    $buffer = $Common->getData($value['host']);
1516
-	    $all_data = json_decode($buffer,true);
1516
+	    $all_data = json_decode($buffer, true);
1517 1517
 	    if ($buffer != '' && is_array($all_data)) {
1518 1518
 		$reset = 0;
1519 1519
 		foreach ($all_data as $line) {
1520 1520
 	    	    $data = array();
1521 1521
 	    	    //$data['id'] = $line['id']; // id not usable
1522 1522
 	    	    $data['id'] = trim($line['flight_id']);
1523
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1523
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1524 1524
 	    	    $data['pilot_name'] = $line['pilot_name'];
1525 1525
 	    	    $data['pilot_id'] = $line['pilot_id'];
1526 1526
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1564,24 +1564,24 @@  discard block
 block discarded – undo
1564 1564
 	    //$buffer = $Common->getData($hosts[$id]);
1565 1565
 	    if ($globalDebug) echo 'Get Data...'."\n";
1566 1566
 	    $buffer = $Common->getData($value['host']);
1567
-	    $all_data = json_decode($buffer,true);
1567
+	    $all_data = json_decode($buffer, true);
1568 1568
 	    if ($buffer != '') {
1569 1569
 		$Source->deleteLocationBySource('blitzortung');
1570
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1571
-		$buffer = explode('\n',$buffer);
1570
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1571
+		$buffer = explode('\n', $buffer);
1572 1572
 		foreach ($buffer as $buffer_line) {
1573
-		    $line = json_decode($buffer_line,true);
1573
+		    $line = json_decode($buffer_line, true);
1574 1574
 		    if (isset($line['time'])) {
1575 1575
 			$data = array();
1576 1576
 			$data['altitude'] = $line['alt']; // altitude
1577 1577
 			$data['latitude'] = $line['lat']; // lat
1578 1578
 			$data['longitude'] = $line['lon']; // long
1579
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1579
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1580 1580
 			$data['id_source'] = $id_source;
1581 1581
 			$data['format_source'] = 'blitzortung';
1582 1582
 			$SI->add($data);
1583 1583
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1584
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1584
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1585 1585
 			unset($data);
1586 1586
 		    }
1587 1587
 		}
@@ -1593,15 +1593,15 @@  discard block
 block discarded – undo
1593 1593
         $arr = $httpfeeds;
1594 1594
         $w = $e = null;
1595 1595
         if (isset($arr[$id])) {
1596
-            $nn = stream_select($arr,$w,$e,$timeout);
1596
+            $nn = stream_select($arr, $w, $e, $timeout);
1597 1597
             if ($nn > 0) {
1598 1598
                 foreach ($httpfeeds as $feed) {
1599
-                    $buffer = stream_get_line($feed,2000,"\n");
1599
+                    $buffer = stream_get_line($feed, 2000, "\n");
1600 1600
                     if ($buffer === FALSE) {
1601 1601
                         connect_all($globalSources);
1602 1602
                     }
1603
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1604
-                    $buffer = explode('\n',$buffer);
1603
+                    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1604
+                    $buffer = explode('\n', $buffer);
1605 1605
                     foreach ($buffer as $line) {
1606 1606
                         if ($line != '') {
1607 1607
                             $line = json_decode($line, true);
@@ -1641,11 +1641,11 @@  discard block
 block discarded – undo
1641 1641
 		    //$value = $formats[$nb];
1642 1642
 		    $format = $globalSources[$nb]['format'];
1643 1643
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1644
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1644
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1645 1645
 		    } elseif ($format === 'vrstcp') {
1646 1646
 			$buffer = @socket_read($r, 6000);
1647 1647
 		    } else {
1648
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1648
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1649 1649
 		    }
1650 1650
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1651 1651
 		    //echo $buffer."\n";
@@ -1655,8 +1655,8 @@  discard block
 block discarded – undo
1655 1655
 		    //$SI::del();
1656 1656
 		    if ($buffer !== FALSE) {
1657 1657
 			if ($format === 'vrstcp') {
1658
-			    $buffer = explode('},{',$buffer);
1659
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1658
+			    $buffer = explode('},{', $buffer);
1659
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1660 1660
 		    }
1661 1661
 		    // SBS format is CSV format
1662 1662
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1683,7 +1683,7 @@  discard block
 block discarded – undo
1683 1683
 			    $ais_data = $AIS->parse_line(trim($buffer));
1684 1684
 			    $data = array();
1685 1685
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1686
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1686
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1687 1687
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1688 1688
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1689 1689
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1694,13 +1694,13 @@  discard block
 block discarded – undo
1694 1694
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1695 1695
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1696 1696
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1697
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1697
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1698 1698
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1699 1699
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1700 1700
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1701 1701
 
1702 1702
 			    if (isset($ais_data['timestamp'])) {
1703
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1703
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1704 1704
 			    } else {
1705 1705
 				$data['datetime'] = date('Y-m-d H:i:s');
1706 1706
 			    }
@@ -1711,10 +1711,10 @@  discard block
 block discarded – undo
1711 1711
                         } elseif ($format === 'flightgearsp') {
1712 1712
                     	    //echo $buffer."\n";
1713 1713
                     	    if (strlen($buffer) > 5) {
1714
-				$line = explode(',',$buffer);
1714
+				$line = explode(',', $buffer);
1715 1715
 				$data = array();
1716 1716
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1717
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1717
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1718 1718
 				$data['ident'] = $line[6];
1719 1719
 				$data['aircraft_name'] = $line[7];
1720 1720
 				$data['longitude'] = $line[1];
@@ -1731,16 +1731,16 @@  discard block
 block discarded – undo
1731 1731
                         } elseif ($format === 'acars') {
1732 1732
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1733 1733
 			    $ACARS->add(trim($buffer));
1734
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1734
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1735 1735
 			    $ACARS->deleteLiveAcarsData();
1736 1736
 			} elseif ($format === 'flightgearmp') {
1737
-			    if (substr($buffer,0,1) != '#') {
1737
+			    if (substr($buffer, 0, 1) != '#') {
1738 1738
 				$data = array();
1739 1739
 				//echo $buffer."\n";
1740
-				$line = explode(' ',$buffer);
1740
+				$line = explode(' ', $buffer);
1741 1741
 				if (count($line) === 11) {
1742
-				    $userserver = explode('@',$line[0]);
1743
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1742
+				    $userserver = explode('@', $line[0]);
1743
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1744 1744
 				    $data['ident'] = $userserver[0];
1745 1745
 				    $data['registration'] = $userserver[0];
1746 1746
 				    $data['latitude'] = $line[4];
@@ -1748,8 +1748,8 @@  discard block
 block discarded – undo
1748 1748
 				    $data['altitude'] = $line[6];
1749 1749
 				    $data['datetime'] = date('Y-m-d H:i:s');
1750 1750
 				    $aircraft_type = $line[10];
1751
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1752
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1751
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1752
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1753 1753
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1754 1754
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1755 1755
 				}
@@ -1758,8 +1758,8 @@  discard block
 block discarded – undo
1758 1758
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1759 1759
 			    die;
1760 1760
 			} elseif ($format === 'vrstcp') {
1761
-			    foreach($buffer as $all_data) {
1762
-				$line = json_decode('{'.$all_data.'}',true);
1761
+			    foreach ($buffer as $all_data) {
1762
+				$line = json_decode('{'.$all_data.'}', true);
1763 1763
 				$data = array();
1764 1764
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1765 1765
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1785,16 +1785,16 @@  discard block
 block discarded – undo
1785 1785
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1786 1786
 				unset($data);
1787 1787
 			    }
1788
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1788
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1789 1789
 			    $line = explode("\t", $buffer);
1790
-			    for($k = 0; $k < count($line); $k=$k+2) {
1790
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1791 1791
 				$key = $line[$k];
1792
-			        $lined[$key] = $line[$k+1];
1792
+			        $lined[$key] = $line[$k + 1];
1793 1793
 			    }
1794 1794
     			    if (count($lined) > 3) {
1795 1795
     				$data['hex'] = $lined['hexid'];
1796 1796
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1797
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1797
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1798 1798
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1799 1799
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1800 1800
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1813,23 +1813,23 @@  discard block
 block discarded – undo
1813 1813
     			    } else $error = true;
1814 1814
 			} elseif ($format === 'aprs' && $use_aprs) {
1815 1815
 			    if ($aprs_connect === 0) {
1816
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1816
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1817 1817
 				$aprs_connect = 1;
1818 1818
 			    }
1819 1819
 			    
1820
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1820
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1821 1821
 				$aprs_last_tx = time();
1822 1822
 				$data_aprs = "# Keep alive";
1823
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1823
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1824 1824
 			    }
1825 1825
 			    
1826 1826
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1827 1827
 			    //echo 'APRS data : '.$buffer."\n";
1828
-			    $buffer = str_replace('APRS <- ','',$buffer);
1829
-			    $buffer = str_replace('APRS -> ','',$buffer);
1828
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1829
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1830 1830
 			    //echo $buffer."\n";
1831 1831
 			    date_default_timezone_set('UTC');
1832
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1832
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1833 1833
 				$line = $APRS->parse($buffer);
1834 1834
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1835 1835
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1844,7 +1844,7 @@  discard block
 block discarded – undo
1844 1844
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1845 1845
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1846 1846
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1847
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1847
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1848 1848
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1849 1849
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1850 1850
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1932,29 +1932,29 @@  discard block
 block discarded – undo
1932 1932
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1933 1933
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1934 1934
 					$Source->deleteOldLocationByType('gs');
1935
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1936
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1935
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1936
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1937 1937
 					} else {
1938
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1938
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1939 1939
 					}
1940 1940
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1941 1941
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1942 1942
 					if ($globalDebug) echo '# Weather Station added'."\n";
1943 1943
 					$Source->deleteOldLocationByType('wx');
1944 1944
 					$weather_data = json_encode($line);
1945
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1946
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1945
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1946
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1947 1947
 					} else {
1948
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1948
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1949 1949
 					}
1950 1950
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1951 1951
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1952 1952
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1953 1953
 					$Source->deleteOldLocationByType('lightning');
1954
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1955
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1954
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1955
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1956 1956
 					} else {
1957
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1957
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1958 1958
 					}
1959 1959
 				    } elseif ($globalDebug) {
1960 1960
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1963,7 +1963,7 @@  discard block
 block discarded – undo
1963 1963
 				    unset($data);
1964 1964
 				}
1965 1965
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1966
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1966
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1967 1967
 				}
1968 1968
 				/*
1969 1969
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) {
@@ -1972,7 +1972,7 @@  discard block
 block discarded – undo
1972 1972
 				*/
1973 1973
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1974 1974
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1975
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1975
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1976 1976
 					$Source->deleteOldLocationByType('lightning');
1977 1977
 					$Source->deleteOldLocationByType('wx');
1978 1978
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2059,7 +2059,7 @@  discard block
 block discarded – undo
2059 2059
 				connect_all($sourceee);
2060 2060
 				$sourceee = array();
2061 2061
 				//connect_all($globalSources);
2062
-				$tt[$format]=0;
2062
+				$tt[$format] = 0;
2063 2063
 				break;
2064 2064
 			    } 
2065 2065
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2069,14 +2069,14 @@  discard block
 block discarded – undo
2069 2069
 	    } else {
2070 2070
 		$error = socket_strerror(socket_last_error());
2071 2071
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2072
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2072
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2073 2073
 			if (isset($globalDebug)) echo "Restarting...\n";
2074 2074
 			// Restart the script if possible
2075 2075
 			if (is_array($sockets)) {
2076 2076
 			    if ($globalDebug) echo "Shutdown all sockets...";
2077 2077
 			    
2078 2078
 			    foreach ($sockets as $sock) {
2079
-				@socket_shutdown($sock,2);
2079
+				@socket_shutdown($sock, 2);
2080 2080
 				@socket_close($sock);
2081 2081
 			    }
2082 2082
 			    
Please login to merge, or discard this patch.
require/class.ACARS.php 1 patch
Spacing   +258 added lines, -258 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";
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 		$ident = '';
120 120
 		$message = '';
121 121
 		$result = array();
122
-		$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);
123
-		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);
124
-		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);
125
-		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);
122
+		$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);
123
+		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);
124
+		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);
125
+		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);
126 126
 		if ($n != 0 && ($registration != '' || $ident != '' || $label != '' || $block_id != '' || $msg_no != '')) {
127
-			$registration = str_replace('.','',$registration);
128
-			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
127
+			$registration = str_replace('.', '', $registration);
128
+			$result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message);
129 129
 			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
130 130
 		} else $message = $data;
131 131
 		$decode = array();
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
 				$temp = '';
146 146
 				$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);
147 147
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
148
-					$latitude = $la / 10000.0;
149
-					$longitude = $ln / 10000.0;
148
+					$latitude = $la/10000.0;
149
+					$longitude = $ln/10000.0;
150 150
 					if ($lac == 'S') $latitude = '-'.$latitude;
151 151
 					if ($lnc == 'W') $longitude = '-'.$longitude;
152 152
 					// Temp not always available
153 153
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
154
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
155
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
154
+					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt);
155
+					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C');
156 156
 
157 157
 					//$icao = $Translation->checkTranslation($ident);
158 158
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
 				$dhour = '';
165 165
 				$darr = '';
166 166
 				$ahour = '';
167
-				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
167
+				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour);
168 168
 				if ($n == 4 && strlen($darr) == 4) {
169
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
170
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
171
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
169
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
170
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
171
+					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n";
172 172
 					//$icao = ACARS->ident2icao($ident);
173 173
 					//$icao = $Translation->checkTranslation($ident);
174 174
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
175 175
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
176 176
 					$found = true;
177 177
 				}
178
-				elseif ($n == 2 || $n  == 4) {
179
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
178
+				elseif ($n == 2 || $n == 4) {
179
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
180 180
 					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
181 181
 					//$icao = ACARS->ident2icao($ident);
182 182
 					//$icao = $Translation->checkTranslation($ident);
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
 				$ahour = '';
235 235
 				$aair = '';
236 236
 				$apiste = '';
237
-				$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
+				$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);
238 238
 				if ($n > 8) {
239
-					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";
240
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
241
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
239
+					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";
240
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
241
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
242 242
 					$icao = trim($aident);
243 243
 
244 244
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
 				if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
264 264
 					$las = $las.'.'.$lass;
265 265
 					$lns = $lns.'.'.$lns;
266
-					$latitude = $las / 1000.0;
267
-					$longitude = $lns / 1000.0;
266
+					$latitude = $las/1000.0;
267
+					$longitude = $lns/1000.0;
268 268
 					if ($lac == 'S') $latitude = '-'.$latitude;
269 269
 					if ($lnc == 'W') $longitude = '-'.$longitude;
270 270
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
@@ -359,17 +359,17 @@  discard block
 block discarded – undo
359 359
 				$alt = '';
360 360
 				$fuel = '';
361 361
 				$speed = '';
362
-				$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
+				$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);
363 363
 				if ($n == 9) {
364 364
 					//if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
365 365
 					$icao = trim($aident);
366 366
 					$decode['icao'] = $icao;
367
-					$latitude = $las / 100.0;
368
-					$longitude = $lns / 100.0;
367
+					$latitude = $las/100.0;
368
+					$longitude = $lns/100.0;
369 369
 					if ($lac == 'S') $latitude = '-'.$latitude;
370 370
 					if ($lnc == 'W') $longitude = '-'.$longitude;
371 371
 
372
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
372
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed);
373 373
 					$found = true;
374 374
 				}
375 375
 			}
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 					if ($lac == 'S') $latitude = '-'.$latitude;
389 389
 					if ($lnc == 'W') $longitude = '-'.$longitude;
390 390
 
391
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
391
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
392 392
 					$found = true;
393 393
 				}
394 394
 			}
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 				$dair = '';
422 422
 				$darr = '';
423 423
 				$aident = '';
424
-				$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
+				$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);
425 425
 				if ($n == 8) {
426 426
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
427 427
 					$icao = trim($aident);
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 				*/
454 454
 				$dair = '';
455 455
 				$darr = '';
456
-				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
456
+				$n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr);
457 457
 				if ($n == 3) {
458 458
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
459 459
 					//$icao = $Translation->checkTranslation($ident);
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 				*/
469 469
 				$dair = '';
470 470
 				$darr = '';
471
-				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
471
+				$n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr);
472 472
 				if ($n == 3) {
473 473
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
474 474
 					//$icao = $Translation->checkTranslation($ident);
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 				}
479 479
 			}
480 480
 			if (!$found) {
481
-				$n = sscanf($message,'MET01%4c',$airport);
481
+				$n = sscanf($message, 'MET01%4c', $airport);
482 482
 				if ($n == 1) {
483 483
 					if ($globalDebug) echo 'airport name : '.$airport;
484 484
 					$decode = array('Airport/Waypoint name' => $airport);
@@ -486,241 +486,241 @@  discard block
 block discarded – undo
486 486
 				}
487 487
 			}
488 488
 			if ($label == 'H1') {
489
-				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
490
-					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
489
+				if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) {
490
+					$decode = array_merge(array('Message nature' => 'Equipment failure'), $decode);
491 491
 				}
492
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
493
-					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
492
+				elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) {
493
+					$decode = array_merge(array('Message nature' => 'Take off performance data'), $decode);
494 494
 				}
495
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
496
-					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
495
+				elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) {
496
+					$decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode);
497 497
 				}
498
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
499
-					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
498
+				elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) {
499
+					$decode = array_merge(array('Message nature' => 'Weather observation'), $decode);
500 500
 				}
501
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
502
-					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
501
+				elseif (preg_match(':^#DFB/PIREP:', $message)) {
502
+					$decode = array_merge(array('Message nature' => 'Pilot Report'), $decode);
503 503
 				}
504
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
505
-					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
504
+				elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) {
505
+					$decode = array_merge(array('Message nature' => 'Engine Data'), $decode);
506 506
 				}
507
-				elseif (preg_match(':^#M1AAEP:',$message)) {
508
-					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
507
+				elseif (preg_match(':^#M1AAEP:', $message)) {
508
+					$decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode);
509 509
 				}
510
-				elseif (preg_match(':^#M2APWD:',$message)) {
511
-					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
510
+				elseif (preg_match(':^#M2APWD:', $message)) {
511
+					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode);
512 512
 				}
513
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
514
-					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
513
+				elseif (preg_match(':^#M1BREQPWI:', $message)) {
514
+					$decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode);
515 515
 				}
516
-				elseif (preg_match(':^#CF:',$message)) {
517
-					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
516
+				elseif (preg_match(':^#CF:', $message)) {
517
+					$decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode);
518 518
 				}
519
-				elseif (preg_match(':^#DF:',$message)) {
520
-					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
519
+				elseif (preg_match(':^#DF:', $message)) {
520
+					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode);
521 521
 				}
522
-				elseif (preg_match(':^#EC:',$message)) {
523
-					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
522
+				elseif (preg_match(':^#EC:', $message)) {
523
+					$decode = array_merge(array('Message nature' => 'Engine Display System'), $decode);
524 524
 				}
525
-				elseif (preg_match(':^#EI:',$message)) {
526
-					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
525
+				elseif (preg_match(':^#EI:', $message)) {
526
+					$decode = array_merge(array('Message nature' => 'Engine Report'), $decode);
527 527
 				}
528
-				elseif (preg_match(':^#H1:',$message)) {
529
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
528
+				elseif (preg_match(':^#H1:', $message)) {
529
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode);
530 530
 				}
531
-				elseif (preg_match(':^#H2:',$message)) {
532
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
531
+				elseif (preg_match(':^#H2:', $message)) {
532
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode);
533 533
 				}
534
-				elseif (preg_match(':^#HD:',$message)) {
535
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
534
+				elseif (preg_match(':^#HD:', $message)) {
535
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode);
536 536
 				}
537
-				elseif (preg_match(':^#M1:',$message)) {
538
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
537
+				elseif (preg_match(':^#M1:', $message)) {
538
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode);
539 539
 				}
540
-				elseif (preg_match(':^#M2:',$message)) {
541
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
540
+				elseif (preg_match(':^#M2:', $message)) {
541
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode);
542 542
 				}
543
-				elseif (preg_match(':^#M3:',$message)) {
544
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
543
+				elseif (preg_match(':^#M3:', $message)) {
544
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode);
545 545
 				}
546
-				elseif (preg_match(':^#MD:',$message)) {
547
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
546
+				elseif (preg_match(':^#MD:', $message)) {
547
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode);
548 548
 				}
549
-				elseif (preg_match(':^#PS:',$message)) {
550
-					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
549
+				elseif (preg_match(':^#PS:', $message)) {
550
+					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode);
551 551
 				}
552
-				elseif (preg_match(':^#S1:',$message)) {
553
-					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
552
+				elseif (preg_match(':^#S1:', $message)) {
553
+					$decode = array_merge(array('Message nature' => 'SDU - Left'), $decode);
554 554
 				}
555
-				elseif (preg_match(':^#S2:',$message)) {
556
-					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
555
+				elseif (preg_match(':^#S2:', $message)) {
556
+					$decode = array_merge(array('Message nature' => 'SDU - Right'), $decode);
557 557
 				}
558
-				elseif (preg_match(':^#SD:',$message)) {
559
-					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
558
+				elseif (preg_match(':^#SD:', $message)) {
559
+					$decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode);
560 560
 				}
561
-				elseif (preg_match(':^#T[0-8]:',$message)) {
562
-					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
561
+				elseif (preg_match(':^#T[0-8]:', $message)) {
562
+					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode);
563 563
 				}
564
-				elseif (preg_match(':^#WO:',$message)) {
565
-					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
564
+				elseif (preg_match(':^#WO:', $message)) {
565
+					$decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode);
566 566
 				}
567
-				elseif (preg_match(':^#A1:',$message)) {
568
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
567
+				elseif (preg_match(':^#A1:', $message)) {
568
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode);
569 569
 				}
570
-				elseif (preg_match(':^#A3:',$message)) {
571
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
570
+				elseif (preg_match(':^#A3:', $message)) {
571
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode);
572 572
 				}
573
-				elseif (preg_match(':^#A4:',$message)) {
574
-					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
573
+				elseif (preg_match(':^#A4:', $message)) {
574
+					$decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode);
575 575
 				}
576
-				elseif (preg_match(':^#A6:',$message)) {
577
-					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
576
+				elseif (preg_match(':^#A6:', $message)) {
577
+					$decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode);
578 578
 				}
579
-				elseif (preg_match(':^#A8:',$message)) {
580
-					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
579
+				elseif (preg_match(':^#A8:', $message)) {
580
+					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode);
581 581
 				}
582
-				elseif (preg_match(':^#A9:',$message)) {
583
-					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
582
+				elseif (preg_match(':^#A9:', $message)) {
583
+					$decode = array_merge(array('Message nature' => 'ATIS report'), $decode);
584 584
 				}
585
-				elseif (preg_match(':^#A0:',$message)) {
586
-					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
585
+				elseif (preg_match(':^#A0:', $message)) {
586
+					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode);
587 587
 				}
588
-				elseif (preg_match(':^#AA:',$message)) {
589
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
588
+				elseif (preg_match(':^#AA:', $message)) {
589
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
590 590
 				}
591
-				elseif (preg_match(':^#AB:',$message)) {
592
-					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
591
+				elseif (preg_match(':^#AB:', $message)) {
592
+					$decode = array_merge(array('Message nature' => 'TWIP Report'), $decode);
593 593
 				}
594
-				elseif (preg_match(':^#AC:',$message)) {
595
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
594
+				elseif (preg_match(':^#AC:', $message)) {
595
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode);
596 596
 				}
597
-				elseif (preg_match(':^#AD:',$message)) {
598
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
597
+				elseif (preg_match(':^#AD:', $message)) {
598
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode);
599 599
 				}
600
-				elseif (preg_match(':^#AF:',$message)) {
601
-					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
600
+				elseif (preg_match(':^#AF:', $message)) {
601
+					$decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode);
602 602
 				}
603
-				elseif (preg_match(':^#B1:',$message)) {
604
-					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
603
+				elseif (preg_match(':^#B1:', $message)) {
604
+					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode);
605 605
 				}
606
-				elseif (preg_match(':^#B2:',$message)) {
607
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
606
+				elseif (preg_match(':^#B2:', $message)) {
607
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode);
608 608
 				}
609
-				elseif (preg_match(':^#B3:',$message)) {
610
-					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
609
+				elseif (preg_match(':^#B3:', $message)) {
610
+					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode);
611 611
 				}
612
-				elseif (preg_match(':^#B4:',$message)) {
613
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
612
+				elseif (preg_match(':^#B4:', $message)) {
613
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode);
614 614
 				}
615
-				elseif (preg_match(':^#B6:',$message)) {
616
-					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
615
+				elseif (preg_match(':^#B6:', $message)) {
616
+					$decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode);
617 617
 				}
618
-				elseif (preg_match(':^#B8:',$message)) {
619
-					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
618
+				elseif (preg_match(':^#B8:', $message)) {
619
+					$decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode);
620 620
 				}
621
-				elseif (preg_match(':^#B9:',$message)) {
622
-					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
621
+				elseif (preg_match(':^#B9:', $message)) {
622
+					$decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode);
623 623
 				}
624
-				elseif (preg_match(':^#B0:',$message)) {
625
-					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
624
+				elseif (preg_match(':^#B0:', $message)) {
625
+					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode);
626 626
 				}
627
-				elseif (preg_match(':^#BA:',$message)) {
628
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
627
+				elseif (preg_match(':^#BA:', $message)) {
628
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
629 629
 				}
630
-				elseif (preg_match(':^#BB:',$message)) {
631
-					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
630
+				elseif (preg_match(':^#BB:', $message)) {
631
+					$decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode);
632 632
 				}
633
-				elseif (preg_match(':^#BC:',$message)) {
634
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
633
+				elseif (preg_match(':^#BC:', $message)) {
634
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode);
635 635
 				}
636
-				elseif (preg_match(':^#BD:',$message)) {
637
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
636
+				elseif (preg_match(':^#BD:', $message)) {
637
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode);
638 638
 				}
639
-				elseif (preg_match(':^#BE:',$message)) {
640
-					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
639
+				elseif (preg_match(':^#BE:', $message)) {
640
+					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode);
641 641
 				}
642
-				elseif (preg_match(':^#BF:',$message)) {
643
-					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
642
+				elseif (preg_match(':^#BF:', $message)) {
643
+					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode);
644 644
 				}
645
-				elseif (preg_match(':^#H3:',$message)) {
646
-					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
645
+				elseif (preg_match(':^#H3:', $message)) {
646
+					$decode = array_merge(array('Message nature' => 'Icing Report'), $decode);
647 647
 				}
648 648
 			}
649 649
 			if ($label == '10') {
650
-				if (preg_match(':^DTO01:',$message)) {
651
-					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
650
+				if (preg_match(':^DTO01:', $message)) {
651
+					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode);
652 652
 				}
653
-				elseif (preg_match(':^AIS01:',$message)) {
654
-					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
653
+				elseif (preg_match(':^AIS01:', $message)) {
654
+					$decode = array_merge(array('Message nature' => 'AIS Request'), $decode);
655 655
 				}
656
-				elseif (preg_match(':^FTX01:',$message)) {
657
-					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
656
+				elseif (preg_match(':^FTX01:', $message)) {
657
+					$decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode);
658 658
 				}
659
-				elseif (preg_match(':^FPL01:',$message)) {
660
-					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
659
+				elseif (preg_match(':^FPL01:', $message)) {
660
+					$decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode);
661 661
 				}
662
-				elseif (preg_match(':^WAB01:',$message)) {
663
-					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
662
+				elseif (preg_match(':^WAB01:', $message)) {
663
+					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode);
664 664
 				}
665
-				elseif (preg_match(':^MET01:',$message)) {
666
-					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
665
+				elseif (preg_match(':^MET01:', $message)) {
666
+					$decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode);
667 667
 				}
668
-				elseif (preg_match(':^WAB02:',$message)) {
669
-					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
668
+				elseif (preg_match(':^WAB02:', $message)) {
669
+					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode);
670 670
 				}
671 671
 			}
672 672
 			if ($label == '15') {
673
-				if (preg_match(':^FST01:',$message)) {
674
-					$decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode);
673
+				if (preg_match(':^FST01:', $message)) {
674
+					$decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode);
675 675
 				}
676 676
 			}
677 677
 			if (!$found && $label == 'SA') {
678
-				$n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at);
678
+				$n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at);
679 679
 				if ($n == 4) {
680 680
 					$vsta = array('Version' => $version);
681 681
 					if ($state == 'E') {
682
-						$vsta = array_merge($vsta,array('Link state' => 'Established'));
682
+						$vsta = array_merge($vsta, array('Link state' => 'Established'));
683 683
 					}
684 684
 					elseif ($state == 'L') {
685
-						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
685
+						$vsta = array_merge($vsta, array('Link state' => 'Lost'));
686 686
 					}
687 687
 					else {
688
-						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
688
+						$vsta = array_merge($vsta, array('Link state' => 'Unknown'));
689 689
 					}
690 690
 					if ($type == 'V') {
691
-						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
691
+						$vsta = array_merge($vsta, array('Link type' => 'VHF ACARS'));
692 692
 					}
693 693
 					elseif ($type == 'S') {
694
-						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
694
+						$vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM'));
695 695
 					}
696 696
 					elseif ($type == 'H') {
697
-						$vsta = array_merge($vsta,array('Link type' => 'HF'));
697
+						$vsta = array_merge($vsta, array('Link type' => 'HF'));
698 698
 					}
699 699
 					elseif ($type == 'G') {
700
-						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
700
+						$vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM'));
701 701
 					}
702 702
 					elseif ($type == 'C') {
703
-						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
703
+						$vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM'));
704 704
 					}
705 705
 					elseif ($type == '2') {
706
-						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
706
+						$vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2'));
707 707
 					}
708 708
 					elseif ($type == 'X') {
709
-						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
709
+						$vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero'));
710 710
 					}
711 711
 					elseif ($type == 'I') {
712
-						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
712
+						$vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM'));
713 713
 					}
714 714
 					else {
715
-						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
715
+						$vsta = array_merge($vsta, array('Link type' => 'Unknown'));
716 716
 					}
717
-					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
718
-					$decode = array_merge($vsta,$decode);
717
+					$vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2))));
718
+					$decode = array_merge($vsta, $decode);
719 719
 				}
720 720
 			}
721 721
 
722 722
 			$title = $this->getTitlefromLabel($label);
723
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
723
+			if ($title != '') $decode = array_merge(array('Message title' => $title), $decode);
724 724
 			/*
725 725
 			// Business jets always use GS0001
726 726
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -741,21 +741,21 @@  discard block
 block discarded – undo
741 741
 	* @param String ACARS data in acarsdec data
742 742
 	*
743 743
 	*/
744
-	public function add($data,$message = array()) {
744
+	public function add($data, $message = array()) {
745 745
 		global $globalDebug, $globalACARSArchive;
746 746
 		$Image = new Image($this->db);
747 747
 		$Schedule = new Schedule($this->db);
748 748
 		$Translation = new Translation($this->db);
749 749
 
750
-		$message = array_merge($message,$this->parse($data));
750
+		$message = array_merge($message, $this->parse($data));
751 751
 		if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') {
752
-			$ident = (string)$message['ident'];
752
+			$ident = (string) $message['ident'];
753 753
 			$label = $message['label'];
754 754
 			$block_id = $message['block_id'];
755 755
 			$msg_no = $message['msg_no'];
756 756
 			$msg = $message['message'];
757 757
 			$decode = $message['decode'];
758
-			$registration = (string)$message['registration'];
758
+			$registration = (string) $message['registration'];
759 759
 			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
760 760
 			else $latitude = '';
761 761
 			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
@@ -769,20 +769,20 @@  discard block
 block discarded – undo
769 769
 				$Image->addSpotterImage($registration);
770 770
 			}
771 771
 			// Business jets always use GS0001
772
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
772
+			if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude);
773 773
 			if ($globalDebug && isset($info) && $info != '') echo $info;
774 774
 			if (count($decode) > 0) $decode_json = json_encode($decode);
775 775
 			else $decode_json = '';
776 776
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
777
-				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
777
+				$Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS');
778 778
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
779
-				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
779
+				$Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS');
780 780
 			}
781
-			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
782
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
783
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
781
+			$result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
782
+			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F');
783
+			if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
784 784
 			if ($globalDebug && count($decode) > 0) {
785
-				echo "Human readable data : ".implode(' - ',$decode)."\n";
785
+				echo "Human readable data : ".implode(' - ', $decode)."\n";
786 786
 			}
787 787
 		}
788 788
 	}
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
      * @param string $decode
800 800
      * @return bool
801 801
      */
802
-	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
802
+	public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
803 803
 		global $globalDebug;
804 804
 		date_default_timezone_set('UTC');
805 805
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
@@ -807,22 +807,22 @@  discard block
 block discarded – undo
807 807
 			$this->db = $Connection->db;
808 808
 			if ($globalDebug) echo "Test if not already in Live ACARS table...";
809 809
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
810
-			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
810
+			$query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message);
811 811
 			try {
812 812
 				$stht = $this->db->prepare($query_test);
813 813
 				$stht->execute($query_test_values);
814
-			} catch(PDOException $e) {
814
+			} catch (PDOException $e) {
815 815
 				echo "error : ".$e->getMessage();
816 816
 				return false;
817 817
 			}
818 818
 			if ($stht->fetchColumn() == 0) {
819 819
 				if ($globalDebug) echo "Add Live ACARS data...";
820 820
 				$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)";
821
-				$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"));
821
+				$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"));
822 822
 				try {
823 823
 					$sth = $this->db->prepare($query);
824 824
 					$sth->execute($query_values);
825
-				} catch(PDOException $e) {
825
+				} catch (PDOException $e) {
826 826
 					echo "error : ".$e->getMessage();
827 827
 					return false;
828 828
 				}
@@ -848,10 +848,10 @@  discard block
 block discarded – undo
848 848
      * @param string $decode
849 849
      * @return string
850 850
      */
851
-	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
851
+	public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
852 852
 		global $globalDebug;
853 853
 		date_default_timezone_set('UTC');
854
-		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) {
854
+		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) {
855 855
 			/*
856 856
 				    if ($globalDebug) echo "Test if not already in Archive ACARS table...";
857 857
 			    	    $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message";
@@ -866,11 +866,11 @@  discard block
 block discarded – undo
866 866
 			*/
867 867
 			if ($globalDebug) echo "Add Live ACARS data...";
868 868
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
869
-			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
869
+			$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
870 870
 			try {
871 871
 				$sth = $this->db->prepare($query);
872 872
 				$sth->execute($query_values);
873
-			} catch(PDOException $e) {
873
+			} catch (PDOException $e) {
874 874
 				return "error : ".$e->getMessage();
875 875
 			}
876 876
 			if ($globalDebug) echo "Done\n";
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 		try {
893 893
 			$sth = $this->db->prepare($query);
894 894
 			$sth->execute($query_values);
895
-		} catch(PDOException $e) {
895
+		} catch (PDOException $e) {
896 896
 			echo "error : ".$e->getMessage();
897 897
 			return '';
898 898
 		}
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 		try {
913 913
 			$sth = $this->db->prepare($query);
914 914
 			$sth->execute($query_values);
915
-		} catch(PDOException $e) {
915
+		} catch (PDOException $e) {
916 916
 			echo "error : ".$e->getMessage();
917 917
 			return array();
918 918
 		}
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 		try {
934 934
 			$sth = $this->db->prepare($query);
935 935
 			$sth->execute($query_values);
936
-		} catch(PDOException $e) {
936
+		} catch (PDOException $e) {
937 937
 			echo "error : ".$e->getMessage();
938 938
 			return array();
939 939
 		}
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
      * @param string $label
950 950
      * @return array Return ACARS data in array
951 951
      */
952
-	public function getLatestAcarsData($limit = '',$label = '') {
952
+	public function getLatestAcarsData($limit = '', $label = '') {
953 953
 		global $globalURL;
954 954
 		$Image = new Image($this->db);
955 955
 		$Spotter = new Spotter($this->db);
@@ -960,8 +960,8 @@  discard block
 block discarded – undo
960 960
 		if ($limit != "")
961 961
 		{
962 962
 			$limit_array = explode(",", $limit);
963
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
964
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
963
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
964
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
965 965
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
966 966
 			{
967 967
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 		try {
978 978
 			$sth = $this->db->prepare($query);
979 979
 			$sth->execute($query_values);
980
-		} catch(PDOException $e) {
980
+		} catch (PDOException $e) {
981 981
 			echo "error : ".$e->getMessage();
982 982
 			return array();
983 983
 		}
@@ -985,39 +985,39 @@  discard block
 block discarded – undo
985 985
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
986 986
 			$data = array();
987 987
 			if ($row['registration'] != '') {
988
-				$row['registration'] = str_replace('.','',$row['registration']);
988
+				$row['registration'] = str_replace('.', '', $row['registration']);
989 989
 				$image_array = $Image->getSpotterImage($row['registration']);
990
-				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']));
991
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
992
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
990
+				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']));
991
+				else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
992
+			} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
993 993
 			if ($row['registration'] == '') $row['registration'] = 'NA';
994 994
 			if ($row['ident'] == '') $row['ident'] = 'NA';
995
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
995
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
996 996
 			if (isset($identicao[0])) {
997
-				if (substr($row['ident'],0,2) == 'AF') {
998
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
999
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1000
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1001
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
997
+				if (substr($row['ident'], 0, 2) == 'AF') {
998
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
999
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1000
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1001
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1002 1002
 			} else $icao = $row['ident'];
1003
-			$icao = $Translation->checkTranslation($icao,false);
1004
-			$decode = json_decode($row['decode'],true);
1003
+			$icao = $Translation->checkTranslation($icao, false);
1004
+			$decode = json_decode($row['decode'], true);
1005 1005
 			$found = false;
1006
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1006
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1007 1007
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1008 1008
 				if (isset($airport_info[0]['icao'])) {
1009 1009
 					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1010 1010
 					$found = true;
1011 1011
 				}
1012 1012
 			}
1013
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1013
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1014 1014
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1015 1015
 				if (isset($airport_info[0]['icao'])) {
1016 1016
 					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1017 1017
 					$found = true;
1018 1018
 				}
1019 1019
 			}
1020
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1020
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1021 1021
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1022 1022
 				if (isset($airport_info[0]['icao'])) {
1023 1023
 					$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>';
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 				}
1026 1026
 			}
1027 1027
 			if ($found) $row['decode'] = json_encode($decode);
1028
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1028
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1029 1029
 			$result[] = $data;
1030 1030
 			$i++;
1031 1031
 		}
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
      * @param string $label
1044 1044
      * @return array Return ACARS data in array
1045 1045
      */
1046
-	public function getArchiveAcarsData($limit = '',$label = '') {
1046
+	public function getArchiveAcarsData($limit = '', $label = '') {
1047 1047
 		global $globalURL;
1048 1048
 		$Image = new Image($this->db);
1049 1049
 		$Spotter = new Spotter($this->db);
@@ -1053,8 +1053,8 @@  discard block
 block discarded – undo
1053 1053
 		if ($limit != "")
1054 1054
 		{
1055 1055
 			$limit_array = explode(",", $limit);
1056
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1057
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1056
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1057
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1058 1058
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1059 1059
 			{
1060 1060
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -1075,45 +1075,45 @@  discard block
 block discarded – undo
1075 1075
 		try {
1076 1076
 			$sth = $this->db->prepare($query);
1077 1077
 			$sth->execute($query_values);
1078
-		} catch(PDOException $e) {
1078
+		} catch (PDOException $e) {
1079 1079
 			echo "error : ".$e->getMessage();
1080 1080
 			return array();
1081 1081
 		}
1082
-		$i=0;
1082
+		$i = 0;
1083 1083
 		$result = array();
1084 1084
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1085 1085
 			$data = array();
1086 1086
 			if ($row['registration'] != '') {
1087
-				$row['registration'] = str_replace('.','',$row['registration']);
1087
+				$row['registration'] = str_replace('.', '', $row['registration']);
1088 1088
 				$image_array = $Image->getSpotterImage($row['registration']);
1089
-				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']));
1090
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1091
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1089
+				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']));
1090
+				else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1091
+			} else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1092 1092
 			$icao = '';
1093 1093
 			if ($row['registration'] == '') $row['registration'] = 'NA';
1094 1094
 			if ($row['ident'] == '') $row['ident'] = 'NA';
1095
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1095
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
1096 1096
 			if (isset($identicao[0])) {
1097
-				if (substr($row['ident'],0,2) == 'AF') {
1098
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1099
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1100
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1101
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1097
+				if (substr($row['ident'], 0, 2) == 'AF') {
1098
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1099
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1100
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1101
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1102 1102
 			} else $icao = $row['ident'];
1103 1103
 			$icao = $Translation->checkTranslation($icao);
1104
-			$decode = json_decode($row['decode'],true);
1104
+			$decode = json_decode($row['decode'], true);
1105 1105
 			$found = false;
1106
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1106
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1107 1107
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1108 1108
 				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>';
1109 1109
 				$found = true;
1110 1110
 			}
1111
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1111
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1112 1112
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1113 1113
 				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>';
1114 1114
 				$found = true;
1115 1115
 			}
1116
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1116
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1117 1117
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1118 1118
 				if (isset($airport_info[0]['icao'])) {
1119 1119
 					$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>';
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 				}
1122 1122
 			}
1123 1123
 			if ($found) $row['decode'] = json_encode($decode);
1124
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1124
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1125 1125
 			$result[] = $data;
1126 1126
 			$i++;
1127 1127
 		}
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
      * @param string $longitude
1143 1143
      * @return string
1144 1144
      */
1145
-	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1145
+	public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') {
1146 1146
 		global $globalDebug, $globalDBdriver;
1147 1147
 		$ident = trim($ident);
1148 1148
 		$Translation = new Translation($this->db);
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 			if ($globalDebug) echo "Ident or registration null, exit\n";
1156 1156
 			return '';
1157 1157
 		}
1158
-		$registration = str_replace('.','',$registration);
1158
+		$registration = str_replace('.', '', $registration);
1159 1159
 		$ident = $Translation->ident2icao($ident);
1160 1160
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1161 1161
 		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
 		try {
1165 1165
 			$sthsi = $this->db->prepare($querysi);
1166 1166
 			$sthsi->execute($querysi_values);
1167
-		} catch(PDOException $e) {
1167
+		} catch (PDOException $e) {
1168 1168
 			if ($globalDebug) echo $e->getMessage();
1169 1169
 			return "error : ".$e->getMessage();
1170 1170
 		}
@@ -1174,8 +1174,8 @@  discard block
 block discarded – undo
1174 1174
 			$Translation = new Translation($this->db);
1175 1175
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1176 1176
 			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1177
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1178
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1177
+			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS');
1178
+			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS');
1179 1179
 		} else {
1180 1180
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1181 1181
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
 				try {
1184 1184
 					$sth = $this->db->prepare($query);
1185 1185
 					$sth->execute($query_values);
1186
-				} catch(PDOException $e) {
1186
+				} catch (PDOException $e) {
1187 1187
 					if ($globalDebug) echo $e->getMessage();
1188 1188
 					return "error : ".$e->getMessage();
1189 1189
 				}
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 				$sth->closeCursor();
1192 1192
 				if (isset($result['modes'])) $hex = $result['modes'];
1193 1193
 				else $hex = '';
1194
-				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1194
+				$SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS');
1195 1195
 				if ($this->fromACARSscript) $this->SI->add($SI_data);
1196 1196
 			}
1197 1197
 		}
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 		try {
1202 1202
 			$sth = $this->db->prepare($query);
1203 1203
 			$sth->execute($query_values);
1204
-		} catch(PDOException $e) {
1204
+		} catch (PDOException $e) {
1205 1205
 			if ($globalDebug) echo $e->getMessage();
1206 1206
 			return "error : ".$e->getMessage();
1207 1207
 		}
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1212 1212
 			else $ModeS = '';
1213 1213
 			if ($ModeS == '') {
1214
-				$id = explode('-',$result['flightaware_id']);
1214
+				$id = explode('-', $result['flightaware_id']);
1215 1215
 				$ModeS = $id[0];
1216 1216
 			}
1217 1217
 			if ($ModeS != '') {
@@ -1221,20 +1221,20 @@  discard block
 block discarded – undo
1221 1221
 				try {
1222 1222
 					$sthc = $this->db->prepare($queryc);
1223 1223
 					$sthc->execute($queryc_values);
1224
-				} catch(PDOException $e) {
1224
+				} catch (PDOException $e) {
1225 1225
 					if ($globalDebug) echo $e->getMessage();
1226 1226
 					return "error : ".$e->getMessage();
1227 1227
 				}
1228 1228
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1229 1229
 				$sthc->closeCursor();
1230
-				if (count($row) ==  0) {
1230
+				if (count($row) == 0) {
1231 1231
 					if ($globalDebug) echo " Add to ModeS table - ";
1232 1232
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1233
-					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1233
+					$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1234 1234
 					try {
1235 1235
 						$sthi = $this->db->prepare($queryi);
1236 1236
 						$sthi->execute($queryi_values);
1237
-					} catch(PDOException $e) {
1237
+					} catch (PDOException $e) {
1238 1238
 						if ($globalDebug) echo $e->getMessage();
1239 1239
 						return "error : ".$e->getMessage();
1240 1240
 					}
@@ -1242,15 +1242,15 @@  discard block
 block discarded – undo
1242 1242
 					if ($globalDebug) echo " Update ModeS table - ";
1243 1243
 					if ($ICAOTypeCode != '') {
1244 1244
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1245
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1245
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1246 1246
 					} else {
1247 1247
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1248
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration);
1248
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration);
1249 1249
 					}
1250 1250
 					try {
1251 1251
 						$sthi = $this->db->prepare($queryi);
1252 1252
 						$sthi->execute($queryi_values);
1253
-					} catch(PDOException $e) {
1253
+					} catch (PDOException $e) {
1254 1254
 						if ($globalDebug) echo $e->getMessage();
1255 1255
 						return "error : ".$e->getMessage();
1256 1256
 					}
@@ -1287,12 +1287,12 @@  discard block
 block discarded – undo
1287 1287
 					elseif ($globalDBdriver == 'pgsql') {
1288 1288
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1289 1289
 					}
1290
-					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
1290
+					$queryi_values = array(':Registration' => $registration, ':ident' => $icao);
1291 1291
 				}
1292 1292
 				try {
1293 1293
 					$sthi = $this->db->prepare($queryi);
1294 1294
 					$sthi->execute($queryi_values);
1295
-				} catch(PDOException $e) {
1295
+				} catch (PDOException $e) {
1296 1296
 					if ($globalDebug) echo $e->getMessage();
1297 1297
 					return "error : ".$e->getMessage();
1298 1298
 				}
Please login to merge, or discard this patch.