Completed
Push — master ( b336a7...4ca6dc )
by Yannick
103:26 queued 64:20
created
scripts/daemon-spotter.php 1 patch
Spacing   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
 	    die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
62
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
63 63
     }
64 64
 }
65 65
 
66
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
66
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70 70
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
71
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
72 72
     else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74 74
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
76 76
     else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115 115
     if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
116
+    $SI = new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
120 120
     $SI->connect();
121 121
 */
122
-} else $SI=new SpotterImport($Connection->db);
122
+} else $SI = new SpotterImport($Connection->db);
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
     $MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136
-$SBS=new SBS();
136
+$SBS = new SBS();
137 137
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
138
-	$ACARS=new ACARS($Connection->db,true);
139
-	$Source=new Source($Connection->db);
138
+	$ACARS = new ACARS($Connection->db, true);
139
+	$Source = new Source($Connection->db);
140 140
 }
141
-$Common=new Common();
141
+$Common = new Common();
142 142
 date_default_timezone_set('UTC');
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
146
+    pcntl_signal(SIGINT, function() {
147 147
         global $sockets;
148 148
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149 149
         die("Bye!\n");
@@ -159,40 +159,40 @@  discard block
 block discarded – undo
159 159
 
160 160
 function connect_all($hosts) {
161 161
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
162
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
163 163
     $reset++;
164 164
     if ($globalDebug) echo 'Connect to all...'."\n";
165 165
     foreach ($hosts as $id => $value) {
166 166
 	$host = $value['host'];
167 167
 	$globalSources[$id]['last_exec'] = 0;
168 168
 	// Here we check type of source(s)
169
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
170
-            if (preg_match('/deltadb.txt$/i',$host)) {
169
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
170
+            if (preg_match('/deltadb.txt$/i', $host)) {
171 171
         	//$formats[$id] = 'deltadbtxt';
172 172
         	$globalSources[$id]['format'] = 'deltadbtxt';
173 173
         	//$last_exec['deltadbtxt'] = 0;
174 174
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
175
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
175
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
176 176
         	//$formats[$id] = 'vatsimtxt';
177 177
         	$globalSources[$id]['format'] = 'vatsimtxt';
178 178
         	//$last_exec['vatsimtxt'] = 0;
179 179
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
180
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
180
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
181 181
         	//$formats[$id] = 'aircraftlistjson';
182 182
         	$globalSources[$id]['format'] = 'aircraftlistjson';
183 183
         	//$last_exec['aircraftlistjson'] = 0;
184 184
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
185
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
185
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
186 186
         	//$formats[$id] = 'aircraftjson';
187 187
         	$globalSources[$id]['format'] = 'aircraftjson';
188 188
         	//$last_exec['aircraftlistjson'] = 0;
189 189
         	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
190
-    	    } else if (preg_match('/aircraft$/i',$host)) {
190
+    	    } else if (preg_match('/aircraft$/i', $host)) {
191 191
         	//$formats[$id] = 'planefinderclient';
192 192
         	$globalSources[$id]['format'] = 'planefinderclient';
193 193
         	//$last_exec['aircraftlistjson'] = 0;
194 194
         	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
195
-    	    } else if (preg_match('/opensky/i',$host)) {
195
+    	    } else if (preg_match('/opensky/i', $host)) {
196 196
         	//$formats[$id] = 'aircraftlistjson';
197 197
         	$globalSources[$id]['format'] = 'opensky';
198 198
         	//$last_exec['aircraftlistjson'] = 0;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         	    exit(0);
210 210
         	}
211 211
     	    */
212
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
212
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
213 213
         	//$formats[$id] = 'planeupdatefaa';
214 214
         	$globalSources[$id]['format'] = 'planeupdatefaa';
215 215
         	//$last_exec['planeupdatefaa'] = 0;
@@ -218,37 +218,37 @@  discard block
 block discarded – undo
218 218
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
219 219
         	    exit(0);
220 220
         	}
221
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
221
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
222 222
         	//$formats[$id] = 'phpvmacars';
223 223
         	$globalSources[$id]['format'] = 'phpvmacars';
224 224
         	//$last_exec['phpvmacars'] = 0;
225 225
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
226
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
226
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
227 227
         	//$formats[$id] = 'phpvmacars';
228 228
         	$globalSources[$id]['format'] = 'vaos';
229 229
         	//$last_exec['phpvmacars'] = 0;
230 230
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
231
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
231
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
232 232
         	//$formats[$id] = 'phpvmacars';
233 233
         	$globalSources[$id]['format'] = 'vam';
234 234
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
235
-            } else if (preg_match('/whazzup/i',$host)) {
235
+            } else if (preg_match('/whazzup/i', $host)) {
236 236
         	//$formats[$id] = 'whazzup';
237 237
         	$globalSources[$id]['format'] = 'whazzup';
238 238
         	//$last_exec['whazzup'] = 0;
239 239
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
240
-            } else if (preg_match('/blitzortung/i',$host)) {
240
+            } else if (preg_match('/blitzortung/i', $host)) {
241 241
         	$globalSources[$id]['format'] = 'blitzortung';
242 242
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
243
-            } else if (preg_match('/airwhere/i',$host)) {
243
+            } else if (preg_match('/airwhere/i', $host)) {
244 244
         	$globalSources[$id]['format'] = 'airwhere';
245 245
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
246
-            } else if (preg_match('/recentpireps/i',$host)) {
246
+            } else if (preg_match('/recentpireps/i', $host)) {
247 247
         	//$formats[$id] = 'pirepsjson';
248 248
         	$globalSources[$id]['format'] = 'pirepsjson';
249 249
         	//$last_exec['pirepsjson'] = 0;
250 250
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
251
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
251
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
252 252
         	//$formats[$id] = 'fr24json';
253 253
         	$globalSources[$id]['format'] = 'fr24json';
254 254
         	//$last_exec['fr24json'] = 0;
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258 258
         	    exit(0);
259 259
         	}
260
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
260
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
261 261
         	//$formats[$id] = 'fr24json';
262 262
         	$globalSources[$id]['format'] = 'myshiptracking';
263 263
         	//$last_exec['fr24json'] = 0;
@@ -267,22 +267,22 @@  discard block
 block discarded – undo
267 267
         	    exit(0);
268 268
         	}
269 269
             //} else if (preg_match('/10001/',$host)) {
270
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
270
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271 271
         	//$formats[$id] = 'tsv';
272 272
         	$globalSources[$id]['format'] = 'tsv';
273 273
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
274 274
             }
275
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
275
+        } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276 276
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
277
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
277
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
278 278
     		    if ($idf !== false) {
279 279
     			$httpfeeds[$id] = $idf;
280 280
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
281 281
     		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
282 282
     		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
283 283
     		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
284
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
285
-	    $hostport = explode(':',$host);
284
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
285
+	    $hostport = explode(':', $host);
286 286
 	    if (isset($hostport[1])) {
287 287
 		$port = $hostport[1];
288 288
 		$hostn = $hostport[0];
@@ -292,19 +292,19 @@  discard block
 block discarded – undo
292 292
 	    }
293 293
 	    $Common = new Common();
294 294
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
295
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
295
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
296 296
     	    } else {
297
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
297
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
298 298
 	    }
299 299
 	    if ($s) {
300 300
     	        $sockets[$id] = $s;
301 301
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
302
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
302
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
303 303
 			//$formats[$id] = 'aprs';
304 304
 			$globalSources[$id]['format'] = 'aprs';
305 305
 			//$aprs_connect = 0;
306 306
 			//$use_aprs = true;
307
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
307
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
308 308
 			$globalSources[$id]['format'] = 'vrstcp';
309 309
     		    } elseif ($port == '10001') {
310 310
         		//$formats[$id] = 'tsv';
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
346 346
 else $timeout = 20;
347 347
 $errno = '';
348
-$errstr='';
348
+$errstr = '';
349 349
 
350 350
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
351 351
 /* Initiate connections to all the hosts simultaneously */
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 //connect_all($globalSources);
354 354
 
355 355
 if (isset($globalProxy) && $globalProxy) {
356
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
356
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
357 357
 } else {
358 358
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
359 359
 }
@@ -383,16 +383,16 @@  discard block
 block discarded – undo
383 383
 
384 384
 if ($use_aprs) {
385 385
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
386
-	$APRS=new APRS();
386
+	$APRS = new APRS();
387 387
 	$aprs_connect = 0;
388 388
 	$aprs_keep = 120;
389 389
 	$aprs_last_tx = time();
390 390
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
391
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
391
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
392 392
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
393
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
393
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
394 394
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
395
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
395
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
396 396
 	if ($aprs_full) $aprs_filter = '';
397 397
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
398 398
 	else $aprs_pass = '-1';
@@ -406,12 +406,12 @@  discard block
 block discarded – undo
406 406
 sleep(1);
407 407
 if ($globalDebug) echo "SCAN MODE \n\n";
408 408
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
409
-$endtime = time()+$globalCronEnd;
409
+$endtime = time() + $globalCronEnd;
410 410
 $i = 1;
411 411
 $tt = array();
412 412
 // Delete all ATC
413 413
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
414
-	$ATC=new ATC($Connection->db);
414
+	$ATC = new ATC($Connection->db);
415 415
 }
416 416
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
417 417
 	$ATC->deleteAll();
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 while ($i > 0) {
422 422
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
423 423
 
424
-    if (!$globalDaemon) $i = $endtime-time();
424
+    if (!$globalDaemon) $i = $endtime - time();
425 425
     // Delete old ATC
426 426
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
427 427
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	}
436 436
 	if ($max < $globalMinFetch) {
437 437
 	    if ($globalDebug) echo 'Sleeping...'."\n";
438
-	    sleep($globalMinFetch-$max+2);
438
+	    sleep($globalMinFetch - $max + 2);
439 439
 	}
440 440
     }
441 441
 
@@ -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
@@ -528,11 +528,11 @@  discard block
 block discarded – undo
528 528
 	    )
529 529
 	) {
530 530
 	    date_default_timezone_set('CET');
531
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
531
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
532 532
 	    date_default_timezone_set('UTC');
533 533
 	    if ($buffer != '') $reset = 0;
534
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
535
-	    $buffer = explode('\n',$buffer);
534
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
535
+	    $buffer = explode('\n', $buffer);
536 536
 	    foreach ($buffer as $line) {
537 537
 		if ($line != '') {
538 538
 		    //echo "'".$line."'\n";
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 		    $ais_data = $AIS->parse_line(trim($line));
541 541
 		    $data = array();
542 542
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
543
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
543
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
544 544
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
545 545
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
546 546
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
553 553
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
554 554
 		    if (isset($ais_data['timestamp'])) {
555
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
555
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
556 556
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
557 557
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
558 558
 			    $add = true;
@@ -575,21 +575,21 @@  discard block
 block discarded – undo
575 575
 	    $w = $e = null;
576 576
 	    
577 577
 	    if (isset($arr[$id])) {
578
-		$nn = stream_select($arr,$w,$e,$timeout);
578
+		$nn = stream_select($arr, $w, $e, $timeout);
579 579
 		if ($nn > 0) {
580 580
 		    foreach ($httpfeeds as $feed) {
581
-			$buffer = stream_get_line($feed,2000,"\n");
581
+			$buffer = stream_get_line($feed, 2000, "\n");
582 582
 			if ($buffer === FALSE) {
583 583
 			    connect_all($globalSources);
584 584
 			}
585
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
586
-			$buffer = explode('\n',$buffer);
585
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
586
+			$buffer = explode('\n', $buffer);
587 587
 			foreach ($buffer as $line) {
588 588
 			    if ($line != '') {
589 589
 				$ais_data = $AIS->parse_line(trim($line));
590 590
 				$data = array();
591 591
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
592
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
592
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
593 593
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
594 594
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
595 595
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -601,9 +601,9 @@  discard block
 block discarded – undo
601 601
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
602 602
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
603 603
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
604
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
604
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
605 605
 				if (isset($ais_data['timestamp'])) {
606
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
606
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
607 607
 				} else {
608 608
 				    $data['datetime'] = date('Y-m-d H:i:s');
609 609
 				}
@@ -635,10 +635,10 @@  discard block
 block discarded – undo
635 635
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
636 636
 	    )
637 637
 	) {
638
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
638
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
639 639
 	    if ($buffer != '') {
640 640
 		//echo $buffer;
641
-		$all_data = json_decode($buffer,true);
641
+		$all_data = json_decode($buffer, true);
642 642
 		//print_r($all_data);
643 643
 		if (isset($all_data[0]['DATA'])) {
644 644
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 			    $data['ident'] = $line['NAME'];
648 648
 			    $data['mmsi'] = $line['MMSI'];
649 649
 			    if (strlen($data['mmsi']) > 9) {
650
-				$data['mmsi'] = substr($data['mmsi'],-9);
650
+				$data['mmsi'] = substr($data['mmsi'], -9);
651 651
 			    }
652 652
 			    $data['speed'] = $line['SOG'];
653 653
 			    $data['heading'] = $line['COG'];
@@ -657,8 +657,8 @@  discard block
 block discarded – undo
657 657
 			    //$data['type_id'] = $line['TYPE'];
658 658
 			    $data['imo'] = $line['IMO'];
659 659
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
660
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
661
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
660
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
661
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
662 662
 			    $data['format_source'] = 'myshiptracking';
663 663
 			    $data['id_source'] = $id_source;
664 664
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -675,16 +675,16 @@  discard block
 block discarded – undo
675 675
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
676 676
 	    )
677 677
 	) {
678
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
678
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
679 679
 	    if ($buffer != '') {
680
-		$all_data = json_decode($buffer,true);
680
+		$all_data = json_decode($buffer, true);
681 681
 		if (isset($all_data[0]['mmsi'])) {
682 682
 		    foreach ($all_data as $line) {
683 683
 			if ($line != '') {
684 684
 			    $data = array();
685 685
 			    $data['ident'] = $line['shipname'];
686 686
 			    $data['callsign'] = $line['callsign'];
687
-			    $data['mmsi'] = substr($line['mmsi'],-9);
687
+			    $data['mmsi'] = substr($line['mmsi'], -9);
688 688
 			    $data['speed'] = $line['sog'];
689 689
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
690 690
 			    $data['latitude'] = $line['latitude'];
@@ -711,14 +711,14 @@  discard block
 block discarded – undo
711 711
 	) {
712 712
 	    $buffer = $Common->getData($value['host']);
713 713
 	    if ($buffer != '') {
714
-		$all_data = json_decode($buffer,true);
714
+		$all_data = json_decode($buffer, true);
715 715
 		if (isset($all_data['features'][0]['id'])) {
716 716
 		    foreach ($all_data['features'] as $line) {
717 717
 			print_r($line);
718 718
 			$data = array();
719 719
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
720 720
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
721
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
721
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
722 722
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
723 723
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
724 724
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -745,31 +745,31 @@  discard block
 block discarded – undo
745 745
 	    )
746 746
 	) {
747 747
 	    if ($globalDebug) echo 'download...';
748
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
748
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
749 749
 	    if ($globalDebug) echo 'done !'."\n";
750 750
 	    // FIXME: Need more work
751 751
 	    if ($buffer != '') $reset = 0;
752
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
753
-	    $buffer = explode('\n',$buffer);
752
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
753
+	    $buffer = explode('\n', $buffer);
754 754
 	    foreach ($buffer as $line) {
755 755
 		if ($line != '') {
756 756
 		    $data = array();
757 757
 		    //echo $line."\n";
758
-		    $data['mmsi'] = (int)substr($line,0,9);
759
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
760
-		    $data['status_id'] = substr($line,21,2);
761
-		    $data['type_id'] = substr($line,24,3);
762
-		    $data['latitude'] = substr($line,29,9);
763
-		    $data['longitude'] = substr($line,41,9);
764
-		    $data['speed'] = round(substr($line,51,5));
758
+		    $data['mmsi'] = (int) substr($line, 0, 9);
759
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
760
+		    $data['status_id'] = substr($line, 21, 2);
761
+		    $data['type_id'] = substr($line, 24, 3);
762
+		    $data['latitude'] = substr($line, 29, 9);
763
+		    $data['longitude'] = substr($line, 41, 9);
764
+		    $data['speed'] = round(substr($line, 51, 5));
765 765
 		    //$data['course'] = substr($line,57,5);
766
-		    $data['heading'] = round(substr($line,63,3));
766
+		    $data['heading'] = round(substr($line, 63, 3));
767 767
 		    //$data['draft'] = substr($line,67,4);
768 768
 		    //$data['length'] = substr($line,72,3);
769 769
 		    //$data['beam'] = substr($line,76,2);
770
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
770
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
771 771
 		    //$data['callsign'] = trim(substr($line,100,7);
772
-		    $data['arrival_code'] = substr($line,108,20);
772
+		    $data['arrival_code'] = substr($line, 108, 20);
773 773
 		    //$data['etaDate'] = substr($line,129,5);
774 774
 		    //$data['etaTime'] = substr($line,135,5);
775 775
 		    $data['format_source'] = 'shipplotter';
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 	    )
790 790
 	) {
791 791
 	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
792
-		$authsailaway = $Common->getData('http://backend.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);
792
+		$authsailaway = $Common->getData('http://backend.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);
793 793
 		//echo $authsailaway;
794 794
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
795 795
 		if (isset($setcookie[1][0])) {
@@ -798,18 +798,18 @@  discard block
 block discarded – undo
798 798
 	    }
799 799
 
800 800
 	    if ($globalDebug) echo '! Download... ';
801
-	    for ($i =0; $i <= 1; $i++) {
801
+	    for ($i = 0; $i <= 1; $i++) {
802 802
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
803 803
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
804 804
 	    if ($globalDebug) echo 'done'."\n";
805 805
 	    if ($buffer != '') {
806
-		$all_data = json_decode($buffer,true);
806
+		$all_data = json_decode($buffer, true);
807 807
 		if (isset($all_data['missions'])) {
808 808
 			foreach ($all_data['missions'] as $mission) {
809 809
 				$mission_user = $mission['usrname'];
810
-				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
811
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
812
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
810
+				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']));
811
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
812
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie);
813 813
 					else $racebuffer = '';
814 814
 					$bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
815 815
 				} else {
@@ -817,19 +817,19 @@  discard block
 block discarded – undo
817 817
 					$racebuffer = '';
818 818
 				}
819 819
 				if ($racebuffer != '') {
820
-					$race_data = json_decode($racebuffer,true);
820
+					$race_data = json_decode($racebuffer, true);
821 821
 					//print_r($race_data);
822 822
 					unset($racebuffer);
823 823
 					if (isset($race_data['mission'])) {
824 824
 					    $datar = array();
825 825
 					    $datar['id'] = $mission['misnr'];
826 826
 					    $datar['desc'] = $race_data['mission']['misdescr'];
827
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
828
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
827
+					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname'])));
828
+					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle'])));
829 829
 					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
830 830
 					    $markers = array();
831 831
 					    foreach ($race_data['mission']['course'] as $course) {
832
-						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
832
+						$markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']);
833 833
 					    }
834 834
 					    $datar['markers'] = json_encode($markers);
835 835
 					    //print_r($datar);
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
 					}
838 838
 				}
839 839
 				if ($bufferm != '') {
840
-					$mission_data = json_decode($bufferm,true);
840
+					$mission_data = json_decode($bufferm, true);
841 841
 					unset($bufferm);
842 842
 					if (isset($mission_data['leaderboard'][0]['results'])) {
843 843
 						foreach ($mission_data['leaderboard'][0]['results'] as $sail) {
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 								//$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr'];
851 851
 								$data['id'] = $sail['misnr'].'-'.$sail['usrnr'];
852 852
 								$data['datetime'] = date('Y-m-d H:i:s');
853
-								$data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart']));
853
+								$data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart']));
854 854
 								$data['last_update'] = date('Y-m-d H:i:s');
855 855
 								$data['status'] = $sail['status'];
856 856
 								$data['type'] = $sail['btptype'];
@@ -861,16 +861,16 @@  discard block
 block discarded – undo
861 861
 									$data['longitude'] = $pos['longitude'];
862 862
 								}
863 863
 								if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') {
864
-									$resultdescr = explode(',',$sail['resultdescr']);
864
+									$resultdescr = explode(',', $sail['resultdescr']);
865 865
 									if (count($resultdescr) > 2) {
866
-										$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2);
867
-										$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1]));
866
+										$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2);
867
+										$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1]));
868 868
 										if (isset($resultdescr[3])) {
869
-											$data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3);
869
+											$data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3);
870 870
 										}
871 871
 									}
872 872
 								}
873
-								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
873
+								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
874 874
 								$data['captain_id'] = $sail['usrnr'];
875 875
 								$data['captain_name'] = $sail['usrname'];
876 876
 								$data['race_id'] = $sail['misnr'];
@@ -918,8 +918,8 @@  discard block
 block discarded – undo
918 918
 	) {
919 919
 	    //$buffer = $Common->getData($hosts[$id]);
920 920
 	    $buffer = $Common->getData($value['host']);
921
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
922
-	    $buffer = explode('\n',$buffer);
921
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
922
+	    $buffer = explode('\n', $buffer);
923 923
 	    $reset = 0;
924 924
 	    foreach ($buffer as $line) {
925 925
     		if ($line != '') {
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
931 931
 			$data['pilot_id'] = $line[1];
932 932
 			$data['pilot_name'] = $line[2];
933
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
933
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
934 934
 			$data['ident'] = $line[0]; // ident
935 935
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
936 936
 			$data['speed'] = $line[8]; // speed
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
947 947
 			//if (isset($line[37])) $data['last_update'] = $line[37];
948 948
 		        $data['departure_airport_icao'] = $line[11];
949
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
949
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
950 950
 		        $data['arrival_airport_icao'] = $line[13];
951 951
 			$data['frequency'] = $line[4];
952 952
 			$data['type'] = $line[18];
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
     			$data['id_source'] = $id_source;
956 956
 	    		//$data['arrival_airport_time'] = ;
957 957
 	    		if ($line[9] != '') {
958
-	    		    $aircraft_data = explode('/',$line[9]);
958
+	    		    $aircraft_data = explode('/', $line[9]);
959 959
 	    		    if (isset($aircraft_data[1])) {
960 960
 	    			$data['aircraft_icao'] = $aircraft_data[1];
961 961
 	    		    }
@@ -970,9 +970,9 @@  discard block
 block discarded – undo
970 970
     			if ($line[3] === 'PILOT') $SI->add($data);
971 971
 			elseif ($line[3] === 'ATC') {
972 972
 				//print_r($data);
973
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
974
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
975
-				$typec = substr($data['ident'],-3);
973
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
974
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
975
+				$typec = substr($data['ident'], -3);
976 976
 				if ($typec === 'APP') $data['type'] = 'Approach';
977 977
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
978 978
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -984,8 +984,8 @@  discard block
 block discarded – undo
984 984
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
985 985
 				if (!isset($data['source_name'])) $data['source_name'] = '';
986 986
 				if (isset($ATC)) {
987
-					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']);
988
-					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
+					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']);
988
+					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']);
989 989
 				}
990 990
 			}
991 991
     			unset($data);
@@ -1001,24 +1001,24 @@  discard block
 block discarded – undo
1001 1001
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1002 1002
     	    )
1003 1003
     	) {
1004
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1004
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
1005 1005
 	    if ($buffer != '') {
1006 1006
 		$all_data = simplexml_load_string($buffer);
1007
-		foreach($all_data->children() as $childdata) {
1007
+		foreach ($all_data->children() as $childdata) {
1008 1008
 			$data = array();
1009 1009
 			$line = $childdata;
1010 1010
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
1011
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
1012
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1013
-			$data['latitude'] = (float)$line['pktLatitude'];
1014
-			$data['longitude'] = (float)$line['pktLongitude'];
1015
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1016
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1017
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1011
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
1012
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
1013
+			$data['latitude'] = (float) $line['pktLatitude'];
1014
+			$data['longitude'] = (float) $line['pktLongitude'];
1015
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
1016
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
1017
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
1018 1018
 			$data['altitude_relative'] = 'AMSL';
1019
-			$data['pilot_id'] = (int)$line['pktPilotID'];
1019
+			$data['pilot_id'] = (int) $line['pktPilotID'];
1020 1020
 			$data['aircraft_icao'] = 'PARAGLIDER';
1021
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1021
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1022 1022
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1023 1023
 			$data['format_source'] = $value['format'];
1024 1024
 			$SI->add($data);
@@ -1026,22 +1026,22 @@  discard block
 block discarded – undo
1026 1026
 		}
1027 1027
 	    }
1028 1028
 	    $Source->deleteOldLocationByType('gs');
1029
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1029
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
1030 1030
 	    if ($buffer != '') {
1031 1031
 		$all_data = simplexml_load_string($buffer);
1032
-		foreach($all_data->children() as $childdata) {
1032
+		foreach ($all_data->children() as $childdata) {
1033 1033
 			$data = array();
1034 1034
 			$line = $childdata;
1035
-			$data['id'] = (int)$line['gsID'];
1036
-			$data['latitude'] = (float)$line['gsLatitude'];
1037
-			$data['longitude'] = (float)$line['gsLongitude'];
1038
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
1035
+			$data['id'] = (int) $line['gsID'];
1036
+			$data['latitude'] = (float) $line['gsLatitude'];
1037
+			$data['longitude'] = (float) $line['gsLongitude'];
1038
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
1039 1039
 			$data['altitude_relative'] = 'AMSL';
1040
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
1040
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
1041 1041
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
1042
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1042
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1043 1043
 			} else {
1044
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1044
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1045 1045
 			}
1046 1046
 			unset($data);
1047 1047
 		}
@@ -1059,9 +1059,9 @@  discard block
 block discarded – undo
1059 1059
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1060 1060
 	    )
1061 1061
 	) {
1062
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1062
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1063 1063
 	    if ($buffer != '') {
1064
-	        $all_data = json_decode($buffer,true);
1064
+	        $all_data = json_decode($buffer, true);
1065 1065
 		if (isset($all_data['acList'])) {
1066 1066
 		    $reset = 0;
1067 1067
 		    foreach ($all_data['acList'] as $line) {
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1078 1078
 			$data['emergency'] = ''; // emergency
1079 1079
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1080
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1080
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1081 1081
 			else $data['datetime'] = date('Y-m-d H:i:s');
1082 1082
 			//$data['datetime'] = date('Y-m-d H:i:s');
1083 1083
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1103 1103
 			$data['squawk'] = $line['squawk']; // squawk
1104 1104
 			$data['emergency'] = ''; // emergency
1105
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1105
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1106 1106
 			else $data['datetime'] = date('Y-m-d H:i:s');
1107 1107
 			$data['format_source'] = 'aircraftlistjson';
1108 1108
 			$data['id_source'] = $id_source;
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
     	    )
1124 1124
     	) {
1125 1125
 	    $buffer = $Common->getData($value['host']);
1126
-	    $all_data = json_decode($buffer,true);
1126
+	    $all_data = json_decode($buffer, true);
1127 1127
 	    if (isset($all_data['planes'])) {
1128 1128
 		$reset = 0;
1129 1129
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1140,12 +1140,12 @@  discard block
 block discarded – undo
1140 1140
 		    $data['emergency'] = ''; // emergency
1141 1141
 		    $data['registration'] = $line[2];
1142 1142
 		    $data['aircraft_icao'] = $line[0];
1143
-		    $deparr = explode('-',$line[1]);
1143
+		    $deparr = explode('-', $line[1]);
1144 1144
 		    if (count($deparr) === 2) {
1145 1145
 			$data['departure_airport_icao'] = $deparr[0];
1146 1146
 			$data['arrival_airport_icao'] = $deparr[1];
1147 1147
 		    }
1148
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1148
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1149 1149
 	    	    $data['format_source'] = 'planeupdatefaa';
1150 1150
     		    $data['id_source'] = $id_source;
1151 1151
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 	    )
1164 1164
 	) {
1165 1165
 	    $buffer = $Common->getData($value['host']);
1166
-	    $all_data = json_decode($buffer,true);
1166
+	    $all_data = json_decode($buffer, true);
1167 1167
 	    if (isset($all_data['states'])) {
1168 1168
 		$reset = 0;
1169 1169
 		foreach ($all_data['states'] as $key => $line) {
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
 		    //$data['emergency'] = ''; // emergency
1181 1181
 		    //$data['registration'] = $line[2];
1182 1182
 		    //$data['aircraft_icao'] = $line[0];
1183
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1183
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1184 1184
 		    $data['format_source'] = 'opensky';
1185 1185
 		    $data['id_source'] = $id_source;
1186 1186
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1197,8 +1197,8 @@  discard block
 block discarded – undo
1197 1197
 	    )
1198 1198
 	) {
1199 1199
 	    $buffer = $Common->getData($value['host']);
1200
-	    $all_data = json_decode($buffer,true);
1201
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1200
+	    $all_data = json_decode($buffer, true);
1201
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1202 1202
 		$reset = 0;
1203 1203
 		foreach ($all_data['aircraft'] as $key => $line) {
1204 1204
 		    $data = array();
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
 	    )
1237 1237
 	) {
1238 1238
 	    $buffer = $Common->getData($value['host']);
1239
-	    $all_data = json_decode($buffer,true);
1239
+	    $all_data = json_decode($buffer, true);
1240 1240
 	    if (isset($all_data['aircraft'])) {
1241 1241
 		$reset = 0;
1242 1242
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 		    //$data['emergency'] = ''; // emergency
1254 1254
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1255 1255
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1256
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1256
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1257 1257
 		    $data['format_source'] = 'planefinderclient';
1258 1258
 		    $data['id_source'] = $id_source;
1259 1259
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
 	) {
1273 1273
 	    //$buffer = $Common->getData($hosts[$id]);
1274 1274
 	    $buffer = $Common->getData($value['host']);
1275
-	    $all_data = json_decode($buffer,true);
1275
+	    $all_data = json_decode($buffer, true);
1276 1276
 	    if (!empty($all_data)) $reset = 0;
1277 1277
 	    foreach ($all_data as $key => $line) {
1278 1278
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1310,11 +1310,11 @@  discard block
 block discarded – undo
1310 1310
 	    )
1311 1311
 	) {
1312 1312
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1313
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1313
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1314 1314
 	    //echo $buffer;
1315
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1316
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1317
-	    $all_data = json_decode($buffer,true);
1315
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1316
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1317
+	    $all_data = json_decode($buffer, true);
1318 1318
 	    if (json_last_error() != JSON_ERROR_NONE) {
1319 1319
 		die(json_last_error_msg());
1320 1320
 	    }
@@ -1337,7 +1337,7 @@  discard block
 block discarded – undo
1337 1337
 			//$data['departure_airport_iata'] = $line[11];
1338 1338
 			//$data['arrival_airport_iata'] = $line[12];
1339 1339
 	    		//$data['emergency'] = ''; // emergency
1340
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1340
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1341 1341
 	    		$data['format_source'] = 'radarvirtueljson';
1342 1342
     			$data['id_source'] = $id_source;
1343 1343
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1358,14 +1358,14 @@  discard block
 block discarded – undo
1358 1358
 	) {
1359 1359
 	    //$buffer = $Common->getData($hosts[$id]);
1360 1360
 	    $buffer = $Common->getData($value['host'].'?'.time());
1361
-	    $all_data = json_decode(utf8_encode($buffer),true);
1361
+	    $all_data = json_decode(utf8_encode($buffer), true);
1362 1362
 	    
1363 1363
 	    if (isset($all_data['pireps'])) {
1364 1364
 		$reset = 0;
1365 1365
 	        foreach ($all_data['pireps'] as $line) {
1366 1366
 		    $data = array();
1367 1367
 		    $data['id'] = $line['id'];
1368
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1368
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1369 1369
 		    $data['ident'] = $line['callsign']; // ident
1370 1370
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1371 1371
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1395,9 +1395,9 @@  discard block
 block discarded – undo
1395 1395
 			$SI->add($data);
1396 1396
 		    //    print_r($data);
1397 1397
     		    } elseif ($line['icon'] === 'ct') {
1398
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1399
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1400
-			$typec = substr($data['ident'],-3);
1398
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1399
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1400
+			$typec = substr($data['ident'], -3);
1401 1401
 			$data['type'] = '';
1402 1402
 			if ($typec === 'APP') $data['type'] = 'Approach';
1403 1403
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1409 1409
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1410 1410
 			else $data['type'] = 'Observer';
1411
-			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']);
1411
+			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']);
1412 1412
 		    }
1413 1413
 		    unset($data);
1414 1414
 		}
@@ -1425,14 +1425,14 @@  discard block
 block discarded – undo
1425 1425
 	    //$buffer = $Common->getData($hosts[$id]);
1426 1426
 	    if ($globalDebug) echo 'Get Data...'."\n";
1427 1427
 	    $buffer = $Common->getData($value['host']);
1428
-	    $all_data = json_decode($buffer,true);
1428
+	    $all_data = json_decode($buffer, true);
1429 1429
 	    if ($buffer != '' && is_array($all_data)) {
1430 1430
 		$reset = 0;
1431 1431
 		foreach ($all_data as $line) {
1432 1432
 	    	    $data = array();
1433 1433
 	    	    //$data['id'] = $line['id']; // id not usable
1434 1434
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1435
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1435
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1436 1436
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1437 1437
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1438 1438
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1447,7 +1447,7 @@  discard block
 block discarded – undo
1447 1447
 	    	    //$data['datetime'] = $line['lastupdate'];
1448 1448
 	    	    //$data['last_update'] = $line['lastupdate'];
1449 1449
 	    	    if (isset($value['timezone'])) {
1450
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1450
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1451 1451
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1452 1452
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1453 1453
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1463,14 +1463,14 @@  discard block
 block discarded – undo
1463 1463
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1464 1464
 		    if (isset($line['aircraftname'])) {
1465 1465
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1466
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1467
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1466
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1467
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1468 1468
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1469 1469
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1470 1470
 	    		else {
1471
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1472
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1473
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1471
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1472
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1473
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1474 1474
 	    		}
1475 1475
 	    	    }
1476 1476
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
 	    //$buffer = $Common->getData($hosts[$id]);
1496 1496
 	    if ($globalDebug) echo 'Get Data...'."\n";
1497 1497
 	    $buffer = $Common->getData($value['host']);
1498
-	    $all_data = json_decode($buffer,true);
1498
+	    $all_data = json_decode($buffer, true);
1499 1499
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1500 1500
 		$reset = 0;
1501 1501
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1506,7 +1506,7 @@  discard block
 block discarded – undo
1506 1506
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1507 1507
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1508 1508
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1509
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1509
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1510 1510
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1511 1511
 	    	    $data['altitude'] = $line['altitude']; // altitude
1512 1512
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1517,7 +1517,7 @@  discard block
 block discarded – undo
1517 1517
 	    	    //$data['squawk'] = ''; // squawk
1518 1518
 	    	    //$data['emergency'] = ''; // emergency
1519 1519
 	    	    if (isset($value['timezone'])) {
1520
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1520
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1521 1521
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1522 1522
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1523 1523
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1553,14 +1553,14 @@  discard block
 block discarded – undo
1553 1553
 	    //$buffer = $Common->getData($hosts[$id]);
1554 1554
 	    if ($globalDebug) echo 'Get Data...'."\n";
1555 1555
 	    $buffer = $Common->getData($value['host']);
1556
-	    $all_data = json_decode($buffer,true);
1556
+	    $all_data = json_decode($buffer, true);
1557 1557
 	    if ($buffer != '' && is_array($all_data)) {
1558 1558
 		$reset = 0;
1559 1559
 		foreach ($all_data as $line) {
1560 1560
 	    	    $data = array();
1561 1561
 	    	    //$data['id'] = $line['id']; // id not usable
1562 1562
 	    	    $data['id'] = trim($line['flight_id']);
1563
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1563
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1564 1564
 	    	    $data['pilot_name'] = $line['pilot_name'];
1565 1565
 	    	    $data['pilot_id'] = $line['pilot_id'];
1566 1566
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1604,24 +1604,24 @@  discard block
 block discarded – undo
1604 1604
 	    //$buffer = $Common->getData($hosts[$id]);
1605 1605
 	    if ($globalDebug) echo 'Get Data...'."\n";
1606 1606
 	    $buffer = $Common->getData($value['host']);
1607
-	    $all_data = json_decode($buffer,true);
1607
+	    $all_data = json_decode($buffer, true);
1608 1608
 	    if ($buffer != '') {
1609 1609
 		$Source->deleteLocationBySource('blitzortung');
1610
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1611
-		$buffer = explode('\n',$buffer);
1610
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1611
+		$buffer = explode('\n', $buffer);
1612 1612
 		foreach ($buffer as $buffer_line) {
1613
-		    $line = json_decode($buffer_line,true);
1613
+		    $line = json_decode($buffer_line, true);
1614 1614
 		    if (isset($line['time'])) {
1615 1615
 			$data = array();
1616 1616
 			$data['altitude'] = $line['alt']; // altitude
1617 1617
 			$data['latitude'] = $line['lat']; // lat
1618 1618
 			$data['longitude'] = $line['lon']; // long
1619
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1619
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1620 1620
 			$data['id_source'] = $id_source;
1621 1621
 			$data['format_source'] = 'blitzortung';
1622 1622
 			$SI->add($data);
1623 1623
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1624
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1624
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1625 1625
 			unset($data);
1626 1626
 		    }
1627 1627
 		}
@@ -1633,15 +1633,15 @@  discard block
 block discarded – undo
1633 1633
         $arr = $httpfeeds;
1634 1634
         $w = $e = null;
1635 1635
         if (isset($arr[$id])) {
1636
-            $nn = stream_select($arr,$w,$e,$timeout);
1636
+            $nn = stream_select($arr, $w, $e, $timeout);
1637 1637
             if ($nn > 0) {
1638 1638
                 foreach ($httpfeeds as $feed) {
1639
-                    $buffer = stream_get_line($feed,2000,"\n");
1639
+                    $buffer = stream_get_line($feed, 2000, "\n");
1640 1640
                     if ($buffer === FALSE) {
1641 1641
                         connect_all($globalSources);
1642 1642
                     }
1643
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1644
-                    $buffer = explode('\n',$buffer);
1643
+                    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1644
+                    $buffer = explode('\n', $buffer);
1645 1645
                     foreach ($buffer as $line) {
1646 1646
                         if ($line != '') {
1647 1647
                             $line = json_decode($line, true);
@@ -1681,11 +1681,11 @@  discard block
 block discarded – undo
1681 1681
 		    //$value = $formats[$nb];
1682 1682
 		    $format = $globalSources[$nb]['format'];
1683 1683
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1684
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1684
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1685 1685
 		    } elseif ($format === 'vrstcp') {
1686 1686
 			$buffer = @socket_read($r, 6000);
1687 1687
 		    } else {
1688
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1688
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1689 1689
 		    }
1690 1690
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1691 1691
 		    //echo $buffer."\n";
@@ -1695,8 +1695,8 @@  discard block
 block discarded – undo
1695 1695
 		    //$SI::del();
1696 1696
 		    if ($buffer !== FALSE) {
1697 1697
 			if ($format === 'vrstcp') {
1698
-			    $buffer = explode('},{',$buffer);
1699
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1698
+			    $buffer = explode('},{', $buffer);
1699
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1700 1700
 		    }
1701 1701
 		    // SBS format is CSV format
1702 1702
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1723,7 +1723,7 @@  discard block
 block discarded – undo
1723 1723
 			    $ais_data = $AIS->parse_line(trim($buffer));
1724 1724
 			    $data = array();
1725 1725
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1726
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1726
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1727 1727
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1728 1728
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1729 1729
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1734,13 +1734,13 @@  discard block
 block discarded – undo
1734 1734
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1735 1735
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1736 1736
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1737
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1737
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1738 1738
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1739 1739
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1740 1740
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1741 1741
 
1742 1742
 			    if (isset($ais_data['timestamp'])) {
1743
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1743
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1744 1744
 			    } else {
1745 1745
 				$data['datetime'] = date('Y-m-d H:i:s');
1746 1746
 			    }
@@ -1751,10 +1751,10 @@  discard block
 block discarded – undo
1751 1751
                         } elseif ($format === 'flightgearsp') {
1752 1752
                     	    //echo $buffer."\n";
1753 1753
                     	    if (strlen($buffer) > 5) {
1754
-				$line = explode(',',$buffer);
1754
+				$line = explode(',', $buffer);
1755 1755
 				$data = array();
1756 1756
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1757
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1757
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1758 1758
 				$data['ident'] = $line[6];
1759 1759
 				$data['aircraft_name'] = $line[7];
1760 1760
 				$data['longitude'] = $line[1];
@@ -1771,16 +1771,16 @@  discard block
 block discarded – undo
1771 1771
                         } elseif ($format === 'acars') {
1772 1772
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1773 1773
 			    $ACARS->add(trim($buffer));
1774
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1774
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1775 1775
 			    $ACARS->deleteLiveAcarsData();
1776 1776
 			} elseif ($format === 'flightgearmp') {
1777
-			    if (substr($buffer,0,1) != '#') {
1777
+			    if (substr($buffer, 0, 1) != '#') {
1778 1778
 				$data = array();
1779 1779
 				//echo $buffer."\n";
1780
-				$line = explode(' ',$buffer);
1780
+				$line = explode(' ', $buffer);
1781 1781
 				if (count($line) === 11) {
1782
-				    $userserver = explode('@',$line[0]);
1783
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1782
+				    $userserver = explode('@', $line[0]);
1783
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1784 1784
 				    $data['ident'] = $userserver[0];
1785 1785
 				    $data['registration'] = $userserver[0];
1786 1786
 				    $data['latitude'] = $line[4];
@@ -1788,8 +1788,8 @@  discard block
 block discarded – undo
1788 1788
 				    $data['altitude'] = $line[6];
1789 1789
 				    $data['datetime'] = date('Y-m-d H:i:s');
1790 1790
 				    $aircraft_type = $line[10];
1791
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1792
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1791
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1792
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1793 1793
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1794 1794
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1795 1795
 				}
@@ -1798,8 +1798,8 @@  discard block
 block discarded – undo
1798 1798
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1799 1799
 			    die;
1800 1800
 			} elseif ($format === 'vrstcp') {
1801
-			    foreach($buffer as $all_data) {
1802
-				$line = json_decode('{'.$all_data.'}',true);
1801
+			    foreach ($buffer as $all_data) {
1802
+				$line = json_decode('{'.$all_data.'}', true);
1803 1803
 				$data = array();
1804 1804
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1805 1805
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1825,16 +1825,16 @@  discard block
 block discarded – undo
1825 1825
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1826 1826
 				unset($data);
1827 1827
 			    }
1828
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1828
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1829 1829
 			    $line = explode("\t", $buffer);
1830
-			    for($k = 0; $k < count($line); $k=$k+2) {
1830
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1831 1831
 				$key = $line[$k];
1832
-			        $lined[$key] = $line[$k+1];
1832
+			        $lined[$key] = $line[$k + 1];
1833 1833
 			    }
1834 1834
     			    if (count($lined) > 3) {
1835 1835
     				$data['hex'] = $lined['hexid'];
1836 1836
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1837
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1837
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1838 1838
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1839 1839
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1840 1840
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1853,23 +1853,23 @@  discard block
 block discarded – undo
1853 1853
     			    } else $error = true;
1854 1854
 			} elseif ($format === 'aprs' && $use_aprs) {
1855 1855
 			    if ($aprs_connect === 0) {
1856
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1856
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1857 1857
 				$aprs_connect = 1;
1858 1858
 			    }
1859 1859
 			    
1860
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1860
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1861 1861
 				$aprs_last_tx = time();
1862 1862
 				$data_aprs = "# Keep alive";
1863
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1863
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1864 1864
 			    }
1865 1865
 			    
1866 1866
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1867 1867
 			    //echo 'APRS data : '.$buffer."\n";
1868
-			    $buffer = str_replace('APRS <- ','',$buffer);
1869
-			    $buffer = str_replace('APRS -> ','',$buffer);
1868
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1869
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1870 1870
 			    //echo $buffer."\n";
1871 1871
 			    date_default_timezone_set('UTC');
1872
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1872
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1873 1873
 				$line = $APRS->parse($buffer);
1874 1874
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1875 1875
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1884,7 +1884,7 @@  discard block
 block discarded – undo
1884 1884
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1885 1885
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1886 1886
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1887
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1887
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1888 1888
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1889 1889
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1890 1890
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1972,29 +1972,29 @@  discard block
 block discarded – undo
1972 1972
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1973 1973
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1974 1974
 					$Source->deleteOldLocationByType('gs');
1975
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1976
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1975
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1976
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1977 1977
 					} else {
1978
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1978
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1979 1979
 					}
1980 1980
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1981 1981
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1982 1982
 					if ($globalDebug) echo '# Weather Station added'."\n";
1983 1983
 					$Source->deleteOldLocationByType('wx');
1984 1984
 					$weather_data = json_encode($line);
1985
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1986
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1985
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1986
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1987 1987
 					} else {
1988
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1988
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1989 1989
 					}
1990 1990
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1991 1991
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1992 1992
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1993 1993
 					$Source->deleteOldLocationByType('lightning');
1994
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1995
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1994
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1995
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1996 1996
 					} else {
1997
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1997
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1998 1998
 					}
1999 1999
 				    } elseif ($globalDebug) {
2000 2000
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -2003,7 +2003,7 @@  discard block
 block discarded – undo
2003 2003
 				    unset($data);
2004 2004
 				}
2005 2005
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2006
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2006
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
2007 2007
 				}
2008 2008
 				/*
2009 2009
 				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')) {
@@ -2012,7 +2012,7 @@  discard block
 block discarded – undo
2012 2012
 				*/
2013 2013
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2014 2014
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2015
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2015
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
2016 2016
 					$Source->deleteOldLocationByType('lightning');
2017 2017
 					$Source->deleteOldLocationByType('wx');
2018 2018
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2099,7 +2099,7 @@  discard block
 block discarded – undo
2099 2099
 				connect_all($sourceee);
2100 2100
 				$sourceee = array();
2101 2101
 				//connect_all($globalSources);
2102
-				$tt[$format]=0;
2102
+				$tt[$format] = 0;
2103 2103
 				break;
2104 2104
 			    } 
2105 2105
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2109,14 +2109,14 @@  discard block
 block discarded – undo
2109 2109
 	    } else {
2110 2110
 		$error = socket_strerror(socket_last_error());
2111 2111
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2112
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2112
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2113 2113
 			if (isset($globalDebug)) echo "Restarting...\n";
2114 2114
 			// Restart the script if possible
2115 2115
 			if (is_array($sockets)) {
2116 2116
 			    if ($globalDebug) echo "Shutdown all sockets...";
2117 2117
 			    
2118 2118
 			    foreach ($sockets as $sock) {
2119
-				@socket_shutdown($sock,2);
2119
+				@socket_shutdown($sock, 2);
2120 2120
 				@socket_close($sock);
2121 2121
 			    }
2122 2122
 			    
Please login to merge, or discard this patch.