Completed
Push — master ( 968df7...cae9ac )
by Yannick
49:38 queued 16:47
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
@@ -523,11 +523,11 @@  discard block
 block discarded – undo
523 523
 	    )
524 524
 	) {
525 525
 	    date_default_timezone_set('CET');
526
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
526
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
527 527
 	    date_default_timezone_set('UTC');
528 528
 	    if ($buffer != '') $reset = 0;
529
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
530
-	    $buffer = explode('\n',$buffer);
529
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
530
+	    $buffer = explode('\n', $buffer);
531 531
 	    foreach ($buffer as $line) {
532 532
 		if ($line != '') {
533 533
 		    //echo "'".$line."'\n";
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 		    $ais_data = $AIS->parse_line(trim($line));
536 536
 		    $data = array();
537 537
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
538
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
538
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
539 539
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
540 540
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
541 541
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
548 548
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
549 549
 		    if (isset($ais_data['timestamp'])) {
550
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
550
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
551 551
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
552 552
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
553 553
 			    $add = true;
@@ -570,21 +570,21 @@  discard block
 block discarded – undo
570 570
 	    $w = $e = null;
571 571
 	    
572 572
 	    if (isset($arr[$id])) {
573
-		$nn = stream_select($arr,$w,$e,$timeout);
573
+		$nn = stream_select($arr, $w, $e, $timeout);
574 574
 		if ($nn > 0) {
575 575
 		    foreach ($httpfeeds as $feed) {
576
-			$buffer = stream_get_line($feed,2000,"\n");
576
+			$buffer = stream_get_line($feed, 2000, "\n");
577 577
 			if ($buffer === FALSE) {
578 578
 			    connect_all($globalSources);
579 579
 			}
580
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
581
-			$buffer = explode('\n',$buffer);
580
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
581
+			$buffer = explode('\n', $buffer);
582 582
 			foreach ($buffer as $line) {
583 583
 			    if ($line != '') {
584 584
 				$ais_data = $AIS->parse_line(trim($line));
585 585
 				$data = array();
586 586
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
587
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
587
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
588 588
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
589 589
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
590 590
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -596,9 +596,9 @@  discard block
 block discarded – undo
596 596
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
597 597
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
598 598
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
599
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
599
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
600 600
 				if (isset($ais_data['timestamp'])) {
601
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
601
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
602 602
 				} else {
603 603
 				    $data['datetime'] = date('Y-m-d H:i:s');
604 604
 				}
@@ -630,10 +630,10 @@  discard block
 block discarded – undo
630 630
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
631 631
 	    )
632 632
 	) {
633
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
633
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
634 634
 	    if ($buffer != '') {
635 635
 		//echo $buffer;
636
-		$all_data = json_decode($buffer,true);
636
+		$all_data = json_decode($buffer, true);
637 637
 		//print_r($all_data);
638 638
 		if (isset($all_data[0]['DATA'])) {
639 639
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 			    $data['ident'] = $line['NAME'];
643 643
 			    $data['mmsi'] = $line['MMSI'];
644 644
 			    if (strlen($data['mmsi']) > 9) {
645
-				$data['mmsi'] = substr($data['mmsi'],-9);
645
+				$data['mmsi'] = substr($data['mmsi'], -9);
646 646
 			    }
647 647
 			    $data['speed'] = $line['SOG'];
648 648
 			    $data['heading'] = $line['COG'];
@@ -652,8 +652,8 @@  discard block
 block discarded – undo
652 652
 			    //$data['type_id'] = $line['TYPE'];
653 653
 			    $data['imo'] = $line['IMO'];
654 654
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
655
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
656
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
655
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
656
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
657 657
 			    $data['format_source'] = 'myshiptracking';
658 658
 			    $data['id_source'] = $id_source;
659 659
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -670,16 +670,16 @@  discard block
 block discarded – undo
670 670
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
671 671
 	    )
672 672
 	) {
673
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
673
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
674 674
 	    if ($buffer != '') {
675
-		$all_data = json_decode($buffer,true);
675
+		$all_data = json_decode($buffer, true);
676 676
 		if (isset($all_data[0]['mmsi'])) {
677 677
 		    foreach ($all_data as $line) {
678 678
 			if ($line != '') {
679 679
 			    $data = array();
680 680
 			    $data['ident'] = $line['shipname'];
681 681
 			    $data['callsign'] = $line['callsign'];
682
-			    $data['mmsi'] = substr($line['mmsi'],-9);
682
+			    $data['mmsi'] = substr($line['mmsi'], -9);
683 683
 			    $data['speed'] = $line['sog'];
684 684
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
685 685
 			    $data['latitude'] = $line['latitude'];
@@ -706,14 +706,14 @@  discard block
 block discarded – undo
706 706
 	) {
707 707
 	    $buffer = $Common->getData($value['host']);
708 708
 	    if ($buffer != '') {
709
-		$all_data = json_decode($buffer,true);
709
+		$all_data = json_decode($buffer, true);
710 710
 		if (isset($all_data['features'][0]['id'])) {
711 711
 		    foreach ($all_data['features'] as $line) {
712 712
 			print_r($line);
713 713
 			$data = array();
714 714
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
715 715
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
716
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
716
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
717 717
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
718 718
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
719 719
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -740,31 +740,31 @@  discard block
 block discarded – undo
740 740
 	    )
741 741
 	) {
742 742
 	    if ($globalDebug) echo 'download...';
743
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
743
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
744 744
 	    if ($globalDebug) echo 'done !'."\n";
745 745
 	    // FIXME: Need more work
746 746
 	    if ($buffer != '') $reset = 0;
747
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
748
-	    $buffer = explode('\n',$buffer);
747
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
748
+	    $buffer = explode('\n', $buffer);
749 749
 	    foreach ($buffer as $line) {
750 750
 		if ($line != '') {
751 751
 		    $data = array();
752 752
 		    //echo $line."\n";
753
-		    $data['mmsi'] = (int)substr($line,0,9);
754
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
755
-		    $data['status_id'] = substr($line,21,2);
756
-		    $data['type_id'] = substr($line,24,3);
757
-		    $data['latitude'] = substr($line,29,9);
758
-		    $data['longitude'] = substr($line,41,9);
759
-		    $data['speed'] = round(substr($line,51,5));
753
+		    $data['mmsi'] = (int) substr($line, 0, 9);
754
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
755
+		    $data['status_id'] = substr($line, 21, 2);
756
+		    $data['type_id'] = substr($line, 24, 3);
757
+		    $data['latitude'] = substr($line, 29, 9);
758
+		    $data['longitude'] = substr($line, 41, 9);
759
+		    $data['speed'] = round(substr($line, 51, 5));
760 760
 		    //$data['course'] = substr($line,57,5);
761
-		    $data['heading'] = round(substr($line,63,3));
761
+		    $data['heading'] = round(substr($line, 63, 3));
762 762
 		    //$data['draft'] = substr($line,67,4);
763 763
 		    //$data['length'] = substr($line,72,3);
764 764
 		    //$data['beam'] = substr($line,76,2);
765
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
765
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
766 766
 		    //$data['callsign'] = trim(substr($line,100,7);
767
-		    $data['arrival_code'] = substr($line,108,20);
767
+		    $data['arrival_code'] = substr($line, 108, 20);
768 768
 		    //$data['etaDate'] = substr($line,129,5);
769 769
 		    //$data['etaTime'] = substr($line,135,5);
770 770
 		    $data['format_source'] = 'shipplotter';
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 	    )
785 785
 	) {
786 786
 	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
787
-		$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);
787
+		$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);
788 788
 		//echo $authsailaway;
789 789
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
790 790
 		if (isset($setcookie[1][0])) {
@@ -793,18 +793,18 @@  discard block
 block discarded – undo
793 793
 	    }
794 794
 
795 795
 	    if ($globalDebug) echo '! Download... ';
796
-	    for ($i =0; $i <= 1; $i++) {
796
+	    for ($i = 0; $i <= 1; $i++) {
797 797
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
798 798
 		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
799 799
 	    if ($globalDebug) echo 'done'."\n";
800 800
 	    if ($buffer != '') {
801
-		$all_data = json_decode($buffer,true);
801
+		$all_data = json_decode($buffer, true);
802 802
 		if (isset($all_data['missions'])) {
803 803
 			foreach ($all_data['missions'] as $mission) {
804 804
 				$mission_user = $mission['usrname'];
805
-				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
806
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
807
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
805
+				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']));
806
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
807
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie);
808 808
 					else $racebuffer = '';
809 809
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
810 810
 				} else {
@@ -812,19 +812,19 @@  discard block
 block discarded – undo
812 812
 					$racebuffer = '';
813 813
 				}
814 814
 				if ($racebuffer != '') {
815
-					$race_data = json_decode($racebuffer,true);
815
+					$race_data = json_decode($racebuffer, true);
816 816
 					//print_r($race_data);
817 817
 					unset($racebuffer);
818 818
 					if (isset($race_data['mission'])) {
819 819
 					    $datar = array();
820 820
 					    $datar['id'] = $mission['misnr'];
821 821
 					    $datar['desc'] = $race_data['mission']['misdescr'];
822
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
823
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
822
+					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname'])));
823
+					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle'])));
824 824
 					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
825 825
 					    $markers = array();
826 826
 					    foreach ($race_data['mission']['course'] as $course) {
827
-						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
827
+						$markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']);
828 828
 					    }
829 829
 					    $datar['markers'] = json_encode($markers);
830 830
 					    //print_r($datar);
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 					}
833 833
 				}
834 834
 				if ($bufferm != '') {
835
-					$mission_data = json_decode($bufferm,true);
835
+					$mission_data = json_decode($bufferm, true);
836 836
 					unset($bufferm);
837 837
 					if (isset($mission_data['leaderboard'][0]['results'])) {
838 838
 						foreach ($mission_data['leaderboard'][0]['results'] as $sail) {
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
 								//$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr'];
846 846
 								$data['id'] = $sail['misnr'].'-'.$sail['usrnr'];
847 847
 								$data['datetime'] = date('Y-m-d H:i:s');
848
-								$data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart']));
848
+								$data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart']));
849 849
 								$data['last_update'] = date('Y-m-d H:i:s');
850 850
 								$data['status'] = $sail['status'];
851 851
 								$data['type'] = $sail['btptype'];
@@ -856,16 +856,16 @@  discard block
 block discarded – undo
856 856
 									$data['longitude'] = $pos['longitude'];
857 857
 								}
858 858
 								if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') {
859
-									$resultdescr = explode(',',$sail['resultdescr']);
859
+									$resultdescr = explode(',', $sail['resultdescr']);
860 860
 									if (count($resultdescr) > 2) {
861
-										$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2);
862
-										$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1]));
861
+										$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2);
862
+										$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1]));
863 863
 										if (isset($resultdescr[3])) {
864
-											$data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3);
864
+											$data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3);
865 865
 										}
866 866
 									}
867 867
 								}
868
-								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
868
+								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
869 869
 								$data['captain_id'] = $sail['usrnr'];
870 870
 								$data['captain_name'] = $sail['usrname'];
871 871
 								$data['race_id'] = $sail['misnr'];
@@ -913,8 +913,8 @@  discard block
 block discarded – undo
913 913
 	) {
914 914
 	    //$buffer = $Common->getData($hosts[$id]);
915 915
 	    $buffer = $Common->getData($value['host']);
916
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
917
-	    $buffer = explode('\n',$buffer);
916
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
917
+	    $buffer = explode('\n', $buffer);
918 918
 	    $reset = 0;
919 919
 	    foreach ($buffer as $line) {
920 920
     		if ($line != '') {
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
926 926
 			$data['pilot_id'] = $line[1];
927 927
 			$data['pilot_name'] = $line[2];
928
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
928
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
929 929
 			$data['ident'] = $line[0]; // ident
930 930
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
931 931
 			$data['speed'] = $line[8]; // speed
@@ -941,7 +941,7 @@  discard block
 block discarded – undo
941 941
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
942 942
 			//if (isset($line[37])) $data['last_update'] = $line[37];
943 943
 		        $data['departure_airport_icao'] = $line[11];
944
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
944
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
945 945
 		        $data['arrival_airport_icao'] = $line[13];
946 946
 			$data['frequency'] = $line[4];
947 947
 			$data['type'] = $line[18];
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
     			$data['id_source'] = $id_source;
951 951
 	    		//$data['arrival_airport_time'] = ;
952 952
 	    		if ($line[9] != '') {
953
-	    		    $aircraft_data = explode('/',$line[9]);
953
+	    		    $aircraft_data = explode('/', $line[9]);
954 954
 	    		    if (isset($aircraft_data[1])) {
955 955
 	    			$data['aircraft_icao'] = $aircraft_data[1];
956 956
 	    		    }
@@ -965,9 +965,9 @@  discard block
 block discarded – undo
965 965
     			if ($line[3] === 'PILOT') $SI->add($data);
966 966
 			elseif ($line[3] === 'ATC') {
967 967
 				//print_r($data);
968
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
969
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
970
-				$typec = substr($data['ident'],-3);
968
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
969
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
970
+				$typec = substr($data['ident'], -3);
971 971
 				if ($typec === 'APP') $data['type'] = 'Approach';
972 972
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
973 973
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -979,8 +979,8 @@  discard block
 block discarded – undo
979 979
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
980 980
 				if (!isset($data['source_name'])) $data['source_name'] = '';
981 981
 				if (isset($ATC)) {
982
-					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']);
983
-					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']);
982
+					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']);
983
+					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']);
984 984
 				}
985 985
 			}
986 986
     			unset($data);
@@ -996,24 +996,24 @@  discard block
 block discarded – undo
996 996
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
997 997
     	    )
998 998
     	) {
999
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
999
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
1000 1000
 	    if ($buffer != '') {
1001 1001
 		$all_data = simplexml_load_string($buffer);
1002
-		foreach($all_data->children() as $childdata) {
1002
+		foreach ($all_data->children() as $childdata) {
1003 1003
 			$data = array();
1004 1004
 			$line = $childdata;
1005 1005
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
1006
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
1007
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1008
-			$data['latitude'] = (float)$line['pktLatitude'];
1009
-			$data['longitude'] = (float)$line['pktLongitude'];
1010
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1011
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1012
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1006
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
1007
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
1008
+			$data['latitude'] = (float) $line['pktLatitude'];
1009
+			$data['longitude'] = (float) $line['pktLongitude'];
1010
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
1011
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
1012
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
1013 1013
 			$data['altitude_relative'] = 'AMSL';
1014
-			$data['pilot_id'] = (int)$line['pktPilotID'];
1014
+			$data['pilot_id'] = (int) $line['pktPilotID'];
1015 1015
 			$data['aircraft_icao'] = 'PARAGLIDER';
1016
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1016
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1017 1017
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1018 1018
 			$data['format_source'] = $value['format'];
1019 1019
 			$SI->add($data);
@@ -1021,22 +1021,22 @@  discard block
 block discarded – undo
1021 1021
 		}
1022 1022
 	    }
1023 1023
 	    $Source->deleteOldLocationByType('gs');
1024
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1024
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
1025 1025
 	    if ($buffer != '') {
1026 1026
 		$all_data = simplexml_load_string($buffer);
1027
-		foreach($all_data->children() as $childdata) {
1027
+		foreach ($all_data->children() as $childdata) {
1028 1028
 			$data = array();
1029 1029
 			$line = $childdata;
1030
-			$data['id'] = (int)$line['gsID'];
1031
-			$data['latitude'] = (float)$line['gsLatitude'];
1032
-			$data['longitude'] = (float)$line['gsLongitude'];
1033
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
1030
+			$data['id'] = (int) $line['gsID'];
1031
+			$data['latitude'] = (float) $line['gsLatitude'];
1032
+			$data['longitude'] = (float) $line['gsLongitude'];
1033
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
1034 1034
 			$data['altitude_relative'] = 'AMSL';
1035
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
1035
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
1036 1036
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
1037
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1037
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1038 1038
 			} else {
1039
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1039
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1040 1040
 			}
1041 1041
 			unset($data);
1042 1042
 		}
@@ -1054,9 +1054,9 @@  discard block
 block discarded – undo
1054 1054
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1055 1055
 	    )
1056 1056
 	) {
1057
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1057
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1058 1058
 	    if ($buffer != '') {
1059
-	        $all_data = json_decode($buffer,true);
1059
+	        $all_data = json_decode($buffer, true);
1060 1060
 		if (isset($all_data['acList'])) {
1061 1061
 		    $reset = 0;
1062 1062
 		    foreach ($all_data['acList'] as $line) {
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1073 1073
 			$data['emergency'] = ''; // emergency
1074 1074
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1075
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1075
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1076 1076
 			else $data['datetime'] = date('Y-m-d H:i:s');
1077 1077
 			//$data['datetime'] = date('Y-m-d H:i:s');
1078 1078
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1098 1098
 			$data['squawk'] = $line['squawk']; // squawk
1099 1099
 			$data['emergency'] = ''; // emergency
1100
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1100
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1101 1101
 			else $data['datetime'] = date('Y-m-d H:i:s');
1102 1102
 			$data['format_source'] = 'aircraftlistjson';
1103 1103
 			$data['id_source'] = $id_source;
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
     	    )
1119 1119
     	) {
1120 1120
 	    $buffer = $Common->getData($value['host']);
1121
-	    $all_data = json_decode($buffer,true);
1121
+	    $all_data = json_decode($buffer, true);
1122 1122
 	    if (isset($all_data['planes'])) {
1123 1123
 		$reset = 0;
1124 1124
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1135,12 +1135,12 @@  discard block
 block discarded – undo
1135 1135
 		    $data['emergency'] = ''; // emergency
1136 1136
 		    $data['registration'] = $line[2];
1137 1137
 		    $data['aircraft_icao'] = $line[0];
1138
-		    $deparr = explode('-',$line[1]);
1138
+		    $deparr = explode('-', $line[1]);
1139 1139
 		    if (count($deparr) === 2) {
1140 1140
 			$data['departure_airport_icao'] = $deparr[0];
1141 1141
 			$data['arrival_airport_icao'] = $deparr[1];
1142 1142
 		    }
1143
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1143
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1144 1144
 	    	    $data['format_source'] = 'planeupdatefaa';
1145 1145
     		    $data['id_source'] = $id_source;
1146 1146
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
 	    )
1159 1159
 	) {
1160 1160
 	    $buffer = $Common->getData($value['host']);
1161
-	    $all_data = json_decode($buffer,true);
1161
+	    $all_data = json_decode($buffer, true);
1162 1162
 	    if (isset($all_data['states'])) {
1163 1163
 		$reset = 0;
1164 1164
 		foreach ($all_data['states'] as $key => $line) {
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 		    //$data['emergency'] = ''; // emergency
1176 1176
 		    //$data['registration'] = $line[2];
1177 1177
 		    //$data['aircraft_icao'] = $line[0];
1178
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1178
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1179 1179
 		    $data['format_source'] = 'opensky';
1180 1180
 		    $data['id_source'] = $id_source;
1181 1181
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1192,8 +1192,8 @@  discard block
 block discarded – undo
1192 1192
 	    )
1193 1193
 	) {
1194 1194
 	    $buffer = $Common->getData($value['host']);
1195
-	    $all_data = json_decode($buffer,true);
1196
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1195
+	    $all_data = json_decode($buffer, true);
1196
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1197 1197
 		$reset = 0;
1198 1198
 		foreach ($all_data['aircraft'] as $key => $line) {
1199 1199
 		    $data = array();
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 	    )
1232 1232
 	) {
1233 1233
 	    $buffer = $Common->getData($value['host']);
1234
-	    $all_data = json_decode($buffer,true);
1234
+	    $all_data = json_decode($buffer, true);
1235 1235
 	    if (isset($all_data['aircraft'])) {
1236 1236
 		$reset = 0;
1237 1237
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1248,7 +1248,7 @@  discard block
 block discarded – undo
1248 1248
 		    //$data['emergency'] = ''; // emergency
1249 1249
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1250 1250
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1251
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1251
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1252 1252
 		    $data['format_source'] = 'planefinderclient';
1253 1253
 		    $data['id_source'] = $id_source;
1254 1254
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
 	) {
1268 1268
 	    //$buffer = $Common->getData($hosts[$id]);
1269 1269
 	    $buffer = $Common->getData($value['host']);
1270
-	    $all_data = json_decode($buffer,true);
1270
+	    $all_data = json_decode($buffer, true);
1271 1271
 	    if (!empty($all_data)) $reset = 0;
1272 1272
 	    foreach ($all_data as $key => $line) {
1273 1273
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1305,11 +1305,11 @@  discard block
 block discarded – undo
1305 1305
 	    )
1306 1306
 	) {
1307 1307
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1308
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1308
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1309 1309
 	    //echo $buffer;
1310
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1311
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1312
-	    $all_data = json_decode($buffer,true);
1310
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1311
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1312
+	    $all_data = json_decode($buffer, true);
1313 1313
 	    if (json_last_error() != JSON_ERROR_NONE) {
1314 1314
 		die(json_last_error_msg());
1315 1315
 	    }
@@ -1332,7 +1332,7 @@  discard block
 block discarded – undo
1332 1332
 			//$data['departure_airport_iata'] = $line[11];
1333 1333
 			//$data['arrival_airport_iata'] = $line[12];
1334 1334
 	    		//$data['emergency'] = ''; // emergency
1335
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1335
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1336 1336
 	    		$data['format_source'] = 'radarvirtueljson';
1337 1337
     			$data['id_source'] = $id_source;
1338 1338
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1353,14 +1353,14 @@  discard block
 block discarded – undo
1353 1353
 	) {
1354 1354
 	    //$buffer = $Common->getData($hosts[$id]);
1355 1355
 	    $buffer = $Common->getData($value['host'].'?'.time());
1356
-	    $all_data = json_decode(utf8_encode($buffer),true);
1356
+	    $all_data = json_decode(utf8_encode($buffer), true);
1357 1357
 	    
1358 1358
 	    if (isset($all_data['pireps'])) {
1359 1359
 		$reset = 0;
1360 1360
 	        foreach ($all_data['pireps'] as $line) {
1361 1361
 		    $data = array();
1362 1362
 		    $data['id'] = $line['id'];
1363
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1363
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1364 1364
 		    $data['ident'] = $line['callsign']; // ident
1365 1365
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1366 1366
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1390,9 +1390,9 @@  discard block
 block discarded – undo
1390 1390
 			$SI->add($data);
1391 1391
 		    //    print_r($data);
1392 1392
     		    } elseif ($line['icon'] === 'ct') {
1393
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1394
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1395
-			$typec = substr($data['ident'],-3);
1393
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1394
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1395
+			$typec = substr($data['ident'], -3);
1396 1396
 			$data['type'] = '';
1397 1397
 			if ($typec === 'APP') $data['type'] = 'Approach';
1398 1398
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1403,7 +1403,7 @@  discard block
 block discarded – undo
1403 1403
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1404 1404
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1405 1405
 			else $data['type'] = 'Observer';
1406
-			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']);
1406
+			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']);
1407 1407
 		    }
1408 1408
 		    unset($data);
1409 1409
 		}
@@ -1420,14 +1420,14 @@  discard block
 block discarded – undo
1420 1420
 	    //$buffer = $Common->getData($hosts[$id]);
1421 1421
 	    if ($globalDebug) echo 'Get Data...'."\n";
1422 1422
 	    $buffer = $Common->getData($value['host']);
1423
-	    $all_data = json_decode($buffer,true);
1423
+	    $all_data = json_decode($buffer, true);
1424 1424
 	    if ($buffer != '' && is_array($all_data)) {
1425 1425
 		$reset = 0;
1426 1426
 		foreach ($all_data as $line) {
1427 1427
 	    	    $data = array();
1428 1428
 	    	    //$data['id'] = $line['id']; // id not usable
1429 1429
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1430
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1430
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1431 1431
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1432 1432
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1433 1433
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1442,7 +1442,7 @@  discard block
 block discarded – undo
1442 1442
 	    	    //$data['datetime'] = $line['lastupdate'];
1443 1443
 	    	    //$data['last_update'] = $line['lastupdate'];
1444 1444
 	    	    if (isset($value['timezone'])) {
1445
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1445
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1446 1446
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1447 1447
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1448 1448
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1458,14 +1458,14 @@  discard block
 block discarded – undo
1458 1458
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1459 1459
 		    if (isset($line['aircraftname'])) {
1460 1460
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1461
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1462
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1461
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1462
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1463 1463
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1464 1464
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1465 1465
 	    		else {
1466
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1467
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1468
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1466
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1467
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1468
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1469 1469
 	    		}
1470 1470
 	    	    }
1471 1471
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1490,7 +1490,7 @@  discard block
 block discarded – undo
1490 1490
 	    //$buffer = $Common->getData($hosts[$id]);
1491 1491
 	    if ($globalDebug) echo 'Get Data...'."\n";
1492 1492
 	    $buffer = $Common->getData($value['host']);
1493
-	    $all_data = json_decode($buffer,true);
1493
+	    $all_data = json_decode($buffer, true);
1494 1494
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1495 1495
 		$reset = 0;
1496 1496
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1501,7 +1501,7 @@  discard block
 block discarded – undo
1501 1501
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1502 1502
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1503 1503
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1504
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1504
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1505 1505
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1506 1506
 	    	    $data['altitude'] = $line['altitude']; // altitude
1507 1507
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
 	    	    //$data['squawk'] = ''; // squawk
1513 1513
 	    	    //$data['emergency'] = ''; // emergency
1514 1514
 	    	    if (isset($value['timezone'])) {
1515
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1515
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1516 1516
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1517 1517
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1518 1518
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1548,14 +1548,14 @@  discard block
 block discarded – undo
1548 1548
 	    //$buffer = $Common->getData($hosts[$id]);
1549 1549
 	    if ($globalDebug) echo 'Get Data...'."\n";
1550 1550
 	    $buffer = $Common->getData($value['host']);
1551
-	    $all_data = json_decode($buffer,true);
1551
+	    $all_data = json_decode($buffer, true);
1552 1552
 	    if ($buffer != '' && is_array($all_data)) {
1553 1553
 		$reset = 0;
1554 1554
 		foreach ($all_data as $line) {
1555 1555
 	    	    $data = array();
1556 1556
 	    	    //$data['id'] = $line['id']; // id not usable
1557 1557
 	    	    $data['id'] = trim($line['flight_id']);
1558
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1558
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1559 1559
 	    	    $data['pilot_name'] = $line['pilot_name'];
1560 1560
 	    	    $data['pilot_id'] = $line['pilot_id'];
1561 1561
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1599,24 +1599,24 @@  discard block
 block discarded – undo
1599 1599
 	    //$buffer = $Common->getData($hosts[$id]);
1600 1600
 	    if ($globalDebug) echo 'Get Data...'."\n";
1601 1601
 	    $buffer = $Common->getData($value['host']);
1602
-	    $all_data = json_decode($buffer,true);
1602
+	    $all_data = json_decode($buffer, true);
1603 1603
 	    if ($buffer != '') {
1604 1604
 		$Source->deleteLocationBySource('blitzortung');
1605
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1606
-		$buffer = explode('\n',$buffer);
1605
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1606
+		$buffer = explode('\n', $buffer);
1607 1607
 		foreach ($buffer as $buffer_line) {
1608
-		    $line = json_decode($buffer_line,true);
1608
+		    $line = json_decode($buffer_line, true);
1609 1609
 		    if (isset($line['time'])) {
1610 1610
 			$data = array();
1611 1611
 			$data['altitude'] = $line['alt']; // altitude
1612 1612
 			$data['latitude'] = $line['lat']; // lat
1613 1613
 			$data['longitude'] = $line['lon']; // long
1614
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1614
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1615 1615
 			$data['id_source'] = $id_source;
1616 1616
 			$data['format_source'] = 'blitzortung';
1617 1617
 			$SI->add($data);
1618 1618
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1619
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1619
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1620 1620
 			unset($data);
1621 1621
 		    }
1622 1622
 		}
@@ -1628,15 +1628,15 @@  discard block
 block discarded – undo
1628 1628
         $arr = $httpfeeds;
1629 1629
         $w = $e = null;
1630 1630
         if (isset($arr[$id])) {
1631
-            $nn = stream_select($arr,$w,$e,$timeout);
1631
+            $nn = stream_select($arr, $w, $e, $timeout);
1632 1632
             if ($nn > 0) {
1633 1633
                 foreach ($httpfeeds as $feed) {
1634
-                    $buffer = stream_get_line($feed,2000,"\n");
1634
+                    $buffer = stream_get_line($feed, 2000, "\n");
1635 1635
                     if ($buffer === FALSE) {
1636 1636
                         connect_all($globalSources);
1637 1637
                     }
1638
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1639
-                    $buffer = explode('\n',$buffer);
1638
+                    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1639
+                    $buffer = explode('\n', $buffer);
1640 1640
                     foreach ($buffer as $line) {
1641 1641
                         if ($line != '') {
1642 1642
                             $line = json_decode($line, true);
@@ -1676,11 +1676,11 @@  discard block
 block discarded – undo
1676 1676
 		    //$value = $formats[$nb];
1677 1677
 		    $format = $globalSources[$nb]['format'];
1678 1678
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1679
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1679
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1680 1680
 		    } elseif ($format === 'vrstcp') {
1681 1681
 			$buffer = @socket_read($r, 6000);
1682 1682
 		    } else {
1683
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1683
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1684 1684
 		    }
1685 1685
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1686 1686
 		    //echo $buffer."\n";
@@ -1690,8 +1690,8 @@  discard block
 block discarded – undo
1690 1690
 		    //$SI::del();
1691 1691
 		    if ($buffer !== FALSE) {
1692 1692
 			if ($format === 'vrstcp') {
1693
-			    $buffer = explode('},{',$buffer);
1694
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1693
+			    $buffer = explode('},{', $buffer);
1694
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1695 1695
 		    }
1696 1696
 		    // SBS format is CSV format
1697 1697
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1718,7 +1718,7 @@  discard block
 block discarded – undo
1718 1718
 			    $ais_data = $AIS->parse_line(trim($buffer));
1719 1719
 			    $data = array();
1720 1720
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1721
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1721
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1722 1722
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1723 1723
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1724 1724
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1729,13 +1729,13 @@  discard block
 block discarded – undo
1729 1729
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1730 1730
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1731 1731
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1732
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1732
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1733 1733
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1734 1734
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1735 1735
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1736 1736
 
1737 1737
 			    if (isset($ais_data['timestamp'])) {
1738
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1738
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1739 1739
 			    } else {
1740 1740
 				$data['datetime'] = date('Y-m-d H:i:s');
1741 1741
 			    }
@@ -1746,10 +1746,10 @@  discard block
 block discarded – undo
1746 1746
                         } elseif ($format === 'flightgearsp') {
1747 1747
                     	    //echo $buffer."\n";
1748 1748
                     	    if (strlen($buffer) > 5) {
1749
-				$line = explode(',',$buffer);
1749
+				$line = explode(',', $buffer);
1750 1750
 				$data = array();
1751 1751
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1752
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1752
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1753 1753
 				$data['ident'] = $line[6];
1754 1754
 				$data['aircraft_name'] = $line[7];
1755 1755
 				$data['longitude'] = $line[1];
@@ -1766,16 +1766,16 @@  discard block
 block discarded – undo
1766 1766
                         } elseif ($format === 'acars') {
1767 1767
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1768 1768
 			    $ACARS->add(trim($buffer));
1769
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1769
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1770 1770
 			    $ACARS->deleteLiveAcarsData();
1771 1771
 			} elseif ($format === 'flightgearmp') {
1772
-			    if (substr($buffer,0,1) != '#') {
1772
+			    if (substr($buffer, 0, 1) != '#') {
1773 1773
 				$data = array();
1774 1774
 				//echo $buffer."\n";
1775
-				$line = explode(' ',$buffer);
1775
+				$line = explode(' ', $buffer);
1776 1776
 				if (count($line) === 11) {
1777
-				    $userserver = explode('@',$line[0]);
1778
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1777
+				    $userserver = explode('@', $line[0]);
1778
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1779 1779
 				    $data['ident'] = $userserver[0];
1780 1780
 				    $data['registration'] = $userserver[0];
1781 1781
 				    $data['latitude'] = $line[4];
@@ -1783,8 +1783,8 @@  discard block
 block discarded – undo
1783 1783
 				    $data['altitude'] = $line[6];
1784 1784
 				    $data['datetime'] = date('Y-m-d H:i:s');
1785 1785
 				    $aircraft_type = $line[10];
1786
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1787
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1786
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1787
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1788 1788
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1789 1789
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1790 1790
 				}
@@ -1793,8 +1793,8 @@  discard block
 block discarded – undo
1793 1793
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1794 1794
 			    die;
1795 1795
 			} elseif ($format === 'vrstcp') {
1796
-			    foreach($buffer as $all_data) {
1797
-				$line = json_decode('{'.$all_data.'}',true);
1796
+			    foreach ($buffer as $all_data) {
1797
+				$line = json_decode('{'.$all_data.'}', true);
1798 1798
 				$data = array();
1799 1799
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1800 1800
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1820,16 +1820,16 @@  discard block
 block discarded – undo
1820 1820
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1821 1821
 				unset($data);
1822 1822
 			    }
1823
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1823
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1824 1824
 			    $line = explode("\t", $buffer);
1825
-			    for($k = 0; $k < count($line); $k=$k+2) {
1825
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1826 1826
 				$key = $line[$k];
1827
-			        $lined[$key] = $line[$k+1];
1827
+			        $lined[$key] = $line[$k + 1];
1828 1828
 			    }
1829 1829
     			    if (count($lined) > 3) {
1830 1830
     				$data['hex'] = $lined['hexid'];
1831 1831
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1832
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1832
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1833 1833
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1834 1834
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1835 1835
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1848,23 +1848,23 @@  discard block
 block discarded – undo
1848 1848
     			    } else $error = true;
1849 1849
 			} elseif ($format === 'aprs' && $use_aprs) {
1850 1850
 			    if ($aprs_connect === 0) {
1851
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1851
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1852 1852
 				$aprs_connect = 1;
1853 1853
 			    }
1854 1854
 			    
1855
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1855
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1856 1856
 				$aprs_last_tx = time();
1857 1857
 				$data_aprs = "# Keep alive";
1858
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1858
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1859 1859
 			    }
1860 1860
 			    
1861 1861
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1862 1862
 			    //echo 'APRS data : '.$buffer."\n";
1863
-			    $buffer = str_replace('APRS <- ','',$buffer);
1864
-			    $buffer = str_replace('APRS -> ','',$buffer);
1863
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1864
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1865 1865
 			    //echo $buffer."\n";
1866 1866
 			    date_default_timezone_set('UTC');
1867
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1867
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1868 1868
 				$line = $APRS->parse($buffer);
1869 1869
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1870 1870
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1879,7 +1879,7 @@  discard block
 block discarded – undo
1879 1879
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1880 1880
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1881 1881
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1882
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1882
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1883 1883
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1884 1884
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1885 1885
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1967,29 +1967,29 @@  discard block
 block discarded – undo
1967 1967
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1968 1968
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1969 1969
 					$Source->deleteOldLocationByType('gs');
1970
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1971
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1970
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1971
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1972 1972
 					} else {
1973
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1973
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1974 1974
 					}
1975 1975
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1976 1976
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1977 1977
 					if ($globalDebug) echo '# Weather Station added'."\n";
1978 1978
 					$Source->deleteOldLocationByType('wx');
1979 1979
 					$weather_data = json_encode($line);
1980
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1981
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1980
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1981
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1982 1982
 					} else {
1983
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1983
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1984 1984
 					}
1985 1985
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1986 1986
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1987 1987
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1988 1988
 					$Source->deleteOldLocationByType('lightning');
1989
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1990
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1989
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1990
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1991 1991
 					} else {
1992
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1992
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1993 1993
 					}
1994 1994
 				    } elseif ($globalDebug) {
1995 1995
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1998,7 +1998,7 @@  discard block
 block discarded – undo
1998 1998
 				    unset($data);
1999 1999
 				}
2000 2000
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2001
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2001
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
2002 2002
 				}
2003 2003
 				/*
2004 2004
 				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')) {
@@ -2007,7 +2007,7 @@  discard block
 block discarded – undo
2007 2007
 				*/
2008 2008
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2009 2009
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2010
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2010
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
2011 2011
 					$Source->deleteOldLocationByType('lightning');
2012 2012
 					$Source->deleteOldLocationByType('wx');
2013 2013
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2094,7 +2094,7 @@  discard block
 block discarded – undo
2094 2094
 				connect_all($sourceee);
2095 2095
 				$sourceee = array();
2096 2096
 				//connect_all($globalSources);
2097
-				$tt[$format]=0;
2097
+				$tt[$format] = 0;
2098 2098
 				break;
2099 2099
 			    } 
2100 2100
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2104,14 +2104,14 @@  discard block
 block discarded – undo
2104 2104
 	    } else {
2105 2105
 		$error = socket_strerror(socket_last_error());
2106 2106
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2107
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2107
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2108 2108
 			if (isset($globalDebug)) echo "Restarting...\n";
2109 2109
 			// Restart the script if possible
2110 2110
 			if (is_array($sockets)) {
2111 2111
 			    if ($globalDebug) echo "Shutdown all sockets...";
2112 2112
 			    
2113 2113
 			    foreach ($sockets as $sock) {
2114
-				@socket_shutdown($sock,2);
2114
+				@socket_shutdown($sock, 2);
2115 2115
 				@socket_close($sock);
2116 2116
 			    }
2117 2117
 			    
Please login to merge, or discard this patch.