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