Completed
Push — master ( 128a26...3f35c5 )
by Yannick
58:51 queued 28:47
created
scripts/daemon-spotter.php 1 patch
Spacing   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
 	    die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
53
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
54 54
     }
55 55
 }
56 56
 
57
-$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'));
57
+$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'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65 65
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
66
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
67 67
     else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106 106
     if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
107
+    $SI = new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
111 111
     $SI->connect();
112 112
 */
113
-} else $SI=new SpotterImport($Connection->db);
113
+} else $SI = new SpotterImport($Connection->db);
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
     $MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127
-$SBS=new SBS();
127
+$SBS = new SBS();
128 128
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
129
-	$ACARS=new ACARS($Connection->db,true);
130
-	$Source=new Source($Connection->db);
129
+	$ACARS = new ACARS($Connection->db, true);
130
+	$Source = new Source($Connection->db);
131 131
 }
132
-$Common=new Common();
132
+$Common = new Common();
133 133
 date_default_timezone_set('UTC');
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
137
+    pcntl_signal(SIGINT, function() {
138 138
         global $sockets;
139 139
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140 140
         die("Bye!\n");
@@ -150,30 +150,30 @@  discard block
 block discarded – undo
150 150
 
151 151
 function connect_all($hosts) {
152 152
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
153
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
154 154
     $reset++;
155 155
     if ($globalDebug) echo 'Connect to all...'."\n";
156 156
     foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
160
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
+            if (preg_match('/deltadb.txt$/i', $host)) {
162 162
         	//$formats[$id] = 'deltadbtxt';
163 163
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 164
         	//$last_exec['deltadbtxt'] = 0;
165 165
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
166
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
167 167
         	//$formats[$id] = 'vatsimtxt';
168 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 169
         	//$last_exec['vatsimtxt'] = 0;
170 170
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
171
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
172 172
         	//$formats[$id] = 'aircraftlistjson';
173 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 174
         	//$last_exec['aircraftlistjson'] = 0;
175 175
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/opensky/i',$host)) {
176
+    	    } else if (preg_match('/opensky/i', $host)) {
177 177
         	//$formats[$id] = 'aircraftlistjson';
178 178
         	$globalSources[$id]['format'] = 'opensky';
179 179
         	//$last_exec['aircraftlistjson'] = 0;
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
         	    exit(0);
191 191
         	}
192 192
     	    */
193
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
193
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
194 194
         	//$formats[$id] = 'planeupdatefaa';
195 195
         	$globalSources[$id]['format'] = 'planeupdatefaa';
196 196
         	//$last_exec['planeupdatefaa'] = 0;
@@ -199,37 +199,37 @@  discard block
 block discarded – undo
199 199
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200 200
         	    exit(0);
201 201
         	}
202
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
202
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
203 203
         	//$formats[$id] = 'phpvmacars';
204 204
         	$globalSources[$id]['format'] = 'phpvmacars';
205 205
         	//$last_exec['phpvmacars'] = 0;
206 206
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
207
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
207
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
208 208
         	//$formats[$id] = 'phpvmacars';
209 209
         	$globalSources[$id]['format'] = 'vaos';
210 210
         	//$last_exec['phpvmacars'] = 0;
211 211
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
212
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
212
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
213 213
         	//$formats[$id] = 'phpvmacars';
214 214
         	$globalSources[$id]['format'] = 'vam';
215 215
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
216
-            } else if (preg_match('/whazzup/i',$host)) {
216
+            } else if (preg_match('/whazzup/i', $host)) {
217 217
         	//$formats[$id] = 'whazzup';
218 218
         	$globalSources[$id]['format'] = 'whazzup';
219 219
         	//$last_exec['whazzup'] = 0;
220 220
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
221
-            } else if (preg_match('/blitzortung/i',$host)) {
221
+            } else if (preg_match('/blitzortung/i', $host)) {
222 222
         	$globalSources[$id]['format'] = 'blitzortung';
223 223
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
224
-            } else if (preg_match('/airwhere/i',$host)) {
224
+            } else if (preg_match('/airwhere/i', $host)) {
225 225
         	$globalSources[$id]['format'] = 'airwhere';
226 226
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
227
-            } else if (preg_match('/recentpireps/i',$host)) {
227
+            } else if (preg_match('/recentpireps/i', $host)) {
228 228
         	//$formats[$id] = 'pirepsjson';
229 229
         	$globalSources[$id]['format'] = 'pirepsjson';
230 230
         	//$last_exec['pirepsjson'] = 0;
231 231
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
232
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
232
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
233 233
         	//$formats[$id] = 'fr24json';
234 234
         	$globalSources[$id]['format'] = 'fr24json';
235 235
         	//$last_exec['fr24json'] = 0;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
239 239
         	    exit(0);
240 240
         	}
241
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
241
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
242 242
         	//$formats[$id] = 'fr24json';
243 243
         	$globalSources[$id]['format'] = 'myshiptracking';
244 244
         	//$last_exec['fr24json'] = 0;
@@ -248,21 +248,21 @@  discard block
 block discarded – undo
248 248
         	    exit(0);
249 249
         	}
250 250
             //} else if (preg_match('/10001/',$host)) {
251
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
251
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
252 252
         	//$formats[$id] = 'tsv';
253 253
         	$globalSources[$id]['format'] = 'tsv';
254 254
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
255 255
             }
256
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
256
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
257 257
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
258
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
258
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
259 259
     		    if ($idf !== false) {
260 260
     			$httpfeeds[$id] = $idf;
261 261
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
262 262
     		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
263 263
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
264
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
265
-	    $hostport = explode(':',$host);
264
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
265
+	    $hostport = explode(':', $host);
266 266
 	    if (isset($hostport[1])) {
267 267
 		$port = $hostport[1];
268 268
 		$hostn = $hostport[0];
@@ -272,19 +272,19 @@  discard block
 block discarded – undo
272 272
 	    }
273 273
 	    $Common = new Common();
274 274
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
275
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
275
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
276 276
     	    } else {
277
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
277
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
278 278
 	    }
279 279
 	    if ($s) {
280 280
     	        $sockets[$id] = $s;
281 281
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
282
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
282
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
283 283
 			//$formats[$id] = 'aprs';
284 284
 			$globalSources[$id]['format'] = 'aprs';
285 285
 			//$aprs_connect = 0;
286 286
 			//$use_aprs = true;
287
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
287
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
288 288
 			$globalSources[$id]['format'] = 'vrstcp';
289 289
     		    } elseif ($port == '10001') {
290 290
         		//$formats[$id] = 'tsv';
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
324 324
 else $timeout = 20;
325 325
 $errno = '';
326
-$errstr='';
326
+$errstr = '';
327 327
 
328 328
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
329 329
 /* Initiate connections to all the hosts simultaneously */
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 //connect_all($globalSources);
332 332
 
333 333
 if (isset($globalProxy) && $globalProxy) {
334
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
334
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
335 335
 } else {
336 336
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
337 337
 }
@@ -361,16 +361,16 @@  discard block
 block discarded – undo
361 361
 
362 362
 if ($use_aprs) {
363 363
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
364
-	$APRS=new APRS();
364
+	$APRS = new APRS();
365 365
 	$aprs_connect = 0;
366 366
 	$aprs_keep = 120;
367 367
 	$aprs_last_tx = time();
368 368
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
369
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
369
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
370 370
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
371
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
371
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
372 372
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
373
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
373
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
374 374
 	if ($aprs_full) $aprs_filter = '';
375 375
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
376 376
 	else $aprs_pass = '-1';
@@ -384,12 +384,12 @@  discard block
 block discarded – undo
384 384
 sleep(1);
385 385
 if ($globalDebug) echo "SCAN MODE \n\n";
386 386
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
387
-$endtime = time()+$globalCronEnd;
387
+$endtime = time() + $globalCronEnd;
388 388
 $i = 1;
389 389
 $tt = array();
390 390
 // Delete all ATC
391 391
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
392
-	$ATC=new ATC($Connection->db);
392
+	$ATC = new ATC($Connection->db);
393 393
 }
394 394
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
395 395
 	$ATC->deleteAll();
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 
398 398
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
399 399
 while ($i > 0) {
400
-    if (!$globalDaemon) $i = $endtime-time();
400
+    if (!$globalDaemon) $i = $endtime - time();
401 401
     // Delete old ATC
402 402
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
403 403
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 	}
412 412
 	if ($max != $globalMinFetch) {
413 413
 	    if ($globalDebug) echo 'Sleeping...'."\n";
414
-	    sleep($globalMinFetch-$max+2);
414
+	    sleep($globalMinFetch - $max + 2);
415 415
 	}
416 416
     }
417 417
 
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
 	    //$buffer = $Common->getData($hosts[$id]);
431 431
 	    $buffer = $Common->getData($value['host']);
432 432
 	    if ($buffer != '') $reset = 0;
433
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434
-	    $buffer = explode('\n',$buffer);
433
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
434
+	    $buffer = explode('\n', $buffer);
435 435
 	    foreach ($buffer as $line) {
436 436
     		if ($line != '' && count($line) > 7) {
437 437
     		    $line = explode(',', $line);
@@ -464,11 +464,11 @@  discard block
 block discarded – undo
464 464
 	    )
465 465
 	) {
466 466
 	    date_default_timezone_set('CET');
467
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
467
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
468 468
 	    date_default_timezone_set('UTC');
469 469
 	    if ($buffer != '') $reset = 0;
470
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
471
-	    $buffer = explode('\n',$buffer);
470
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
471
+	    $buffer = explode('\n', $buffer);
472 472
 	    foreach ($buffer as $line) {
473 473
 		if ($line != '') {
474 474
 		    //echo "'".$line."'\n";
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 		    $ais_data = $AIS->parse_line(trim($line));
477 477
 		    $data = array();
478 478
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
479
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
479
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
480 480
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
481 481
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
482 482
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
489 489
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
490 490
 		    if (isset($ais_data['timestamp'])) {
491
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
491
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
492 492
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
493 493
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
494 494
 			    $add = true;
@@ -511,21 +511,21 @@  discard block
 block discarded – undo
511 511
 	    $w = $e = null;
512 512
 	    
513 513
 	    if (isset($arr[$id])) {
514
-		$nn = stream_select($arr,$w,$e,$timeout);
514
+		$nn = stream_select($arr, $w, $e, $timeout);
515 515
 		if ($nn > 0) {
516 516
 		    foreach ($httpfeeds as $feed) {
517
-			$buffer = stream_get_line($feed,2000,"\n");
517
+			$buffer = stream_get_line($feed, 2000, "\n");
518 518
 			if ($buffer === FALSE) {
519 519
 			    connect_all($globalSources);
520 520
 			}
521
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
522
-			$buffer = explode('\n',$buffer);
521
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
522
+			$buffer = explode('\n', $buffer);
523 523
 			foreach ($buffer as $line) {
524 524
 			    if ($line != '') {
525 525
 				$ais_data = $AIS->parse_line(trim($line));
526 526
 				$data = array();
527 527
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
528
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
528
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
529 529
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
530 530
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
531 531
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -537,9 +537,9 @@  discard block
 block discarded – undo
537 537
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
538 538
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
539 539
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
540
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
540
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
541 541
 				if (isset($ais_data['timestamp'])) {
542
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
542
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
543 543
 				} else {
544 544
 				    $data['datetime'] = date('Y-m-d H:i:s');
545 545
 				}
@@ -571,10 +571,10 @@  discard block
 block discarded – undo
571 571
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
572 572
 	    )
573 573
 	) {
574
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
574
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
575 575
 	    if ($buffer != '') {
576 576
 		//echo $buffer;
577
-		$all_data = json_decode($buffer,true);
577
+		$all_data = json_decode($buffer, true);
578 578
 		//print_r($all_data);
579 579
 		if (isset($all_data[0]['DATA'])) {
580 580
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 			    $data['ident'] = $line['NAME'];
584 584
 			    $data['mmsi'] = $line['MMSI'];
585 585
 			    if (strlen($data['mmsi']) > 9) {
586
-				$data['mmsi'] = substr($data['mmsi'],-9);
586
+				$data['mmsi'] = substr($data['mmsi'], -9);
587 587
 			    }
588 588
 			    $data['speed'] = $line['SOG'];
589 589
 			    $data['heading'] = $line['COG'];
@@ -593,8 +593,8 @@  discard block
 block discarded – undo
593 593
 			    //$data['type_id'] = $line['TYPE'];
594 594
 			    $data['imo'] = $line['IMO'];
595 595
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
596
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
597
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
596
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
597
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
598 598
 			    $data['format_source'] = 'myshiptracking';
599 599
 			    $data['id_source'] = $id_source;
600 600
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -611,16 +611,16 @@  discard block
 block discarded – undo
611 611
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
612 612
 	    )
613 613
 	) {
614
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
614
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
615 615
 	    if ($buffer != '') {
616
-		$all_data = json_decode($buffer,true);
616
+		$all_data = json_decode($buffer, true);
617 617
 		if (isset($all_data[0]['mmsi'])) {
618 618
 		    foreach ($all_data as $line) {
619 619
 			if ($line != '') {
620 620
 			    $data = array();
621 621
 			    $data['ident'] = $line['shipname'];
622 622
 			    $data['callsign'] = $line['callsign'];
623
-			    $data['mmsi'] = substr($line['mmsi'],-9);
623
+			    $data['mmsi'] = substr($line['mmsi'], -9);
624 624
 			    $data['speed'] = $line['sog'];
625 625
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
626 626
 			    $data['latitude'] = $line['latitude'];
@@ -647,14 +647,14 @@  discard block
 block discarded – undo
647 647
 	) {
648 648
 	    $buffer = $Common->getData($value['host']);
649 649
 	    if ($buffer != '') {
650
-		$all_data = json_decode($buffer,true);
650
+		$all_data = json_decode($buffer, true);
651 651
 		if (isset($all_data['features'][0]['id'])) {
652 652
 		    foreach ($all_data['features'] as $line) {
653 653
 			print_r($line);
654 654
 			$data = array();
655 655
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
656 656
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
657
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
657
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
658 658
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
659 659
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
660 660
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -681,31 +681,31 @@  discard block
 block discarded – undo
681 681
 	    )
682 682
 	) {
683 683
 	    echo 'download...';
684
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
684
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
685 685
 	    echo 'done !'."\n";
686 686
 	    // FIXME: Need more work
687 687
 	    if ($buffer != '') $reset = 0;
688
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
689
-	    $buffer = explode('\n',$buffer);
688
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
689
+	    $buffer = explode('\n', $buffer);
690 690
 	    foreach ($buffer as $line) {
691 691
 		if ($line != '') {
692 692
 		    $data = array();
693 693
 		    echo $line."\n";
694
-		    $data['mmsi'] = (int)substr($line,0,9);
695
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
696
-		    $data['status_id'] = substr($line,21,2);
697
-		    $data['type_id'] = substr($line,24,3);
698
-		    $data['latitude'] = substr($line,29,9);
699
-		    $data['longitude'] = substr($line,41,9);
700
-		    $data['speed'] = round(substr($line,51,5));
694
+		    $data['mmsi'] = (int) substr($line, 0, 9);
695
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
696
+		    $data['status_id'] = substr($line, 21, 2);
697
+		    $data['type_id'] = substr($line, 24, 3);
698
+		    $data['latitude'] = substr($line, 29, 9);
699
+		    $data['longitude'] = substr($line, 41, 9);
700
+		    $data['speed'] = round(substr($line, 51, 5));
701 701
 		    //$data['course'] = substr($line,57,5);
702
-		    $data['heading'] = round(substr($line,63,3));
702
+		    $data['heading'] = round(substr($line, 63, 3));
703 703
 		    //$data['draft'] = substr($line,67,4);
704 704
 		    //$data['length'] = substr($line,72,3);
705 705
 		    //$data['beam'] = substr($line,76,2);
706
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
706
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
707 707
 		    //$data['callsign'] = trim(substr($line,100,7);
708
-		    $data['arrival_code'] = substr($line,108,20);
708
+		    $data['arrival_code'] = substr($line, 108, 20);
709 709
 		    //$data['etaDate'] = substr($line,129,5);
710 710
 		    //$data['etaTime'] = substr($line,135,5);
711 711
 		    $data['format_source'] = 'shipplotter';
@@ -736,8 +736,8 @@  discard block
 block discarded – undo
736 736
 	) {
737 737
 	    //$buffer = $Common->getData($hosts[$id]);
738 738
 	    $buffer = $Common->getData($value['host']);
739
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
740
-	    $buffer = explode('\n',$buffer);
739
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
740
+	    $buffer = explode('\n', $buffer);
741 741
 	    $reset = 0;
742 742
 	    foreach ($buffer as $line) {
743 743
     		if ($line != '') {
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
749 749
 			$data['pilot_id'] = $line[1];
750 750
 			$data['pilot_name'] = $line[2];
751
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
751
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
752 752
 			$data['ident'] = $line[0]; // ident
753 753
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
754 754
 			$data['speed'] = $line[8]; // speed
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
765 765
 			//if (isset($line[37])) $data['last_update'] = $line[37];
766 766
 		        $data['departure_airport_icao'] = $line[11];
767
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
767
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
768 768
 		        $data['arrival_airport_icao'] = $line[13];
769 769
 			$data['frequency'] = $line[4];
770 770
 			$data['type'] = $line[18];
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
     			$data['id_source'] = $id_source;
774 774
 	    		//$data['arrival_airport_time'] = ;
775 775
 	    		if ($line[9] != '') {
776
-	    		    $aircraft_data = explode('/',$line[9]);
776
+	    		    $aircraft_data = explode('/', $line[9]);
777 777
 	    		    if (isset($aircraft_data[1])) {
778 778
 	    			$data['aircraft_icao'] = $aircraft_data[1];
779 779
 	    		    }
@@ -788,9 +788,9 @@  discard block
 block discarded – undo
788 788
     			if ($line[3] == 'PILOT') $SI->add($data);
789 789
 			elseif ($line[3] == 'ATC') {
790 790
 				//print_r($data);
791
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
792
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
793
-				$typec = substr($data['ident'],-3);
791
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
792
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
793
+				$typec = substr($data['ident'], -3);
794 794
 				if ($typec == 'APP') $data['type'] = 'Approach';
795 795
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
796 796
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -802,8 +802,8 @@  discard block
 block discarded – undo
802 802
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
803 803
 				if (!isset($data['source_name'])) $data['source_name'] = '';
804 804
 				if (isset($ATC)) {
805
-					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']);
806
-					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']);
805
+					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']);
806
+					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']);
807 807
 				}
808 808
 			}
809 809
     			unset($data);
@@ -819,24 +819,24 @@  discard block
 block discarded – undo
819 819
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
820 820
     	    )
821 821
     	) {
822
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
822
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
823 823
 	    if ($buffer != '') {
824 824
 		$all_data = simplexml_load_string($buffer);
825
-		foreach($all_data->children() as $childdata) {
825
+		foreach ($all_data->children() as $childdata) {
826 826
 			$data = array();
827 827
 			$line = $childdata;
828 828
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
829
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
830
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
831
-			$data['latitude'] = (float)$line['pktLatitude'];
832
-			$data['longitude'] = (float)$line['pktLongitude'];
833
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
834
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
835
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
829
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
830
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
831
+			$data['latitude'] = (float) $line['pktLatitude'];
832
+			$data['longitude'] = (float) $line['pktLongitude'];
833
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
834
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
835
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
836 836
 			$data['altitude_relative'] = 'AMSL';
837
-			$data['pilot_id'] = (int)$line['pktPilotID'];
837
+			$data['pilot_id'] = (int) $line['pktPilotID'];
838 838
 			$data['aircraft_icao'] = 'PARAGLIDER';
839
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
839
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
840 840
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
841 841
 			$data['format_source'] = $value['format'];
842 842
 			$SI->add($data);
@@ -844,22 +844,22 @@  discard block
 block discarded – undo
844 844
 		}
845 845
 	    }
846 846
 	    $Source->deleteOldLocationByType('gs');
847
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
847
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
848 848
 	    if ($buffer != '') {
849 849
 		$all_data = simplexml_load_string($buffer);
850
-		foreach($all_data->children() as $childdata) {
850
+		foreach ($all_data->children() as $childdata) {
851 851
 			$data = array();
852 852
 			$line = $childdata;
853
-			$data['id'] = (int)$line['gsID'];
854
-			$data['latitude'] = (float)$line['gsLatitude'];
855
-			$data['longitude'] = (float)$line['gsLongitude'];
856
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
853
+			$data['id'] = (int) $line['gsID'];
854
+			$data['latitude'] = (float) $line['gsLatitude'];
855
+			$data['longitude'] = (float) $line['gsLongitude'];
856
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
857 857
 			$data['altitude_relative'] = 'AMSL';
858
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
858
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
859 859
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
860
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
860
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
861 861
 			} else {
862
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
862
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
863 863
 			}
864 864
 			unset($data);
865 865
 		}
@@ -877,9 +877,9 @@  discard block
 block discarded – undo
877 877
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
878 878
 	    )
879 879
 	) {
880
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
880
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
881 881
 	    if ($buffer != '') {
882
-	        $all_data = json_decode($buffer,true);
882
+	        $all_data = json_decode($buffer, true);
883 883
 		if (isset($all_data['acList'])) {
884 884
 		    $reset = 0;
885 885
 		    foreach ($all_data['acList'] as $line) {
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
896 896
 			$data['emergency'] = ''; // emergency
897 897
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
898
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
898
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
899 899
 			else $data['datetime'] = date('Y-m-d H:i:s');
900 900
 			//$data['datetime'] = date('Y-m-d H:i:s');
901 901
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
 			$data['verticalrate'] = $line['vrt']; // verticale rate
921 921
 			$data['squawk'] = $line['squawk']; // squawk
922 922
 			$data['emergency'] = ''; // emergency
923
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
923
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
924 924
 			else $data['datetime'] = date('Y-m-d H:i:s');
925 925
 			$data['format_source'] = 'aircraftlistjson';
926 926
 			$data['id_source'] = $id_source;
@@ -941,7 +941,7 @@  discard block
 block discarded – undo
941 941
     	    )
942 942
     	) {
943 943
 	    $buffer = $Common->getData($value['host']);
944
-	    $all_data = json_decode($buffer,true);
944
+	    $all_data = json_decode($buffer, true);
945 945
 	    if (isset($all_data['planes'])) {
946 946
 		$reset = 0;
947 947
 		foreach ($all_data['planes'] as $key => $line) {
@@ -958,12 +958,12 @@  discard block
 block discarded – undo
958 958
 		    $data['emergency'] = ''; // emergency
959 959
 		    $data['registration'] = $line[2];
960 960
 		    $data['aircraft_icao'] = $line[0];
961
-		    $deparr = explode('-',$line[1]);
961
+		    $deparr = explode('-', $line[1]);
962 962
 		    if (count($deparr) == 2) {
963 963
 			$data['departure_airport_icao'] = $deparr[0];
964 964
 			$data['arrival_airport_icao'] = $deparr[1];
965 965
 		    }
966
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
966
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
967 967
 	    	    $data['format_source'] = 'planeupdatefaa';
968 968
     		    $data['id_source'] = $id_source;
969 969
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 	    )
982 982
 	) {
983 983
 	    $buffer = $Common->getData($value['host']);
984
-	    $all_data = json_decode($buffer,true);
984
+	    $all_data = json_decode($buffer, true);
985 985
 	    if (isset($all_data['states'])) {
986 986
 		$reset = 0;
987 987
 		foreach ($all_data['states'] as $key => $line) {
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
 		    //$data['emergency'] = ''; // emergency
999 999
 		    //$data['registration'] = $line[2];
1000 1000
 		    //$data['aircraft_icao'] = $line[0];
1001
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1001
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1002 1002
 		    $data['format_source'] = 'opensky';
1003 1003
 		    $data['id_source'] = $id_source;
1004 1004
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
 	) {
1018 1018
 	    //$buffer = $Common->getData($hosts[$id]);
1019 1019
 	    $buffer = $Common->getData($value['host']);
1020
-	    $all_data = json_decode($buffer,true);
1020
+	    $all_data = json_decode($buffer, true);
1021 1021
 	    if (!empty($all_data)) $reset = 0;
1022 1022
 	    foreach ($all_data as $key => $line) {
1023 1023
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1055,11 +1055,11 @@  discard block
 block discarded – undo
1055 1055
 	    )
1056 1056
 	) {
1057 1057
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1058
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1058
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1059 1059
 	    //echo $buffer;
1060
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1061
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1062
-	    $all_data = json_decode($buffer,true);
1060
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1061
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1062
+	    $all_data = json_decode($buffer, true);
1063 1063
 	    if (json_last_error() != JSON_ERROR_NONE) {
1064 1064
 		die(json_last_error_msg());
1065 1065
 	    }
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
 			//$data['departure_airport_iata'] = $line[11];
1083 1083
 			//$data['arrival_airport_iata'] = $line[12];
1084 1084
 	    		//$data['emergency'] = ''; // emergency
1085
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1085
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1086 1086
 	    		$data['format_source'] = 'radarvirtueljson';
1087 1087
     			$data['id_source'] = $id_source;
1088 1088
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1103,14 +1103,14 @@  discard block
 block discarded – undo
1103 1103
 	) {
1104 1104
 	    //$buffer = $Common->getData($hosts[$id]);
1105 1105
 	    $buffer = $Common->getData($value['host'].'?'.time());
1106
-	    $all_data = json_decode(utf8_encode($buffer),true);
1106
+	    $all_data = json_decode(utf8_encode($buffer), true);
1107 1107
 	    
1108 1108
 	    if (isset($all_data['pireps'])) {
1109 1109
 		$reset = 0;
1110 1110
 	        foreach ($all_data['pireps'] as $line) {
1111 1111
 		    $data = array();
1112 1112
 		    $data['id'] = $line['id'];
1113
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1113
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1114 1114
 		    $data['ident'] = $line['callsign']; // ident
1115 1115
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1116 1116
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1140,9 +1140,9 @@  discard block
 block discarded – undo
1140 1140
 			$SI->add($data);
1141 1141
 		    //    print_r($data);
1142 1142
     		    } elseif ($line['icon'] == 'ct') {
1143
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1144
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1145
-			$typec = substr($data['ident'],-3);
1143
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1144
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1145
+			$typec = substr($data['ident'], -3);
1146 1146
 			$data['type'] = '';
1147 1147
 			if ($typec == 'APP') $data['type'] = 'Approach';
1148 1148
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1154 1154
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1155 1155
 			else $data['type'] = 'Observer';
1156
-			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']);
1156
+			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']);
1157 1157
 		    }
1158 1158
 		    unset($data);
1159 1159
 		}
@@ -1170,14 +1170,14 @@  discard block
 block discarded – undo
1170 1170
 	    //$buffer = $Common->getData($hosts[$id]);
1171 1171
 	    if ($globalDebug) echo 'Get Data...'."\n";
1172 1172
 	    $buffer = $Common->getData($value['host']);
1173
-	    $all_data = json_decode($buffer,true);
1173
+	    $all_data = json_decode($buffer, true);
1174 1174
 	    if ($buffer != '' && is_array($all_data)) {
1175 1175
 		$reset = 0;
1176 1176
 		foreach ($all_data as $line) {
1177 1177
 	    	    $data = array();
1178 1178
 	    	    //$data['id'] = $line['id']; // id not usable
1179 1179
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1180
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1180
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1181 1181
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1182 1182
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1183 1183
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1192,7 +1192,7 @@  discard block
 block discarded – undo
1192 1192
 	    	    //$data['datetime'] = $line['lastupdate'];
1193 1193
 	    	    //$data['last_update'] = $line['lastupdate'];
1194 1194
 	    	    if (isset($value['timezone'])) {
1195
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1195
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1196 1196
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1197 1197
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1198 1198
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1208,14 +1208,14 @@  discard block
 block discarded – undo
1208 1208
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1209 1209
 		    if (isset($line['aircraftname'])) {
1210 1210
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1211
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1212
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1211
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1212
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1213 1213
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1214 1214
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1215 1215
 	    		else {
1216
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1217
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1218
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1216
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1217
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1218
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1219 1219
 	    		}
1220 1220
 	    	    }
1221 1221
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
 	    //$buffer = $Common->getData($hosts[$id]);
1241 1241
 	    if ($globalDebug) echo 'Get Data...'."\n";
1242 1242
 	    $buffer = $Common->getData($value['host']);
1243
-	    $all_data = json_decode($buffer,true);
1243
+	    $all_data = json_decode($buffer, true);
1244 1244
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1245 1245
 		$reset = 0;
1246 1246
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1252 1252
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1253 1253
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1254
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1254
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1255 1255
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1256 1256
 	    	    $data['altitude'] = $line['altitude']; // altitude
1257 1257
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
 	    	    //$data['squawk'] = ''; // squawk
1263 1263
 	    	    //$data['emergency'] = ''; // emergency
1264 1264
 	    	    if (isset($value['timezone'])) {
1265
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1265
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1266 1266
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1267 1267
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1268 1268
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1298,14 +1298,14 @@  discard block
 block discarded – undo
1298 1298
 	    //$buffer = $Common->getData($hosts[$id]);
1299 1299
 	    if ($globalDebug) echo 'Get Data...'."\n";
1300 1300
 	    $buffer = $Common->getData($value['host']);
1301
-	    $all_data = json_decode($buffer,true);
1301
+	    $all_data = json_decode($buffer, true);
1302 1302
 	    if ($buffer != '' && is_array($all_data)) {
1303 1303
 		$reset = 0;
1304 1304
 		foreach ($all_data as $line) {
1305 1305
 	    	    $data = array();
1306 1306
 	    	    //$data['id'] = $line['id']; // id not usable
1307 1307
 	    	    $data['id'] = trim($line['flight_id']);
1308
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1308
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1309 1309
 	    	    $data['pilot_name'] = $line['pilot_name'];
1310 1310
 	    	    $data['pilot_id'] = $line['pilot_id'];
1311 1311
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1349,24 +1349,24 @@  discard block
 block discarded – undo
1349 1349
 	    //$buffer = $Common->getData($hosts[$id]);
1350 1350
 	    if ($globalDebug) echo 'Get Data...'."\n";
1351 1351
 	    $buffer = $Common->getData($value['host']);
1352
-	    $all_data = json_decode($buffer,true);
1352
+	    $all_data = json_decode($buffer, true);
1353 1353
 	    if ($buffer != '') {
1354 1354
 		$Source->deleteLocationBySource('blitzortung');
1355
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1356
-		$buffer = explode('\n',$buffer);
1355
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1356
+		$buffer = explode('\n', $buffer);
1357 1357
 		foreach ($buffer as $buffer_line) {
1358
-		    $line = json_decode($buffer_line,true);
1358
+		    $line = json_decode($buffer_line, true);
1359 1359
 		    if (isset($line['time'])) {
1360 1360
 			$data = array();
1361 1361
 			$data['altitude'] = $line['alt']; // altitude
1362 1362
 			$data['latitude'] = $line['lat']; // lat
1363 1363
 			$data['longitude'] = $line['lon']; // long
1364
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1364
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1365 1365
 			$data['id_source'] = $id_source;
1366 1366
 			$data['format_source'] = 'blitzortung';
1367 1367
 			$SI->add($data);
1368 1368
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1369
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1369
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1370 1370
 			unset($data);
1371 1371
 		    }
1372 1372
 		}
@@ -1391,11 +1391,11 @@  discard block
 block discarded – undo
1391 1391
 		    //$value = $formats[$nb];
1392 1392
 		    $format = $globalSources[$nb]['format'];
1393 1393
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1394
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1394
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1395 1395
 		    } elseif ($format == 'vrstcp') {
1396 1396
 			$buffer = @socket_read($r, 6000);
1397 1397
 		    } else {
1398
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1398
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1399 1399
 		    }
1400 1400
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1401 1401
 		    //echo $buffer."\n";
@@ -1405,8 +1405,8 @@  discard block
 block discarded – undo
1405 1405
 		    //$SI::del();
1406 1406
 		    if ($buffer !== FALSE) {
1407 1407
 			if ($format == 'vrstcp') {
1408
-			    $buffer = explode('},{',$buffer);
1409
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1408
+			    $buffer = explode('},{', $buffer);
1409
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1410 1410
 		    }
1411 1411
 		    // SBS format is CSV format
1412 1412
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1430,7 +1430,7 @@  discard block
 block discarded – undo
1430 1430
 			    $ais_data = $AIS->parse_line(trim($buffer));
1431 1431
 			    $data = array();
1432 1432
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1433
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1433
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1434 1434
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1435 1435
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1436 1436
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1441,13 +1441,13 @@  discard block
 block discarded – undo
1441 1441
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1442 1442
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1443 1443
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1444
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1444
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1445 1445
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1446 1446
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1447 1447
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1448 1448
 
1449 1449
 			    if (isset($ais_data['timestamp'])) {
1450
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1450
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1451 1451
 			    } else {
1452 1452
 				$data['datetime'] = date('Y-m-d H:i:s');
1453 1453
 			    }
@@ -1458,10 +1458,10 @@  discard block
 block discarded – undo
1458 1458
                         } elseif ($format == 'flightgearsp') {
1459 1459
                     	    //echo $buffer."\n";
1460 1460
                     	    if (strlen($buffer) > 5) {
1461
-				$line = explode(',',$buffer);
1461
+				$line = explode(',', $buffer);
1462 1462
 				$data = array();
1463 1463
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1464
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1464
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1465 1465
 				$data['ident'] = $line[6];
1466 1466
 				$data['aircraft_name'] = $line[7];
1467 1467
 				$data['longitude'] = $line[1];
@@ -1478,16 +1478,16 @@  discard block
 block discarded – undo
1478 1478
                         } elseif ($format == 'acars') {
1479 1479
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1480 1480
 			    $ACARS->add(trim($buffer));
1481
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1481
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1482 1482
 			    $ACARS->deleteLiveAcarsData();
1483 1483
 			} elseif ($format == 'flightgearmp') {
1484
-			    if (substr($buffer,0,1) != '#') {
1484
+			    if (substr($buffer, 0, 1) != '#') {
1485 1485
 				$data = array();
1486 1486
 				//echo $buffer."\n";
1487
-				$line = explode(' ',$buffer);
1487
+				$line = explode(' ', $buffer);
1488 1488
 				if (count($line) == 11) {
1489
-				    $userserver = explode('@',$line[0]);
1490
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1489
+				    $userserver = explode('@', $line[0]);
1490
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1491 1491
 				    $data['ident'] = $userserver[0];
1492 1492
 				    $data['registration'] = $userserver[0];
1493 1493
 				    $data['latitude'] = $line[4];
@@ -1495,8 +1495,8 @@  discard block
 block discarded – undo
1495 1495
 				    $data['altitude'] = $line[6];
1496 1496
 				    $data['datetime'] = date('Y-m-d H:i:s');
1497 1497
 				    $aircraft_type = $line[10];
1498
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1499
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1498
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1499
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1500 1500
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1501 1501
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1502 1502
 				}
@@ -1505,8 +1505,8 @@  discard block
 block discarded – undo
1505 1505
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1506 1506
 			    die;
1507 1507
 			} elseif ($format == 'vrstcp') {
1508
-			    foreach($buffer as $all_data) {
1509
-				$line = json_decode('{'.$all_data.'}',true);
1508
+			    foreach ($buffer as $all_data) {
1509
+				$line = json_decode('{'.$all_data.'}', true);
1510 1510
 				$data = array();
1511 1511
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1512 1512
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1532,16 +1532,16 @@  discard block
 block discarded – undo
1532 1532
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1533 1533
 				unset($data);
1534 1534
 			    }
1535
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1535
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1536 1536
 			    $line = explode("\t", $buffer);
1537
-			    for($k = 0; $k < count($line); $k=$k+2) {
1537
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1538 1538
 				$key = $line[$k];
1539
-			        $lined[$key] = $line[$k+1];
1539
+			        $lined[$key] = $line[$k + 1];
1540 1540
 			    }
1541 1541
     			    if (count($lined) > 3) {
1542 1542
     				$data['hex'] = $lined['hexid'];
1543 1543
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1544
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1544
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1545 1545
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1546 1546
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1547 1547
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1560,23 +1560,23 @@  discard block
 block discarded – undo
1560 1560
     			    } else $error = true;
1561 1561
 			} elseif ($format == 'aprs' && $use_aprs) {
1562 1562
 			    if ($aprs_connect == 0) {
1563
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1563
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1564 1564
 				$aprs_connect = 1;
1565 1565
 			    }
1566 1566
 			    
1567
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1567
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1568 1568
 				$aprs_last_tx = time();
1569 1569
 				$data_aprs = "# Keep alive";
1570
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1570
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1571 1571
 			    }
1572 1572
 			    
1573 1573
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1574 1574
 			    //echo 'APRS data : '.$buffer."\n";
1575
-			    $buffer = str_replace('APRS <- ','',$buffer);
1576
-			    $buffer = str_replace('APRS -> ','',$buffer);
1575
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1576
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1577 1577
 			    //echo $buffer."\n";
1578 1578
 			    date_default_timezone_set('UTC');
1579
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1579
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1580 1580
 				$line = $APRS->parse($buffer);
1581 1581
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1582 1582
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1592 1592
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1593 1593
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1594
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1594
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1595 1595
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1596 1596
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1597 1597
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1674,29 +1674,29 @@  discard block
 block discarded – undo
1674 1674
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1675 1675
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1676 1676
 					$Source->deleteOldLocationByType('gs');
1677
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1678
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1677
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1678
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1679 1679
 					} else {
1680
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1680
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1681 1681
 					}
1682 1682
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1683 1683
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1684 1684
 					if ($globalDebug) echo '# Weather Station added'."\n";
1685 1685
 					$Source->deleteOldLocationByType('wx');
1686 1686
 					$weather_data = json_encode($line);
1687
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1688
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1687
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1688
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1689 1689
 					} else {
1690
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1690
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1691 1691
 					}
1692 1692
 				    } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1693 1693
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1694 1694
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1695 1695
 					$Source->deleteOldLocationByType('lightning');
1696
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1697
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1696
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1697
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1698 1698
 					} else {
1699
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1699
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1700 1700
 					}
1701 1701
 				    } elseif ($globalDebug) {
1702 1702
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
 				    unset($data);
1706 1706
 				}
1707 1707
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1708
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1708
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1709 1709
 				}
1710 1710
 				/*
1711 1711
 				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')) {
@@ -1714,7 +1714,7 @@  discard block
 block discarded – undo
1714 1714
 				*/
1715 1715
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1716 1716
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1717
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1717
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1718 1718
 					$Source->deleteOldLocationByType('lightning');
1719 1719
 					$Source->deleteOldLocationByType('wx');
1720 1720
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1799,7 +1799,7 @@  discard block
 block discarded – undo
1799 1799
 				connect_all($sourceee);
1800 1800
 				$sourceee = array();
1801 1801
 				//connect_all($globalSources);
1802
-				$tt[$format]=0;
1802
+				$tt[$format] = 0;
1803 1803
 				break;
1804 1804
 			    } 
1805 1805
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -1809,14 +1809,14 @@  discard block
 block discarded – undo
1809 1809
 	    } else {
1810 1810
 		$error = socket_strerror(socket_last_error());
1811 1811
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1812
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1812
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1813 1813
 			if (isset($globalDebug)) echo "Restarting...\n";
1814 1814
 			// Restart the script if possible
1815 1815
 			if (is_array($sockets)) {
1816 1816
 			    if ($globalDebug) echo "Shutdown all sockets...";
1817 1817
 			    
1818 1818
 			    foreach ($sockets as $sock) {
1819
-				@socket_shutdown($sock,2);
1819
+				@socket_shutdown($sock, 2);
1820 1820
 				@socket_close($sock);
1821 1821
 			    }
1822 1822
 			    
Please login to merge, or discard this patch.