Completed
Push — master ( 8cab2f...d50392 )
by Yannick
36:54
created
scripts/daemon-spotter.php 1 patch
Spacing   +231 added lines, -231 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,7 +159,7 @@  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) {
@@ -167,33 +167,33 @@  discard block
 block discarded – undo
167 167
 	$udp = false;
168 168
 	$globalSources[$id]['last_exec'] = 0;
169 169
 	// Here we check type of source(s)
170
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
-            if (preg_match('/deltadb.txt$/i',$host)) {
170
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
+            if (preg_match('/deltadb.txt$/i', $host)) {
172 172
         	//$formats[$id] = 'deltadbtxt';
173 173
         	$globalSources[$id]['format'] = 'deltadbtxt';
174 174
         	//$last_exec['deltadbtxt'] = 0;
175 175
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
176
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
177 177
         	//$formats[$id] = 'vatsimtxt';
178 178
         	$globalSources[$id]['format'] = 'vatsimtxt';
179 179
         	//$last_exec['vatsimtxt'] = 0;
180 180
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
181
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
182 182
         	//$formats[$id] = 'aircraftlistjson';
183 183
         	$globalSources[$id]['format'] = 'aircraftlistjson';
184 184
         	//$last_exec['aircraftlistjson'] = 0;
185 185
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
186
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
187 187
         	//$formats[$id] = 'aircraftjson';
188 188
         	$globalSources[$id]['format'] = 'aircraftjson';
189 189
         	//$last_exec['aircraftlistjson'] = 0;
190 190
         	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
-    	    } else if (preg_match('/aircraft$/i',$host)) {
191
+    	    } else if (preg_match('/aircraft$/i', $host)) {
192 192
         	//$formats[$id] = 'planefinderclient';
193 193
         	$globalSources[$id]['format'] = 'planefinderclient';
194 194
         	//$last_exec['aircraftlistjson'] = 0;
195 195
         	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
-    	    } else if (preg_match('/opensky/i',$host)) {
196
+    	    } else if (preg_match('/opensky/i', $host)) {
197 197
         	//$formats[$id] = 'aircraftlistjson';
198 198
         	$globalSources[$id]['format'] = 'opensky';
199 199
         	//$last_exec['aircraftlistjson'] = 0;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         	    exit(0);
211 211
         	}
212 212
     	    */
213
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
213
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
214 214
         	//$formats[$id] = 'planeupdatefaa';
215 215
         	$globalSources[$id]['format'] = 'planeupdatefaa';
216 216
         	//$last_exec['planeupdatefaa'] = 0;
@@ -219,37 +219,37 @@  discard block
 block discarded – undo
219 219
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220 220
         	    exit(0);
221 221
         	}
222
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
222
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
223 223
         	//$formats[$id] = 'phpvmacars';
224 224
         	$globalSources[$id]['format'] = 'phpvmacars';
225 225
         	//$last_exec['phpvmacars'] = 0;
226 226
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
227
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
228 228
         	//$formats[$id] = 'phpvmacars';
229 229
         	$globalSources[$id]['format'] = 'vaos';
230 230
         	//$last_exec['phpvmacars'] = 0;
231 231
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
232
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
233 233
         	//$formats[$id] = 'phpvmacars';
234 234
         	$globalSources[$id]['format'] = 'vam';
235 235
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
-            } else if (preg_match('/whazzup/i',$host)) {
236
+            } else if (preg_match('/whazzup/i', $host)) {
237 237
         	//$formats[$id] = 'whazzup';
238 238
         	$globalSources[$id]['format'] = 'whazzup';
239 239
         	//$last_exec['whazzup'] = 0;
240 240
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
-            } else if (preg_match('/blitzortung/i',$host)) {
241
+            } else if (preg_match('/blitzortung/i', $host)) {
242 242
         	$globalSources[$id]['format'] = 'blitzortung';
243 243
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
-            } else if (preg_match('/airwhere/i',$host)) {
244
+            } else if (preg_match('/airwhere/i', $host)) {
245 245
         	$globalSources[$id]['format'] = 'airwhere';
246 246
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
-            } else if (preg_match('/recentpireps/i',$host)) {
247
+            } else if (preg_match('/recentpireps/i', $host)) {
248 248
         	//$formats[$id] = 'pirepsjson';
249 249
         	$globalSources[$id]['format'] = 'pirepsjson';
250 250
         	//$last_exec['pirepsjson'] = 0;
251 251
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
252
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
253 253
         	//$formats[$id] = 'fr24json';
254 254
         	$globalSources[$id]['format'] = 'fr24json';
255 255
         	//$last_exec['fr24json'] = 0;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259 259
         	    exit(0);
260 260
         	}
261
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
261
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
262 262
         	//$formats[$id] = 'fr24json';
263 263
         	$globalSources[$id]['format'] = 'myshiptracking';
264 264
         	//$last_exec['fr24json'] = 0;
@@ -268,14 +268,14 @@  discard block
 block discarded – undo
268 268
         	    exit(0);
269 269
         	}
270 270
             //} else if (preg_match('/10001/',$host)) {
271
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272 272
         	//$formats[$id] = 'tsv';
273 273
         	$globalSources[$id]['format'] = 'tsv';
274 274
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275 275
             }
276
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276
+        } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277 277
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
278
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
279 279
     		    if ($idf !== false) {
280 280
     			$httpfeeds[$id] = $idf;
281 281
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
     		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284 284
     		elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n";
285 285
     		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
286
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
287
-	    $hostport = explode(':',$host);
286
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
287
+	    $hostport = explode(':', $host);
288 288
 	    if (isset($hostport[1])) {
289 289
 		$port = $hostport[1];
290 290
 		$hostn = $hostport[0];
@@ -294,20 +294,20 @@  discard block
 block discarded – undo
294 294
 	    }
295 295
 	    $Common = new Common();
296 296
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
297
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
297
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
298 298
     	    } else {
299 299
     		$udp = true;
300
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
300
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
301 301
 	    }
302 302
 	    if ($s) {
303 303
     	        $sockets[$id] = $s;
304 304
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
305
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
305
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
306 306
 			//$formats[$id] = 'aprs';
307 307
 			$globalSources[$id]['format'] = 'aprs';
308 308
 			//$aprs_connect = 0;
309 309
 			//$use_aprs = true;
310
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
310
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
311 311
 			$globalSources[$id]['format'] = 'vrstcp';
312 312
     		    } elseif ($port == '10001') {
313 313
         		//$formats[$id] = 'tsv';
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
350 350
 else $timeout = 20;
351 351
 $errno = '';
352
-$errstr='';
352
+$errstr = '';
353 353
 
354 354
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
355 355
 /* Initiate connections to all the hosts simultaneously */
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 //connect_all($globalSources);
358 358
 
359 359
 if (isset($globalProxy) && $globalProxy) {
360
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
360
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
361 361
 } else {
362 362
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
363 363
 }
@@ -387,16 +387,16 @@  discard block
 block discarded – undo
387 387
 
388 388
 if ($use_aprs) {
389 389
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
390
-	$APRS=new APRS();
390
+	$APRS = new APRS();
391 391
 	$aprs_connect = 0;
392 392
 	$aprs_keep = 120;
393 393
 	$aprs_last_tx = time();
394 394
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
395
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
395
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
396 396
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
397
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
397
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
398 398
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
399
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
399
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
400 400
 	if ($aprs_full) $aprs_filter = '';
401 401
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
402 402
 	else $aprs_pass = '-1';
@@ -410,12 +410,12 @@  discard block
 block discarded – undo
410 410
 sleep(1);
411 411
 if ($globalDebug) echo "SCAN MODE \n\n";
412 412
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
413
-$endtime = time()+$globalCronEnd;
413
+$endtime = time() + $globalCronEnd;
414 414
 $i = 1;
415 415
 $tt = array();
416 416
 // Delete all ATC
417 417
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
418
-	$ATC=new ATC($Connection->db);
418
+	$ATC = new ATC($Connection->db);
419 419
 }
420 420
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
421 421
 	$ATC->deleteAll();
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 while ($i > 0) {
426 426
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
427 427
 
428
-    if (!$globalDaemon) $i = $endtime-time();
428
+    if (!$globalDaemon) $i = $endtime - time();
429 429
     // Delete old ATC
430 430
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
431 431
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	}
440 440
 	if ($max < $globalMinFetch) {
441 441
 	    if ($globalDebug) echo 'Sleeping...'."\n";
442
-	    sleep($globalMinFetch-$max+2);
442
+	    sleep($globalMinFetch - $max + 2);
443 443
 	}
444 444
     }
445 445
 
@@ -494,10 +494,10 @@  discard block
 block discarded – undo
494 494
             //$buffer = $Common->getData($hosts[$id]);
495 495
             $buffer = $Common->getData($value['host']);
496 496
             if ($buffer != '') {
497
-                $all_data = json_decode($buffer,true);
497
+                $all_data = json_decode($buffer, true);
498 498
                 foreach ($all_data as $line) {
499 499
                     $data = array();
500
-                    $data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
500
+                    $data['datetime'] = date('Y-m-d H:i:s', $line['uti']);
501 501
                     $data['hex'] = $line['hex']; // hex
502 502
                     $data['ident'] = $line['fli']; // ident
503 503
                     $data['altitude'] = $line['alt']; // altitude
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
 	    )
533 533
 	) {
534 534
 	    date_default_timezone_set('CET');
535
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
535
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
536 536
 	    date_default_timezone_set('UTC');
537 537
 	    if ($buffer != '') $reset = 0;
538
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539
-	    $buffer = explode('\n',$buffer);
538
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
539
+	    $buffer = explode('\n', $buffer);
540 540
 	    foreach ($buffer as $line) {
541 541
 		if ($line != '') {
542 542
 		    //echo "'".$line."'\n";
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 		    $ais_data = $AIS->parse_line(trim($line));
545 545
 		    $data = array();
546 546
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
547
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
547
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
548 548
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
549 549
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
550 550
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
557 557
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
558 558
 		    if (isset($ais_data['timestamp'])) {
559
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
559
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
560 560
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
561 561
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
562 562
 			    $add = true;
@@ -579,21 +579,21 @@  discard block
 block discarded – undo
579 579
 	    $w = $e = null;
580 580
 	    
581 581
 	    if (isset($arr[$id])) {
582
-		$nn = stream_select($arr,$w,$e,$timeout);
582
+		$nn = stream_select($arr, $w, $e, $timeout);
583 583
 		if ($nn > 0) {
584 584
 		    foreach ($httpfeeds as $feed) {
585
-			$buffer = stream_get_line($feed,2000,"\n");
585
+			$buffer = stream_get_line($feed, 2000, "\n");
586 586
 			if ($buffer === FALSE) {
587 587
 			    connect_all($globalSources);
588 588
 			}
589
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
590
-			$buffer = explode('\n',$buffer);
589
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
590
+			$buffer = explode('\n', $buffer);
591 591
 			foreach ($buffer as $line) {
592 592
 			    if ($line != '') {
593 593
 				$ais_data = $AIS->parse_line(trim($line));
594 594
 				$data = array();
595 595
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
596
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
596
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
597 597
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
598 598
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
599 599
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -605,9 +605,9 @@  discard block
 block discarded – undo
605 605
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
606 606
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
607 607
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
608
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
608
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
609 609
 				if (isset($ais_data['timestamp'])) {
610
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
610
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
611 611
 				} else {
612 612
 				    $data['datetime'] = date('Y-m-d H:i:s');
613 613
 				}
@@ -639,10 +639,10 @@  discard block
 block discarded – undo
639 639
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
640 640
 	    )
641 641
 	) {
642
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
642
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
643 643
 	    if ($buffer != '') {
644 644
 		//echo $buffer;
645
-		$all_data = json_decode($buffer,true);
645
+		$all_data = json_decode($buffer, true);
646 646
 		//print_r($all_data);
647 647
 		if (isset($all_data[0]['DATA'])) {
648 648
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 			    $data['ident'] = $line['NAME'];
652 652
 			    $data['mmsi'] = $line['MMSI'];
653 653
 			    if (strlen($data['mmsi']) > 9) {
654
-				$data['mmsi'] = substr($data['mmsi'],-9);
654
+				$data['mmsi'] = substr($data['mmsi'], -9);
655 655
 			    }
656 656
 			    $data['speed'] = $line['SOG'];
657 657
 			    $data['heading'] = $line['COG'];
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
 			    //$data['type_id'] = $line['TYPE'];
662 662
 			    $data['imo'] = $line['IMO'];
663 663
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
664
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
665
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
664
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
665
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
666 666
 			    $data['format_source'] = 'myshiptracking';
667 667
 			    $data['id_source'] = $id_source;
668 668
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -679,16 +679,16 @@  discard block
 block discarded – undo
679 679
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
680 680
 	    )
681 681
 	) {
682
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
682
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
683 683
 	    if ($buffer != '') {
684
-		$all_data = json_decode($buffer,true);
684
+		$all_data = json_decode($buffer, true);
685 685
 		if (isset($all_data[0]['mmsi'])) {
686 686
 		    foreach ($all_data as $line) {
687 687
 			if ($line != '') {
688 688
 			    $data = array();
689 689
 			    $data['ident'] = $line['shipname'];
690 690
 			    $data['callsign'] = $line['callsign'];
691
-			    $data['mmsi'] = substr($line['mmsi'],-9);
691
+			    $data['mmsi'] = substr($line['mmsi'], -9);
692 692
 			    $data['speed'] = $line['sog'];
693 693
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
694 694
 			    $data['latitude'] = $line['latitude'];
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
 	) {
716 716
 	    $buffer = $Common->getData($value['host']);
717 717
 	    if ($buffer != '') {
718
-		$all_data = json_decode($buffer,true);
718
+		$all_data = json_decode($buffer, true);
719 719
 		if (isset($all_data['features'][0]['id'])) {
720 720
 		    foreach ($all_data['features'] as $line) {
721 721
 			print_r($line);
722 722
 			$data = array();
723 723
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
724 724
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
725
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
725
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
726 726
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
727 727
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
728 728
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -749,31 +749,31 @@  discard block
 block discarded – undo
749 749
 	    )
750 750
 	) {
751 751
 	    if ($globalDebug) echo 'download...';
752
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
752
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
753 753
 	    if ($globalDebug) echo 'done !'."\n";
754 754
 	    // FIXME: Need more work
755 755
 	    if ($buffer != '') $reset = 0;
756
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
757
-	    $buffer = explode('\n',$buffer);
756
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
757
+	    $buffer = explode('\n', $buffer);
758 758
 	    foreach ($buffer as $line) {
759 759
 		if ($line != '') {
760 760
 		    $data = array();
761 761
 		    //echo $line."\n";
762
-		    $data['mmsi'] = (int)substr($line,0,9);
763
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
764
-		    $data['status_id'] = substr($line,21,2);
765
-		    $data['type_id'] = substr($line,24,3);
766
-		    $data['latitude'] = substr($line,29,9);
767
-		    $data['longitude'] = substr($line,41,9);
768
-		    $data['speed'] = round(substr($line,51,5));
762
+		    $data['mmsi'] = (int) substr($line, 0, 9);
763
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
764
+		    $data['status_id'] = substr($line, 21, 2);
765
+		    $data['type_id'] = substr($line, 24, 3);
766
+		    $data['latitude'] = substr($line, 29, 9);
767
+		    $data['longitude'] = substr($line, 41, 9);
768
+		    $data['speed'] = round(substr($line, 51, 5));
769 769
 		    //$data['course'] = substr($line,57,5);
770
-		    $data['heading'] = round(substr($line,63,3));
770
+		    $data['heading'] = round(substr($line, 63, 3));
771 771
 		    //$data['draft'] = substr($line,67,4);
772 772
 		    //$data['length'] = substr($line,72,3);
773 773
 		    //$data['beam'] = substr($line,76,2);
774
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
774
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
775 775
 		    //$data['callsign'] = trim(substr($line,100,7);
776
-		    $data['arrival_code'] = substr($line,108,20);
776
+		    $data['arrival_code'] = substr($line, 108, 20);
777 777
 		    //$data['etaDate'] = substr($line,129,5);
778 778
 		    //$data['etaTime'] = substr($line,135,5);
779 779
 		    $data['format_source'] = 'shipplotter';
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 	    )
793 793
 	) {
794 794
 	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
795
-		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
795
+		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl', 'post', array('submitlogin' => 'Login', 'email' => $globalSailaway['email'], 'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'), '', '', '', '', '', false, false, true);
796 796
 		//echo $authsailaway;
797 797
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
798 798
 		if (isset($setcookie[1][0])) {
@@ -801,19 +801,19 @@  discard block
 block discarded – undo
801 801
 	    }
802 802
 
803 803
 	    if ($globalDebug) echo '! Download... ';
804
-	    for ($i =0; $i <= 1; $i++) {
804
+	    for ($i = 0; $i <= 1; $i++) {
805 805
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
806 806
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
807 807
 	    if ($globalDebug) echo 'done'."\n";
808 808
 	    if ($buffer != '') {
809
-		$all_data = json_decode($buffer,true);
809
+		$all_data = json_decode($buffer, true);
810 810
 		if (isset($all_data['missions'])) {
811 811
 			foreach ($all_data['missions'] as $mission) {
812 812
 				$mission_user = $mission['usrname'];
813
-				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
814
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
813
+				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']));
814
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
815 815
 					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') {
816
-						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
816
+						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie);
817 817
 						sleep(30);
818 818
 					} else $racebuffer = '';
819 819
 					$bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
@@ -822,19 +822,19 @@  discard block
 block discarded – undo
822 822
 					$racebuffer = '';
823 823
 				}
824 824
 				if ($racebuffer != '') {
825
-					$race_data = json_decode($racebuffer,true);
825
+					$race_data = json_decode($racebuffer, true);
826 826
 					//print_r($race_data);
827 827
 					unset($racebuffer);
828 828
 					if (isset($race_data['mission'])) {
829 829
 					    $datar = array();
830 830
 					    $datar['id'] = $mission['misnr'];
831 831
 					    $datar['desc'] = $race_data['mission']['misdescr'];
832
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
833
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
832
+					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname'])));
833
+					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle'])));
834 834
 					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
835 835
 					    $markers = array();
836 836
 					    foreach ($race_data['mission']['course'] as $course) {
837
-						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
837
+						$markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']);
838 838
 					    }
839 839
 					    $datar['markers'] = json_encode($markers);
840 840
 					    //print_r($datar);
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 					}
843 843
 				}
844 844
 				if ($bufferm != '') {
845
-					$mission_data = json_decode($bufferm,true);
845
+					$mission_data = json_decode($bufferm, true);
846 846
 					unset($bufferm);
847 847
 					if (isset($mission_data['leaderboard'][0]['results'])) {
848 848
 						foreach ($mission_data['leaderboard'][0]['results'] as $sail) {
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 								//$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr'];
856 856
 								$data['id'] = $sail['misnr'].'-'.$sail['usrnr'];
857 857
 								$data['datetime'] = date('Y-m-d H:i:s');
858
-								$data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart']));
858
+								$data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart']));
859 859
 								$data['last_update'] = date('Y-m-d H:i:s');
860 860
 								$data['status'] = $sail['status'];
861 861
 								$data['type'] = $sail['btptype'];
@@ -866,16 +866,16 @@  discard block
 block discarded – undo
866 866
 									$data['longitude'] = $pos['longitude'];
867 867
 								}
868 868
 								if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') {
869
-									$resultdescr = explode(',',$sail['resultdescr']);
869
+									$resultdescr = explode(',', $sail['resultdescr']);
870 870
 									if (count($resultdescr) > 2) {
871
-										$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2);
872
-										$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1]));
871
+										$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2);
872
+										$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1]));
873 873
 										if (isset($resultdescr[3])) {
874
-											$data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3);
874
+											$data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3);
875 875
 										}
876 876
 									}
877 877
 								}
878
-								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
878
+								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
879 879
 								$data['captain_id'] = $sail['usrnr'];
880 880
 								$data['captain_name'] = $sail['usrname'];
881 881
 								$data['race_id'] = $sail['misnr'];
@@ -928,9 +928,9 @@  discard block
 block discarded – undo
928 928
 		exit(0);
929 929
 	    }
930 930
 	    if ($globalDebug) echo '! Download... ';
931
-	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key'],'get','','','','',30);
931
+	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key'], 'get', '', '', '', '', 30);
932 932
 	    if ($buffer != '') {
933
-		$data = json_decode($buffer,true);
933
+		$data = json_decode($buffer, true);
934 934
 		//print_r($data);
935 935
 		if (isset($data['boats'])) {
936 936
 		    foreach ($data['boats'] as $sail) {
@@ -942,12 +942,12 @@  discard block
 block discarded – undo
942 942
 			$data['longitude'] = $sail['ubtlon'];
943 943
 			$data['type_id'] = 36;
944 944
 			$data['heading'] = $sail['ubtheading'];
945
-			$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
945
+			$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
946 946
 			$data['captain_name'] = $sail['usrname'];
947
-			$allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52&#39; Cruising Cat','50&#39; Performance Cruiser','Nordic Folkboat');
947
+			$allboats = array('Sailaway Cruiser 38', 'Mini Transat', 'Caribbean Rose', '52&#39; Cruising Cat', '50&#39; Performance Cruiser', 'Nordic Folkboat');
948 948
 			$boattype = $sail['ubtbtpnr'];
949
-			$data['type'] = $allboats[$boattype-1];
950
-			$data['speed'] = round($sail['ubtspeed']*3.6,2);
949
+			$data['type'] = $allboats[$boattype - 1];
950
+			$data['speed'] = round($sail['ubtspeed']*3.6, 2);
951 951
 			$data['format_source'] = 'sailaway';
952 952
 			$data['id_source'] = $id_source;
953 953
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -975,8 +975,8 @@  discard block
 block discarded – undo
975 975
 	) {
976 976
 	    //$buffer = $Common->getData($hosts[$id]);
977 977
 	    $buffer = $Common->getData($value['host']);
978
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
979
-	    $buffer = explode('\n',$buffer);
978
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
979
+	    $buffer = explode('\n', $buffer);
980 980
 	    $reset = 0;
981 981
 	    foreach ($buffer as $line) {
982 982
     		if ($line != '') {
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
988 988
 			$data['pilot_id'] = $line[1];
989 989
 			$data['pilot_name'] = $line[2];
990
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
990
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
991 991
 			$data['ident'] = $line[0]; // ident
992 992
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
993 993
 			$data['speed'] = $line[8]; // speed
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
1004 1004
 			//if (isset($line[37])) $data['last_update'] = $line[37];
1005 1005
 		        $data['departure_airport_icao'] = $line[11];
1006
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
1006
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
1007 1007
 		        $data['arrival_airport_icao'] = $line[13];
1008 1008
 			$data['frequency'] = $line[4];
1009 1009
 			$data['type'] = $line[18];
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
     			$data['id_source'] = $id_source;
1013 1013
 	    		//$data['arrival_airport_time'] = ;
1014 1014
 	    		if ($line[9] != '') {
1015
-	    		    $aircraft_data = explode('/',$line[9]);
1015
+	    		    $aircraft_data = explode('/', $line[9]);
1016 1016
 	    		    if (isset($aircraft_data[1])) {
1017 1017
 	    			$data['aircraft_icao'] = $aircraft_data[1];
1018 1018
 	    		    }
@@ -1027,9 +1027,9 @@  discard block
 block discarded – undo
1027 1027
     			if ($line[3] === 'PILOT') $SI->add($data);
1028 1028
 			elseif ($line[3] === 'ATC') {
1029 1029
 				//print_r($data);
1030
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1031
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
1032
-				$typec = substr($data['ident'],-3);
1030
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1031
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1032
+				$typec = substr($data['ident'], -3);
1033 1033
 				if ($typec === 'APP') $data['type'] = 'Approach';
1034 1034
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
1035 1035
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -1041,8 +1041,8 @@  discard block
 block discarded – undo
1041 1041
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
1042 1042
 				if (!isset($data['source_name'])) $data['source_name'] = '';
1043 1043
 				if (isset($ATC)) {
1044
-					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']);
1045
-					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']);
1044
+					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']);
1045
+					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']);
1046 1046
 				}
1047 1047
 			}
1048 1048
     			unset($data);
@@ -1058,24 +1058,24 @@  discard block
 block discarded – undo
1058 1058
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1059 1059
     	    )
1060 1060
     	) {
1061
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1061
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
1062 1062
 	    if ($buffer != '') {
1063 1063
 		$all_data = simplexml_load_string($buffer);
1064
-		foreach($all_data->children() as $childdata) {
1064
+		foreach ($all_data->children() as $childdata) {
1065 1065
 			$data = array();
1066 1066
 			$line = $childdata;
1067 1067
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
1068
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
1069
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1070
-			$data['latitude'] = (float)$line['pktLatitude'];
1071
-			$data['longitude'] = (float)$line['pktLongitude'];
1072
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1073
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1074
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1068
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
1069
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
1070
+			$data['latitude'] = (float) $line['pktLatitude'];
1071
+			$data['longitude'] = (float) $line['pktLongitude'];
1072
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
1073
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
1074
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
1075 1075
 			$data['altitude_relative'] = 'AMSL';
1076
-			$data['pilot_id'] = (int)$line['pktPilotID'];
1076
+			$data['pilot_id'] = (int) $line['pktPilotID'];
1077 1077
 			$data['aircraft_icao'] = 'PARAGLIDER';
1078
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1078
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1079 1079
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1080 1080
 			$data['format_source'] = $value['format'];
1081 1081
 			$SI->add($data);
@@ -1083,22 +1083,22 @@  discard block
 block discarded – undo
1083 1083
 		}
1084 1084
 	    }
1085 1085
 	    $Source->deleteOldLocationByType('gs');
1086
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1086
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
1087 1087
 	    if ($buffer != '') {
1088 1088
 		$all_data = simplexml_load_string($buffer);
1089
-		foreach($all_data->children() as $childdata) {
1089
+		foreach ($all_data->children() as $childdata) {
1090 1090
 			$data = array();
1091 1091
 			$line = $childdata;
1092
-			$data['id'] = (int)$line['gsID'];
1093
-			$data['latitude'] = (float)$line['gsLatitude'];
1094
-			$data['longitude'] = (float)$line['gsLongitude'];
1095
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
1092
+			$data['id'] = (int) $line['gsID'];
1093
+			$data['latitude'] = (float) $line['gsLatitude'];
1094
+			$data['longitude'] = (float) $line['gsLongitude'];
1095
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
1096 1096
 			$data['altitude_relative'] = 'AMSL';
1097
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
1097
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
1098 1098
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
1099
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1099
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1100 1100
 			} else {
1101
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1101
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1102 1102
 			}
1103 1103
 			unset($data);
1104 1104
 		}
@@ -1116,9 +1116,9 @@  discard block
 block discarded – undo
1116 1116
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1117 1117
 	    )
1118 1118
 	) {
1119
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1119
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1120 1120
 	    if ($buffer != '') {
1121
-	        $all_data = json_decode($buffer,true);
1121
+	        $all_data = json_decode($buffer, true);
1122 1122
 		if (isset($all_data['acList'])) {
1123 1123
 		    $reset = 0;
1124 1124
 		    foreach ($all_data['acList'] as $line) {
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1135 1135
 			$data['emergency'] = ''; // emergency
1136 1136
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1137
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1137
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1138 1138
 			else $data['datetime'] = date('Y-m-d H:i:s');
1139 1139
 			//$data['datetime'] = date('Y-m-d H:i:s');
1140 1140
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1160 1160
 			$data['squawk'] = $line['squawk']; // squawk
1161 1161
 			$data['emergency'] = ''; // emergency
1162
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1162
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1163 1163
 			else $data['datetime'] = date('Y-m-d H:i:s');
1164 1164
 			$data['format_source'] = 'aircraftlistjson';
1165 1165
 			$data['id_source'] = $id_source;
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
     	    )
1181 1181
     	) {
1182 1182
 	    $buffer = $Common->getData($value['host']);
1183
-	    $all_data = json_decode($buffer,true);
1183
+	    $all_data = json_decode($buffer, true);
1184 1184
 	    if (isset($all_data['planes'])) {
1185 1185
 		$reset = 0;
1186 1186
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1197,12 +1197,12 @@  discard block
 block discarded – undo
1197 1197
 		    $data['emergency'] = ''; // emergency
1198 1198
 		    $data['registration'] = $line[2];
1199 1199
 		    $data['aircraft_icao'] = $line[0];
1200
-		    $deparr = explode('-',$line[1]);
1200
+		    $deparr = explode('-', $line[1]);
1201 1201
 		    if (count($deparr) === 2) {
1202 1202
 			$data['departure_airport_icao'] = $deparr[0];
1203 1203
 			$data['arrival_airport_icao'] = $deparr[1];
1204 1204
 		    }
1205
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1205
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1206 1206
 	    	    $data['format_source'] = 'planeupdatefaa';
1207 1207
     		    $data['id_source'] = $id_source;
1208 1208
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1220,7 +1220,7 @@  discard block
 block discarded – undo
1220 1220
 	    )
1221 1221
 	) {
1222 1222
 	    $buffer = $Common->getData($value['host']);
1223
-	    $all_data = json_decode($buffer,true);
1223
+	    $all_data = json_decode($buffer, true);
1224 1224
 	    if (isset($all_data['states'])) {
1225 1225
 		$reset = 0;
1226 1226
 		foreach ($all_data['states'] as $key => $line) {
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
 		    //$data['emergency'] = ''; // emergency
1238 1238
 		    //$data['registration'] = $line[2];
1239 1239
 		    //$data['aircraft_icao'] = $line[0];
1240
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1240
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1241 1241
 		    $data['format_source'] = 'opensky';
1242 1242
 		    $data['id_source'] = $id_source;
1243 1243
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1254,8 +1254,8 @@  discard block
 block discarded – undo
1254 1254
 	    )
1255 1255
 	) {
1256 1256
 	    $buffer = $Common->getData($value['host']);
1257
-	    $all_data = json_decode($buffer,true);
1258
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1257
+	    $all_data = json_decode($buffer, true);
1258
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1259 1259
 		$reset = 0;
1260 1260
 		foreach ($all_data['aircraft'] as $key => $line) {
1261 1261
 		    $data = array();
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
 	    )
1294 1294
 	) {
1295 1295
 	    $buffer = $Common->getData($value['host']);
1296
-	    $all_data = json_decode($buffer,true);
1296
+	    $all_data = json_decode($buffer, true);
1297 1297
 	    if (isset($all_data['aircraft'])) {
1298 1298
 		$reset = 0;
1299 1299
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 		    //$data['emergency'] = ''; // emergency
1311 1311
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1312 1312
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1313
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1313
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1314 1314
 		    $data['format_source'] = 'planefinderclient';
1315 1315
 		    $data['id_source'] = $id_source;
1316 1316
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1329,7 +1329,7 @@  discard block
 block discarded – undo
1329 1329
 	) {
1330 1330
 	    //$buffer = $Common->getData($hosts[$id]);
1331 1331
 	    $buffer = $Common->getData($value['host']);
1332
-	    $all_data = json_decode($buffer,true);
1332
+	    $all_data = json_decode($buffer, true);
1333 1333
 	    if (!empty($all_data)) $reset = 0;
1334 1334
 	    foreach ($all_data as $key => $line) {
1335 1335
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1367,11 +1367,11 @@  discard block
 block discarded – undo
1367 1367
 	    )
1368 1368
 	) {
1369 1369
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1370
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1370
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1371 1371
 	    //echo $buffer;
1372
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1373
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1374
-	    $all_data = json_decode($buffer,true);
1372
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1373
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1374
+	    $all_data = json_decode($buffer, true);
1375 1375
 	    if (json_last_error() != JSON_ERROR_NONE) {
1376 1376
 		die(json_last_error_msg());
1377 1377
 	    }
@@ -1394,7 +1394,7 @@  discard block
 block discarded – undo
1394 1394
 			//$data['departure_airport_iata'] = $line[11];
1395 1395
 			//$data['arrival_airport_iata'] = $line[12];
1396 1396
 	    		//$data['emergency'] = ''; // emergency
1397
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1397
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1398 1398
 	    		$data['format_source'] = 'radarvirtueljson';
1399 1399
     			$data['id_source'] = $id_source;
1400 1400
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1415,14 +1415,14 @@  discard block
 block discarded – undo
1415 1415
 	) {
1416 1416
 	    //$buffer = $Common->getData($hosts[$id]);
1417 1417
 	    $buffer = $Common->getData($value['host'].'?'.time());
1418
-	    $all_data = json_decode(utf8_encode($buffer),true);
1418
+	    $all_data = json_decode(utf8_encode($buffer), true);
1419 1419
 	    
1420 1420
 	    if (isset($all_data['pireps'])) {
1421 1421
 		$reset = 0;
1422 1422
 	        foreach ($all_data['pireps'] as $line) {
1423 1423
 		    $data = array();
1424 1424
 		    $data['id'] = $line['id'];
1425
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1425
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1426 1426
 		    $data['ident'] = $line['callsign']; // ident
1427 1427
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1428 1428
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1452,9 +1452,9 @@  discard block
 block discarded – undo
1452 1452
 			$SI->add($data);
1453 1453
 		    //    print_r($data);
1454 1454
     		    } elseif ($line['icon'] === 'ct') {
1455
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1456
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1457
-			$typec = substr($data['ident'],-3);
1455
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1456
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1457
+			$typec = substr($data['ident'], -3);
1458 1458
 			$data['type'] = '';
1459 1459
 			if ($typec === 'APP') $data['type'] = 'Approach';
1460 1460
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1465,7 +1465,7 @@  discard block
 block discarded – undo
1465 1465
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1466 1466
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1467 1467
 			else $data['type'] = 'Observer';
1468
-			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']);
1468
+			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']);
1469 1469
 		    }
1470 1470
 		    unset($data);
1471 1471
 		}
@@ -1482,14 +1482,14 @@  discard block
 block discarded – undo
1482 1482
 	    //$buffer = $Common->getData($hosts[$id]);
1483 1483
 	    if ($globalDebug) echo 'Get Data...'."\n";
1484 1484
 	    $buffer = $Common->getData($value['host']);
1485
-	    $all_data = json_decode($buffer,true);
1485
+	    $all_data = json_decode($buffer, true);
1486 1486
 	    if ($buffer != '' && is_array($all_data)) {
1487 1487
 		$reset = 0;
1488 1488
 		foreach ($all_data as $line) {
1489 1489
 	    	    $data = array();
1490 1490
 	    	    //$data['id'] = $line['id']; // id not usable
1491 1491
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1492
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1492
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1493 1493
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1494 1494
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1495 1495
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1504,7 +1504,7 @@  discard block
 block discarded – undo
1504 1504
 	    	    //$data['datetime'] = $line['lastupdate'];
1505 1505
 	    	    //$data['last_update'] = $line['lastupdate'];
1506 1506
 	    	    if (isset($value['timezone'])) {
1507
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1507
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1508 1508
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1509 1509
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1510 1510
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1520,14 +1520,14 @@  discard block
 block discarded – undo
1520 1520
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1521 1521
 		    if (isset($line['aircraftname'])) {
1522 1522
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1523
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1524
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1523
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1524
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1525 1525
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1526 1526
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1527 1527
 	    		else {
1528
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1529
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1530
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1528
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1529
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1530
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1531 1531
 	    		}
1532 1532
 	    	    }
1533 1533
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1552,7 +1552,7 @@  discard block
 block discarded – undo
1552 1552
 	    //$buffer = $Common->getData($hosts[$id]);
1553 1553
 	    if ($globalDebug) echo 'Get Data...'."\n";
1554 1554
 	    $buffer = $Common->getData($value['host']);
1555
-	    $all_data = json_decode($buffer,true);
1555
+	    $all_data = json_decode($buffer, true);
1556 1556
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1557 1557
 		$reset = 0;
1558 1558
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1564 1564
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1565 1565
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1566
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1566
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1567 1567
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1568 1568
 	    	    $data['altitude'] = $line['altitude']; // altitude
1569 1569
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1574,7 +1574,7 @@  discard block
 block discarded – undo
1574 1574
 	    	    //$data['squawk'] = ''; // squawk
1575 1575
 	    	    //$data['emergency'] = ''; // emergency
1576 1576
 	    	    if (isset($value['timezone'])) {
1577
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1577
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1578 1578
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1579 1579
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1580 1580
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1610,14 +1610,14 @@  discard block
 block discarded – undo
1610 1610
 	    //$buffer = $Common->getData($hosts[$id]);
1611 1611
 	    if ($globalDebug) echo 'Get Data...'."\n";
1612 1612
 	    $buffer = $Common->getData($value['host']);
1613
-	    $all_data = json_decode($buffer,true);
1613
+	    $all_data = json_decode($buffer, true);
1614 1614
 	    if ($buffer != '' && is_array($all_data)) {
1615 1615
 		$reset = 0;
1616 1616
 		foreach ($all_data as $line) {
1617 1617
 	    	    $data = array();
1618 1618
 	    	    //$data['id'] = $line['id']; // id not usable
1619 1619
 	    	    $data['id'] = trim($line['flight_id']);
1620
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1620
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1621 1621
 	    	    $data['pilot_name'] = $line['pilot_name'];
1622 1622
 	    	    $data['pilot_id'] = $line['pilot_id'];
1623 1623
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1661,24 +1661,24 @@  discard block
 block discarded – undo
1661 1661
 	    //$buffer = $Common->getData($hosts[$id]);
1662 1662
 	    if ($globalDebug) echo 'Get Data...'."\n";
1663 1663
 	    $buffer = $Common->getData($value['host']);
1664
-	    $all_data = json_decode($buffer,true);
1664
+	    $all_data = json_decode($buffer, true);
1665 1665
 	    if ($buffer != '') {
1666 1666
 		$Source->deleteLocationBySource('blitzortung');
1667
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1668
-		$buffer = explode('\n',$buffer);
1667
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1668
+		$buffer = explode('\n', $buffer);
1669 1669
 		foreach ($buffer as $buffer_line) {
1670
-		    $line = json_decode($buffer_line,true);
1670
+		    $line = json_decode($buffer_line, true);
1671 1671
 		    if (isset($line['time'])) {
1672 1672
 			$data = array();
1673 1673
 			$data['altitude'] = $line['alt']; // altitude
1674 1674
 			$data['latitude'] = $line['lat']; // lat
1675 1675
 			$data['longitude'] = $line['lon']; // long
1676
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1676
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1677 1677
 			$data['id_source'] = $id_source;
1678 1678
 			$data['format_source'] = 'blitzortung';
1679 1679
 			$SI->add($data);
1680 1680
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1681
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1681
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1682 1682
 			unset($data);
1683 1683
 		    }
1684 1684
 		}
@@ -1690,15 +1690,15 @@  discard block
 block discarded – undo
1690 1690
         $arr = $httpfeeds;
1691 1691
         $w = $e = null;
1692 1692
         if (isset($arr[$id])) {
1693
-            $nn = stream_select($arr,$w,$e,$timeout);
1693
+            $nn = stream_select($arr, $w, $e, $timeout);
1694 1694
             if ($nn > 0) {
1695 1695
                 foreach ($httpfeeds as $feed) {
1696
-                    $buffer = stream_get_line($feed,2000,"\n");
1696
+                    $buffer = stream_get_line($feed, 2000, "\n");
1697 1697
                     if ($buffer === FALSE) {
1698 1698
                         connect_all($globalSources);
1699 1699
                     }
1700
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1701
-                    $buffer = explode('\n',$buffer);
1700
+                    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1701
+                    $buffer = explode('\n', $buffer);
1702 1702
                     foreach ($buffer as $line) {
1703 1703
                         if ($line != '') {
1704 1704
                             $line = json_decode($line, true);
@@ -1738,11 +1738,11 @@  discard block
 block discarded – undo
1738 1738
 		    //$value = $formats[$nb];
1739 1739
 		    $format = $globalSources[$nb]['format'];
1740 1740
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1741
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1741
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1742 1742
 		    } elseif ($format === 'vrstcp') {
1743 1743
 			$buffer = @socket_read($r, 6000);
1744 1744
 		    } else {
1745
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1745
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1746 1746
 		    }
1747 1747
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1748 1748
 		    //echo $buffer."\n";
@@ -1752,8 +1752,8 @@  discard block
 block discarded – undo
1752 1752
 		    //$SI::del();
1753 1753
 		    if ($buffer !== FALSE) {
1754 1754
 			if ($format === 'vrstcp') {
1755
-			    $buffer = explode('},{',$buffer);
1756
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1755
+			    $buffer = explode('},{', $buffer);
1756
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1757 1757
 		    }
1758 1758
 		    // SBS format is CSV format
1759 1759
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1780,7 +1780,7 @@  discard block
 block discarded – undo
1780 1780
 			    $ais_data = $AIS->parse_line(trim($buffer));
1781 1781
 			    $data = array();
1782 1782
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1783
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1783
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1784 1784
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1785 1785
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1786 1786
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1791,13 +1791,13 @@  discard block
 block discarded – undo
1791 1791
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1792 1792
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1793 1793
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1794
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1794
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1795 1795
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1796 1796
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1797 1797
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1798 1798
 
1799 1799
 			    if (isset($ais_data['timestamp'])) {
1800
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1800
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1801 1801
 			    } else {
1802 1802
 				$data['datetime'] = date('Y-m-d H:i:s');
1803 1803
 			    }
@@ -1808,10 +1808,10 @@  discard block
 block discarded – undo
1808 1808
                         } elseif ($format === 'flightgearsp') {
1809 1809
                     	    //echo $buffer."\n";
1810 1810
                     	    if (strlen($buffer) > 5) {
1811
-				$line = explode(',',$buffer);
1811
+				$line = explode(',', $buffer);
1812 1812
 				$data = array();
1813 1813
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1814
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1814
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1815 1815
 				$data['ident'] = $line[6];
1816 1816
 				$data['aircraft_name'] = $line[7];
1817 1817
 				$data['longitude'] = $line[1];
@@ -1828,25 +1828,25 @@  discard block
 block discarded – undo
1828 1828
                         } elseif ($format === 'acars') {
1829 1829
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1830 1830
 			    $ACARS->add(trim($buffer));
1831
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1831
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1832 1832
 			    $ACARS->deleteLiveAcarsData();
1833 1833
 			} elseif ($format === 'acarsjsonudp') {
1834 1834
 			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1835 1835
                             $line = json_decode(trim($buffer), true);
1836 1836
                             if (!empty($line)) {
1837
-				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line);
1837
+				$line = array_merge(array('text' => '', 'tail' => '', 'label' => '', 'block_id' => '', 'flight' => '', 'msgno' => ''), $line);
1838 1838
                                 $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1839 1839
                                 $ACARS->deleteLiveAcarsData();
1840 1840
                             }
1841
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1841
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1842 1842
 			} elseif ($format === 'flightgearmp') {
1843
-			    if (substr($buffer,0,1) != '#') {
1843
+			    if (substr($buffer, 0, 1) != '#') {
1844 1844
 				$data = array();
1845 1845
 				//echo $buffer."\n";
1846
-				$line = explode(' ',$buffer);
1846
+				$line = explode(' ', $buffer);
1847 1847
 				if (count($line) === 11) {
1848
-				    $userserver = explode('@',$line[0]);
1849
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1848
+				    $userserver = explode('@', $line[0]);
1849
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1850 1850
 				    $data['ident'] = $userserver[0];
1851 1851
 				    $data['registration'] = $userserver[0];
1852 1852
 				    $data['latitude'] = $line[4];
@@ -1854,8 +1854,8 @@  discard block
 block discarded – undo
1854 1854
 				    $data['altitude'] = $line[6];
1855 1855
 				    $data['datetime'] = date('Y-m-d H:i:s');
1856 1856
 				    $aircraft_type = $line[10];
1857
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1858
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1857
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1858
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1859 1859
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1860 1860
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1861 1861
 				}
@@ -1864,8 +1864,8 @@  discard block
 block discarded – undo
1864 1864
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1865 1865
 			    die;
1866 1866
 			} elseif ($format === 'vrstcp') {
1867
-			    foreach($buffer as $all_data) {
1868
-				$line = json_decode('{'.$all_data.'}',true);
1867
+			    foreach ($buffer as $all_data) {
1868
+				$line = json_decode('{'.$all_data.'}', true);
1869 1869
 				$data = array();
1870 1870
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1871 1871
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1891,16 +1891,16 @@  discard block
 block discarded – undo
1891 1891
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1892 1892
 				unset($data);
1893 1893
 			    }
1894
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1894
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1895 1895
 			    $line = explode("\t", $buffer);
1896
-			    for($k = 0; $k < count($line); $k=$k+2) {
1896
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1897 1897
 				$key = $line[$k];
1898
-			        $lined[$key] = $line[$k+1];
1898
+			        $lined[$key] = $line[$k + 1];
1899 1899
 			    }
1900 1900
     			    if (count($lined) > 3) {
1901 1901
     				$data['hex'] = $lined['hexid'];
1902 1902
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1903
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1903
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1904 1904
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1905 1905
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1906 1906
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1919,23 +1919,23 @@  discard block
 block discarded – undo
1919 1919
     			    } else $error = true;
1920 1920
 			} elseif ($format === 'aprs' && $use_aprs) {
1921 1921
 			    if ($aprs_connect === 0) {
1922
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1922
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1923 1923
 				$aprs_connect = 1;
1924 1924
 			    }
1925 1925
 			    
1926
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1926
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1927 1927
 				$aprs_last_tx = time();
1928 1928
 				$data_aprs = "# Keep alive";
1929
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1929
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1930 1930
 			    }
1931 1931
 			    
1932 1932
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1933 1933
 			    //echo 'APRS data : '.$buffer."\n";
1934
-			    $buffer = str_replace('APRS <- ','',$buffer);
1935
-			    $buffer = str_replace('APRS -> ','',$buffer);
1934
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1935
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1936 1936
 			    //echo $buffer."\n";
1937 1937
 			    date_default_timezone_set('UTC');
1938
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1938
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1939 1939
 				$line = $APRS->parse($buffer);
1940 1940
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1941 1941
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1950,7 +1950,7 @@  discard block
 block discarded – undo
1950 1950
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1951 1951
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1952 1952
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1953
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1953
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1954 1954
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1955 1955
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1956 1956
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -2038,29 +2038,29 @@  discard block
 block discarded – undo
2038 2038
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
2039 2039
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
2040 2040
 					$Source->deleteOldLocationByType('gs');
2041
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
2042
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
2041
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
2042
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
2043 2043
 					} else {
2044
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
2044
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
2045 2045
 					}
2046 2046
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
2047 2047
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2048 2048
 					if ($globalDebug) echo '# Weather Station added'."\n";
2049 2049
 					$Source->deleteOldLocationByType('wx');
2050 2050
 					$weather_data = json_encode($line);
2051
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
2052
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2051
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
2052
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2053 2053
 					} else {
2054
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2054
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2055 2055
 					}
2056 2056
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2057 2057
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2058 2058
 					if ($globalDebug) echo '☈ Lightning added'."\n";
2059 2059
 					$Source->deleteOldLocationByType('lightning');
2060
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
2061
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2060
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
2061
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2062 2062
 					} else {
2063
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2063
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2064 2064
 					}
2065 2065
 				    } elseif ($globalDebug) {
2066 2066
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -2069,7 +2069,7 @@  discard block
 block discarded – undo
2069 2069
 				    unset($data);
2070 2070
 				}
2071 2071
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2072
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2072
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
2073 2073
 				}
2074 2074
 				/*
2075 2075
 				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')) {
@@ -2078,7 +2078,7 @@  discard block
 block discarded – undo
2078 2078
 				*/
2079 2079
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2080 2080
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2081
-				if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2081
+				if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
2082 2082
 					$Source->deleteOldLocationByType('lightning');
2083 2083
 					$Source->deleteOldLocationByType('wx');
2084 2084
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2165,7 +2165,7 @@  discard block
 block discarded – undo
2165 2165
 				connect_all($sourceee);
2166 2166
 				$sourceee = array();
2167 2167
 				//connect_all($globalSources);
2168
-				$tt[$format]=0;
2168
+				$tt[$format] = 0;
2169 2169
 				break;
2170 2170
 			    } 
2171 2171
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2175,14 +2175,14 @@  discard block
 block discarded – undo
2175 2175
 	    } else {
2176 2176
 		$error = socket_strerror(socket_last_error());
2177 2177
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2178
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2178
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2179 2179
 			if (isset($globalDebug)) echo "Restarting...\n";
2180 2180
 			// Restart the script if possible
2181 2181
 			if (is_array($sockets)) {
2182 2182
 			    if ($globalDebug) echo "Shutdown all sockets...";
2183 2183
 			    
2184 2184
 			    foreach ($sockets as $sock) {
2185
-				@socket_shutdown($sock,2);
2185
+				@socket_shutdown($sock, 2);
2186 2186
 				@socket_close($sock);
2187 2187
 			    }
2188 2188
 			    
Please login to merge, or discard this patch.