Completed
Push — master ( 014bf0...2f98db )
by Yannick
09:33
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';
@@ -796,28 +796,28 @@  discard block
 block discarded – undo
796 796
 		exit(0);
797 797
 	    }
798 798
 	    $sailawayoption = array('key' => $globalSailaway['key']);
799
-	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
800
-	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
799
+	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption, array('usrnr' => $globalSailaway['usrnr']));
800
+	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption, array('ubtnr' => $globalSailaway['ubtnr']));
801 801
 
802 802
 	    for ($i = 0; $i <= 1; $i++) {
803 803
 		if ($globalDebug) echo '! Download... ';
804
-		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2','get','','','','',30);
804
+		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2', 'get', '', '', '', '', 30);
805 805
 		if ($globalDebug) echo 'done'."\n";
806 806
 		if ($buffer != '') {
807
-		    $all_data = json_decode($buffer,true);
807
+		    $all_data = json_decode($buffer, true);
808 808
 		    if (isset($all_data['missions'])) {
809 809
 			foreach ($all_data['missions'] as $mission) {
810 810
 				$mission_user = $mission['usrname'];
811
-				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
812
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
811
+				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']));
812
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
813 813
 					//print_r($mission);
814 814
 					$datar = array();
815 815
 					$datar['id'] = $mission['misnr'];
816 816
 					$datar['desc'] = $mission['misdescr'];
817 817
 					//$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['usrname'])));
818 818
 					$datar['creator'] = '';
819
-					$datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])));
820
-					if (isset($mission['misstart'])) $datar['startdate'] = date('Y-m-d H:i:s',strtotime($mission['misstart']));
819
+					$datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle'])));
820
+					if (isset($mission['misstart'])) $datar['startdate'] = date('Y-m-d H:i:s', strtotime($mission['misstart']));
821 821
 					else $datar['startdate'] = '1970-01-01 00:00:00';
822 822
 					/*
823 823
 					$markers = array();
@@ -837,9 +837,9 @@  discard block
 block discarded – undo
837 837
 		if ($globalDebug) echo '=== Wait... ===';
838 838
 		sleep(10*60);
839 839
 	    }
840
-	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30);
840
+	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption), 'get', '', '', '', '', 30);
841 841
 	    if ($buffer != '') {
842
-		$data = json_decode($buffer,true);
842
+		$data = json_decode($buffer, true);
843 843
 		//print_r($data);
844 844
 		if (isset($data['boats'])) {
845 845
 		    foreach ($data['boats'] as $sail) {
@@ -851,12 +851,12 @@  discard block
 block discarded – undo
851 851
 			$data['longitude'] = $sail['ubtlon'];
852 852
 			$data['type_id'] = 36;
853 853
 			$data['heading'] = $sail['ubtheading'];
854
-			$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
854
+			$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
855 855
 			$data['captain_name'] = $sail['usrname'];
856
-			$allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52&#39; Cruising Cat','50&#39; Performance Cruiser','Nordic Folkboat','32&#39; Offshore Racer');
856
+			$allboats = array('Sailaway Cruiser 38', 'Mini Transat', 'Caribbean Rose', '52&#39; Cruising Cat', '50&#39; Performance Cruiser', 'Nordic Folkboat', '32&#39; Offshore Racer');
857 857
 			$boattype = $sail['ubtbtpnr'];
858
-			if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1];
859
-			$data['speed'] = round($sail['ubtspeed']*3.6,2);
858
+			if (isset($allboats[$boattype - 1])) $data['type'] = $allboats[$boattype - 1];
859
+			$data['speed'] = round($sail['ubtspeed']*3.6, 2);
860 860
 			$data['format_source'] = 'sailaway';
861 861
 			$data['id_source'] = $id_source;
862 862
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -889,12 +889,12 @@  discard block
 block discarded – undo
889 889
 	    }
890 890
 	    if ($globalDebug) echo '! Download... ';
891 891
 	    $sailawayoption = array('key' => $globalSailaway['key']);
892
-	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
893
-	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
894
-	    if (isset($globalSailaway['misnr'])) $sailawayoption = array_merge($sailawayoption,array('misnr' => $globalSailaway['misnr']));
895
-	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30);
892
+	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption, array('usrnr' => $globalSailaway['usrnr']));
893
+	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption, array('ubtnr' => $globalSailaway['ubtnr']));
894
+	    if (isset($globalSailaway['misnr'])) $sailawayoption = array_merge($sailawayoption, array('misnr' => $globalSailaway['misnr']));
895
+	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption), 'get', '', '', '', '', 30);
896 896
 	    if ($buffer != '') {
897
-		$data = json_decode($buffer,true);
897
+		$data = json_decode($buffer, true);
898 898
 		//print_r($data);
899 899
 		if (isset($data['boats'])) {
900 900
 		    foreach ($data['boats'] as $sail) {
@@ -906,12 +906,12 @@  discard block
 block discarded – undo
906 906
 			$data['longitude'] = $sail['ubtlon'];
907 907
 			$data['type_id'] = 36;
908 908
 			$data['heading'] = $sail['ubtheading'];
909
-			$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
909
+			$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
910 910
 			$data['captain_name'] = $sail['usrname'];
911
-			$allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52&#39; Cruising Cat','50&#39; Performance Cruiser','Nordic Folkboat','32&#39; Offshore Racer');
911
+			$allboats = array('Sailaway Cruiser 38', 'Mini Transat', 'Caribbean Rose', '52&#39; Cruising Cat', '50&#39; Performance Cruiser', 'Nordic Folkboat', '32&#39; Offshore Racer');
912 912
 			$boattype = $sail['ubtbtpnr'];
913
-			if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1];
914
-			$data['speed'] = round($sail['ubtspeed']*3.6,2);
913
+			if (isset($allboats[$boattype - 1])) $data['type'] = $allboats[$boattype - 1];
914
+			$data['speed'] = round($sail['ubtspeed']*3.6, 2);
915 915
 			$data['format_source'] = 'sailaway';
916 916
 			$data['id_source'] = $id_source;
917 917
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -939,8 +939,8 @@  discard block
 block discarded – undo
939 939
 	) {
940 940
 	    //$buffer = $Common->getData($hosts[$id]);
941 941
 	    $buffer = $Common->getData($value['host']);
942
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
943
-	    $buffer = explode('\n',$buffer);
942
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
943
+	    $buffer = explode('\n', $buffer);
944 944
 	    $reset = 0;
945 945
 	    foreach ($buffer as $line) {
946 946
     		if ($line != '') {
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
952 952
 			$data['pilot_id'] = $line[1];
953 953
 			$data['pilot_name'] = $line[2];
954
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
954
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
955 955
 			$data['ident'] = $line[0]; // ident
956 956
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
957 957
 			$data['speed'] = $line[8]; // speed
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
968 968
 			//if (isset($line[37])) $data['last_update'] = $line[37];
969 969
 		        $data['departure_airport_icao'] = $line[11];
970
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
970
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
971 971
 		        $data['arrival_airport_icao'] = $line[13];
972 972
 			$data['frequency'] = $line[4];
973 973
 			$data['type'] = $line[18];
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
     			$data['id_source'] = $id_source;
977 977
 	    		//$data['arrival_airport_time'] = ;
978 978
 	    		if ($line[9] != '') {
979
-	    		    $aircraft_data = explode('/',$line[9]);
979
+	    		    $aircraft_data = explode('/', $line[9]);
980 980
 	    		    if (count($aircraft_data) == 2) {
981 981
 				//line[9] may equal to something like 'B738/L' in old FSD server's whazzup.txt file
982 982
 	    			$data['aircraft_icao'] = $aircraft_data[0];
@@ -995,9 +995,9 @@  discard block
 block discarded – undo
995 995
     			if ($line[3] === 'PILOT') $SI->add($data);
996 996
 			elseif ($line[3] === 'ATC') {
997 997
 				//print_r($data);
998
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
999
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
1000
-				$typec = substr($data['ident'],-3);
998
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
999
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1000
+				$typec = substr($data['ident'], -3);
1001 1001
 				if ($typec === 'APP') $data['type'] = 'Approach';
1002 1002
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
1003 1003
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -1009,8 +1009,8 @@  discard block
 block discarded – undo
1009 1009
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
1010 1010
 				if (!isset($data['source_name'])) $data['source_name'] = '';
1011 1011
 				if (isset($ATC)) {
1012
-					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']);
1013
-					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']);
1012
+					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']);
1013
+					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']);
1014 1014
 				}
1015 1015
 			}
1016 1016
     			unset($data);
@@ -1026,24 +1026,24 @@  discard block
 block discarded – undo
1026 1026
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1027 1027
     	    )
1028 1028
     	) {
1029
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1029
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
1030 1030
 	    if ($buffer != '') {
1031 1031
 		$all_data = simplexml_load_string($buffer);
1032
-		foreach($all_data->children() as $childdata) {
1032
+		foreach ($all_data->children() as $childdata) {
1033 1033
 			$data = array();
1034 1034
 			$line = $childdata;
1035 1035
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
1036
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
1037
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1038
-			$data['latitude'] = (float)$line['pktLatitude'];
1039
-			$data['longitude'] = (float)$line['pktLongitude'];
1040
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1041
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1042
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1036
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
1037
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
1038
+			$data['latitude'] = (float) $line['pktLatitude'];
1039
+			$data['longitude'] = (float) $line['pktLongitude'];
1040
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
1041
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
1042
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
1043 1043
 			$data['altitude_relative'] = 'AMSL';
1044
-			$data['pilot_id'] = (int)$line['pktPilotID'];
1044
+			$data['pilot_id'] = (int) $line['pktPilotID'];
1045 1045
 			$data['aircraft_icao'] = 'PARAGLIDER';
1046
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1046
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1047 1047
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1048 1048
 			$data['format_source'] = $value['format'];
1049 1049
 			$SI->add($data);
@@ -1051,22 +1051,22 @@  discard block
 block discarded – undo
1051 1051
 		}
1052 1052
 	    }
1053 1053
 	    $Source->deleteOldLocationByType('gs');
1054
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1054
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
1055 1055
 	    if ($buffer != '') {
1056 1056
 		$all_data = simplexml_load_string($buffer);
1057
-		foreach($all_data->children() as $childdata) {
1057
+		foreach ($all_data->children() as $childdata) {
1058 1058
 			$data = array();
1059 1059
 			$line = $childdata;
1060
-			$data['id'] = (int)$line['gsID'];
1061
-			$data['latitude'] = (float)$line['gsLatitude'];
1062
-			$data['longitude'] = (float)$line['gsLongitude'];
1063
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
1060
+			$data['id'] = (int) $line['gsID'];
1061
+			$data['latitude'] = (float) $line['gsLatitude'];
1062
+			$data['longitude'] = (float) $line['gsLongitude'];
1063
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
1064 1064
 			$data['altitude_relative'] = 'AMSL';
1065
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
1065
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
1066 1066
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
1067
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1067
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1068 1068
 			} else {
1069
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1069
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1070 1070
 			}
1071 1071
 			unset($data);
1072 1072
 		}
@@ -1084,9 +1084,9 @@  discard block
 block discarded – undo
1084 1084
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1085 1085
 	    )
1086 1086
 	) {
1087
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1087
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1088 1088
 	    if ($buffer != '') {
1089
-	        $all_data = json_decode($buffer,true);
1089
+	        $all_data = json_decode($buffer, true);
1090 1090
 		if (isset($all_data['acList'])) {
1091 1091
 		    $reset = 0;
1092 1092
 		    foreach ($all_data['acList'] as $line) {
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1103 1103
 			$data['emergency'] = ''; // emergency
1104 1104
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1105
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1105
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1106 1106
 			else $data['datetime'] = date('Y-m-d H:i:s');
1107 1107
 			//$data['datetime'] = date('Y-m-d H:i:s');
1108 1108
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1128 1128
 			$data['squawk'] = $line['squawk']; // squawk
1129 1129
 			$data['emergency'] = ''; // emergency
1130
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1130
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1131 1131
 			else $data['datetime'] = date('Y-m-d H:i:s');
1132 1132
 			$data['format_source'] = 'aircraftlistjson';
1133 1133
 			$data['id_source'] = $id_source;
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
     	    )
1149 1149
     	) {
1150 1150
 	    $buffer = $Common->getData($value['host']);
1151
-	    $all_data = json_decode($buffer,true);
1151
+	    $all_data = json_decode($buffer, true);
1152 1152
 	    if (isset($all_data['planes'])) {
1153 1153
 		$reset = 0;
1154 1154
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1165,12 +1165,12 @@  discard block
 block discarded – undo
1165 1165
 		    $data['emergency'] = ''; // emergency
1166 1166
 		    $data['registration'] = $line[2];
1167 1167
 		    $data['aircraft_icao'] = $line[0];
1168
-		    $deparr = explode('-',$line[1]);
1168
+		    $deparr = explode('-', $line[1]);
1169 1169
 		    if (count($deparr) === 2) {
1170 1170
 			$data['departure_airport_icao'] = $deparr[0];
1171 1171
 			$data['arrival_airport_icao'] = $deparr[1];
1172 1172
 		    }
1173
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1173
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1174 1174
 	    	    $data['format_source'] = 'planeupdatefaa';
1175 1175
     		    $data['id_source'] = $id_source;
1176 1176
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
 	    )
1189 1189
 	) {
1190 1190
 	    $buffer = $Common->getData($value['host']);
1191
-	    $all_data = json_decode($buffer,true);
1191
+	    $all_data = json_decode($buffer, true);
1192 1192
 	    if (isset($all_data['states'])) {
1193 1193
 		$reset = 0;
1194 1194
 		foreach ($all_data['states'] as $key => $line) {
@@ -1205,7 +1205,7 @@  discard block
 block discarded – undo
1205 1205
 		    //$data['emergency'] = ''; // emergency
1206 1206
 		    //$data['registration'] = $line[2];
1207 1207
 		    //$data['aircraft_icao'] = $line[0];
1208
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1208
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1209 1209
 		    $data['format_source'] = 'opensky';
1210 1210
 		    $data['id_source'] = $id_source;
1211 1211
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1222,8 +1222,8 @@  discard block
 block discarded – undo
1222 1222
 	    )
1223 1223
 	) {
1224 1224
 	    $buffer = $Common->getData($value['host']);
1225
-	    $all_data = json_decode($buffer,true);
1226
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1225
+	    $all_data = json_decode($buffer, true);
1226
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1227 1227
 		$reset = 0;
1228 1228
 		foreach ($all_data['aircraft'] as $key => $line) {
1229 1229
 		    $data = array();
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
 	    )
1262 1262
 	) {
1263 1263
 	    $buffer = $Common->getData($value['host']);
1264
-	    $all_data = json_decode($buffer,true);
1264
+	    $all_data = json_decode($buffer, true);
1265 1265
 	    if (isset($all_data['aircraft'])) {
1266 1266
 		$reset = 0;
1267 1267
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 		    //$data['emergency'] = ''; // emergency
1279 1279
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1280 1280
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1281
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1281
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1282 1282
 		    $data['format_source'] = 'planefinderclient';
1283 1283
 		    $data['id_source'] = $id_source;
1284 1284
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 	) {
1298 1298
 	    //$buffer = $Common->getData($hosts[$id]);
1299 1299
 	    $buffer = $Common->getData($value['host']);
1300
-	    $all_data = json_decode($buffer,true);
1300
+	    $all_data = json_decode($buffer, true);
1301 1301
 	    if (!empty($all_data)) $reset = 0;
1302 1302
 	    foreach ($all_data as $key => $line) {
1303 1303
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1335,11 +1335,11 @@  discard block
 block discarded – undo
1335 1335
 	    )
1336 1336
 	) {
1337 1337
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1338
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1338
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1339 1339
 	    //echo $buffer;
1340
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1341
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1342
-	    $all_data = json_decode($buffer,true);
1340
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1341
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1342
+	    $all_data = json_decode($buffer, true);
1343 1343
 	    if (json_last_error() != JSON_ERROR_NONE) {
1344 1344
 		die(json_last_error_msg());
1345 1345
 	    }
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
 			//$data['departure_airport_iata'] = $line[11];
1363 1363
 			//$data['arrival_airport_iata'] = $line[12];
1364 1364
 	    		//$data['emergency'] = ''; // emergency
1365
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1365
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1366 1366
 	    		$data['format_source'] = 'radarvirtueljson';
1367 1367
     			$data['id_source'] = $id_source;
1368 1368
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1383,14 +1383,14 @@  discard block
 block discarded – undo
1383 1383
 	) {
1384 1384
 	    //$buffer = $Common->getData($hosts[$id]);
1385 1385
 	    $buffer = $Common->getData($value['host'].'?'.time());
1386
-	    $all_data = json_decode(utf8_encode($buffer),true);
1386
+	    $all_data = json_decode(utf8_encode($buffer), true);
1387 1387
 	    
1388 1388
 	    if (isset($all_data['pireps'])) {
1389 1389
 		$reset = 0;
1390 1390
 	        foreach ($all_data['pireps'] as $line) {
1391 1391
 		    $data = array();
1392 1392
 		    $data['id'] = $line['id'];
1393
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1393
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1394 1394
 		    $data['ident'] = $line['callsign']; // ident
1395 1395
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1396 1396
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1420,9 +1420,9 @@  discard block
 block discarded – undo
1420 1420
 			$SI->add($data);
1421 1421
 		    //    print_r($data);
1422 1422
     		    } elseif ($line['icon'] === 'ct') {
1423
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1424
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1425
-			$typec = substr($data['ident'],-3);
1423
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1424
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1425
+			$typec = substr($data['ident'], -3);
1426 1426
 			$data['type'] = '';
1427 1427
 			if ($typec === 'APP') $data['type'] = 'Approach';
1428 1428
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1433,7 +1433,7 @@  discard block
 block discarded – undo
1433 1433
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1434 1434
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1435 1435
 			else $data['type'] = 'Observer';
1436
-			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']);
1436
+			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']);
1437 1437
 		    }
1438 1438
 		    unset($data);
1439 1439
 		}
@@ -1450,7 +1450,7 @@  discard block
 block discarded – undo
1450 1450
 	    //$buffer = $Common->getData($hosts[$id]);
1451 1451
 	    if ($globalDebug) echo 'Get Data...'."\n";
1452 1452
 	    $buffer = $Common->getData($value['host']);
1453
-	    $all_data = json_decode($buffer,true);
1453
+	    $all_data = json_decode($buffer, true);
1454 1454
 	    if ($buffer != '' && is_array($all_data)) {
1455 1455
 		$reset = 0;
1456 1456
 		foreach ($all_data as $line) {
@@ -1458,7 +1458,7 @@  discard block
 block discarded – undo
1458 1458
 	    	    //$data['id'] = $line['id']; // id not usable
1459 1459
 	    	    if (isset($line['pilotid']) && isset($line['registration'])) $data['id'] = $line['pilotid'].$line['flightnum'].trim($line['registration']);
1460 1460
 	    	    elseif (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1461
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1461
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1462 1462
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1463 1463
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1464 1464
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1473,7 +1473,7 @@  discard block
 block discarded – undo
1473 1473
 	    	    //$data['datetime'] = $line['lastupdate'];
1474 1474
 	    	    //$data['last_update'] = $line['lastupdate'];
1475 1475
 	    	    if (isset($value['timezone'])) {
1476
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1476
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1477 1477
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1478 1478
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1479 1479
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1489,14 +1489,14 @@  discard block
 block discarded – undo
1489 1489
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1490 1490
 		    if (isset($line['aircraftname'])) {
1491 1491
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1492
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1493
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1492
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1493
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1494 1494
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1495 1495
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1496 1496
 	    		else {
1497
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1498
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1499
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1497
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1498
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1499
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1500 1500
 	    		}
1501 1501
 	    	    }
1502 1502
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1521,7 +1521,7 @@  discard block
 block discarded – undo
1521 1521
 	    //$buffer = $Common->getData($hosts[$id]);
1522 1522
 	    if ($globalDebug) echo 'Get Data...'."\n";
1523 1523
 	    $buffer = $Common->getData($value['host']);
1524
-	    $all_data = json_decode($buffer,true);
1524
+	    $all_data = json_decode($buffer, true);
1525 1525
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1526 1526
 		$reset = 0;
1527 1527
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1532,7 +1532,7 @@  discard block
 block discarded – undo
1532 1532
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1533 1533
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1534 1534
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1535
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1535
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1536 1536
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1537 1537
 	    	    $data['altitude'] = $line['altitude']; // altitude
1538 1538
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1543,7 +1543,7 @@  discard block
 block discarded – undo
1543 1543
 	    	    //$data['squawk'] = ''; // squawk
1544 1544
 	    	    //$data['emergency'] = ''; // emergency
1545 1545
 	    	    if (isset($value['timezone'])) {
1546
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1546
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1547 1547
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1548 1548
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1549 1549
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1579,14 +1579,14 @@  discard block
 block discarded – undo
1579 1579
 	    //$buffer = $Common->getData($hosts[$id]);
1580 1580
 	    if ($globalDebug) echo 'Get Data...'."\n";
1581 1581
 	    $buffer = $Common->getData($value['host']);
1582
-	    $all_data = json_decode($buffer,true);
1582
+	    $all_data = json_decode($buffer, true);
1583 1583
 	    if ($buffer != '' && is_array($all_data)) {
1584 1584
 		$reset = 0;
1585 1585
 		foreach ($all_data as $line) {
1586 1586
 	    	    $data = array();
1587 1587
 	    	    //$data['id'] = $line['id']; // id not usable
1588 1588
 	    	    $data['id'] = trim($line['flight_id']);
1589
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1589
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1590 1590
 	    	    $data['pilot_name'] = $line['pilot_name'];
1591 1591
 	    	    $data['pilot_id'] = $line['pilot_id'];
1592 1592
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1630,24 +1630,24 @@  discard block
 block discarded – undo
1630 1630
 	    //$buffer = $Common->getData($hosts[$id]);
1631 1631
 	    if ($globalDebug) echo 'Get Data...'."\n";
1632 1632
 	    $buffer = $Common->getData($value['host']);
1633
-	    $all_data = json_decode($buffer,true);
1633
+	    $all_data = json_decode($buffer, true);
1634 1634
 	    if ($buffer != '') {
1635 1635
 		$Source->deleteLocationBySource('blitzortung');
1636
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1637
-		$buffer = explode('\n',$buffer);
1636
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1637
+		$buffer = explode('\n', $buffer);
1638 1638
 		foreach ($buffer as $buffer_line) {
1639
-		    $line = json_decode($buffer_line,true);
1639
+		    $line = json_decode($buffer_line, true);
1640 1640
 		    if (isset($line['time'])) {
1641 1641
 			$data = array();
1642 1642
 			$data['altitude'] = $line['alt']; // altitude
1643 1643
 			$data['latitude'] = $line['lat']; // lat
1644 1644
 			$data['longitude'] = $line['lon']; // long
1645
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1645
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1646 1646
 			$data['id_source'] = $id_source;
1647 1647
 			$data['format_source'] = 'blitzortung';
1648 1648
 			$SI->add($data);
1649 1649
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1650
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1650
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1651 1651
 			unset($data);
1652 1652
 		    }
1653 1653
 		}
@@ -1659,15 +1659,15 @@  discard block
 block discarded – undo
1659 1659
         $arr = $httpfeeds;
1660 1660
         $w = $e = null;
1661 1661
         if (isset($arr[$id])) {
1662
-            $nn = stream_select($arr,$w,$e,$timeout);
1662
+            $nn = stream_select($arr, $w, $e, $timeout);
1663 1663
             if ($nn > 0) {
1664 1664
                 foreach ($httpfeeds as $feed) {
1665
-                    $buffer = stream_get_line($feed,2000,"\n");
1665
+                    $buffer = stream_get_line($feed, 2000, "\n");
1666 1666
                     if ($buffer === FALSE) {
1667 1667
                         connect_all($globalSources);
1668 1668
                     }
1669
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1670
-                    $buffer = explode('\n',$buffer);
1669
+                    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1670
+                    $buffer = explode('\n', $buffer);
1671 1671
                     foreach ($buffer as $line) {
1672 1672
                         if ($line != '') {
1673 1673
                             $line = json_decode($line, true);
@@ -1707,11 +1707,11 @@  discard block
 block discarded – undo
1707 1707
 		    //$value = $formats[$nb];
1708 1708
 		    $format = $globalSources[$nb]['format'];
1709 1709
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1710
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1710
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1711 1711
 		    } elseif ($format === 'vrstcp') {
1712 1712
 			$buffer = @socket_read($r, 6000);
1713 1713
 		    } else {
1714
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1714
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1715 1715
 		    }
1716 1716
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1717 1717
 		    //echo $buffer."\n";
@@ -1721,8 +1721,8 @@  discard block
 block discarded – undo
1721 1721
 		    //$SI::del();
1722 1722
 		    if ($buffer !== FALSE) {
1723 1723
 			if ($format === 'vrstcp') {
1724
-			    $buffer = explode('},{',$buffer);
1725
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1724
+			    $buffer = explode('},{', $buffer);
1725
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1726 1726
 		    }
1727 1727
 		    // SBS format is CSV format
1728 1728
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1749,7 +1749,7 @@  discard block
 block discarded – undo
1749 1749
 			    $ais_data = $AIS->parse_line(trim($buffer));
1750 1750
 			    $data = array();
1751 1751
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1752
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1752
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1753 1753
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1754 1754
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1755 1755
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1760,13 +1760,13 @@  discard block
 block discarded – undo
1760 1760
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1761 1761
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1762 1762
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1763
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1763
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1764 1764
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1765 1765
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1766 1766
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1767 1767
 
1768 1768
 			    if (isset($ais_data['timestamp'])) {
1769
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1769
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1770 1770
 			    } else {
1771 1771
 				$data['datetime'] = date('Y-m-d H:i:s');
1772 1772
 			    }
@@ -1777,10 +1777,10 @@  discard block
 block discarded – undo
1777 1777
                         } elseif ($format === 'flightgearsp') {
1778 1778
                     	    //echo $buffer."\n";
1779 1779
                     	    if (strlen($buffer) > 5) {
1780
-				$line = explode(',',$buffer);
1780
+				$line = explode(',', $buffer);
1781 1781
 				$data = array();
1782 1782
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1783
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1783
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1784 1784
 				$data['ident'] = $line[6];
1785 1785
 				$data['aircraft_name'] = $line[7];
1786 1786
 				$data['longitude'] = $line[1];
@@ -1797,25 +1797,25 @@  discard block
 block discarded – undo
1797 1797
                         } elseif ($format === 'acars') {
1798 1798
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1799 1799
 			    $ACARS->add(trim($buffer));
1800
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1800
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1801 1801
 			    $ACARS->deleteLiveAcarsData();
1802 1802
 			} elseif ($format === 'acarsjsonudp') {
1803 1803
 			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1804 1804
                             $line = json_decode(trim($buffer), true);
1805 1805
                             if (!empty($line)) {
1806
-				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line);
1806
+				$line = array_merge(array('text' => '', 'tail' => '', 'label' => '', 'block_id' => '', 'flight' => '', 'msgno' => ''), $line);
1807 1807
                                 $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'] : '')));
1808 1808
                                 $ACARS->deleteLiveAcarsData();
1809 1809
                             }
1810
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1810
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1811 1811
 			} elseif ($format === 'flightgearmp') {
1812
-			    if (substr($buffer,0,1) != '#') {
1812
+			    if (substr($buffer, 0, 1) != '#') {
1813 1813
 				$data = array();
1814 1814
 				//echo $buffer."\n";
1815
-				$line = explode(' ',$buffer);
1815
+				$line = explode(' ', $buffer);
1816 1816
 				if (count($line) === 11) {
1817
-				    $userserver = explode('@',$line[0]);
1818
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1817
+				    $userserver = explode('@', $line[0]);
1818
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1819 1819
 				    $data['ident'] = $userserver[0];
1820 1820
 				    $data['registration'] = $userserver[0];
1821 1821
 				    $data['latitude'] = $line[4];
@@ -1823,8 +1823,8 @@  discard block
 block discarded – undo
1823 1823
 				    $data['altitude'] = $line[6];
1824 1824
 				    $data['datetime'] = date('Y-m-d H:i:s');
1825 1825
 				    $aircraft_type = $line[10];
1826
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1827
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1826
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1827
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1828 1828
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1829 1829
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1830 1830
 				}
@@ -1833,8 +1833,8 @@  discard block
 block discarded – undo
1833 1833
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1834 1834
 			    die;
1835 1835
 			} elseif ($format === 'vrstcp') {
1836
-			    foreach($buffer as $all_data) {
1837
-				$line = json_decode('{'.$all_data.'}',true);
1836
+			    foreach ($buffer as $all_data) {
1837
+				$line = json_decode('{'.$all_data.'}', true);
1838 1838
 				$data = array();
1839 1839
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1840 1840
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1860,16 +1860,16 @@  discard block
 block discarded – undo
1860 1860
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1861 1861
 				unset($data);
1862 1862
 			    }
1863
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1863
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1864 1864
 			    $line = explode("\t", $buffer);
1865
-			    for($k = 0; $k < count($line); $k=$k+2) {
1865
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1866 1866
 				$key = $line[$k];
1867
-			        $lined[$key] = $line[$k+1];
1867
+			        $lined[$key] = $line[$k + 1];
1868 1868
 			    }
1869 1869
     			    if (count($lined) > 3) {
1870 1870
     				$data['hex'] = $lined['hexid'];
1871 1871
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1872
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1872
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1873 1873
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1874 1874
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1875 1875
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1888,23 +1888,23 @@  discard block
 block discarded – undo
1888 1888
     			    } else $error = true;
1889 1889
 			} elseif ($format === 'aprs' && $use_aprs) {
1890 1890
 			    if ($aprs_connect === 0) {
1891
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1891
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1892 1892
 				$aprs_connect = 1;
1893 1893
 			    }
1894 1894
 			    
1895
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1895
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1896 1896
 				$aprs_last_tx = time();
1897 1897
 				$data_aprs = "# Keep alive";
1898
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1898
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1899 1899
 			    }
1900 1900
 			    
1901 1901
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1902 1902
 			    //echo 'APRS data : '.$buffer."\n";
1903
-			    $buffer = str_replace('APRS <- ','',$buffer);
1904
-			    $buffer = str_replace('APRS -> ','',$buffer);
1903
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1904
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1905 1905
 			    //echo $buffer."\n";
1906 1906
 			    date_default_timezone_set('UTC');
1907
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1907
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1908 1908
 				$line = $APRS->parse($buffer);
1909 1909
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1910 1910
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1919,7 +1919,7 @@  discard block
 block discarded – undo
1919 1919
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1920 1920
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1921 1921
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1922
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1922
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1923 1923
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1924 1924
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1925 1925
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -2007,29 +2007,29 @@  discard block
 block discarded – undo
2007 2007
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
2008 2008
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
2009 2009
 					$Source->deleteOldLocationByType('gs');
2010
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
2011
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
2010
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
2011
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
2012 2012
 					} else {
2013
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
2013
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
2014 2014
 					}
2015 2015
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
2016 2016
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2017 2017
 					if ($globalDebug) echo '# Weather Station added'."\n";
2018 2018
 					$Source->deleteOldLocationByType('wx');
2019 2019
 					$weather_data = json_encode($line);
2020
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
2021
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2020
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
2021
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2022 2022
 					} else {
2023
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2023
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2024 2024
 					}
2025 2025
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2026 2026
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2027 2027
 					if ($globalDebug) echo '☈ Lightning added'."\n";
2028 2028
 					$Source->deleteOldLocationByType('lightning');
2029
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
2030
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2029
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
2030
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2031 2031
 					} else {
2032
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2032
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2033 2033
 					}
2034 2034
 				    } elseif ($globalDebug) {
2035 2035
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -2038,7 +2038,7 @@  discard block
 block discarded – undo
2038 2038
 				    unset($data);
2039 2039
 				}
2040 2040
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2041
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2041
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
2042 2042
 				}
2043 2043
 				/*
2044 2044
 				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')) {
@@ -2047,7 +2047,7 @@  discard block
 block discarded – undo
2047 2047
 				*/
2048 2048
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2049 2049
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2050
-				if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2050
+				if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
2051 2051
 					$Source->deleteOldLocationByType('lightning');
2052 2052
 					$Source->deleteOldLocationByType('wx');
2053 2053
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2134,7 +2134,7 @@  discard block
 block discarded – undo
2134 2134
 				connect_all($sourceee);
2135 2135
 				$sourceee = array();
2136 2136
 				//connect_all($globalSources);
2137
-				$tt[$format]=0;
2137
+				$tt[$format] = 0;
2138 2138
 				break;
2139 2139
 			    } 
2140 2140
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2144,14 +2144,14 @@  discard block
 block discarded – undo
2144 2144
 	    } else {
2145 2145
 		$error = socket_strerror(socket_last_error());
2146 2146
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2147
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2147
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2148 2148
 			if (isset($globalDebug)) echo "Restarting...\n";
2149 2149
 			// Restart the script if possible
2150 2150
 			if (is_array($sockets)) {
2151 2151
 			    if ($globalDebug) echo "Shutdown all sockets...";
2152 2152
 			    
2153 2153
 			    foreach ($sockets as $sock) {
2154
-				@socket_shutdown($sock,2);
2154
+				@socket_shutdown($sock, 2);
2155 2155
 				@socket_close($sock);
2156 2156
 			    }
2157 2157
 			    
Please login to merge, or discard this patch.