Completed
Push — master ( 850369...00e839 )
by Yannick
38:14
created
scripts/daemon-spotter.php 2 patches
Spacing   +224 added lines, -224 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
 
@@ -490,10 +490,10 @@  discard block
 block discarded – undo
490 490
             //$buffer = $Common->getData($hosts[$id]);
491 491
             $buffer = $Common->getData($value['host']);
492 492
             if ($buffer != '') {
493
-                $all_data = json_decode($buffer,true);
493
+                $all_data = json_decode($buffer, true);
494 494
                 foreach ($all_data as $line) {
495 495
                     $data = array();
496
-                    $data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
496
+                    $data['datetime'] = date('Y-m-d H:i:s', $line['uti']);
497 497
                     $data['hex'] = $line['hex']; // hex
498 498
                     $data['ident'] = $line['fli']; // ident
499 499
                     $data['altitude'] = $line['alt']; // altitude
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
                     $data['format_source'] = 'radarcapejson';
511 511
                     $data['id_source'] = $id_source;
512 512
                     if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
513
-                    elseif($line['src'] == 'M') $data['source_name'] = 'MLAT';
513
+                    elseif ($line['src'] == 'M') $data['source_name'] = 'MLAT';
514 514
                     if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
515 515
                     if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
516 516
 
@@ -526,11 +526,11 @@  discard block
 block discarded – undo
526 526
 	    )
527 527
 	) {
528 528
 	    date_default_timezone_set('CET');
529
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
529
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
530 530
 	    date_default_timezone_set('UTC');
531 531
 	    if ($buffer != '') $reset = 0;
532
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
533
-	    $buffer = explode('\n',$buffer);
532
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
533
+	    $buffer = explode('\n', $buffer);
534 534
 	    foreach ($buffer as $line) {
535 535
 		if ($line != '') {
536 536
 		    //echo "'".$line."'\n";
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 		    $ais_data = $AIS->parse_line(trim($line));
539 539
 		    $data = array();
540 540
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
541
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
541
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
542 542
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
543 543
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
544 544
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
551 551
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
552 552
 		    if (isset($ais_data['timestamp'])) {
553
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
553
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
554 554
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
555 555
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
556 556
 			    $add = true;
@@ -573,21 +573,21 @@  discard block
 block discarded – undo
573 573
 	    $w = $e = null;
574 574
 	    
575 575
 	    if (isset($arr[$id])) {
576
-		$nn = stream_select($arr,$w,$e,$timeout);
576
+		$nn = stream_select($arr, $w, $e, $timeout);
577 577
 		if ($nn > 0) {
578 578
 		    foreach ($httpfeeds as $feed) {
579
-			$buffer = stream_get_line($feed,2000,"\n");
579
+			$buffer = stream_get_line($feed, 2000, "\n");
580 580
 			if ($buffer === FALSE) {
581 581
 			    connect_all($globalSources);
582 582
 			}
583
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
584
-			$buffer = explode('\n',$buffer);
583
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
584
+			$buffer = explode('\n', $buffer);
585 585
 			foreach ($buffer as $line) {
586 586
 			    if ($line != '') {
587 587
 				$ais_data = $AIS->parse_line(trim($line));
588 588
 				$data = array();
589 589
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
590
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
590
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
591 591
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
592 592
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
593 593
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -599,9 +599,9 @@  discard block
 block discarded – undo
599 599
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
600 600
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
601 601
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
602
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
602
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
603 603
 				if (isset($ais_data['timestamp'])) {
604
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
604
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
605 605
 				} else {
606 606
 				    $data['datetime'] = date('Y-m-d H:i:s');
607 607
 				}
@@ -633,10 +633,10 @@  discard block
 block discarded – undo
633 633
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
634 634
 	    )
635 635
 	) {
636
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
636
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
637 637
 	    if ($buffer != '') {
638 638
 		//echo $buffer;
639
-		$all_data = json_decode($buffer,true);
639
+		$all_data = json_decode($buffer, true);
640 640
 		//print_r($all_data);
641 641
 		if (isset($all_data[0]['DATA'])) {
642 642
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 			    $data['ident'] = $line['NAME'];
646 646
 			    $data['mmsi'] = $line['MMSI'];
647 647
 			    if (strlen($data['mmsi']) > 9) {
648
-				$data['mmsi'] = substr($data['mmsi'],-9);
648
+				$data['mmsi'] = substr($data['mmsi'], -9);
649 649
 			    }
650 650
 			    $data['speed'] = $line['SOG'];
651 651
 			    $data['heading'] = $line['COG'];
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
 			    //$data['type_id'] = $line['TYPE'];
656 656
 			    $data['imo'] = $line['IMO'];
657 657
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
658
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
659
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
658
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
659
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
660 660
 			    $data['format_source'] = 'myshiptracking';
661 661
 			    $data['id_source'] = $id_source;
662 662
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -673,16 +673,16 @@  discard block
 block discarded – undo
673 673
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
674 674
 	    )
675 675
 	) {
676
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
676
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
677 677
 	    if ($buffer != '') {
678
-		$all_data = json_decode($buffer,true);
678
+		$all_data = json_decode($buffer, true);
679 679
 		if (isset($all_data[0]['mmsi'])) {
680 680
 		    foreach ($all_data as $line) {
681 681
 			if ($line != '') {
682 682
 			    $data = array();
683 683
 			    $data['ident'] = $line['shipname'];
684 684
 			    $data['callsign'] = $line['callsign'];
685
-			    $data['mmsi'] = substr($line['mmsi'],-9);
685
+			    $data['mmsi'] = substr($line['mmsi'], -9);
686 686
 			    $data['speed'] = $line['sog'];
687 687
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
688 688
 			    $data['latitude'] = $line['latitude'];
@@ -709,14 +709,14 @@  discard block
 block discarded – undo
709 709
 	) {
710 710
 	    $buffer = $Common->getData($value['host']);
711 711
 	    if ($buffer != '') {
712
-		$all_data = json_decode($buffer,true);
712
+		$all_data = json_decode($buffer, true);
713 713
 		if (isset($all_data['features'][0]['id'])) {
714 714
 		    foreach ($all_data['features'] as $line) {
715 715
 			print_r($line);
716 716
 			$data = array();
717 717
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
718 718
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
719
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
719
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
720 720
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
721 721
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
722 722
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -743,31 +743,31 @@  discard block
 block discarded – undo
743 743
 	    )
744 744
 	) {
745 745
 	    if ($globalDebug) echo 'download...';
746
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
746
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
747 747
 	    if ($globalDebug) echo 'done !'."\n";
748 748
 	    // FIXME: Need more work
749 749
 	    if ($buffer != '') $reset = 0;
750
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
751
-	    $buffer = explode('\n',$buffer);
750
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
751
+	    $buffer = explode('\n', $buffer);
752 752
 	    foreach ($buffer as $line) {
753 753
 		if ($line != '') {
754 754
 		    $data = array();
755 755
 		    //echo $line."\n";
756
-		    $data['mmsi'] = (int)substr($line,0,9);
757
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
758
-		    $data['status_id'] = substr($line,21,2);
759
-		    $data['type_id'] = substr($line,24,3);
760
-		    $data['latitude'] = substr($line,29,9);
761
-		    $data['longitude'] = substr($line,41,9);
762
-		    $data['speed'] = round(substr($line,51,5));
756
+		    $data['mmsi'] = (int) substr($line, 0, 9);
757
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
758
+		    $data['status_id'] = substr($line, 21, 2);
759
+		    $data['type_id'] = substr($line, 24, 3);
760
+		    $data['latitude'] = substr($line, 29, 9);
761
+		    $data['longitude'] = substr($line, 41, 9);
762
+		    $data['speed'] = round(substr($line, 51, 5));
763 763
 		    //$data['course'] = substr($line,57,5);
764
-		    $data['heading'] = round(substr($line,63,3));
764
+		    $data['heading'] = round(substr($line, 63, 3));
765 765
 		    //$data['draft'] = substr($line,67,4);
766 766
 		    //$data['length'] = substr($line,72,3);
767 767
 		    //$data['beam'] = substr($line,76,2);
768
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
768
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
769 769
 		    //$data['callsign'] = trim(substr($line,100,7);
770
-		    $data['arrival_code'] = substr($line,108,20);
770
+		    $data['arrival_code'] = substr($line, 108, 20);
771 771
 		    //$data['etaDate'] = substr($line,129,5);
772 772
 		    //$data['etaTime'] = substr($line,135,5);
773 773
 		    $data['format_source'] = 'shipplotter';
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 	    )
788 788
 	) {
789 789
 	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
790
-		$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);
790
+		$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);
791 791
 		//echo $authsailaway;
792 792
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
793 793
 		if (isset($setcookie[1][0])) {
@@ -796,18 +796,18 @@  discard block
 block discarded – undo
796 796
 	    }
797 797
 
798 798
 	    if ($globalDebug) echo '! Download... ';
799
-	    for ($i =0; $i <= 1; $i++) {
799
+	    for ($i = 0; $i <= 1; $i++) {
800 800
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
801 801
 		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
802 802
 	    if ($globalDebug) echo 'done'."\n";
803 803
 	    if ($buffer != '') {
804
-		$all_data = json_decode($buffer,true);
804
+		$all_data = json_decode($buffer, true);
805 805
 		if (isset($all_data['missions'])) {
806 806
 			foreach ($all_data['missions'] as $mission) {
807 807
 				$mission_user = $mission['usrname'];
808
-				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
809
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
810
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
808
+				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']));
809
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
810
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie);
811 811
 					else $racebuffer = '';
812 812
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
813 813
 				} else {
@@ -815,19 +815,19 @@  discard block
 block discarded – undo
815 815
 					$racebuffer = '';
816 816
 				}
817 817
 				if ($racebuffer != '') {
818
-					$race_data = json_decode($racebuffer,true);
818
+					$race_data = json_decode($racebuffer, true);
819 819
 					//print_r($race_data);
820 820
 					unset($racebuffer);
821 821
 					if (isset($race_data['mission'])) {
822 822
 					    $datar = array();
823 823
 					    $datar['id'] = $mission['misnr'];
824 824
 					    $datar['desc'] = $race_data['mission']['misdescr'];
825
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
826
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
825
+					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname'])));
826
+					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle'])));
827 827
 					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
828 828
 					    $markers = array();
829 829
 					    foreach ($race_data['mission']['course'] as $course) {
830
-						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
830
+						$markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']);
831 831
 					    }
832 832
 					    $datar['markers'] = json_encode($markers);
833 833
 					    //print_r($datar);
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
 					}
836 836
 				}
837 837
 				if ($bufferm != '') {
838
-					$mission_data = json_decode($bufferm,true);
838
+					$mission_data = json_decode($bufferm, true);
839 839
 					unset($bufferm);
840 840
 					if (isset($mission_data['leaderboard'][0]['results'])) {
841 841
 						foreach ($mission_data['leaderboard'][0]['results'] as $sail) {
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
 								//$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr'];
849 849
 								$data['id'] = $sail['misnr'].'-'.$sail['usrnr'];
850 850
 								$data['datetime'] = date('Y-m-d H:i:s');
851
-								$data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart']));
851
+								$data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart']));
852 852
 								$data['last_update'] = date('Y-m-d H:i:s');
853 853
 								$data['status'] = $sail['status'];
854 854
 								$data['type'] = $sail['btptype'];
@@ -859,16 +859,16 @@  discard block
 block discarded – undo
859 859
 									$data['longitude'] = $pos['longitude'];
860 860
 								}
861 861
 								if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') {
862
-									$resultdescr = explode(',',$sail['resultdescr']);
862
+									$resultdescr = explode(',', $sail['resultdescr']);
863 863
 									if (count($resultdescr) > 2) {
864
-										$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2);
865
-										$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1]));
864
+										$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2);
865
+										$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1]));
866 866
 										if (isset($resultdescr[3])) {
867
-											$data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3);
867
+											$data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3);
868 868
 										}
869 869
 									}
870 870
 								}
871
-								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
871
+								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
872 872
 								$data['captain_id'] = $sail['usrnr'];
873 873
 								$data['captain_name'] = $sail['usrname'];
874 874
 								$data['race_id'] = $sail['misnr'];
@@ -916,8 +916,8 @@  discard block
 block discarded – undo
916 916
 	) {
917 917
 	    //$buffer = $Common->getData($hosts[$id]);
918 918
 	    $buffer = $Common->getData($value['host']);
919
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
920
-	    $buffer = explode('\n',$buffer);
919
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
920
+	    $buffer = explode('\n', $buffer);
921 921
 	    $reset = 0;
922 922
 	    foreach ($buffer as $line) {
923 923
     		if ($line != '') {
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
929 929
 			$data['pilot_id'] = $line[1];
930 930
 			$data['pilot_name'] = $line[2];
931
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
931
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
932 932
 			$data['ident'] = $line[0]; // ident
933 933
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
934 934
 			$data['speed'] = $line[8]; // speed
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
945 945
 			//if (isset($line[37])) $data['last_update'] = $line[37];
946 946
 		        $data['departure_airport_icao'] = $line[11];
947
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
947
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
948 948
 		        $data['arrival_airport_icao'] = $line[13];
949 949
 			$data['frequency'] = $line[4];
950 950
 			$data['type'] = $line[18];
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
     			$data['id_source'] = $id_source;
954 954
 	    		//$data['arrival_airport_time'] = ;
955 955
 	    		if ($line[9] != '') {
956
-	    		    $aircraft_data = explode('/',$line[9]);
956
+	    		    $aircraft_data = explode('/', $line[9]);
957 957
 	    		    if (isset($aircraft_data[1])) {
958 958
 	    			$data['aircraft_icao'] = $aircraft_data[1];
959 959
 	    		    }
@@ -968,9 +968,9 @@  discard block
 block discarded – undo
968 968
     			if ($line[3] === 'PILOT') $SI->add($data);
969 969
 			elseif ($line[3] === 'ATC') {
970 970
 				//print_r($data);
971
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
972
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
973
-				$typec = substr($data['ident'],-3);
971
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
972
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
973
+				$typec = substr($data['ident'], -3);
974 974
 				if ($typec === 'APP') $data['type'] = 'Approach';
975 975
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
976 976
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -982,8 +982,8 @@  discard block
 block discarded – undo
982 982
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
983 983
 				if (!isset($data['source_name'])) $data['source_name'] = '';
984 984
 				if (isset($ATC)) {
985
-					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']);
986
-					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']);
985
+					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']);
986
+					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']);
987 987
 				}
988 988
 			}
989 989
     			unset($data);
@@ -999,24 +999,24 @@  discard block
 block discarded – undo
999 999
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1000 1000
     	    )
1001 1001
     	) {
1002
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1002
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
1003 1003
 	    if ($buffer != '') {
1004 1004
 		$all_data = simplexml_load_string($buffer);
1005
-		foreach($all_data->children() as $childdata) {
1005
+		foreach ($all_data->children() as $childdata) {
1006 1006
 			$data = array();
1007 1007
 			$line = $childdata;
1008 1008
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
1009
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
1010
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1011
-			$data['latitude'] = (float)$line['pktLatitude'];
1012
-			$data['longitude'] = (float)$line['pktLongitude'];
1013
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1014
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1015
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1009
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
1010
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
1011
+			$data['latitude'] = (float) $line['pktLatitude'];
1012
+			$data['longitude'] = (float) $line['pktLongitude'];
1013
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
1014
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
1015
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
1016 1016
 			$data['altitude_relative'] = 'AMSL';
1017
-			$data['pilot_id'] = (int)$line['pktPilotID'];
1017
+			$data['pilot_id'] = (int) $line['pktPilotID'];
1018 1018
 			$data['aircraft_icao'] = 'PARAGLIDER';
1019
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1019
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1020 1020
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1021 1021
 			$data['format_source'] = $value['format'];
1022 1022
 			$SI->add($data);
@@ -1024,22 +1024,22 @@  discard block
 block discarded – undo
1024 1024
 		}
1025 1025
 	    }
1026 1026
 	    $Source->deleteOldLocationByType('gs');
1027
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1027
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
1028 1028
 	    if ($buffer != '') {
1029 1029
 		$all_data = simplexml_load_string($buffer);
1030
-		foreach($all_data->children() as $childdata) {
1030
+		foreach ($all_data->children() as $childdata) {
1031 1031
 			$data = array();
1032 1032
 			$line = $childdata;
1033
-			$data['id'] = (int)$line['gsID'];
1034
-			$data['latitude'] = (float)$line['gsLatitude'];
1035
-			$data['longitude'] = (float)$line['gsLongitude'];
1036
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
1033
+			$data['id'] = (int) $line['gsID'];
1034
+			$data['latitude'] = (float) $line['gsLatitude'];
1035
+			$data['longitude'] = (float) $line['gsLongitude'];
1036
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
1037 1037
 			$data['altitude_relative'] = 'AMSL';
1038
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
1038
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
1039 1039
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
1040
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1040
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1041 1041
 			} else {
1042
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1042
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1043 1043
 			}
1044 1044
 			unset($data);
1045 1045
 		}
@@ -1057,9 +1057,9 @@  discard block
 block discarded – undo
1057 1057
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1058 1058
 	    )
1059 1059
 	) {
1060
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1060
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1061 1061
 	    if ($buffer != '') {
1062
-	        $all_data = json_decode($buffer,true);
1062
+	        $all_data = json_decode($buffer, true);
1063 1063
 		if (isset($all_data['acList'])) {
1064 1064
 		    $reset = 0;
1065 1065
 		    foreach ($all_data['acList'] as $line) {
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1076 1076
 			$data['emergency'] = ''; // emergency
1077 1077
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1078
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1078
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1079 1079
 			else $data['datetime'] = date('Y-m-d H:i:s');
1080 1080
 			//$data['datetime'] = date('Y-m-d H:i:s');
1081 1081
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1101 1101
 			$data['squawk'] = $line['squawk']; // squawk
1102 1102
 			$data['emergency'] = ''; // emergency
1103
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1103
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1104 1104
 			else $data['datetime'] = date('Y-m-d H:i:s');
1105 1105
 			$data['format_source'] = 'aircraftlistjson';
1106 1106
 			$data['id_source'] = $id_source;
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
     	    )
1122 1122
     	) {
1123 1123
 	    $buffer = $Common->getData($value['host']);
1124
-	    $all_data = json_decode($buffer,true);
1124
+	    $all_data = json_decode($buffer, true);
1125 1125
 	    if (isset($all_data['planes'])) {
1126 1126
 		$reset = 0;
1127 1127
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1138,12 +1138,12 @@  discard block
 block discarded – undo
1138 1138
 		    $data['emergency'] = ''; // emergency
1139 1139
 		    $data['registration'] = $line[2];
1140 1140
 		    $data['aircraft_icao'] = $line[0];
1141
-		    $deparr = explode('-',$line[1]);
1141
+		    $deparr = explode('-', $line[1]);
1142 1142
 		    if (count($deparr) === 2) {
1143 1143
 			$data['departure_airport_icao'] = $deparr[0];
1144 1144
 			$data['arrival_airport_icao'] = $deparr[1];
1145 1145
 		    }
1146
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1146
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1147 1147
 	    	    $data['format_source'] = 'planeupdatefaa';
1148 1148
     		    $data['id_source'] = $id_source;
1149 1149
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
 	    )
1162 1162
 	) {
1163 1163
 	    $buffer = $Common->getData($value['host']);
1164
-	    $all_data = json_decode($buffer,true);
1164
+	    $all_data = json_decode($buffer, true);
1165 1165
 	    if (isset($all_data['states'])) {
1166 1166
 		$reset = 0;
1167 1167
 		foreach ($all_data['states'] as $key => $line) {
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
 		    //$data['emergency'] = ''; // emergency
1179 1179
 		    //$data['registration'] = $line[2];
1180 1180
 		    //$data['aircraft_icao'] = $line[0];
1181
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1181
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1182 1182
 		    $data['format_source'] = 'opensky';
1183 1183
 		    $data['id_source'] = $id_source;
1184 1184
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1195,8 +1195,8 @@  discard block
 block discarded – undo
1195 1195
 	    )
1196 1196
 	) {
1197 1197
 	    $buffer = $Common->getData($value['host']);
1198
-	    $all_data = json_decode($buffer,true);
1199
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1198
+	    $all_data = json_decode($buffer, true);
1199
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1200 1200
 		$reset = 0;
1201 1201
 		foreach ($all_data['aircraft'] as $key => $line) {
1202 1202
 		    $data = array();
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
 	    )
1235 1235
 	) {
1236 1236
 	    $buffer = $Common->getData($value['host']);
1237
-	    $all_data = json_decode($buffer,true);
1237
+	    $all_data = json_decode($buffer, true);
1238 1238
 	    if (isset($all_data['aircraft'])) {
1239 1239
 		$reset = 0;
1240 1240
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
 		    //$data['emergency'] = ''; // emergency
1252 1252
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1253 1253
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1254
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1254
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1255 1255
 		    $data['format_source'] = 'planefinderclient';
1256 1256
 		    $data['id_source'] = $id_source;
1257 1257
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 	) {
1271 1271
 	    //$buffer = $Common->getData($hosts[$id]);
1272 1272
 	    $buffer = $Common->getData($value['host']);
1273
-	    $all_data = json_decode($buffer,true);
1273
+	    $all_data = json_decode($buffer, true);
1274 1274
 	    if (!empty($all_data)) $reset = 0;
1275 1275
 	    foreach ($all_data as $key => $line) {
1276 1276
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1308,11 +1308,11 @@  discard block
 block discarded – undo
1308 1308
 	    )
1309 1309
 	) {
1310 1310
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1311
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1311
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1312 1312
 	    //echo $buffer;
1313
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1314
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1315
-	    $all_data = json_decode($buffer,true);
1313
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1314
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1315
+	    $all_data = json_decode($buffer, true);
1316 1316
 	    if (json_last_error() != JSON_ERROR_NONE) {
1317 1317
 		die(json_last_error_msg());
1318 1318
 	    }
@@ -1335,7 +1335,7 @@  discard block
 block discarded – undo
1335 1335
 			//$data['departure_airport_iata'] = $line[11];
1336 1336
 			//$data['arrival_airport_iata'] = $line[12];
1337 1337
 	    		//$data['emergency'] = ''; // emergency
1338
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1338
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1339 1339
 	    		$data['format_source'] = 'radarvirtueljson';
1340 1340
     			$data['id_source'] = $id_source;
1341 1341
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1356,14 +1356,14 @@  discard block
 block discarded – undo
1356 1356
 	) {
1357 1357
 	    //$buffer = $Common->getData($hosts[$id]);
1358 1358
 	    $buffer = $Common->getData($value['host'].'?'.time());
1359
-	    $all_data = json_decode(utf8_encode($buffer),true);
1359
+	    $all_data = json_decode(utf8_encode($buffer), true);
1360 1360
 	    
1361 1361
 	    if (isset($all_data['pireps'])) {
1362 1362
 		$reset = 0;
1363 1363
 	        foreach ($all_data['pireps'] as $line) {
1364 1364
 		    $data = array();
1365 1365
 		    $data['id'] = $line['id'];
1366
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1366
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1367 1367
 		    $data['ident'] = $line['callsign']; // ident
1368 1368
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1369 1369
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1393,9 +1393,9 @@  discard block
 block discarded – undo
1393 1393
 			$SI->add($data);
1394 1394
 		    //    print_r($data);
1395 1395
     		    } elseif ($line['icon'] === 'ct') {
1396
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1397
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1398
-			$typec = substr($data['ident'],-3);
1396
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1397
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1398
+			$typec = substr($data['ident'], -3);
1399 1399
 			$data['type'] = '';
1400 1400
 			if ($typec === 'APP') $data['type'] = 'Approach';
1401 1401
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1406,7 +1406,7 @@  discard block
 block discarded – undo
1406 1406
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1407 1407
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1408 1408
 			else $data['type'] = 'Observer';
1409
-			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']);
1409
+			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']);
1410 1410
 		    }
1411 1411
 		    unset($data);
1412 1412
 		}
@@ -1423,14 +1423,14 @@  discard block
 block discarded – undo
1423 1423
 	    //$buffer = $Common->getData($hosts[$id]);
1424 1424
 	    if ($globalDebug) echo 'Get Data...'."\n";
1425 1425
 	    $buffer = $Common->getData($value['host']);
1426
-	    $all_data = json_decode($buffer,true);
1426
+	    $all_data = json_decode($buffer, true);
1427 1427
 	    if ($buffer != '' && is_array($all_data)) {
1428 1428
 		$reset = 0;
1429 1429
 		foreach ($all_data as $line) {
1430 1430
 	    	    $data = array();
1431 1431
 	    	    //$data['id'] = $line['id']; // id not usable
1432 1432
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1433
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1433
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1434 1434
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1435 1435
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1436 1436
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1445,7 +1445,7 @@  discard block
 block discarded – undo
1445 1445
 	    	    //$data['datetime'] = $line['lastupdate'];
1446 1446
 	    	    //$data['last_update'] = $line['lastupdate'];
1447 1447
 	    	    if (isset($value['timezone'])) {
1448
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1448
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1449 1449
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1450 1450
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1451 1451
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1461,14 +1461,14 @@  discard block
 block discarded – undo
1461 1461
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1462 1462
 		    if (isset($line['aircraftname'])) {
1463 1463
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1464
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1465
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1464
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1465
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1466 1466
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1467 1467
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1468 1468
 	    		else {
1469
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1470
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1471
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1469
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1470
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1471
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1472 1472
 	    		}
1473 1473
 	    	    }
1474 1474
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1493,7 +1493,7 @@  discard block
 block discarded – undo
1493 1493
 	    //$buffer = $Common->getData($hosts[$id]);
1494 1494
 	    if ($globalDebug) echo 'Get Data...'."\n";
1495 1495
 	    $buffer = $Common->getData($value['host']);
1496
-	    $all_data = json_decode($buffer,true);
1496
+	    $all_data = json_decode($buffer, true);
1497 1497
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1498 1498
 		$reset = 0;
1499 1499
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1504,7 +1504,7 @@  discard block
 block discarded – undo
1504 1504
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1505 1505
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1506 1506
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1507
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1507
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1508 1508
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1509 1509
 	    	    $data['altitude'] = $line['altitude']; // altitude
1510 1510
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1515,7 +1515,7 @@  discard block
 block discarded – undo
1515 1515
 	    	    //$data['squawk'] = ''; // squawk
1516 1516
 	    	    //$data['emergency'] = ''; // emergency
1517 1517
 	    	    if (isset($value['timezone'])) {
1518
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1518
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1519 1519
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1520 1520
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1521 1521
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1551,14 +1551,14 @@  discard block
 block discarded – undo
1551 1551
 	    //$buffer = $Common->getData($hosts[$id]);
1552 1552
 	    if ($globalDebug) echo 'Get Data...'."\n";
1553 1553
 	    $buffer = $Common->getData($value['host']);
1554
-	    $all_data = json_decode($buffer,true);
1554
+	    $all_data = json_decode($buffer, true);
1555 1555
 	    if ($buffer != '' && is_array($all_data)) {
1556 1556
 		$reset = 0;
1557 1557
 		foreach ($all_data as $line) {
1558 1558
 	    	    $data = array();
1559 1559
 	    	    //$data['id'] = $line['id']; // id not usable
1560 1560
 	    	    $data['id'] = trim($line['flight_id']);
1561
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1561
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1562 1562
 	    	    $data['pilot_name'] = $line['pilot_name'];
1563 1563
 	    	    $data['pilot_id'] = $line['pilot_id'];
1564 1564
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1602,24 +1602,24 @@  discard block
 block discarded – undo
1602 1602
 	    //$buffer = $Common->getData($hosts[$id]);
1603 1603
 	    if ($globalDebug) echo 'Get Data...'."\n";
1604 1604
 	    $buffer = $Common->getData($value['host']);
1605
-	    $all_data = json_decode($buffer,true);
1605
+	    $all_data = json_decode($buffer, true);
1606 1606
 	    if ($buffer != '') {
1607 1607
 		$Source->deleteLocationBySource('blitzortung');
1608
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1609
-		$buffer = explode('\n',$buffer);
1608
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1609
+		$buffer = explode('\n', $buffer);
1610 1610
 		foreach ($buffer as $buffer_line) {
1611
-		    $line = json_decode($buffer_line,true);
1611
+		    $line = json_decode($buffer_line, true);
1612 1612
 		    if (isset($line['time'])) {
1613 1613
 			$data = array();
1614 1614
 			$data['altitude'] = $line['alt']; // altitude
1615 1615
 			$data['latitude'] = $line['lat']; // lat
1616 1616
 			$data['longitude'] = $line['lon']; // long
1617
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1617
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1618 1618
 			$data['id_source'] = $id_source;
1619 1619
 			$data['format_source'] = 'blitzortung';
1620 1620
 			$SI->add($data);
1621 1621
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1622
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1622
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1623 1623
 			unset($data);
1624 1624
 		    }
1625 1625
 		}
@@ -1631,15 +1631,15 @@  discard block
 block discarded – undo
1631 1631
         $arr = $httpfeeds;
1632 1632
         $w = $e = null;
1633 1633
         if (isset($arr[$id])) {
1634
-            $nn = stream_select($arr,$w,$e,$timeout);
1634
+            $nn = stream_select($arr, $w, $e, $timeout);
1635 1635
             if ($nn > 0) {
1636 1636
                 foreach ($httpfeeds as $feed) {
1637
-                    $buffer = stream_get_line($feed,2000,"\n");
1637
+                    $buffer = stream_get_line($feed, 2000, "\n");
1638 1638
                     if ($buffer === FALSE) {
1639 1639
                         connect_all($globalSources);
1640 1640
                     }
1641
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1642
-                    $buffer = explode('\n',$buffer);
1641
+                    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1642
+                    $buffer = explode('\n', $buffer);
1643 1643
                     foreach ($buffer as $line) {
1644 1644
                         if ($line != '') {
1645 1645
                             $line = json_decode($line, true);
@@ -1679,11 +1679,11 @@  discard block
 block discarded – undo
1679 1679
 		    //$value = $formats[$nb];
1680 1680
 		    $format = $globalSources[$nb]['format'];
1681 1681
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1682
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1682
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1683 1683
 		    } elseif ($format === 'vrstcp') {
1684 1684
 			$buffer = @socket_read($r, 6000);
1685 1685
 		    } else {
1686
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1686
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1687 1687
 		    }
1688 1688
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1689 1689
 		    //echo $buffer."\n";
@@ -1693,8 +1693,8 @@  discard block
 block discarded – undo
1693 1693
 		    //$SI::del();
1694 1694
 		    if ($buffer !== FALSE) {
1695 1695
 			if ($format === 'vrstcp') {
1696
-			    $buffer = explode('},{',$buffer);
1697
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1696
+			    $buffer = explode('},{', $buffer);
1697
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1698 1698
 		    }
1699 1699
 		    // SBS format is CSV format
1700 1700
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1721,7 +1721,7 @@  discard block
 block discarded – undo
1721 1721
 			    $ais_data = $AIS->parse_line(trim($buffer));
1722 1722
 			    $data = array();
1723 1723
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1724
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1724
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1725 1725
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1726 1726
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1727 1727
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1732,13 +1732,13 @@  discard block
 block discarded – undo
1732 1732
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1733 1733
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1734 1734
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1735
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1735
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1736 1736
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1737 1737
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1738 1738
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1739 1739
 
1740 1740
 			    if (isset($ais_data['timestamp'])) {
1741
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1741
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1742 1742
 			    } else {
1743 1743
 				$data['datetime'] = date('Y-m-d H:i:s');
1744 1744
 			    }
@@ -1749,10 +1749,10 @@  discard block
 block discarded – undo
1749 1749
                         } elseif ($format === 'flightgearsp') {
1750 1750
                     	    //echo $buffer."\n";
1751 1751
                     	    if (strlen($buffer) > 5) {
1752
-				$line = explode(',',$buffer);
1752
+				$line = explode(',', $buffer);
1753 1753
 				$data = array();
1754 1754
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1755
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1755
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1756 1756
 				$data['ident'] = $line[6];
1757 1757
 				$data['aircraft_name'] = $line[7];
1758 1758
 				$data['longitude'] = $line[1];
@@ -1769,16 +1769,16 @@  discard block
 block discarded – undo
1769 1769
                         } elseif ($format === 'acars') {
1770 1770
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1771 1771
 			    $ACARS->add(trim($buffer));
1772
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1772
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1773 1773
 			    $ACARS->deleteLiveAcarsData();
1774 1774
 			} elseif ($format === 'flightgearmp') {
1775
-			    if (substr($buffer,0,1) != '#') {
1775
+			    if (substr($buffer, 0, 1) != '#') {
1776 1776
 				$data = array();
1777 1777
 				//echo $buffer."\n";
1778
-				$line = explode(' ',$buffer);
1778
+				$line = explode(' ', $buffer);
1779 1779
 				if (count($line) === 11) {
1780
-				    $userserver = explode('@',$line[0]);
1781
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1780
+				    $userserver = explode('@', $line[0]);
1781
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1782 1782
 				    $data['ident'] = $userserver[0];
1783 1783
 				    $data['registration'] = $userserver[0];
1784 1784
 				    $data['latitude'] = $line[4];
@@ -1786,8 +1786,8 @@  discard block
 block discarded – undo
1786 1786
 				    $data['altitude'] = $line[6];
1787 1787
 				    $data['datetime'] = date('Y-m-d H:i:s');
1788 1788
 				    $aircraft_type = $line[10];
1789
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1790
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1789
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1790
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1791 1791
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1792 1792
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1793 1793
 				}
@@ -1796,8 +1796,8 @@  discard block
 block discarded – undo
1796 1796
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1797 1797
 			    die;
1798 1798
 			} elseif ($format === 'vrstcp') {
1799
-			    foreach($buffer as $all_data) {
1800
-				$line = json_decode('{'.$all_data.'}',true);
1799
+			    foreach ($buffer as $all_data) {
1800
+				$line = json_decode('{'.$all_data.'}', true);
1801 1801
 				$data = array();
1802 1802
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1803 1803
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1823,16 +1823,16 @@  discard block
 block discarded – undo
1823 1823
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1824 1824
 				unset($data);
1825 1825
 			    }
1826
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1826
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1827 1827
 			    $line = explode("\t", $buffer);
1828
-			    for($k = 0; $k < count($line); $k=$k+2) {
1828
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1829 1829
 				$key = $line[$k];
1830
-			        $lined[$key] = $line[$k+1];
1830
+			        $lined[$key] = $line[$k + 1];
1831 1831
 			    }
1832 1832
     			    if (count($lined) > 3) {
1833 1833
     				$data['hex'] = $lined['hexid'];
1834 1834
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1835
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1835
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1836 1836
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1837 1837
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1838 1838
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1851,23 +1851,23 @@  discard block
 block discarded – undo
1851 1851
     			    } else $error = true;
1852 1852
 			} elseif ($format === 'aprs' && $use_aprs) {
1853 1853
 			    if ($aprs_connect === 0) {
1854
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1854
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1855 1855
 				$aprs_connect = 1;
1856 1856
 			    }
1857 1857
 			    
1858
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1858
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1859 1859
 				$aprs_last_tx = time();
1860 1860
 				$data_aprs = "# Keep alive";
1861
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1861
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1862 1862
 			    }
1863 1863
 			    
1864 1864
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1865 1865
 			    //echo 'APRS data : '.$buffer."\n";
1866
-			    $buffer = str_replace('APRS <- ','',$buffer);
1867
-			    $buffer = str_replace('APRS -> ','',$buffer);
1866
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1867
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1868 1868
 			    //echo $buffer."\n";
1869 1869
 			    date_default_timezone_set('UTC');
1870
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1870
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1871 1871
 				$line = $APRS->parse($buffer);
1872 1872
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1873 1873
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1882,7 +1882,7 @@  discard block
 block discarded – undo
1882 1882
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1883 1883
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1884 1884
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1885
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1885
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1886 1886
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1887 1887
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1888 1888
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1970,29 +1970,29 @@  discard block
 block discarded – undo
1970 1970
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1971 1971
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1972 1972
 					$Source->deleteOldLocationByType('gs');
1973
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1974
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1973
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1974
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1975 1975
 					} else {
1976
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1976
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1977 1977
 					}
1978 1978
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1979 1979
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1980 1980
 					if ($globalDebug) echo '# Weather Station added'."\n";
1981 1981
 					$Source->deleteOldLocationByType('wx');
1982 1982
 					$weather_data = json_encode($line);
1983
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1984
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1983
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1984
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1985 1985
 					} else {
1986
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1986
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1987 1987
 					}
1988 1988
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1989 1989
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1990 1990
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1991 1991
 					$Source->deleteOldLocationByType('lightning');
1992
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1993
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1992
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1993
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1994 1994
 					} else {
1995
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1995
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1996 1996
 					}
1997 1997
 				    } elseif ($globalDebug) {
1998 1998
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -2001,7 +2001,7 @@  discard block
 block discarded – undo
2001 2001
 				    unset($data);
2002 2002
 				}
2003 2003
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2004
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2004
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
2005 2005
 				}
2006 2006
 				/*
2007 2007
 				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')) {
@@ -2010,7 +2010,7 @@  discard block
 block discarded – undo
2010 2010
 				*/
2011 2011
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2012 2012
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2013
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2013
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
2014 2014
 					$Source->deleteOldLocationByType('lightning');
2015 2015
 					$Source->deleteOldLocationByType('wx');
2016 2016
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2097,7 +2097,7 @@  discard block
 block discarded – undo
2097 2097
 				connect_all($sourceee);
2098 2098
 				$sourceee = array();
2099 2099
 				//connect_all($globalSources);
2100
-				$tt[$format]=0;
2100
+				$tt[$format] = 0;
2101 2101
 				break;
2102 2102
 			    } 
2103 2103
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2107,14 +2107,14 @@  discard block
 block discarded – undo
2107 2107
 	    } else {
2108 2108
 		$error = socket_strerror(socket_last_error());
2109 2109
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2110
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2110
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2111 2111
 			if (isset($globalDebug)) echo "Restarting...\n";
2112 2112
 			// Restart the script if possible
2113 2113
 			if (is_array($sockets)) {
2114 2114
 			    if ($globalDebug) echo "Shutdown all sockets...";
2115 2115
 			    
2116 2116
 			    foreach ($sockets as $sock) {
2117
-				@socket_shutdown($sock,2);
2117
+				@socket_shutdown($sock, 2);
2118 2118
 				@socket_close($sock);
2119 2119
 			    }
2120 2120
 			    
Please login to merge, or discard this patch.
Braces   +1228 added lines, -413 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
26 28
 
27 29
 if ($globalInstalled === FALSE) {
28 30
     echo "This script MUST be run after install script. Use your web browser to run install/index.php";
@@ -68,66 +70,107 @@  discard block
 block discarded – undo
68 70
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 71
 if (isset($options['s'])) {
70 72
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
-    else $globalSources[] = array('host' => $options['s']);
73
-} elseif (isset($options['source'])) {
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['s']);
77
+    }
78
+    } elseif (isset($options['source'])) {
74 79
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
-    else $globalSources[] = array('host' => $options['source']);
77
-}
80
+    if (isset($options['format'])) {
81
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
82
+    } else {
83
+    	$globalSources[] = array('host' => $options['source']);
84
+    }
85
+    }
78 86
 if (isset($options['aprsserverhost'])) {
79 87
 	$globalServerAPRS = TRUE;
80 88
 	$globalServerAPRShost = $options['aprsserverhost'];
81 89
 }
82
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
83
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
84
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
85
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
90
+if (isset($options['aprsserverport'])) {
91
+	$globalServerAPRSport = $options['aprsserverport'];
92
+}
93
+if (isset($options['aprsserverssid'])) {
94
+	$globalServerAPRSssid = $options['aprsserverssid'];
95
+}
96
+if (isset($options['aprsserverpass'])) {
97
+	$globalServerAPRSpass = $options['aprsserverpass'];
98
+}
99
+if (isset($options['noaprsserver'])) {
100
+	$globalServerAPRS = FALSE;
101
+}
86 102
 if (isset($options['enable-aircraft'])) {
87
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
103
+	if ($globalDebug) {
104
+		echo 'Enable Aircraft mode'."\n";
105
+	}
88 106
 	$globalAircraft = TRUE; 
89 107
 }
90 108
 if (isset($options['disable-aircraft'])) {
91
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
109
+	if ($globalDebug) {
110
+		echo 'Disable Aircraft mode'."\n";
111
+	}
92 112
 	$globalAircraft = FALSE;
93 113
 }
94 114
 if (isset($options['enable-tracker'])) {
95
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
115
+	if ($globalDebug) {
116
+		echo 'Enable Tracker mode'."\n";
117
+	}
96 118
 	$globalTracker = TRUE; 
97 119
 }
98 120
 if (isset($options['disable-tracker'])) {
99
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
121
+	if ($globalDebug) {
122
+		echo 'Disable Tracker mode'."\n";
123
+	}
100 124
 	$globalTracker = FALSE;
101 125
 }
102 126
 if (isset($options['enable-marine'])) {
103
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
127
+	if ($globalDebug) {
128
+		echo 'Enable Marine mode'."\n";
129
+	}
104 130
 	$globalMarine = TRUE;
105 131
 }
106 132
 if (isset($options['disable-marine'])) {
107
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
133
+	if ($globalDebug) {
134
+		echo 'Disable Marine mode'."\n";
135
+	}
108 136
 	$globalMarine = FALSE;
109 137
 }
110
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
111
-if (isset($options['server'])) $globalServer = TRUE;
112
-if (isset($options['idsource'])) $id_source = $options['idsource'];
113
-else $id_source = 1;
138
+if (isset($options['nodaemon'])) {
139
+	$globalDaemon = FALSE;
140
+}
141
+if (isset($options['server'])) {
142
+	$globalServer = TRUE;
143
+}
144
+if (isset($options['idsource'])) {
145
+	$id_source = $options['idsource'];
146
+} else {
147
+	$id_source = 1;
148
+}
114 149
 if (isset($globalServer) && $globalServer) {
115
-    if ($globalDebug) echo "Using Server Mode\n";
150
+    if ($globalDebug) {
151
+    	echo "Using Server Mode\n";
152
+    }
116 153
     $SI=new SpotterServer();
117 154
 /*
118 155
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 156
     $SI = new adsb2aprs();
120 157
     $SI->connect();
121 158
 */
122
-} else $SI=new SpotterImport($Connection->db);
159
+} else {
160
+	$SI=new SpotterImport($Connection->db);
161
+}
123 162
 
124
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
163
+if (isset($globalTracker) && $globalTracker) {
164
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
165
+}
125 166
 if (isset($globalMarine) && $globalMarine) {
126 167
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
127 168
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
128 169
 }
129 170
 
130
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
171
+if (isset($globalTracker) && $globalTracker) {
172
+	$TI = new TrackerImport($Connection->db);
173
+}
131 174
 if (isset($globalMarine) && $globalMarine) {
132 175
     $AIS = new AIS();
133 176
     $MI = new MarineImport($Connection->db);
@@ -152,7 +195,9 @@  discard block
 block discarded – undo
152 195
 }
153 196
 
154 197
 // let's try and connect
155
-if ($globalDebug) echo "Connecting...\n";
198
+if ($globalDebug) {
199
+	echo "Connecting...\n";
200
+}
156 201
 $use_aprs = false;
157 202
 $aprs_full = false;
158 203
 $reset = 0;
@@ -161,7 +206,9 @@  discard block
 block discarded – undo
161 206
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162 207
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163 208
     $reset++;
164
-    if ($globalDebug) echo 'Connect to all...'."\n";
209
+    if ($globalDebug) {
210
+    	echo 'Connect to all...'."\n";
211
+    }
165 212
     foreach ($hosts as $id => $value) {
166 213
 	$host = $value['host'];
167 214
 	$globalSources[$id]['last_exec'] = 0;
@@ -171,32 +218,44 @@  discard block
 block discarded – undo
171 218
         	//$formats[$id] = 'deltadbtxt';
172 219
         	$globalSources[$id]['format'] = 'deltadbtxt';
173 220
         	//$last_exec['deltadbtxt'] = 0;
174
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
221
+        	if ($globalDebug) {
222
+        		echo "Connect to deltadb source (".$host.")...\n";
223
+        	}
175 224
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
176 225
         	//$formats[$id] = 'vatsimtxt';
177 226
         	$globalSources[$id]['format'] = 'vatsimtxt';
178 227
         	//$last_exec['vatsimtxt'] = 0;
179
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to vatsim source (".$host.")...\n";
230
+        	}
180 231
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
181 232
         	//$formats[$id] = 'aircraftlistjson';
182 233
         	$globalSources[$id]['format'] = 'aircraftlistjson';
183 234
         	//$last_exec['aircraftlistjson'] = 0;
184
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
235
+        	if ($globalDebug) {
236
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
237
+        	}
185 238
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
186 239
         	//$formats[$id] = 'aircraftjson';
187 240
         	$globalSources[$id]['format'] = 'aircraftjson';
188 241
         	//$last_exec['aircraftlistjson'] = 0;
189
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
242
+        	if ($globalDebug) {
243
+        		echo "Connect to aircraft.json source (".$host.")...\n";
244
+        	}
190 245
     	    } else if (preg_match('/aircraft$/i',$host)) {
191 246
         	//$formats[$id] = 'planefinderclient';
192 247
         	$globalSources[$id]['format'] = 'planefinderclient';
193 248
         	//$last_exec['aircraftlistjson'] = 0;
194
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
249
+        	if ($globalDebug) {
250
+        		echo "Connect to planefinderclient source (".$host.")...\n";
251
+        	}
195 252
     	    } else if (preg_match('/opensky/i',$host)) {
196 253
         	//$formats[$id] = 'aircraftlistjson';
197 254
         	$globalSources[$id]['format'] = 'opensky';
198 255
         	//$last_exec['aircraftlistjson'] = 0;
199
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
256
+        	if ($globalDebug) {
257
+        		echo "Connect to opensky source (".$host.")...\n";
258
+        	}
200 259
     	    /*
201 260
     	    // Disabled for now, site change source format
202 261
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -213,7 +272,9 @@  discard block
 block discarded – undo
213 272
         	//$formats[$id] = 'planeupdatefaa';
214 273
         	$globalSources[$id]['format'] = 'planeupdatefaa';
215 274
         	//$last_exec['planeupdatefaa'] = 0;
216
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
275
+        	if ($globalDebug) {
276
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
277
+        	}
217 278
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
218 279
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
219 280
         	    exit(0);
@@ -222,37 +283,53 @@  discard block
 block discarded – undo
222 283
         	//$formats[$id] = 'phpvmacars';
223 284
         	$globalSources[$id]['format'] = 'phpvmacars';
224 285
         	//$last_exec['phpvmacars'] = 0;
225
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
286
+        	if ($globalDebug) {
287
+        		echo "Connect to phpvmacars source (".$host.")...\n";
288
+        	}
226 289
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
227 290
         	//$formats[$id] = 'phpvmacars';
228 291
         	$globalSources[$id]['format'] = 'vaos';
229 292
         	//$last_exec['phpvmacars'] = 0;
230
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
293
+        	if ($globalDebug) {
294
+        		echo "Connect to vaos source (".$host.")...\n";
295
+        	}
231 296
             } else if (preg_match('/VAM-json.php$/i',$host)) {
232 297
         	//$formats[$id] = 'phpvmacars';
233 298
         	$globalSources[$id]['format'] = 'vam';
234
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
299
+        	if ($globalDebug) {
300
+        		echo "Connect to Vam source (".$host.")...\n";
301
+        	}
235 302
             } else if (preg_match('/whazzup/i',$host)) {
236 303
         	//$formats[$id] = 'whazzup';
237 304
         	$globalSources[$id]['format'] = 'whazzup';
238 305
         	//$last_exec['whazzup'] = 0;
239
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
306
+        	if ($globalDebug) {
307
+        		echo "Connect to whazzup source (".$host.")...\n";
308
+        	}
240 309
             } else if (preg_match('/blitzortung/i',$host)) {
241 310
         	$globalSources[$id]['format'] = 'blitzortung';
242
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
311
+        	if ($globalDebug) {
312
+        		echo "Connect to blitzortung source (".$host.")...\n";
313
+        	}
243 314
             } else if (preg_match('/airwhere/i',$host)) {
244 315
         	$globalSources[$id]['format'] = 'airwhere';
245
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
316
+        	if ($globalDebug) {
317
+        		echo "Connect to airwhere source (".$host.")...\n";
318
+        	}
246 319
             } else if (preg_match('/recentpireps/i',$host)) {
247 320
         	//$formats[$id] = 'pirepsjson';
248 321
         	$globalSources[$id]['format'] = 'pirepsjson';
249 322
         	//$last_exec['pirepsjson'] = 0;
250
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
323
+        	if ($globalDebug) {
324
+        		echo "Connect to pirepsjson source (".$host.")...\n";
325
+        	}
251 326
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
252 327
         	//$formats[$id] = 'fr24json';
253 328
         	$globalSources[$id]['format'] = 'fr24json';
254 329
         	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
330
+        	if ($globalDebug) {
331
+        		echo "Connect to fr24 source (".$host.")...\n";
332
+        	}
256 333
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257 334
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258 335
         	    exit(0);
@@ -261,7 +338,9 @@  discard block
 block discarded – undo
261 338
         	//$formats[$id] = 'fr24json';
262 339
         	$globalSources[$id]['format'] = 'myshiptracking';
263 340
         	//$last_exec['fr24json'] = 0;
264
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
341
+        	if ($globalDebug) {
342
+        		echo "Connect to myshiptracking source (".$host.")...\n";
343
+        	}
265 344
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
266 345
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
267 346
         	    exit(0);
@@ -270,17 +349,26 @@  discard block
 block discarded – undo
270 349
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271 350
         	//$formats[$id] = 'tsv';
272 351
         	$globalSources[$id]['format'] = 'tsv';
273
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
352
+        	if ($globalDebug) {
353
+        		echo "Connect to tsv source (".$host.")...\n";
354
+        	}
274 355
             }
275 356
         } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276 357
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
277 358
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
278 359
     		    if ($idf !== false) {
279 360
     			$httpfeeds[$id] = $idf;
280
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
281
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
282
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
283
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
361
+        		if ($globalDebug) {
362
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
363
+        		}
364
+    		    } elseif ($globalDebug) {
365
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
366
+    		    }
367
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') {
368
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
369
+    		} elseif ($globalDebug) {
370
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
371
+    		}
284 372
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
285 373
 	    $hostport = explode(':',$host);
286 374
 	    if (isset($hostport[1])) {
@@ -320,19 +408,27 @@  discard block
 block discarded – undo
320 408
         		//$formats[$id] = 'beast';
321 409
         		$globalSources[$id]['format'] = 'beast';
322 410
 		    //} else $formats[$id] = 'sbs';
323
-		    } else $globalSources[$id]['format'] = 'sbs';
411
+		    } else {
412
+		    	$globalSources[$id]['format'] = 'sbs';
413
+		    }
324 414
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
325 415
 		}
326
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
416
+		if ($globalDebug) {
417
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
418
+		}
327 419
             } else {
328
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
420
+		if ($globalDebug) {
421
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
422
+		}
329 423
 		sleep(10);
330 424
 		connect_all($hosts);
331 425
     	    }
332 426
         }
333 427
     }
334 428
 }
335
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
429
+if (!isset($globalMinFetch)) {
430
+	$globalMinFetch = 15;
431
+}
336 432
 
337 433
 // Initialize all
338 434
 $status = array();
@@ -341,13 +437,19 @@  discard block
 block discarded – undo
341 437
 $formats = array();
342 438
 $last_exec = array();
343 439
 $time = time();
344
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
345
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
346
-else $timeout = 20;
440
+if (isset($globalSourcesTimeout)) {
441
+	$timeout = $globalSourcesTimeOut;
442
+} else if (isset($globalSBS1TimeOut)) {
443
+	$timeout = $globalSBS1TimeOut;
444
+} else {
445
+	$timeout = 20;
446
+}
347 447
 $errno = '';
348 448
 $errstr='';
349 449
 
350
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
450
+if (!isset($globalDaemon)) {
451
+	$globalDaemon = TRUE;
452
+}
351 453
 /* Initiate connections to all the hosts simultaneously */
352 454
 //connect_all($hosts);
353 455
 //connect_all($globalSources);
@@ -376,7 +478,9 @@  discard block
 block discarded – undo
376 478
     if (isset($source['format']) && $source['format'] == 'aprs') {
377 479
 	$aprs_connect = 0;
378 480
 	$use_aprs = true;
379
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
481
+	if (isset($source['port']) && $source['port'] == '10152') {
482
+		$aprs_full = true;
483
+	}
380 484
 	break;
381 485
     }
382 486
 }
@@ -387,25 +491,46 @@  discard block
 block discarded – undo
387 491
 	$aprs_connect = 0;
388 492
 	$aprs_keep = 120;
389 493
 	$aprs_last_tx = time();
390
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
391
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
392
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
393
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
394
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
395
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
396
-	if ($aprs_full) $aprs_filter = '';
397
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
398
-	else $aprs_pass = '-1';
494
+	if (isset($globalAPRSversion)) {
495
+		$aprs_version = $globalAPRSversion;
496
+	} else {
497
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
498
+	}
499
+	if (isset($globalAPRSssid)) {
500
+		$aprs_ssid = $globalAPRSssid;
501
+	} else {
502
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
503
+	}
504
+	if (isset($globalAPRSfilter)) {
505
+		$aprs_filter = $globalAPRSfilter;
506
+	} else {
507
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
508
+	}
509
+	if ($aprs_full) {
510
+		$aprs_filter = '';
511
+	}
512
+	if (isset($globalAPRSpass)) {
513
+		$aprs_pass = $globalAPRSpass;
514
+	} else {
515
+		$aprs_pass = '-1';
516
+	}
399 517
 
400
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
401
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
402
-}
518
+	if ($aprs_filter != '') {
519
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
520
+	} else {
521
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
522
+	}
523
+	}
403 524
 
404 525
 // connected - lets do some work
405 526
 //if ($globalDebug) echo "Connected!\n";
406 527
 sleep(1);
407
-if ($globalDebug) echo "SCAN MODE \n\n";
408
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
528
+if ($globalDebug) {
529
+	echo "SCAN MODE \n\n";
530
+}
531
+if (!isset($globalCronEnd)) {
532
+	$globalCronEnd = 60;
533
+}
409 534
 $endtime = time()+$globalCronEnd;
410 535
 $i = 1;
411 536
 $tt = array();
@@ -419,22 +544,32 @@  discard block
 block discarded – undo
419 544
 
420 545
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
421 546
 while ($i > 0) {
422
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
547
+    if (function_exists('pcntl_fork')) {
548
+    	pcntl_signal_dispatch();
549
+    }
423 550
 
424
-    if (!$globalDaemon) $i = $endtime-time();
551
+    if (!$globalDaemon) {
552
+    	$i = $endtime-time();
553
+    }
425 554
     // Delete old ATC
426 555
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
427
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
556
+	if ($globalDebug) {
557
+		echo 'Delete old ATC...'."\n";
558
+	}
428 559
         $ATC->deleteOldATC();
429 560
     }
430 561
     
431 562
     if (count($last_exec) == count($globalSources)) {
432 563
 	$max = $globalMinFetch;
433 564
 	foreach ($last_exec as $last) {
434
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
565
+	    if ((time() - $last['last']) < $max) {
566
+	    	$max = time() - $last['last'];
567
+	    }
435 568
 	}
436 569
 	if ($max < $globalMinFetch) {
437
-	    if ($globalDebug) echo 'Sleeping...'."\n";
570
+	    if ($globalDebug) {
571
+	    	echo 'Sleeping...'."\n";
572
+	    }
438 573
 	    sleep($globalMinFetch-$max+2);
439 574
 	}
440 575
     }
@@ -444,7 +579,9 @@  discard block
 block discarded – undo
444 579
     foreach ($globalSources as $id => $value) {
445 580
 	date_default_timezone_set('UTC');
446 581
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
447
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
582
+	if (!isset($last_exec[$id]['last'])) {
583
+		$last_exec[$id]['last'] = 0;
584
+	}
448 585
 	if ($value['format'] === 'deltadbtxt' && 
449 586
 	    (
450 587
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -453,7 +590,9 @@  discard block
 block discarded – undo
453 590
 	) {
454 591
         //$buffer = $Common->getData($hosts[$id]);
455 592
         $buffer = $Common->getData($value['host']);
456
-        if ($buffer != '') $reset = 0;
593
+        if ($buffer != '') {
594
+        	$reset = 0;
595
+        }
457 596
         $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
458 597
         $buffer = explode('\n', $buffer);
459 598
         foreach ($buffer as $line) {
@@ -462,20 +601,41 @@  discard block
 block discarded – undo
462 601
                 $data = array();
463 602
                 $data['hex'] = $line[1]; // hex
464 603
                 $data['ident'] = $line[2]; // ident
465
-                if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
466
-                if (isset($line[4])) $data['speed'] = $line[4]; // speed
467
-                if (isset($line[5])) $data['heading'] = $line[5]; // heading
468
-                if (isset($line[6])) $data['latitude'] = $line[6]; // lat
469
-                if (isset($line[7])) $data['longitude'] = $line[7]; // long
604
+                if (isset($line[3])) {
605
+                	$data['altitude'] = $line[3];
606
+                }
607
+                // altitude
608
+                if (isset($line[4])) {
609
+                	$data['speed'] = $line[4];
610
+                }
611
+                // speed
612
+                if (isset($line[5])) {
613
+                	$data['heading'] = $line[5];
614
+                }
615
+                // heading
616
+                if (isset($line[6])) {
617
+                	$data['latitude'] = $line[6];
618
+                }
619
+                // lat
620
+                if (isset($line[7])) {
621
+                	$data['longitude'] = $line[7];
622
+                }
623
+                // long
470 624
                 $data['verticalrate'] = ''; // vertical rate
471 625
                 //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
472 626
                 $data['emergency'] = ''; // emergency
473 627
                 $data['datetime'] = date('Y-m-d H:i:s');
474 628
                 $data['format_source'] = 'deltadbtxt';
475 629
                 $data['id_source'] = $id_source;
476
-                if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
477
-                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
478
-                if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
630
+                if (isset($value['name']) && $value['name'] != '') {
631
+                	$data['source_name'] = $value['name'];
632
+                }
633
+                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
634
+                	$data['noarchive'] = true;
635
+                }
636
+                if (isset($value['sourcestats'])) {
637
+                	$data['sourcestats'] = $value['sourcestats'];
638
+                }
479 639
                 $SI->add($data);
480 640
                 unset($data);
481 641
             }
@@ -509,10 +669,17 @@  discard block
 block discarded – undo
509 669
                     $data['datetime'] = date('Y-m-d H:i:s');
510 670
                     $data['format_source'] = 'radarcapejson';
511 671
                     $data['id_source'] = $id_source;
512
-                    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
513
-                    elseif($line['src'] == 'M') $data['source_name'] = 'MLAT';
514
-                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
515
-                    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
672
+                    if (isset($value['name']) && $value['name'] != '') {
673
+                    	$data['source_name'] = $value['name'];
674
+                    } elseif($line['src'] == 'M') {
675
+                    	$data['source_name'] = 'MLAT';
676
+                    }
677
+                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
678
+                    	$data['noarchive'] = true;
679
+                    }
680
+                    if (isset($value['sourcestats'])) {
681
+                    	$data['sourcestats'] = $value['sourcestats'];
682
+                    }
516 683
 
517 684
                     $SI->add($data);
518 685
                     unset($data);
@@ -528,7 +695,9 @@  discard block
 block discarded – undo
528 695
 	    date_default_timezone_set('CET');
529 696
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
530 697
 	    date_default_timezone_set('UTC');
531
-	    if ($buffer != '') $reset = 0;
698
+	    if ($buffer != '') {
699
+	    	$reset = 0;
700
+	    }
532 701
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
533 702
 	    $buffer = explode('\n',$buffer);
534 703
 	    foreach ($buffer as $line) {
@@ -537,18 +706,42 @@  discard block
 block discarded – undo
537 706
 		    $add = false;
538 707
 		    $ais_data = $AIS->parse_line(trim($line));
539 708
 		    $data = array();
540
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
541
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
542
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
543
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
544
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
545
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
546
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
547
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
548
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
549
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
550
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
551
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
709
+		    if (isset($ais_data['ident'])) {
710
+		    	$data['ident'] = $ais_data['ident'];
711
+		    }
712
+		    if (isset($ais_data['mmsi'])) {
713
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
714
+		    }
715
+		    if (isset($ais_data['speed'])) {
716
+		    	$data['speed'] = $ais_data['speed'];
717
+		    }
718
+		    if (isset($ais_data['heading'])) {
719
+		    	$data['heading'] = $ais_data['heading'];
720
+		    }
721
+		    if (isset($ais_data['latitude'])) {
722
+		    	$data['latitude'] = $ais_data['latitude'];
723
+		    }
724
+		    if (isset($ais_data['longitude'])) {
725
+		    	$data['longitude'] = $ais_data['longitude'];
726
+		    }
727
+		    if (isset($ais_data['status'])) {
728
+		    	$data['status'] = $ais_data['status'];
729
+		    }
730
+		    if (isset($ais_data['statusid'])) {
731
+		    	$data['status_id'] = $ais_data['statusid'];
732
+		    }
733
+		    if (isset($ais_data['type'])) {
734
+		    	$data['type'] = $ais_data['type'];
735
+		    }
736
+		    if (isset($ais_data['typeid'])) {
737
+		    	$data['type_id'] = $ais_data['typeid'];
738
+		    }
739
+		    if (isset($ais_data['imo'])) {
740
+		    	$data['imo'] = $ais_data['imo'];
741
+		    }
742
+		    if (isset($ais_data['callsign'])) {
743
+		    	$data['callsign'] = $ais_data['callsign'];
744
+		    }
552 745
 		    if (isset($ais_data['timestamp'])) {
553 746
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
554 747
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -562,8 +755,12 @@  discard block
 block discarded – undo
562 755
 		    $data['format_source'] = 'aisnmeatxt';
563 756
     		    $data['id_source'] = $id_source;
564 757
 		    //print_r($data);
565
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
566
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
758
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
759
+		    	$data['noarchive'] = true;
760
+		    }
761
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
762
+		    	$MI->add($data);
763
+		    }
567 764
 		    unset($data);
568 765
 		}
569 766
     	    }
@@ -586,20 +783,48 @@  discard block
 block discarded – undo
586 783
 			    if ($line != '') {
587 784
 				$ais_data = $AIS->parse_line(trim($line));
588 785
 				$data = array();
589
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
590
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
591
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
592
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
593
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
594
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
595
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
596
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
597
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
598
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
599
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
600
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
601
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
602
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
786
+				if (isset($ais_data['ident'])) {
787
+					$data['ident'] = $ais_data['ident'];
788
+				}
789
+				if (isset($ais_data['mmsi'])) {
790
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
791
+				}
792
+				if (isset($ais_data['speed'])) {
793
+					$data['speed'] = $ais_data['speed'];
794
+				}
795
+				if (isset($ais_data['heading'])) {
796
+					$data['heading'] = $ais_data['heading'];
797
+				}
798
+				if (isset($ais_data['latitude'])) {
799
+					$data['latitude'] = $ais_data['latitude'];
800
+				}
801
+				if (isset($ais_data['longitude'])) {
802
+					$data['longitude'] = $ais_data['longitude'];
803
+				}
804
+				if (isset($ais_data['status'])) {
805
+					$data['status'] = $ais_data['status'];
806
+				}
807
+				if (isset($ais_data['statusid'])) {
808
+					$data['status_id'] = $ais_data['statusid'];
809
+				}
810
+				if (isset($ais_data['type'])) {
811
+					$data['type'] = $ais_data['type'];
812
+				}
813
+				if (isset($ais_data['typeid'])) {
814
+					$data['type_id'] = $ais_data['typeid'];
815
+				}
816
+				if (isset($ais_data['imo'])) {
817
+					$data['imo'] = $ais_data['imo'];
818
+				}
819
+				if (isset($ais_data['callsign'])) {
820
+					$data['callsign'] = $ais_data['callsign'];
821
+				}
822
+				if (isset($ais_data['destination'])) {
823
+					$data['arrival_code'] = $ais_data['destination'];
824
+				}
825
+				if (isset($ais_data['eta_ts'])) {
826
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
827
+				}
603 828
 				if (isset($ais_data['timestamp'])) {
604 829
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
605 830
 				} else {
@@ -607,18 +832,27 @@  discard block
 block discarded – undo
607 832
 				}
608 833
 				$data['format_source'] = 'aisnmeahttp';
609 834
 				$data['id_source'] = $id_source;
610
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
611
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
835
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
836
+					$data['noarchive'] = true;
837
+				}
838
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
839
+					$MI->add($data);
840
+				}
612 841
 				unset($data);
613 842
 			    }
614 843
 			}
615 844
 		    }
616 845
 		} else {
617 846
 		    $format = $value['format'];
618
-		    if (isset($tt[$format])) $tt[$format]++;
619
-		    else $tt[$format] = 0;
847
+		    if (isset($tt[$format])) {
848
+		    	$tt[$format]++;
849
+		    } else {
850
+		    	$tt[$format] = 0;
851
+		    }
620 852
 		    if ($tt[$format] > 30) {
621
-			if ($globalDebug) echo 'Reconnect...'."\n";
853
+			if ($globalDebug) {
854
+				echo 'Reconnect...'."\n";
855
+			}
622 856
 			sleep(2);
623 857
 			//$sourceeen[] = $value;
624 858
 			//connect_all($sourceeen);
@@ -654,12 +888,18 @@  discard block
 block discarded – undo
654 888
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
655 889
 			    //$data['type_id'] = $line['TYPE'];
656 890
 			    $data['imo'] = $line['IMO'];
657
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
658
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
891
+			    if ($line['DEST'] != '') {
892
+			    	$data['arrival_code'] = $line['DEST'];
893
+			    }
894
+			    if ($line['ARV'] != '') {
895
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
896
+			    }
659 897
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
660 898
 			    $data['format_source'] = 'myshiptracking';
661 899
 			    $data['id_source'] = $id_source;
662
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
900
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
901
+			    	$data['noarchive'] = true;
902
+			    }
663 903
 			    $MI->add($data);
664 904
 			    unset($data);
665 905
 			}
@@ -684,7 +924,9 @@  discard block
 block discarded – undo
684 924
 			    $data['callsign'] = $line['callsign'];
685 925
 			    $data['mmsi'] = substr($line['mmsi'],-9);
686 926
 			    $data['speed'] = $line['sog'];
687
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
927
+			    if ($line['heading'] != '511') {
928
+			    	$data['heading'] = $line['heading'];
929
+			    }
688 930
 			    $data['latitude'] = $line['latitude'];
689 931
 			    $data['longitude'] = $line['longitude'];
690 932
 			    $data['type_id'] = $line['shiptype'];
@@ -692,7 +934,9 @@  discard block
 block discarded – undo
692 934
 			    $data['datetime'] = $line['time'];
693 935
 			    $data['format_source'] = 'boatbeaconapp';
694 936
 			    $data['id_source'] = $id_source;
695
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
937
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
938
+			    	$data['noarchive'] = true;
939
+			    }
696 940
 			    $MI->add($data);
697 941
 			    unset($data);
698 942
 			}
@@ -714,22 +958,44 @@  discard block
 block discarded – undo
714 958
 		    foreach ($all_data['features'] as $line) {
715 959
 			print_r($line);
716 960
 			$data = array();
717
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
718
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
719
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
720
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
721
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
722
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
961
+			if (isset($line['properties']['name'])) {
962
+				$data['ident'] = $line['properties']['name'];
963
+			}
964
+			if (isset($line['properties']['callsign'])) {
965
+				$data['callsign'] = $line['properties']['callsign'];
966
+			}
967
+			if (isset($line['properties']['mmsi'])) {
968
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
969
+			}
970
+			if (isset($line['properties']['imo'])) {
971
+				$data['imo'] = $line['properties']['imo'];
972
+			}
973
+			if (isset($line['properties']['speed'])) {
974
+				$data['speed'] = $line['properties']['speed'];
975
+			}
976
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
977
+				$data['heading'] = $line['properties']['heading'];
978
+			}
723 979
 			$data['latitude'] = $line['geometry']['coordinates'][1];
724 980
 			$data['longitude'] = $line['geometry']['coordinates'][0];
725
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
726
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
727
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
981
+			if (isset($line['properties']['vesselType'])) {
982
+				$data['type'] = $line['properties']['vesselType'];
983
+			}
984
+			if (isset($line['properties']['destination'])) {
985
+				$data['arrival_code'] = $line['properties']['destination'];
986
+			}
987
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
988
+				$data['arrival_date'] = $line['properties']['eta'];
989
+			}
728 990
 			$data['format_source'] = 'boatnerd';
729 991
 			$data['id_source'] = $id_source;
730 992
 			$data['datetime'] = date('Y-m-d H:i:s');
731
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
732
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
993
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
994
+				$data['noarchive'] = true;
995
+			}
996
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
997
+				$MI->add($data);
998
+			}
733 999
 			unset($data);
734 1000
 		    }
735 1001
 		}
@@ -742,11 +1008,17 @@  discard block
 block discarded – undo
742 1008
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
743 1009
 	    )
744 1010
 	) {
745
-	    if ($globalDebug) echo 'download...';
1011
+	    if ($globalDebug) {
1012
+	    	echo 'download...';
1013
+	    }
746 1014
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
747
-	    if ($globalDebug) echo 'done !'."\n";
1015
+	    if ($globalDebug) {
1016
+	    	echo 'done !'."\n";
1017
+	    }
748 1018
 	    // FIXME: Need more work
749
-	    if ($buffer != '') $reset = 0;
1019
+	    if ($buffer != '') {
1020
+	    	$reset = 0;
1021
+	    }
750 1022
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
751 1023
 	    $buffer = explode('\n',$buffer);
752 1024
 	    foreach ($buffer as $line) {
@@ -772,7 +1044,9 @@  discard block
 block discarded – undo
772 1044
 		    //$data['etaTime'] = substr($line,135,5);
773 1045
 		    $data['format_source'] = 'shipplotter';
774 1046
     		    $data['id_source'] = $id_source;
775
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1047
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1048
+		    	$data['noarchive'] = true;
1049
+		    }
776 1050
 		    //print_r($data);
777 1051
 		    //echo 'Add...'."\n";
778 1052
 		    $MI->add($data);
@@ -795,11 +1069,17 @@  discard block
 block discarded – undo
795 1069
 		}
796 1070
 	    }
797 1071
 
798
-	    if ($globalDebug) echo '! Download... ';
1072
+	    if ($globalDebug) {
1073
+	    	echo '! Download... ';
1074
+	    }
799 1075
 	    for ($i =0; $i <= 1; $i++) {
800
-		if ($globalDebug) echo 'Racetype: '.$i.' ';
1076
+		if ($globalDebug) {
1077
+			echo 'Racetype: '.$i.' ';
1078
+		}
801 1079
 		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
802
-	    if ($globalDebug) echo 'done'."\n";
1080
+	    if ($globalDebug) {
1081
+	    	echo 'done'."\n";
1082
+	    }
803 1083
 	    if ($buffer != '') {
804 1084
 		$all_data = json_decode($buffer,true);
805 1085
 		if (isset($all_data['missions'])) {
@@ -807,8 +1087,11 @@  discard block
 block discarded – undo
807 1087
 				$mission_user = $mission['usrname'];
808 1088
 				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
809 1089
 				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
810
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
811
-					else $racebuffer = '';
1090
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') {
1091
+						$racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
1092
+					} else {
1093
+						$racebuffer = '';
1094
+					}
812 1095
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
813 1096
 				} else {
814 1097
 					$bufferm = '';
@@ -872,7 +1155,9 @@  discard block
 block discarded – undo
872 1155
 								$data['captain_id'] = $sail['usrnr'];
873 1156
 								$data['captain_name'] = $sail['usrname'];
874 1157
 								$data['race_id'] = $sail['misnr'];
875
-								if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank'];
1158
+								if ($sail['rank'] != 'DNF') {
1159
+									$data['race_rank'] = $sail['rank'];
1160
+								}
876 1161
 								$data['race_time'] = $sail['racetime'];
877 1162
 								if ($mission_user != '') {
878 1163
 									$data['race_name'] = $mission_name.' ('.$mission_user.')';
@@ -882,7 +1167,9 @@  discard block
 block discarded – undo
882 1167
 								//$data['callsign'] = trim(substr($line,100,7);
883 1168
 								$data['format_source'] = 'sailaway';
884 1169
 								$data['id_source'] = $id_source;
885
-								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1170
+								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1171
+									$data['noarchive'] = true;
1172
+								}
886 1173
 								//print_r($data);
887 1174
 								//if ($data['race_id'] == '48') print_r($data);
888 1175
 								//echo 'Add...'."\n";
@@ -924,16 +1211,28 @@  discard block
 block discarded – undo
924 1211
     		    $line = explode(':', $line);
925 1212
     		    if (count($line) > 30 && $line[0] != 'callsign') {
926 1213
 			$data = array();
927
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
928
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1214
+			if (isset($line[37]) && $line[37] != '') {
1215
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1216
+			} else {
1217
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1218
+			}
929 1219
 			$data['pilot_id'] = $line[1];
930 1220
 			$data['pilot_name'] = $line[2];
931 1221
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
932 1222
 			$data['ident'] = $line[0]; // ident
933
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1223
+			if ($line[7] != '' && $line[7] != 0) {
1224
+				$data['altitude'] = $line[7];
1225
+			}
1226
+			// altitude
934 1227
 			$data['speed'] = $line[8]; // speed
935
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
936
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1228
+			if (isset($line[45])) {
1229
+				$data['heading'] = $line[45];
1230
+			}
1231
+			// heading
1232
+			elseif (isset($line[38])) {
1233
+				$data['heading'] = $line[38];
1234
+			}
1235
+			// heading
937 1236
 			$data['latitude'] = $line[5]; // lat
938 1237
 	        	$data['longitude'] = $line[6]; // long
939 1238
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -949,7 +1248,9 @@  discard block
 block discarded – undo
949 1248
 			$data['frequency'] = $line[4];
950 1249
 			$data['type'] = $line[18];
951 1250
 			$data['range'] = $line[19];
952
-			if (isset($line[35])) $data['info'] = $line[35];
1251
+			if (isset($line[35])) {
1252
+				$data['info'] = $line[35];
1253
+			}
953 1254
     			$data['id_source'] = $id_source;
954 1255
 	    		//$data['arrival_airport_time'] = ;
955 1256
 	    		if ($line[9] != '') {
@@ -963,27 +1264,47 @@  discard block
 block discarded – undo
963 1264
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
964 1265
 	    		*/
965 1266
 	    		$data['format_source'] = $value['format'];
966
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
967
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
968
-    			if ($line[3] === 'PILOT') $SI->add($data);
969
-			elseif ($line[3] === 'ATC') {
1267
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1268
+				$data['noarchive'] = true;
1269
+			}
1270
+			if (isset($value['name']) && $value['name'] != '') {
1271
+				$data['source_name'] = $value['name'];
1272
+			}
1273
+    			if ($line[3] === 'PILOT') {
1274
+    				$SI->add($data);
1275
+    			} elseif ($line[3] === 'ATC') {
970 1276
 				//print_r($data);
971 1277
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
972 1278
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
973 1279
 				$typec = substr($data['ident'],-3);
974
-				if ($typec === 'APP') $data['type'] = 'Approach';
975
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
976
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
977
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
978
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
979
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
980
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
981
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
982
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
983
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1280
+				if ($typec === 'APP') {
1281
+					$data['type'] = 'Approach';
1282
+				} elseif ($typec === 'TWR') {
1283
+					$data['type'] = 'Tower';
1284
+				} elseif ($typec === 'OBS') {
1285
+					$data['type'] = 'Observer';
1286
+				} elseif ($typec === 'GND') {
1287
+					$data['type'] = 'Ground';
1288
+				} elseif ($typec === 'DEL') {
1289
+					$data['type'] = 'Delivery';
1290
+				} elseif ($typec === 'DEP') {
1291
+					$data['type'] = 'Departure';
1292
+				} elseif ($typec === 'FSS') {
1293
+					$data['type'] = 'Flight Service Station';
1294
+				} elseif ($typec === 'CTR') {
1295
+					$data['type'] = 'Control Radar or Centre';
1296
+				} elseif ($data['type'] === '') {
1297
+					$data['type'] = 'Observer';
1298
+				}
1299
+				if (!isset($data['source_name'])) {
1300
+					$data['source_name'] = '';
1301
+				}
984 1302
 				if (isset($ATC)) {
985
-					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']);
986
-					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']);
1303
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1304
+						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']);
1305
+					} else {
1306
+						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']);
1307
+					}
987 1308
 				}
988 1309
 			}
989 1310
     			unset($data);
@@ -1010,14 +1331,20 @@  discard block
 block discarded – undo
1010 1331
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1011 1332
 			$data['latitude'] = (float)$line['pktLatitude'];
1012 1333
 			$data['longitude'] = (float)$line['pktLongitude'];
1013
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1014
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1334
+			if ((float)$line['pktTrack'] != 0) {
1335
+				$data['heading'] = (float)$line['pktTrack'];
1336
+			}
1337
+			if ((int)$line['pktSpeed'] != 0) {
1338
+				$data['speed'] = (int)$line['pktSpeed'];
1339
+			}
1015 1340
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1016 1341
 			$data['altitude_relative'] = 'AMSL';
1017 1342
 			$data['pilot_id'] = (int)$line['pktPilotID'];
1018 1343
 			$data['aircraft_icao'] = 'PARAGLIDER';
1019 1344
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1020
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1345
+			if (isset($pilot_data[4])) {
1346
+				$data['pilot_name'] = $pilot_data[4];
1347
+			}
1021 1348
 			$data['format_source'] = $value['format'];
1022 1349
 			$SI->add($data);
1023 1350
 			unset($data);
@@ -1065,25 +1392,59 @@  discard block
 block discarded – undo
1065 1392
 		    foreach ($all_data['acList'] as $line) {
1066 1393
 			$data = array();
1067 1394
 			$data['hex'] = $line['Icao']; // hex
1068
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1069
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1070
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1071
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1072
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1073
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1395
+			if (isset($line['Call'])) {
1396
+				$data['ident'] = $line['Call'];
1397
+			}
1398
+			// ident
1399
+			if (isset($line['Alt'])) {
1400
+				$data['altitude'] = $line['Alt'];
1401
+			}
1402
+			// altitude
1403
+			if (isset($line['Spd'])) {
1404
+				$data['speed'] = $line['Spd'];
1405
+			}
1406
+			// speed
1407
+			if (isset($line['Trak'])) {
1408
+				$data['heading'] = $line['Trak'];
1409
+			}
1410
+			// heading
1411
+			if (isset($line['Lat'])) {
1412
+				$data['latitude'] = $line['Lat'];
1413
+			}
1414
+			// lat
1415
+			if (isset($line['Long'])) {
1416
+				$data['longitude'] = $line['Long'];
1417
+			}
1418
+			// long
1074 1419
 			//$data['verticalrate'] = $line['']; // verticale rate
1075
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1420
+			if (isset($line['Sqk'])) {
1421
+				$data['squawk'] = $line['Sqk'];
1422
+			}
1423
+			// squawk
1076 1424
 			$data['emergency'] = ''; // emergency
1077
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1078
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1079
-			else $data['datetime'] = date('Y-m-d H:i:s');
1425
+			if (isset($line['Reg'])) {
1426
+				$data['registration'] = $line['Reg'];
1427
+			}
1428
+			if (isset($line['PosTime'])) {
1429
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1430
+			} else {
1431
+				$data['datetime'] = date('Y-m-d H:i:s');
1432
+			}
1080 1433
 			//$data['datetime'] = date('Y-m-d H:i:s');
1081
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1434
+			if (isset($line['Type'])) {
1435
+				$data['aircraft_icao'] = $line['Type'];
1436
+			}
1082 1437
 			$data['format_source'] = 'aircraftlistjson';
1083 1438
 			$data['id_source'] = $id_source;
1084
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1085
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1086
-			if (isset($data['latitude'])) $SI->add($data);
1439
+			if (isset($value['name']) && $value['name'] != '') {
1440
+				$data['source_name'] = $value['name'];
1441
+			}
1442
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1443
+				$data['noarchive'] = true;
1444
+			}
1445
+			if (isset($data['latitude'])) {
1446
+				$SI->add($data);
1447
+			}
1087 1448
 			unset($data);
1088 1449
 		    }
1089 1450
 		} elseif (is_array($all_data)) {
@@ -1100,17 +1461,26 @@  discard block
 block discarded – undo
1100 1461
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1101 1462
 			$data['squawk'] = $line['squawk']; // squawk
1102 1463
 			$data['emergency'] = ''; // emergency
1103
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1104
-			else $data['datetime'] = date('Y-m-d H:i:s');
1464
+			if (isset($line['PosTime'])) {
1465
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1466
+			} else {
1467
+				$data['datetime'] = date('Y-m-d H:i:s');
1468
+			}
1105 1469
 			$data['format_source'] = 'aircraftlistjson';
1106 1470
 			$data['id_source'] = $id_source;
1107
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1108
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1471
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1472
+				$data['noarchive'] = true;
1473
+			}
1474
+			if (isset($value['name']) && $value['name'] != '') {
1475
+				$data['source_name'] = $value['name'];
1476
+			}
1109 1477
 			$SI->add($data);
1110 1478
 			unset($data);
1111 1479
 		    }
1112 1480
 		}
1113
-	    } elseif ($globalDebug) echo 'No data'."\n";
1481
+	    } elseif ($globalDebug) {
1482
+	    	echo 'No data'."\n";
1483
+	    }
1114 1484
     	    //$last_exec['aircraftlistjson'] = time();
1115 1485
     	    $last_exec[$id]['last'] = time();
1116 1486
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -1146,8 +1516,12 @@  discard block
 block discarded – undo
1146 1516
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1147 1517
 	    	    $data['format_source'] = 'planeupdatefaa';
1148 1518
     		    $data['id_source'] = $id_source;
1149
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1150
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1519
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1520
+		    	$data['noarchive'] = true;
1521
+		    }
1522
+		    if (isset($value['name']) && $value['name'] != '') {
1523
+		    	$data['source_name'] = $value['name'];
1524
+		    }
1151 1525
 		    $SI->add($data);
1152 1526
 		    unset($data);
1153 1527
 		}
@@ -1181,7 +1555,9 @@  discard block
 block discarded – undo
1181 1555
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1182 1556
 		    $data['format_source'] = 'opensky';
1183 1557
 		    $data['id_source'] = $id_source;
1184
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1558
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1559
+		    	$data['noarchive'] = true;
1560
+		    }
1185 1561
 		    $SI->add($data);
1186 1562
 		    unset($data);
1187 1563
 		}
@@ -1201,15 +1577,42 @@  discard block
 block discarded – undo
1201 1577
 		foreach ($all_data['aircraft'] as $key => $line) {
1202 1578
 		    $data = array();
1203 1579
 		    // add support for ground vehicule with ~ in front of hex
1204
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1205
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1206
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1207
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1208
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1209
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1210
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1211
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1212
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1580
+		    if (isset($line['hex'])) {
1581
+		    	$data['hex'] = $line['hex'];
1582
+		    }
1583
+		    // hex
1584
+		    if (isset($line['flight'])) {
1585
+		    	$data['ident'] = trim($line['flight']);
1586
+		    }
1587
+		    // ident
1588
+		    if (isset($line['altitude'])) {
1589
+		    	$data['altitude'] = $line['altitude'];
1590
+		    }
1591
+		    // altitude
1592
+		    if (isset($line['speed'])) {
1593
+		    	$data['speed'] = $line['speed'];
1594
+		    }
1595
+		    // speed
1596
+		    if (isset($line['track'])) {
1597
+		    	$data['heading'] = $line['track'];
1598
+		    }
1599
+		    // heading
1600
+		    if (isset($line['lat'])) {
1601
+		    	$data['latitude'] = $line['lat'];
1602
+		    }
1603
+		    // lat
1604
+		    if (isset($line['lon'])) {
1605
+		    	$data['longitude'] = $line['lon'];
1606
+		    }
1607
+		    // long
1608
+		    if (isset($line['vert_rate'])) {
1609
+		    	$data['verticalrate'] = $line['vert_rate'];
1610
+		    }
1611
+		    // verticale rate
1612
+		    if (isset($line['squawk'])) {
1613
+		    	$data['squawk'] = $line['squawk'];
1614
+		    }
1615
+		    // squawk
1213 1616
 		    //$data['emergency'] = ''; // emergency
1214 1617
 		    //$data['registration'] = $line[2];
1215 1618
 		    //$data['aircraft_icao'] = $line[0];
@@ -1217,10 +1620,17 @@  discard block
 block discarded – undo
1217 1620
 		    $data['format_source'] = 'aircraftjson';
1218 1621
 		    $data['id_source'] = $id_source;
1219 1622
 		    if (isset($value['name']) && $value['name'] != '') {
1220
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1221
-			    else $data['source_name'] = $value['name'];
1222
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1223
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1623
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1624
+			    	$data['source_name'] = $value['name'].'_MLAT';
1625
+			    } else {
1626
+			    	$data['source_name'] = $value['name'];
1627
+			    }
1628
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1629
+		    	$data['source_name'] = 'MLAT';
1630
+		    }
1631
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1632
+		    	$data['noarchive'] = true;
1633
+		    }
1224 1634
 		    $SI->add($data);
1225 1635
 		    unset($data);
1226 1636
 		}
@@ -1240,22 +1650,54 @@  discard block
 block discarded – undo
1240 1650
 		foreach ($all_data['aircraft'] as $key => $line) {
1241 1651
 		    $data = array();
1242 1652
 		    $data['hex'] = $key; // hex
1243
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1244
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1245
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1246
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1247
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1248
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1249
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1250
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1653
+		    if (isset($line['callsign'])) {
1654
+		    	$data['ident'] = trim($line['callsign']);
1655
+		    }
1656
+		    // ident
1657
+		    if (isset($line['altitude'])) {
1658
+		    	$data['altitude'] = $line['altitude'];
1659
+		    }
1660
+		    // altitude
1661
+		    if (isset($line['speed'])) {
1662
+		    	$data['speed'] = $line['speed'];
1663
+		    }
1664
+		    // speed
1665
+		    if (isset($line['heading'])) {
1666
+		    	$data['heading'] = $line['heading'];
1667
+		    }
1668
+		    // heading
1669
+		    if (isset($line['lat'])) {
1670
+		    	$data['latitude'] = $line['lat'];
1671
+		    }
1672
+		    // lat
1673
+		    if (isset($line['lon'])) {
1674
+		    	$data['longitude'] = $line['lon'];
1675
+		    }
1676
+		    // long
1677
+		    if (isset($line['vert_rate'])) {
1678
+		    	$data['verticalrate'] = $line['vert_rate'];
1679
+		    }
1680
+		    // verticale rate
1681
+		    if (isset($line['squawk'])) {
1682
+		    	$data['squawk'] = $line['squawk'];
1683
+		    }
1684
+		    // squawk
1251 1685
 		    //$data['emergency'] = ''; // emergency
1252
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1253
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1686
+		    if (isset($line['reg'])) {
1687
+		    	$data['registration'] = $line['reg'];
1688
+		    }
1689
+		    if (isset($line['type'])) {
1690
+		    	$data['aircraft_icao'] = $line['type'];
1691
+		    }
1254 1692
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1255 1693
 		    $data['format_source'] = 'planefinderclient';
1256 1694
 		    $data['id_source'] = $id_source;
1257
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1258
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1695
+		    if (isset($value['name']) && $value['name'] != '') {
1696
+		    	$data['source_name'] = $value['name'];
1697
+		    }
1698
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1699
+		    	$data['noarchive'] = true;
1700
+		    }
1259 1701
 		    $SI->add($data);
1260 1702
 		    unset($data);
1261 1703
 		}
@@ -1271,7 +1713,9 @@  discard block
 block discarded – undo
1271 1713
 	    //$buffer = $Common->getData($hosts[$id]);
1272 1714
 	    $buffer = $Common->getData($value['host']);
1273 1715
 	    $all_data = json_decode($buffer,true);
1274
-	    if (!empty($all_data)) $reset = 0;
1716
+	    if (!empty($all_data)) {
1717
+	    	$reset = 0;
1718
+	    }
1275 1719
 	    foreach ($all_data as $key => $line) {
1276 1720
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1277 1721
 		    $data = array();
@@ -1292,8 +1736,12 @@  discard block
 block discarded – undo
1292 1736
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1293 1737
 	    	    $data['format_source'] = 'fr24json';
1294 1738
     		    $data['id_source'] = $id_source;
1295
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1296
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1739
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1740
+		    	$data['noarchive'] = true;
1741
+		    }
1742
+		    if (isset($value['name']) && $value['name'] != '') {
1743
+		    	$data['source_name'] = $value['name'];
1744
+		    }
1297 1745
 		    $SI->add($data);
1298 1746
 		    unset($data);
1299 1747
 		}
@@ -1322,24 +1770,42 @@  discard block
 block discarded – undo
1322 1770
 		    if (isset($line['inf'])) {
1323 1771
 			$data = array();
1324 1772
 			$data['hex'] = $line['inf']['ia'];
1325
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1773
+			if (isset($line['inf']['cs'])) {
1774
+				$data['ident'] = $line['inf']['cs'];
1775
+			}
1776
+			//$line[13]
1326 1777
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1327
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1328
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1778
+	    		if (isset($line['inf']['gs'])) {
1779
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1780
+	    		}
1781
+	    		// speed
1782
+	    		if (isset($line['inf']['tr'])) {
1783
+	    			$data['heading'] = $line['inf']['tr'];
1784
+	    		}
1785
+	    		// heading
1329 1786
 	    		$data['latitude'] = $line['pt'][0]; // lat
1330 1787
 	    		$data['longitude'] = $line['pt'][1]; // long
1331 1788
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1332
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1789
+	    		if (isset($line['inf']['sq'])) {
1790
+	    			$data['squawk'] = $line['inf']['sq'];
1791
+	    		}
1792
+	    		// squawk
1333 1793
 	    		//$data['aircraft_icao'] = $line[8];
1334
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1794
+	    		if (isset($line['inf']['rc'])) {
1795
+	    			$data['registration'] = $line['inf']['rc'];
1796
+	    		}
1335 1797
 			//$data['departure_airport_iata'] = $line[11];
1336 1798
 			//$data['arrival_airport_iata'] = $line[12];
1337 1799
 	    		//$data['emergency'] = ''; // emergency
1338 1800
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1339 1801
 	    		$data['format_source'] = 'radarvirtueljson';
1340 1802
     			$data['id_source'] = $id_source;
1341
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1342
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1803
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1804
+				$data['noarchive'] = true;
1805
+			}
1806
+			if (isset($value['name']) && $value['name'] != '') {
1807
+				$data['source_name'] = $value['name'];
1808
+			}
1343 1809
 			$SI->add($data);
1344 1810
 			unset($data);
1345 1811
 		    }
@@ -1365,30 +1831,65 @@  discard block
 block discarded – undo
1365 1831
 		    $data['id'] = $line['id'];
1366 1832
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1367 1833
 		    $data['ident'] = $line['callsign']; // ident
1368
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1369
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1370
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1371
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1372
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1373
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1834
+		    if (isset($line['pilotid'])) {
1835
+		    	$data['pilot_id'] = $line['pilotid'];
1836
+		    }
1837
+		    // pilot id
1838
+		    if (isset($line['name'])) {
1839
+		    	$data['pilot_name'] = $line['name'];
1840
+		    }
1841
+		    // pilot name
1842
+		    if (isset($line['alt'])) {
1843
+		    	$data['altitude'] = $line['alt'];
1844
+		    }
1845
+		    // altitude
1846
+		    if (isset($line['gs'])) {
1847
+		    	$data['speed'] = $line['gs'];
1848
+		    }
1849
+		    // speed
1850
+		    if (isset($line['heading'])) {
1851
+		    	$data['heading'] = $line['heading'];
1852
+		    }
1853
+		    // heading
1854
+		    if (isset($line['route'])) {
1855
+		    	$data['waypoints'] = $line['route'];
1856
+		    }
1857
+		    // route
1374 1858
 		    $data['latitude'] = $line['lat']; // lat
1375 1859
 		    $data['longitude'] = $line['lon']; // long
1376 1860
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1377 1861
 		    //$data['squawk'] = $line['squawk']; // squawk
1378 1862
 		    //$data['emergency'] = ''; // emergency
1379
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1380
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1381
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1863
+		    if (isset($line['depicao'])) {
1864
+		    	$data['departure_airport_icao'] = $line['depicao'];
1865
+		    }
1866
+		    if (isset($line['deptime'])) {
1867
+		    	$data['departure_airport_time'] = $line['deptime'];
1868
+		    }
1869
+		    if (isset($line['arricao'])) {
1870
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1871
+		    }
1382 1872
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1383
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1384
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1385
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1386
-		    else $data['info'] = '';
1873
+		    if (isset($line['aircraft'])) {
1874
+		    	$data['aircraft_icao'] = $line['aircraft'];
1875
+		    }
1876
+		    if (isset($line['transponder'])) {
1877
+		    	$data['squawk'] = $line['transponder'];
1878
+		    }
1879
+		    if (isset($line['atis'])) {
1880
+		    	$data['info'] = $line['atis'];
1881
+		    } else {
1882
+		    	$data['info'] = '';
1883
+		    }
1387 1884
 		    $data['format_source'] = 'pireps';
1388 1885
     		    $data['id_source'] = $id_source;
1389 1886
 		    $data['datetime'] = date('Y-m-d H:i:s');
1390
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1391
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1887
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1888
+		    	$data['noarchive'] = true;
1889
+		    }
1890
+		    if (isset($value['name']) && $value['name'] != '') {
1891
+		    	$data['source_name'] = $value['name'];
1892
+		    }
1392 1893
 		    if ($line['icon'] === 'plane') {
1393 1894
 			$SI->add($data);
1394 1895
 		    //    print_r($data);
@@ -1397,16 +1898,28 @@  discard block
 block discarded – undo
1397 1898
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1398 1899
 			$typec = substr($data['ident'],-3);
1399 1900
 			$data['type'] = '';
1400
-			if ($typec === 'APP') $data['type'] = 'Approach';
1401
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1402
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1403
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1404
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1405
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1406
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1407
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1408
-			else $data['type'] = 'Observer';
1409
-			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']);
1901
+			if ($typec === 'APP') {
1902
+				$data['type'] = 'Approach';
1903
+			} elseif ($typec === 'TWR') {
1904
+				$data['type'] = 'Tower';
1905
+			} elseif ($typec === 'OBS') {
1906
+				$data['type'] = 'Observer';
1907
+			} elseif ($typec === 'GND') {
1908
+				$data['type'] = 'Ground';
1909
+			} elseif ($typec === 'DEL') {
1910
+				$data['type'] = 'Delivery';
1911
+			} elseif ($typec === 'DEP') {
1912
+				$data['type'] = 'Departure';
1913
+			} elseif ($typec === 'FSS') {
1914
+				$data['type'] = 'Flight Service Station';
1915
+			} elseif ($typec === 'CTR') {
1916
+				$data['type'] = 'Control Radar or Centre';
1917
+			} else {
1918
+				$data['type'] = 'Observer';
1919
+			}
1920
+			if (isset($ATC)) {
1921
+				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']);
1922
+			}
1410 1923
 		    }
1411 1924
 		    unset($data);
1412 1925
 		}
@@ -1421,7 +1934,9 @@  discard block
 block discarded – undo
1421 1934
 	    )
1422 1935
 	) {
1423 1936
 	    //$buffer = $Common->getData($hosts[$id]);
1424
-	    if ($globalDebug) echo 'Get Data...'."\n";
1937
+	    if ($globalDebug) {
1938
+	    	echo 'Get Data...'."\n";
1939
+	    }
1425 1940
 	    $buffer = $Common->getData($value['host']);
1426 1941
 	    $all_data = json_decode($buffer,true);
1427 1942
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1429,10 +1944,16 @@  discard block
 block discarded – undo
1429 1944
 		foreach ($all_data as $line) {
1430 1945
 	    	    $data = array();
1431 1946
 	    	    //$data['id'] = $line['id']; // id not usable
1432
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1947
+	    	    if (isset($line['pilotid'])) {
1948
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1949
+	    	    }
1433 1950
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1434
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1435
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1951
+	    	    if (isset($line['pilotname'])) {
1952
+	    	    	$data['pilot_name'] = $line['pilotname'];
1953
+	    	    }
1954
+	    	    if (isset($line['pilotid'])) {
1955
+	    	    	$data['pilot_id'] = $line['pilotid'];
1956
+	    	    }
1436 1957
 	    	    $data['ident'] = $line['flightnum']; // ident
1437 1958
 	    	    $data['altitude'] = $line['alt']; // altitude
1438 1959
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1448,7 +1969,9 @@  discard block
 block discarded – undo
1448 1969
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1449 1970
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1450 1971
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1451
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1972
+	    	    } else {
1973
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1974
+	    	    }
1452 1975
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1453 1976
 	    	    $data['departure_airport_time'] = $line['deptime'];
1454 1977
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1456,29 +1979,47 @@  discard block
 block discarded – undo
1456 1979
     		    if (isset($line['registration'])) {
1457 1980
     			$data['registration'] = $line['registration'];
1458 1981
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1459
-    		    } else $data['registration'] = $line['aircraft'];
1460
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1461
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1982
+    		    } else {
1983
+    		    	$data['registration'] = $line['aircraft'];
1984
+    		    }
1985
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1986
+		    	$data['noarchive'] = true;
1987
+		    }
1988
+		    if (isset($line['route'])) {
1989
+		    	$data['waypoints'] = $line['route'];
1990
+		    }
1991
+		    // route
1462 1992
 		    if (isset($line['aircraftname'])) {
1463 1993
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1464 1994
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1465 1995
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1466
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1467
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1468
-	    		else {
1996
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1997
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1998
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1999
+	    			$data['aircraft_icao'] = $aircraft_data[1];
2000
+	    		} else {
1469 2001
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1470
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1471
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
2002
+	    		    if (isset($aircraft_data[1])) {
2003
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
2004
+	    		    } else {
2005
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
2006
+	    		    }
1472 2007
 	    		}
1473 2008
 	    	    }
1474
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
2009
+    		    if (isset($line['route'])) {
2010
+    		    	$data['waypoints'] = $line['route'];
2011
+    		    }
1475 2012
     		    $data['id_source'] = $id_source;
1476 2013
 	    	    $data['format_source'] = 'phpvmacars';
1477
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2014
+		    if (isset($value['name']) && $value['name'] != '') {
2015
+		    	$data['source_name'] = $value['name'];
2016
+		    }
1478 2017
 		    $SI->add($data);
1479 2018
 		    unset($data);
1480 2019
 		}
1481
-		if ($globalDebug) echo 'No more data...'."\n";
2020
+		if ($globalDebug) {
2021
+			echo 'No more data...'."\n";
2022
+		}
1482 2023
 		unset($buffer);
1483 2024
 		unset($all_data);
1484 2025
 	    }
@@ -1491,7 +2032,9 @@  discard block
 block discarded – undo
1491 2032
 	    )
1492 2033
 	) {
1493 2034
 	    //$buffer = $Common->getData($hosts[$id]);
1494
-	    if ($globalDebug) echo 'Get Data...'."\n";
2035
+	    if ($globalDebug) {
2036
+	    	echo 'Get Data...'."\n";
2037
+	    }
1495 2038
 	    $buffer = $Common->getData($value['host']);
1496 2039
 	    $all_data = json_decode($buffer,true);
1497 2040
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1502,10 +2045,16 @@  discard block
 block discarded – undo
1502 2045
 	    	    //$data['id'] = $line['id']; // id not usable
1503 2046
 	    	    $data['id'] = $line['id'];
1504 2047
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1505
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1506
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
2048
+	    	    if (isset($line['user']['username'])) {
2049
+	    	    	$data['pilot_name'] = $line['user']['username'];
2050
+	    	    }
2051
+	    	    if (isset($line['user_id'])) {
2052
+	    	    	$data['pilot_id'] = $line['user_id'];
2053
+	    	    }
1507 2054
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1508
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2055
+	    	    if (is_numeric($data['ident'])) {
2056
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2057
+	    	    }
1509 2058
 	    	    $data['altitude'] = $line['altitude']; // altitude
1510 2059
 	    	    $data['speed'] = $line['groundspeed']; // speed
1511 2060
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1518,7 +2067,9 @@  discard block
 block discarded – undo
1518 2067
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1519 2068
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1520 2069
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1521
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
2070
+	    	    } else {
2071
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
2072
+	    	    }
1522 2073
 	    	    
1523 2074
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1524 2075
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1526,17 +2077,26 @@  discard block
 block discarded – undo
1526 2077
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1527 2078
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1528 2079
 
1529
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1530
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
2080
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2081
+		    	$data['noarchive'] = true;
2082
+		    }
2083
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
2084
+		    	$data['waypoints'] = $line['bid']['route'];
2085
+		    }
2086
+		    // route
1531 2087
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1532 2088
 
1533 2089
     		    $data['id_source'] = $id_source;
1534 2090
 	    	    $data['format_source'] = 'vaos';
1535
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2091
+		    if (isset($value['name']) && $value['name'] != '') {
2092
+		    	$data['source_name'] = $value['name'];
2093
+		    }
1536 2094
 		    $SI->add($data);
1537 2095
 		    unset($data);
1538 2096
 		}
1539
-		if ($globalDebug) echo 'No more data...'."\n";
2097
+		if ($globalDebug) {
2098
+			echo 'No more data...'."\n";
2099
+		}
1540 2100
 		unset($buffer);
1541 2101
 		unset($all_data);
1542 2102
 	    }
@@ -1549,7 +2109,9 @@  discard block
 block discarded – undo
1549 2109
 	    )
1550 2110
 	) {
1551 2111
 	    //$buffer = $Common->getData($hosts[$id]);
1552
-	    if ($globalDebug) echo 'Get Data...'."\n";
2112
+	    if ($globalDebug) {
2113
+	    	echo 'Get Data...'."\n";
2114
+	    }
1553 2115
 	    $buffer = $Common->getData($value['host']);
1554 2116
 	    $all_data = json_decode($buffer,true);
1555 2117
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1578,16 +2140,25 @@  discard block
 block discarded – undo
1578 2140
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1579 2141
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1580 2142
     		    //$data['registration'] = $line['aircraft'];
1581
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2143
+		    if (isset($line['route'])) {
2144
+		    	$data['waypoints'] = $line['route'];
2145
+		    }
2146
+		    // route
1582 2147
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1583 2148
     		    $data['id_source'] = $id_source;
1584 2149
 	    	    $data['format_source'] = 'vam';
1585
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1586
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2150
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2151
+		    	$data['noarchive'] = true;
2152
+		    }
2153
+		    if (isset($value['name']) && $value['name'] != '') {
2154
+		    	$data['source_name'] = $value['name'];
2155
+		    }
1587 2156
 		    $SI->add($data);
1588 2157
 		    unset($data);
1589 2158
 		}
1590
-		if ($globalDebug) echo 'No more data...'."\n";
2159
+		if ($globalDebug) {
2160
+			echo 'No more data...'."\n";
2161
+		}
1591 2162
 		unset($buffer);
1592 2163
 		unset($all_data);
1593 2164
 	    }
@@ -1600,7 +2171,9 @@  discard block
 block discarded – undo
1600 2171
 	    )
1601 2172
 	) {
1602 2173
 	    //$buffer = $Common->getData($hosts[$id]);
1603
-	    if ($globalDebug) echo 'Get Data...'."\n";
2174
+	    if ($globalDebug) {
2175
+	    	echo 'Get Data...'."\n";
2176
+	    }
1604 2177
 	    $buffer = $Common->getData($value['host']);
1605 2178
 	    $all_data = json_decode($buffer,true);
1606 2179
 	    if ($buffer != '') {
@@ -1618,12 +2191,16 @@  discard block
 block discarded – undo
1618 2191
 			$data['id_source'] = $id_source;
1619 2192
 			$data['format_source'] = 'blitzortung';
1620 2193
 			$SI->add($data);
1621
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2194
+			if ($globalDebug) {
2195
+				echo '☈ Lightning added'."\n";
2196
+			}
1622 2197
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1623 2198
 			unset($data);
1624 2199
 		    }
1625 2200
 		}
1626
-		if ($globalDebug) echo 'No more data...'."\n";
2201
+		if ($globalDebug) {
2202
+			echo 'No more data...'."\n";
2203
+		}
1627 2204
 		unset($buffer);
1628 2205
 	    }
1629 2206
 	    $last_exec[$id]['last'] = time();
@@ -1652,10 +2229,15 @@  discard block
 block discarded – undo
1652 2229
                 }
1653 2230
             } else {
1654 2231
                 $format = $value['format'];
1655
-                if (isset($tt[$format])) $tt[$format]++;
1656
-                else $tt[$format] = 0;
2232
+                if (isset($tt[$format])) {
2233
+                	$tt[$format]++;
2234
+                } else {
2235
+                	$tt[$format] = 0;
2236
+                }
1657 2237
                 if ($tt[$format] > 30) {
1658
-                    if ($globalDebug) echo 'Reconnect...'."\n";
2238
+                    if ($globalDebug) {
2239
+                    	echo 'Reconnect...'."\n";
2240
+                    }
1659 2241
                     sleep(2);
1660 2242
                     //$sourceeen[] = $value;
1661 2243
                     //connect_all($sourceeen);
@@ -1672,7 +2254,9 @@  discard block
 block discarded – undo
1672 2254
 	    $write = NULL;
1673 2255
 	    $e = NULL;
1674 2256
 	    $n = socket_select($read, $write, $e, $timeout);
1675
-	    if ($e != NULL) var_dump($e);
2257
+	    if ($e != NULL) {
2258
+	    	var_dump($e);
2259
+	    }
1676 2260
 	    if ($n > 0) {
1677 2261
 		$reset = 0;
1678 2262
 		foreach ($read as $nb => $r) {
@@ -1694,13 +2278,17 @@  discard block
 block discarded – undo
1694 2278
 		    if ($buffer !== FALSE) {
1695 2279
 			if ($format === 'vrstcp') {
1696 2280
 			    $buffer = explode('},{',$buffer);
1697
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2281
+			} else {
2282
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2283
+			}
1698 2284
 		    }
1699 2285
 		    // SBS format is CSV format
1700 2286
 		    if ($buffer !== FALSE && $buffer !== '') {
1701 2287
 			$tt[$format] = 0;
1702 2288
 			if ($format === 'acarssbs3') {
1703
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2289
+			    if ($globalDebug) {
2290
+			    	echo 'ACARS : '.$buffer."\n";
2291
+			    }
1704 2292
 			    $ACARS->add(trim($buffer));
1705 2293
 			    $ACARS->deleteLiveAcarsData();
1706 2294
 			} elseif ($format === 'raw') {
@@ -1710,9 +2298,15 @@  discard block
 block discarded – undo
1710 2298
 				//if (!empty($data)) print_r($data);
1711 2299
 				$data['datetime'] = date('Y-m-d H:i:s');
1712 2300
 				$data['format_source'] = 'raw';
1713
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1714
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1715
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2301
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2302
+					$data['source_name'] = $globalSources[$nb]['name'];
2303
+				}
2304
+				if (isset($globalSources[$nb]['sourcestats'])) {
2305
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2306
+				}
2307
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2308
+					$data['noarchive'] = true;
2309
+				}
1716 2310
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1717 2311
 				$SI->add($data);
1718 2312
 				unset($data);
@@ -1720,22 +2314,54 @@  discard block
 block discarded – undo
1720 2314
 			} elseif ($format === 'ais') {
1721 2315
 			    $ais_data = $AIS->parse_line(trim($buffer));
1722 2316
 			    $data = array();
1723
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1724
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1725
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1726
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1727
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1728
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1729
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1730
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1731
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1732
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1733
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1734
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1735
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1736
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1737
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1738
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2317
+			    if (isset($ais_data['ident'])) {
2318
+			    	$data['ident'] = $ais_data['ident'];
2319
+			    }
2320
+			    if (isset($ais_data['mmsi'])) {
2321
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2322
+			    }
2323
+			    if (isset($ais_data['speed'])) {
2324
+			    	$data['speed'] = $ais_data['speed'];
2325
+			    }
2326
+			    if (isset($ais_data['heading'])) {
2327
+			    	$data['heading'] = $ais_data['heading'];
2328
+			    }
2329
+			    if (isset($ais_data['latitude'])) {
2330
+			    	$data['latitude'] = $ais_data['latitude'];
2331
+			    }
2332
+			    if (isset($ais_data['longitude'])) {
2333
+			    	$data['longitude'] = $ais_data['longitude'];
2334
+			    }
2335
+			    if (isset($ais_data['status'])) {
2336
+			    	$data['status'] = $ais_data['status'];
2337
+			    }
2338
+			    if (isset($ais_data['statusid'])) {
2339
+			    	$data['status_id'] = $ais_data['statusid'];
2340
+			    }
2341
+			    if (isset($ais_data['type'])) {
2342
+			    	$data['type'] = $ais_data['type'];
2343
+			    }
2344
+			    if (isset($ais_data['imo'])) {
2345
+			    	$data['imo'] = $ais_data['imo'];
2346
+			    }
2347
+			    if (isset($ais_data['callsign'])) {
2348
+			    	$data['callsign'] = $ais_data['callsign'];
2349
+			    }
2350
+			    if (isset($ais_data['destination'])) {
2351
+			    	$data['arrival_code'] = $ais_data['destination'];
2352
+			    }
2353
+			    if (isset($ais_data['eta_ts'])) {
2354
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2355
+			    }
2356
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2357
+			    	$data['noarchive'] = true;
2358
+			    }
2359
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2360
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2361
+			    }
2362
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2363
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2364
+			    }
1739 2365
 
1740 2366
 			    if (isset($ais_data['timestamp'])) {
1741 2367
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1744,7 +2370,9 @@  discard block
 block discarded – undo
1744 2370
 			    }
1745 2371
 			    $data['format_source'] = 'aisnmea';
1746 2372
     			    $data['id_source'] = $id_source;
1747
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2373
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2374
+			    	$MI->add($data);
2375
+			    }
1748 2376
 			    unset($data);
1749 2377
                         } elseif ($format === 'flightgearsp') {
1750 2378
                     	    //echo $buffer."\n";
@@ -1762,12 +2390,18 @@  discard block
 block discarded – undo
1762 2390
 				$data['speed'] = round($line[5]*1.94384);
1763 2391
 				$data['datetime'] = date('Y-m-d H:i:s');
1764 2392
 				$data['format_source'] = 'flightgearsp';
1765
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1766
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2393
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2394
+					$data['noarchive'] = true;
2395
+				}
2396
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2397
+					$SI->add($data);
2398
+				}
1767 2399
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1768 2400
 			    }
1769 2401
                         } elseif ($format === 'acars') {
1770
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2402
+                    	    if ($globalDebug) {
2403
+                    	    	echo 'ACARS : '.$buffer."\n";
2404
+                    	    }
1771 2405
 			    $ACARS->add(trim($buffer));
1772 2406
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1773 2407
 			    $ACARS->deleteLiveAcarsData();
@@ -1788,8 +2422,12 @@  discard block
 block discarded – undo
1788 2422
 				    $aircraft_type = $line[10];
1789 2423
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1790 2424
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1791
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1792
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2425
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2426
+				    	$data['noarchive'] = true;
2427
+				    }
2428
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2429
+				    	$SI->add($data);
2430
+				    }
1793 2431
 				}
1794 2432
 			    }
1795 2433
 			} elseif ($format === 'beast') {
@@ -1799,28 +2437,62 @@  discard block
 block discarded – undo
1799 2437
 			    foreach($buffer as $all_data) {
1800 2438
 				$line = json_decode('{'.$all_data.'}',true);
1801 2439
 				$data = array();
1802
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1803
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1804
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1805
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1806
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1807
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1808
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2440
+				if (isset($line['Icao'])) {
2441
+					$data['hex'] = $line['Icao'];
2442
+				}
2443
+				// hex
2444
+				if (isset($line['Call'])) {
2445
+					$data['ident'] = $line['Call'];
2446
+				}
2447
+				// ident
2448
+				if (isset($line['Alt'])) {
2449
+					$data['altitude'] = $line['Alt'];
2450
+				}
2451
+				// altitude
2452
+				if (isset($line['Spd'])) {
2453
+					$data['speed'] = $line['Spd'];
2454
+				}
2455
+				// speed
2456
+				if (isset($line['Trak'])) {
2457
+					$data['heading'] = $line['Trak'];
2458
+				}
2459
+				// heading
2460
+				if (isset($line['Lat'])) {
2461
+					$data['latitude'] = $line['Lat'];
2462
+				}
2463
+				// lat
2464
+				if (isset($line['Long'])) {
2465
+					$data['longitude'] = $line['Long'];
2466
+				}
2467
+				// long
1809 2468
 				//$data['verticalrate'] = $line['']; // verticale rate
1810
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2469
+				if (isset($line['Sqk'])) {
2470
+					$data['squawk'] = $line['Sqk'];
2471
+				}
2472
+				// squawk
1811 2473
 				$data['emergency'] = ''; // emergency
1812
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2474
+				if (isset($line['Reg'])) {
2475
+					$data['registration'] = $line['Reg'];
2476
+				}
1813 2477
 				/*
1814 2478
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1815 2479
 				else $data['datetime'] = date('Y-m-d H:i:s');
1816 2480
 				*/
1817 2481
 				$data['datetime'] = date('Y-m-d H:i:s');
1818
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2482
+				if (isset($line['Type'])) {
2483
+					$data['aircraft_icao'] = $line['Type'];
2484
+				}
1819 2485
 		    		$data['format_source'] = 'vrstcp';
1820 2486
 				$data['id_source'] = $id_source;
1821
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1822
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1823
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2487
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2488
+					$data['noarchive'] = true;
2489
+				}
2490
+				if (isset($value['name']) && $value['name'] != '') {
2491
+					$data['source_name'] = $value['name'];
2492
+				}
2493
+				if (isset($data['latitude']) && isset($data['hex'])) {
2494
+					$SI->add($data);
2495
+				}
1824 2496
 				unset($data);
1825 2497
 			    }
1826 2498
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1833,22 +2505,46 @@  discard block
 block discarded – undo
1833 2505
     				$data['hex'] = $lined['hexid'];
1834 2506
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1835 2507
     				$data['datetime'] = date('Y-m-d H:i:s');;
1836
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1837
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1838
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1839
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1840
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1841
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1842
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2508
+    				if (isset($lined['ident'])) {
2509
+    					$data['ident'] = $lined['ident'];
2510
+    				}
2511
+    				if (isset($lined['lat'])) {
2512
+    					$data['latitude'] = $lined['lat'];
2513
+    				}
2514
+    				if (isset($lined['lon'])) {
2515
+    					$data['longitude'] = $lined['lon'];
2516
+    				}
2517
+    				if (isset($lined['speed'])) {
2518
+    					$data['speed'] = $lined['speed'];
2519
+    				}
2520
+    				if (isset($lined['squawk'])) {
2521
+    					$data['squawk'] = $lined['squawk'];
2522
+    				}
2523
+    				if (isset($lined['alt'])) {
2524
+    					$data['altitude'] = $lined['alt'];
2525
+    				}
2526
+    				if (isset($lined['heading'])) {
2527
+    					$data['heading'] = $lined['heading'];
2528
+    				}
1843 2529
     				$data['id_source'] = $id_source;
1844 2530
     				$data['format_source'] = 'tsv';
1845
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1846
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1847
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1848
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2531
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2532
+    					$data['source_name'] = $globalSources[$nb]['name'];
2533
+    				}
2534
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2535
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2536
+    				}
2537
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2538
+					$data['noarchive'] = true;
2539
+				}
2540
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2541
+    					$SI->add($data);
2542
+    				}
1849 2543
     				unset($lined);
1850 2544
     				unset($data);
1851
-    			    } else $error = true;
2545
+    			    } else {
2546
+    			    	$error = true;
2547
+    			    }
1852 2548
 			} elseif ($format === 'aprs' && $use_aprs) {
1853 2549
 			    if ($aprs_connect === 0) {
1854 2550
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1874,47 +2570,96 @@  discard block
 block discarded – undo
1874 2570
 				    $aprs_last_tx = time();
1875 2571
 				    $data = array();
1876 2572
 				    //print_r($line);
1877
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1878
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1879
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1880
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1881
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1882
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1883
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1884
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1885
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1886
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2573
+				    if (isset($line['address'])) {
2574
+				    	$data['hex'] = $line['address'];
2575
+				    }
2576
+				    if (isset($line['mmsi'])) {
2577
+				    	$data['mmsi'] = $line['mmsi'];
2578
+				    }
2579
+				    if (isset($line['imo'])) {
2580
+				    	$data['imo'] = $line['imo'];
2581
+				    }
2582
+				    if (isset($line['squawk'])) {
2583
+				    	$data['squawk'] = $line['squawk'];
2584
+				    }
2585
+				    if (isset($line['arrival_code'])) {
2586
+				    	$data['arrival_code'] = $line['arrival_code'];
2587
+				    }
2588
+				    if (isset($line['arrival_date'])) {
2589
+				    	$data['arrival_date'] = $line['arrival_date'];
2590
+				    }
2591
+				    if (isset($line['typeid'])) {
2592
+				    	$data['type_id'] = $line['typeid'];
2593
+				    }
2594
+				    if (isset($line['statusid'])) {
2595
+				    	$data['status_id'] = $line['statusid'];
2596
+				    }
2597
+				    if (isset($line['timestamp'])) {
2598
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2599
+				    } else {
2600
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2601
+				    }
1887 2602
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1888
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2603
+				    if (isset($line['ident'])) {
2604
+				    	$data['ident'] = $line['ident'];
2605
+				    }
1889 2606
 				    $data['latitude'] = $line['latitude'];
1890 2607
 				    $data['longitude'] = $line['longitude'];
1891 2608
 				    //$data['verticalrate'] = $line[16];
1892
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2609
+				    if (isset($line['speed'])) {
2610
+				    	$data['speed'] = $line['speed'];
2611
+				    }
1893 2612
 				    //else $data['speed'] = 0;
1894
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1895
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1896
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2613
+				    if (isset($line['altitude'])) {
2614
+				    	$data['altitude'] = $line['altitude'];
2615
+				    }
2616
+				    if (isset($line['comment'])) {
2617
+				    	$data['comment'] = $line['comment'];
2618
+				    }
2619
+				    if (isset($line['symbol'])) {
2620
+				    	$data['type'] = $line['symbol'];
2621
+				    }
1897 2622
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1898 2623
 				    
1899
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2624
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2625
+				    	$data['heading'] = $line['heading'];
2626
+				    }
1900 2627
 				    //else echo 'No heading...'."\n";
1901 2628
 				    //else $data['heading'] = 0;
1902
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2629
+				    if (isset($line['stealth'])) {
2630
+				    	$data['aircraft_type'] = $line['stealth'];
2631
+				    }
1903 2632
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1904
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1905
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1906
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1907
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2633
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2634
+				    	$data['noarchive'] = true;
2635
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2636
+				    	$data['noarchive'] = false;
2637
+				    }
2638
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2639
+				    	$data['noarchive'] = true;
2640
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2641
+				    	$data['noarchive'] = false;
2642
+				    }
1908 2643
     				    $data['id_source'] = $id_source;
1909
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1910
-				    else $data['format_source'] = 'aprs';
2644
+    				    if (isset($line['format_source'])) {
2645
+    				    	$data['format_source'] = $line['format_source'];
2646
+    				    } else {
2647
+				    	$data['format_source'] = 'aprs';
2648
+				    }
1911 2649
 				    $data['source_name'] = $line['source'];
1912
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1913
-				    else $data['source_type'] = 'flarm';
1914
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2650
+				    if (isset($line['source_type'])) {
2651
+				    	$data['source_type'] = $line['source_type'];
2652
+				    } else {
2653
+				    	$data['source_type'] = 'flarm';
2654
+				    }
2655
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2656
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2657
+    				    }
1915 2658
 				    $currentdate = date('Y-m-d H:i:s');
1916 2659
 				    $aprsdate = strtotime($data['datetime']);
1917
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2660
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2661
+				    	$data['altitude_relative'] = 'AMSL';
2662
+				    }
1918 2663
 				    // Accept data if time <= system time + 20s
1919 2664
 				    //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1920 2665
 				    if (
@@ -1926,7 +2671,9 @@  discard block
 block discarded – undo
1926 2671
 					$send = $SI->add($data);
1927 2672
 				    } elseif ($data['source_type'] === 'ais') {
1928 2673
 					$data['type'] = '';
1929
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2674
+					if (isset($globalMarine) && $globalMarine) {
2675
+						$send = $MI->add($data);
2676
+					}
1930 2677
 				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1931 2678
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1932 2679
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
@@ -1934,8 +2681,12 @@  discard block
 block discarded – undo
1934 2681
 					    $line['symbol'] === 'Glider' || 
1935 2682
 					    $line['symbol'] === 'No. Plane' || 
1936 2683
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1937
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1938
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2684
+					    if ($line['symbol'] === 'Ballon') {
2685
+					    	$data['aircraft_icao'] = 'BALL';
2686
+					    }
2687
+					    if ($line['symbol'] === 'Glider') {
2688
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2689
+					    }
1939 2690
 					    $send = $SI->add($data);
1940 2691
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1941 2692
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1966,9 +2717,13 @@  discard block
 block discarded – undo
1966 2717
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1967 2718
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1968 2719
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1969
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2720
+					if (isset($globalTracker) && $globalTracker) {
2721
+						$send = $TI->add($data);
2722
+					}
1970 2723
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1971
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2724
+					if (!isset($data['altitude'])) {
2725
+						$data['altitude'] = 0;
2726
+					}
1972 2727
 					$Source->deleteOldLocationByType('gs');
1973 2728
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1974 2729
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1977,7 +2732,9 @@  discard block
 block discarded – undo
1977 2732
 					}
1978 2733
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1979 2734
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1980
-					if ($globalDebug) echo '# Weather Station added'."\n";
2735
+					if ($globalDebug) {
2736
+						echo '# Weather Station added'."\n";
2737
+					}
1981 2738
 					$Source->deleteOldLocationByType('wx');
1982 2739
 					$weather_data = json_encode($line);
1983 2740
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1987,7 +2744,9 @@  discard block
 block discarded – undo
1987 2744
 					}
1988 2745
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1989 2746
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1990
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2747
+					if ($globalDebug) {
2748
+						echo '☈ Lightning added'."\n";
2749
+					}
1991 2750
 					$Source->deleteOldLocationByType('lightning');
1992 2751
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1993 2752
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1999,8 +2758,7 @@  discard block
 block discarded – undo
1999 2758
 				    	print_r($line);
2000 2759
 				    }
2001 2760
 				    unset($data);
2002
-				}
2003
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2761
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2004 2762
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2005 2763
 				}
2006 2764
 				/*
@@ -2009,7 +2767,9 @@  discard block
 block discarded – undo
2009 2767
 				}
2010 2768
 				*/
2011 2769
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2012
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2770
+				elseif ($line === true && $globalDebug) {
2771
+					echo '!! Failed : '.$buffer."!!\n";
2772
+				}
2013 2773
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2014 2774
 					$Source->deleteOldLocationByType('lightning');
2015 2775
 					$Source->deleteOldLocationByType('wx');
@@ -2046,27 +2806,47 @@  discard block
 block discarded – undo
2046 2806
     				$data['ground'] = $line[21];
2047 2807
     				$data['emergency'] = $line[19];
2048 2808
     				$data['format_source'] = 'sbs';
2049
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
2050
-				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
2051
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2052
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2809
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2810
+					$data['source_name'] = $globalSources[$nb]['name'];
2811
+				} elseif ($line[0] == 'MLAT') {
2812
+					$data['source_name'] = 'MLAT';
2813
+				}
2814
+				if (isset($globalSources[$nb]['sourcestats'])) {
2815
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2816
+				}
2817
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2818
+					$data['noarchive'] = true;
2819
+				}
2053 2820
     				$data['id_source'] = $id_source;
2054
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2055
-    				else $error = true;
2821
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2822
+    					$send = $SI->add($data);
2823
+    				} else {
2824
+    					$error = true;
2825
+    				}
2056 2826
     				unset($data);
2057
-    			    } else $error = true;
2827
+    			    } else {
2828
+    			    	$error = true;
2829
+    			    }
2058 2830
 			    if ($error) {
2059 2831
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
2060
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2832
+					if ($globalDebug) {
2833
+						echo "Not a message. Ignoring... \n";
2834
+					}
2061 2835
 				} else {
2062
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2836
+					if ($globalDebug) {
2837
+						echo "Wrong line format. Ignoring... \n";
2838
+					}
2063 2839
 					if ($globalDebug) {
2064 2840
 						echo $buffer;
2065 2841
 						//print_r($line);
2066 2842
 					}
2067 2843
 					//socket_close($r);
2068
-					if ($globalDebug) echo "Reconnect after an error...\n";
2069
-					if ($format === 'aprs') $aprs_connect = 0;
2844
+					if ($globalDebug) {
2845
+						echo "Reconnect after an error...\n";
2846
+					}
2847
+					if ($format === 'aprs') {
2848
+						$aprs_connect = 0;
2849
+					}
2070 2850
 					$sourceer[$nb] = $globalSources[$nb];
2071 2851
 					connect_all($sourceer);
2072 2852
 					$sourceer = array();
@@ -2074,10 +2854,14 @@  discard block
 block discarded – undo
2074 2854
 			    }
2075 2855
 			}
2076 2856
 			// Sleep for xxx microseconds
2077
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2857
+			if (isset($globalSBSSleep)) {
2858
+				usleep($globalSBSSleep);
2859
+			}
2078 2860
 		    } else {
2079 2861
 			if ($format === 'flightgearmp') {
2080
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2862
+			    	if ($globalDebug) {
2863
+			    		echo "Reconnect FlightGear MP...";
2864
+			    	}
2081 2865
 				//@socket_close($r);
2082 2866
 				sleep($globalMinFetch);
2083 2867
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2086,10 +2870,15 @@  discard block
 block discarded – undo
2086 2870
 				break;
2087 2871
 				
2088 2872
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2089
-			    if (isset($tt[$format])) $tt[$format]++;
2090
-			    else $tt[$format] = 0;
2873
+			    if (isset($tt[$format])) {
2874
+			    	$tt[$format]++;
2875
+			    } else {
2876
+			    	$tt[$format] = 0;
2877
+			    }
2091 2878
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
2092
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2879
+				if ($globalDebug) {
2880
+					echo "ERROR : Reconnect ".$format."...";
2881
+				}
2093 2882
 				//@socket_close($r);
2094 2883
 				sleep(2);
2095 2884
 				$aprs_connect = 0;
@@ -2107,11 +2896,17 @@  discard block
 block discarded – undo
2107 2896
 	    } else {
2108 2897
 		$error = socket_strerror(socket_last_error());
2109 2898
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2110
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2111
-			if (isset($globalDebug)) echo "Restarting...\n";
2899
+			if ($globalDebug) {
2900
+				echo "ERROR : socket_select give this error ".$error . "\n";
2901
+			}
2902
+			if (isset($globalDebug)) {
2903
+				echo "Restarting...\n";
2904
+			}
2112 2905
 			// Restart the script if possible
2113 2906
 			if (is_array($sockets)) {
2114
-			    if ($globalDebug) echo "Shutdown all sockets...";
2907
+			    if ($globalDebug) {
2908
+			    	echo "Shutdown all sockets...";
2909
+			    }
2115 2910
 			    
2116 2911
 			    foreach ($sockets as $sock) {
2117 2912
 				@socket_shutdown($sock,2);
@@ -2119,25 +2914,45 @@  discard block
 block discarded – undo
2119 2914
 			    }
2120 2915
 			    
2121 2916
 			}
2122
-			if ($globalDebug) echo "Waiting...";
2917
+			if ($globalDebug) {
2918
+				echo "Waiting...";
2919
+			}
2123 2920
 			sleep(2);
2124 2921
 			$time = time();
2125 2922
 			//connect_all($hosts);
2126 2923
 			$aprs_connect = 0;
2127
-			if ($reset%5 === 0) sleep(20);
2128
-			if ($reset%10 === 0) sleep(100);
2129
-			if ($reset%20 === 0) sleep(200);
2130
-			if ($reset > 100) exit('Too many attempts...');
2131
-			if ($globalDebug) echo "Restart all connections...";
2924
+			if ($reset%5 === 0) {
2925
+				sleep(20);
2926
+			}
2927
+			if ($reset%10 === 0) {
2928
+				sleep(100);
2929
+			}
2930
+			if ($reset%20 === 0) {
2931
+				sleep(200);
2932
+			}
2933
+			if ($reset > 100) {
2934
+				exit('Too many attempts...');
2935
+			}
2936
+			if ($globalDebug) {
2937
+				echo "Restart all connections...";
2938
+			}
2132 2939
 			connect_all($globalSources);
2133 2940
 		}
2134 2941
 	    }
2135 2942
 	}
2136 2943
 	if ($globalDaemon === false) {
2137
-	    if ($globalDebug) echo 'Check all...'."\n";
2138
-	    if (isset($SI)) $SI->checkAll();
2139
-	    if (isset($TI)) $TI->checkAll();
2140
-	    if (isset($MI)) $MI->checkAll();
2944
+	    if ($globalDebug) {
2945
+	    	echo 'Check all...'."\n";
2946
+	    }
2947
+	    if (isset($SI)) {
2948
+	    	$SI->checkAll();
2949
+	    }
2950
+	    if (isset($TI)) {
2951
+	    	$TI->checkAll();
2952
+	    }
2953
+	    if (isset($MI)) {
2954
+	    	$MI->checkAll();
2955
+	    }
2141 2956
 	}
2142 2957
     }
2143 2958
 }
Please login to merge, or discard this patch.