Completed
Push — master ( c50638...8c94fe )
by Yannick
35:08
created
scripts/daemon-spotter.php 1 patch
Spacing   +183 added lines, -183 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,15 +124,15 @@  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();
128
-$ACARS=new ACARS($Connection->db,true);
129
-$Source=new Source($Connection->db);
130
-$Common=new Common();
127
+$SBS = new SBS();
128
+$ACARS = new ACARS($Connection->db, true);
129
+$Source = new Source($Connection->db);
130
+$Common = new Common();
131 131
 date_default_timezone_set('UTC');
132 132
 //$servertz = system('date +%Z');
133 133
 // signal handler - playing nice with sockets and dump1090
134 134
 if (function_exists('pcntl_fork')) {
135
-    pcntl_signal(SIGINT,  function() {
135
+    pcntl_signal(SIGINT, function() {
136 136
         global $sockets;
137 137
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
138 138
         die("Bye!\n");
@@ -148,30 +148,30 @@  discard block
 block discarded – undo
148 148
 
149 149
 function connect_all($hosts) {
150 150
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
151
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
151
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
152 152
     $reset++;
153 153
     if ($globalDebug) echo 'Connect to all...'."\n";
154 154
     foreach ($hosts as $id => $value) {
155 155
 	$host = $value['host'];
156 156
 	$globalSources[$id]['last_exec'] = 0;
157 157
 	// Here we check type of source(s)
158
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
159
-            if (preg_match('/deltadb.txt$/i',$host)) {
158
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
159
+            if (preg_match('/deltadb.txt$/i', $host)) {
160 160
         	//$formats[$id] = 'deltadbtxt';
161 161
         	$globalSources[$id]['format'] = 'deltadbtxt';
162 162
         	//$last_exec['deltadbtxt'] = 0;
163 163
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
164
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
164
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
165 165
         	//$formats[$id] = 'vatsimtxt';
166 166
         	$globalSources[$id]['format'] = 'vatsimtxt';
167 167
         	//$last_exec['vatsimtxt'] = 0;
168 168
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
169
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
169
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
170 170
         	//$formats[$id] = 'aircraftlistjson';
171 171
         	$globalSources[$id]['format'] = 'aircraftlistjson';
172 172
         	//$last_exec['aircraftlistjson'] = 0;
173 173
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
174
-    	    } else if (preg_match('/opensky/i',$host)) {
174
+    	    } else if (preg_match('/opensky/i', $host)) {
175 175
         	//$formats[$id] = 'aircraftlistjson';
176 176
         	$globalSources[$id]['format'] = 'opensky';
177 177
         	//$last_exec['aircraftlistjson'] = 0;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         	    exit(0);
189 189
         	}
190 190
     	    */
191
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
191
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
192 192
         	//$formats[$id] = 'planeupdatefaa';
193 193
         	$globalSources[$id]['format'] = 'planeupdatefaa';
194 194
         	//$last_exec['planeupdatefaa'] = 0;
@@ -197,32 +197,32 @@  discard block
 block discarded – undo
197 197
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
198 198
         	    exit(0);
199 199
         	}
200
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
200
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
201 201
         	//$formats[$id] = 'phpvmacars';
202 202
         	$globalSources[$id]['format'] = 'phpvmacars';
203 203
         	//$last_exec['phpvmacars'] = 0;
204 204
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
205
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
205
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
206 206
         	//$formats[$id] = 'phpvmacars';
207 207
         	$globalSources[$id]['format'] = 'vam';
208 208
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
209
-            } else if (preg_match('/whazzup/i',$host)) {
209
+            } else if (preg_match('/whazzup/i', $host)) {
210 210
         	//$formats[$id] = 'whazzup';
211 211
         	$globalSources[$id]['format'] = 'whazzup';
212 212
         	//$last_exec['whazzup'] = 0;
213 213
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
214
-            } else if (preg_match('/blitzortung/i',$host)) {
214
+            } else if (preg_match('/blitzortung/i', $host)) {
215 215
         	$globalSources[$id]['format'] = 'blitzortung';
216 216
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
217
-            } else if (preg_match('/airwhere/i',$host)) {
217
+            } else if (preg_match('/airwhere/i', $host)) {
218 218
         	$globalSources[$id]['format'] = 'airwhere';
219 219
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
220
-            } else if (preg_match('/recentpireps/i',$host)) {
220
+            } else if (preg_match('/recentpireps/i', $host)) {
221 221
         	//$formats[$id] = 'pirepsjson';
222 222
         	$globalSources[$id]['format'] = 'pirepsjson';
223 223
         	//$last_exec['pirepsjson'] = 0;
224 224
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
225
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
225
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
226 226
         	//$formats[$id] = 'fr24json';
227 227
         	$globalSources[$id]['format'] = 'fr24json';
228 228
         	//$last_exec['fr24json'] = 0;
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
232 232
         	    exit(0);
233 233
         	}
234
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
234
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
235 235
         	//$formats[$id] = 'fr24json';
236 236
         	$globalSources[$id]['format'] = 'myshiptracking';
237 237
         	//$last_exec['fr24json'] = 0;
@@ -241,22 +241,22 @@  discard block
 block discarded – undo
241 241
         	    exit(0);
242 242
         	}
243 243
             //} else if (preg_match('/10001/',$host)) {
244
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
244
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
245 245
         	//$formats[$id] = 'tsv';
246 246
         	$globalSources[$id]['format'] = 'tsv';
247 247
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
248 248
             }
249
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
249
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
250 250
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
251
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
251
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
252 252
     		    if ($idf !== false) {
253 253
     			$httpfeeds[$id] = $idf;
254 254
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
255 255
     		    }
256 256
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
257 257
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
258
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
259
-	    $hostport = explode(':',$host);
258
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
259
+	    $hostport = explode(':', $host);
260 260
 	    if (isset($hostport[1])) {
261 261
 		$port = $hostport[1];
262 262
 		$hostn = $hostport[0];
@@ -266,19 +266,19 @@  discard block
 block discarded – undo
266 266
 	    }
267 267
 	    $Common = new Common();
268 268
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
269
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
269
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
270 270
     	    } else {
271
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
271
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
272 272
 	    }
273 273
 	    if ($s) {
274 274
     	        $sockets[$id] = $s;
275 275
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
276
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
276
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
277 277
 			//$formats[$id] = 'aprs';
278 278
 			$globalSources[$id]['format'] = 'aprs';
279 279
 			//$aprs_connect = 0;
280 280
 			//$use_aprs = true;
281
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
281
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
282 282
 			$globalSources[$id]['format'] = 'vrstcp';
283 283
     		    } elseif ($port == '10001') {
284 284
         		//$formats[$id] = 'tsv';
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
318 318
 else $timeout = 20;
319 319
 $errno = '';
320
-$errstr='';
320
+$errstr = '';
321 321
 
322 322
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
323 323
 /* Initiate connections to all the hosts simultaneously */
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 //connect_all($globalSources);
326 326
 
327 327
 if (isset($globalProxy) && $globalProxy) {
328
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
328
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
329 329
 } else {
330 330
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
331 331
 }
@@ -355,16 +355,16 @@  discard block
 block discarded – undo
355 355
 
356 356
 if ($use_aprs) {
357 357
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
358
-	$APRS=new APRS();
358
+	$APRS = new APRS();
359 359
 	$aprs_connect = 0;
360 360
 	$aprs_keep = 120;
361 361
 	$aprs_last_tx = time();
362 362
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
363
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
363
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
364 364
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
365
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
365
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
366 366
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
367
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
367
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
368 368
 	if ($aprs_full) $aprs_filter = '';
369 369
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
370 370
 	else $aprs_pass = '-1';
@@ -378,12 +378,12 @@  discard block
 block discarded – undo
378 378
 sleep(1);
379 379
 if ($globalDebug) echo "SCAN MODE \n\n";
380 380
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
381
-$endtime = time()+$globalCronEnd;
381
+$endtime = time() + $globalCronEnd;
382 382
 $i = 1;
383 383
 $tt = array();
384 384
 // Delete all ATC
385 385
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
386
-	$ATC=new ATC($Connection->db);
386
+	$ATC = new ATC($Connection->db);
387 387
 }
388 388
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
389 389
 	$ATC->deleteAll();
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 
392 392
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
393 393
 while ($i > 0) {
394
-    if (!$globalDaemon) $i = $endtime-time();
394
+    if (!$globalDaemon) $i = $endtime - time();
395 395
     // Delete old ATC
396 396
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
397 397
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	}
406 406
 	if ($max != $globalMinFetch) {
407 407
 	    if ($globalDebug) echo 'Sleeping...'."\n";
408
-	    sleep($globalMinFetch-$max+2);
408
+	    sleep($globalMinFetch - $max + 2);
409 409
 	}
410 410
     }
411 411
 
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
 	    //$buffer = $Common->getData($hosts[$id]);
425 425
 	    $buffer = $Common->getData($value['host']);
426 426
 	    if ($buffer != '') $reset = 0;
427
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
428
-	    $buffer = explode('\n',$buffer);
427
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
428
+	    $buffer = explode('\n', $buffer);
429 429
 	    foreach ($buffer as $line) {
430 430
     		if ($line != '' && count($line) > 7) {
431 431
     		    $line = explode(',', $line);
@@ -458,11 +458,11 @@  discard block
 block discarded – undo
458 458
 	    )
459 459
 	) {
460 460
 	    date_default_timezone_set('CET');
461
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
461
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
462 462
 	    date_default_timezone_set('UTC');
463 463
 	    if ($buffer != '') $reset = 0;
464
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
465
-	    $buffer = explode('\n',$buffer);
464
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
465
+	    $buffer = explode('\n', $buffer);
466 466
 	    foreach ($buffer as $line) {
467 467
 		if ($line != '') {
468 468
 		    //echo "'".$line."'\n";
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
481 481
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
482 482
 		    if (isset($ais_data['timestamp'])) {
483
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
483
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
484 484
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
485 485
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
486 486
 			    $add = true;
@@ -503,12 +503,12 @@  discard block
 block discarded – undo
503 503
 	    $w = $e = null;
504 504
 	    
505 505
 	    if (isset($arr[$id])) {
506
-		$nn = stream_select($arr,$w,$e,$timeout);
506
+		$nn = stream_select($arr, $w, $e, $timeout);
507 507
 		if ($nn > 0) {
508 508
 		    foreach ($httpfeeds as $feed) {
509
-			$buffer = stream_get_line($feed,2000,"\n");
510
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
511
-			$buffer = explode('\n',$buffer);
509
+			$buffer = stream_get_line($feed, 2000, "\n");
510
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
511
+			$buffer = explode('\n', $buffer);
512 512
 			foreach ($buffer as $line) {
513 513
 			    if ($line != '') {
514 514
 				$ais_data = $AIS->parse_line(trim($line));
@@ -526,9 +526,9 @@  discard block
 block discarded – undo
526 526
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
527 527
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
528 528
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
529
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
529
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
530 530
 				if (isset($ais_data['timestamp'])) {
531
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
531
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
532 532
 				} else {
533 533
 				    $data['datetime'] = date('Y-m-d H:i:s');
534 534
 				}
@@ -559,10 +559,10 @@  discard block
 block discarded – undo
559 559
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
560 560
 	    )
561 561
 	) {
562
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
562
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
563 563
 	    if ($buffer != '') {
564 564
 		//echo $buffer;
565
-		$all_data = json_decode($buffer,true);
565
+		$all_data = json_decode($buffer, true);
566 566
 		//print_r($all_data);
567 567
 		if (isset($all_data[0]['DATA'])) {
568 568
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 			    $data['ident'] = $line['NAME'];
572 572
 			    $data['mmsi'] = $line['MMSI'];
573 573
 			    if (strlen($data['mmsi']) > 9) {
574
-				$data['mmsi'] = substr($data['mmsi'],-9);
574
+				$data['mmsi'] = substr($data['mmsi'], -9);
575 575
 			    }
576 576
 			    $data['speed'] = $line['SOG'];
577 577
 			    $data['heading'] = $line['COG'];
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
581 581
 			    $data['imo'] = $line['IMO'];
582 582
 			    //$data['arrival_code'] = $ais_data['destination'];
583
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
583
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
584 584
 			    $data['format_source'] = 'myshiptracking';
585 585
 			    $data['id_source'] = $id_source;
586 586
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -597,9 +597,9 @@  discard block
 block discarded – undo
597 597
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
598 598
 	    )
599 599
 	) {
600
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
600
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
601 601
 	    if ($buffer != '') {
602
-		$all_data = json_decode($buffer,true);
602
+		$all_data = json_decode($buffer, true);
603 603
 		if (isset($all_data[0]['mmsi'])) {
604 604
 		    foreach ($all_data as $line) {
605 605
 			if ($line != '') {
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 	) {
634 634
 	    $buffer = $Common->getData($value['host']);
635 635
 	    if ($buffer != '') {
636
-		$all_data = json_decode($buffer,true);
636
+		$all_data = json_decode($buffer, true);
637 637
 		if (isset($all_data['features'][0]['id'])) {
638 638
 		    foreach ($all_data['features'] as $line) {
639 639
 			$data = array();
@@ -666,27 +666,27 @@  discard block
 block discarded – undo
666 666
 	    )
667 667
 	) {
668 668
 	    echo 'download...';
669
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
669
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
670 670
 	    echo 'done !'."\n";
671 671
 	    if ($buffer != '') $reset = 0;
672
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
673
-	    $buffer = explode('\n',$buffer);
672
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
673
+	    $buffer = explode('\n', $buffer);
674 674
 	    foreach ($buffer as $line) {
675 675
 		if ($line != '') {
676 676
 		    $data = array();
677
-		    $data['mmsi'] = (int)substr($line,0,9);
678
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
677
+		    $data['mmsi'] = (int) substr($line, 0, 9);
678
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
679 679
 		    //$data['status'] = substr($line,21,2);
680 680
 		    //$data['type'] = substr($line,24,3);
681
-		    $data['latitude'] = substr($line,29,9);
682
-		    $data['longitude'] = substr($line,41,9);
683
-		    $data['speed'] = round(substr($line,51,5));
681
+		    $data['latitude'] = substr($line, 29, 9);
682
+		    $data['longitude'] = substr($line, 41, 9);
683
+		    $data['speed'] = round(substr($line, 51, 5));
684 684
 		    //$data['course'] = substr($line,57,5);
685
-		    $data['heading'] = round(substr($line,63,3));
685
+		    $data['heading'] = round(substr($line, 63, 3));
686 686
 		    //$data['draft'] = substr($line,67,4);
687 687
 		    //$data['length'] = substr($line,72,3);
688 688
 		    //$data['beam'] = substr($line,76,2);
689
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
689
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
690 690
 		    //$data['callsign'] = trim(substr($line,100,7);
691 691
 		    //$data['dest'] = substr($line,108,20);
692 692
 		    //$data['etaDate'] = substr($line,129,5);
@@ -719,8 +719,8 @@  discard block
 block discarded – undo
719 719
 	) {
720 720
 	    //$buffer = $Common->getData($hosts[$id]);
721 721
 	    $buffer = $Common->getData($value['host']);
722
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
723
-	    $buffer = explode('\n',$buffer);
722
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
723
+	    $buffer = explode('\n', $buffer);
724 724
 	    $reset = 0;
725 725
 	    foreach ($buffer as $line) {
726 726
     		if ($line != '') {
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
732 732
 			$data['pilot_id'] = $line[1];
733 733
 			$data['pilot_name'] = $line[2];
734
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
734
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
735 735
 			$data['ident'] = $line[0]; // ident
736 736
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
737 737
 			$data['speed'] = $line[8]; // speed
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
748 748
 			//if (isset($line[37])) $data['last_update'] = $line[37];
749 749
 		        $data['departure_airport_icao'] = $line[11];
750
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
750
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
751 751
 		        $data['arrival_airport_icao'] = $line[13];
752 752
 			$data['frequency'] = $line[4];
753 753
 			$data['type'] = $line[18];
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
     			$data['id_source'] = $id_source;
757 757
 	    		//$data['arrival_airport_time'] = ;
758 758
 	    		if ($line[9] != '') {
759
-	    		    $aircraft_data = explode('/',$line[9]);
759
+	    		    $aircraft_data = explode('/', $line[9]);
760 760
 	    		    if (isset($aircraft_data[1])) {
761 761
 	    			$data['aircraft_icao'] = $aircraft_data[1];
762 762
 	    		    }
@@ -771,9 +771,9 @@  discard block
 block discarded – undo
771 771
     			if ($line[3] == 'PILOT') $SI->add($data);
772 772
 			elseif ($line[3] == 'ATC') {
773 773
 				//print_r($data);
774
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
775
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
776
-				$typec = substr($data['ident'],-3);
774
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
775
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
776
+				$typec = substr($data['ident'], -3);
777 777
 				if ($typec == 'APP') $data['type'] = 'Approach';
778 778
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
779 779
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -785,8 +785,8 @@  discard block
 block discarded – undo
785 785
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
786 786
 				if (!isset($data['source_name'])) $data['source_name'] = '';
787 787
 				if (isset($ATC)) {
788
-					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']);
789
-					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']);
788
+					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']);
789
+					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']);
790 790
 				}
791 791
 			}
792 792
     			unset($data);
@@ -802,24 +802,24 @@  discard block
 block discarded – undo
802 802
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
803 803
     	    )
804 804
     	) {
805
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
805
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
806 806
 	    if ($buffer != '') {
807 807
 		$all_data = simplexml_load_string($buffer);
808
-		foreach($all_data->children() as $childdata) {
808
+		foreach ($all_data->children() as $childdata) {
809 809
 			$data = array();
810 810
 			$line = $childdata;
811 811
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
812
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
813
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
814
-			$data['latitude'] = (float)$line['pktLatitude'];
815
-			$data['longitude'] = (float)$line['pktLongitude'];
816
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
817
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
818
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
812
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
813
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
814
+			$data['latitude'] = (float) $line['pktLatitude'];
815
+			$data['longitude'] = (float) $line['pktLongitude'];
816
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
817
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
818
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
819 819
 			$data['altitude_relative'] = 'AMSL';
820
-			$data['pilot_id'] = (int)$line['pktPilotID'];
820
+			$data['pilot_id'] = (int) $line['pktPilotID'];
821 821
 			$data['aircraft_icao'] = 'PARAGLIDER';
822
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
822
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
823 823
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
824 824
 			$data['format_source'] = $value['format'];
825 825
 			$SI->add($data);
@@ -827,22 +827,22 @@  discard block
 block discarded – undo
827 827
 		}
828 828
 	    }
829 829
 	    $Source->deleteOldLocationByType('gs');
830
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
830
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
831 831
 	    if ($buffer != '') {
832 832
 		$all_data = simplexml_load_string($buffer);
833
-		foreach($all_data->children() as $childdata) {
833
+		foreach ($all_data->children() as $childdata) {
834 834
 			$data = array();
835 835
 			$line = $childdata;
836
-			$data['id'] = (int)$line['gsID'];
837
-			$data['latitude'] = (float)$line['gsLatitude'];
838
-			$data['longitude'] = (float)$line['gsLongitude'];
839
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
836
+			$data['id'] = (int) $line['gsID'];
837
+			$data['latitude'] = (float) $line['gsLatitude'];
838
+			$data['longitude'] = (float) $line['gsLongitude'];
839
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
840 840
 			$data['altitude_relative'] = 'AMSL';
841
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
841
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
842 842
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
843
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
843
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
844 844
 			} else {
845
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
845
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
846 846
 			}
847 847
 			unset($data);
848 848
 		}
@@ -860,9 +860,9 @@  discard block
 block discarded – undo
860 860
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
861 861
 	    )
862 862
 	) {
863
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
863
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
864 864
 	    if ($buffer != '') {
865
-	        $all_data = json_decode($buffer,true);
865
+	        $all_data = json_decode($buffer, true);
866 866
 		if (isset($all_data['acList'])) {
867 867
 		    $reset = 0;
868 868
 		    foreach ($all_data['acList'] as $line) {
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
879 879
 			$data['emergency'] = ''; // emergency
880 880
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
881
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
881
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
882 882
 			else $data['datetime'] = date('Y-m-d H:i:s');
883 883
 			//$data['datetime'] = date('Y-m-d H:i:s');
884 884
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
 			$data['verticalrate'] = $line['vrt']; // verticale rate
904 904
 			$data['squawk'] = $line['squawk']; // squawk
905 905
 			$data['emergency'] = ''; // emergency
906
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
906
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
907 907
 			else $data['datetime'] = date('Y-m-d H:i:s');
908 908
 			$data['format_source'] = 'aircraftlistjson';
909 909
 			$data['id_source'] = $id_source;
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
     	    )
925 925
     	) {
926 926
 	    $buffer = $Common->getData($value['host']);
927
-	    $all_data = json_decode($buffer,true);
927
+	    $all_data = json_decode($buffer, true);
928 928
 	    if (isset($all_data['planes'])) {
929 929
 		$reset = 0;
930 930
 		foreach ($all_data['planes'] as $key => $line) {
@@ -941,12 +941,12 @@  discard block
 block discarded – undo
941 941
 		    $data['emergency'] = ''; // emergency
942 942
 		    $data['registration'] = $line[2];
943 943
 		    $data['aircraft_icao'] = $line[0];
944
-		    $deparr = explode('-',$line[1]);
944
+		    $deparr = explode('-', $line[1]);
945 945
 		    if (count($deparr) == 2) {
946 946
 			$data['departure_airport_icao'] = $deparr[0];
947 947
 			$data['arrival_airport_icao'] = $deparr[1];
948 948
 		    }
949
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
949
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
950 950
 	    	    $data['format_source'] = 'planeupdatefaa';
951 951
     		    $data['id_source'] = $id_source;
952 952
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 	    )
965 965
 	) {
966 966
 	    $buffer = $Common->getData($value['host']);
967
-	    $all_data = json_decode($buffer,true);
967
+	    $all_data = json_decode($buffer, true);
968 968
 	    if (isset($all_data['states'])) {
969 969
 		$reset = 0;
970 970
 		foreach ($all_data['states'] as $key => $line) {
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 		    //$data['emergency'] = ''; // emergency
982 982
 		    //$data['registration'] = $line[2];
983 983
 		    //$data['aircraft_icao'] = $line[0];
984
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
984
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
985 985
 		    $data['format_source'] = 'opensky';
986 986
 		    $data['id_source'] = $id_source;
987 987
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
 	) {
1001 1001
 	    //$buffer = $Common->getData($hosts[$id]);
1002 1002
 	    $buffer = $Common->getData($value['host']);
1003
-	    $all_data = json_decode($buffer,true);
1003
+	    $all_data = json_decode($buffer, true);
1004 1004
 	    if (!empty($all_data)) $reset = 0;
1005 1005
 	    foreach ($all_data as $key => $line) {
1006 1006
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1038,11 +1038,11 @@  discard block
 block discarded – undo
1038 1038
 	    )
1039 1039
 	) {
1040 1040
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1041
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1041
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1042 1042
 	    //echo $buffer;
1043
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1044
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1045
-	    $all_data = json_decode($buffer,true);
1043
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1044
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1045
+	    $all_data = json_decode($buffer, true);
1046 1046
 	    if (json_last_error() != JSON_ERROR_NONE) {
1047 1047
 		die(json_last_error_msg());
1048 1048
 	    }
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 			//$data['departure_airport_iata'] = $line[11];
1066 1066
 			//$data['arrival_airport_iata'] = $line[12];
1067 1067
 	    		//$data['emergency'] = ''; // emergency
1068
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1068
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1069 1069
 	    		$data['format_source'] = 'radarvirtueljson';
1070 1070
     			$data['id_source'] = $id_source;
1071 1071
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1086,14 +1086,14 @@  discard block
 block discarded – undo
1086 1086
 	) {
1087 1087
 	    //$buffer = $Common->getData($hosts[$id]);
1088 1088
 	    $buffer = $Common->getData($value['host'].'?'.time());
1089
-	    $all_data = json_decode(utf8_encode($buffer),true);
1089
+	    $all_data = json_decode(utf8_encode($buffer), true);
1090 1090
 	    
1091 1091
 	    if (isset($all_data['pireps'])) {
1092 1092
 		$reset = 0;
1093 1093
 	        foreach ($all_data['pireps'] as $line) {
1094 1094
 		    $data = array();
1095 1095
 		    $data['id'] = $line['id'];
1096
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1096
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1097 1097
 		    $data['ident'] = $line['callsign']; // ident
1098 1098
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1099 1099
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1123,9 +1123,9 @@  discard block
 block discarded – undo
1123 1123
 			$SI->add($data);
1124 1124
 		    //    print_r($data);
1125 1125
     		    } elseif ($line['icon'] == 'ct') {
1126
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1127
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1128
-			$typec = substr($data['ident'],-3);
1126
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1127
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1128
+			$typec = substr($data['ident'], -3);
1129 1129
 			$data['type'] = '';
1130 1130
 			if ($typec == 'APP') $data['type'] = 'Approach';
1131 1131
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1137 1137
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1138 1138
 			else $data['type'] = 'Observer';
1139
-			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']);
1139
+			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']);
1140 1140
 		    }
1141 1141
 		    unset($data);
1142 1142
 		}
@@ -1153,14 +1153,14 @@  discard block
 block discarded – undo
1153 1153
 	    //$buffer = $Common->getData($hosts[$id]);
1154 1154
 	    if ($globalDebug) echo 'Get Data...'."\n";
1155 1155
 	    $buffer = $Common->getData($value['host']);
1156
-	    $all_data = json_decode($buffer,true);
1156
+	    $all_data = json_decode($buffer, true);
1157 1157
 	    if ($buffer != '' && is_array($all_data)) {
1158 1158
 		$reset = 0;
1159 1159
 		foreach ($all_data as $line) {
1160 1160
 	    	    $data = array();
1161 1161
 	    	    //$data['id'] = $line['id']; // id not usable
1162 1162
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1163
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1163
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1164 1164
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1165 1165
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1166 1166
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 	    	    //$data['datetime'] = $line['lastupdate'];
1176 1176
 	    	    //$data['last_update'] = $line['lastupdate'];
1177 1177
 	    	    if (isset($value['timezone'])) {
1178
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1178
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1179 1179
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1180 1180
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1181 1181
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1188,14 +1188,14 @@  discard block
 block discarded – undo
1188 1188
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1189 1189
 		    if (isset($line['aircraftname'])) {
1190 1190
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1191
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1192
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1191
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1192
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1193 1193
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1194 1194
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1195 1195
 	    		else {
1196
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1197
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1198
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1196
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1197
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1198
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1199 1199
 	    		}
1200 1200
 	    	    }
1201 1201
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1220,14 +1220,14 @@  discard block
 block discarded – undo
1220 1220
 	    //$buffer = $Common->getData($hosts[$id]);
1221 1221
 	    if ($globalDebug) echo 'Get Data...'."\n";
1222 1222
 	    $buffer = $Common->getData($value['host']);
1223
-	    $all_data = json_decode($buffer,true);
1223
+	    $all_data = json_decode($buffer, true);
1224 1224
 	    if ($buffer != '' && is_array($all_data)) {
1225 1225
 		$reset = 0;
1226 1226
 		foreach ($all_data as $line) {
1227 1227
 	    	    $data = array();
1228 1228
 	    	    //$data['id'] = $line['id']; // id not usable
1229 1229
 	    	    $data['id'] = trim($line['flight_id']);
1230
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1230
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1231 1231
 	    	    $data['pilot_name'] = $line['pilot_name'];
1232 1232
 	    	    $data['pilot_id'] = $line['pilot_id'];
1233 1233
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1271,24 +1271,24 @@  discard block
 block discarded – undo
1271 1271
 	    //$buffer = $Common->getData($hosts[$id]);
1272 1272
 	    if ($globalDebug) echo 'Get Data...'."\n";
1273 1273
 	    $buffer = $Common->getData($value['host']);
1274
-	    $all_data = json_decode($buffer,true);
1274
+	    $all_data = json_decode($buffer, true);
1275 1275
 	    if ($buffer != '') {
1276 1276
 		$Source->deleteLocationBySource('blitzortung');
1277
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1278
-		$buffer = explode('\n',$buffer);
1277
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1278
+		$buffer = explode('\n', $buffer);
1279 1279
 		foreach ($buffer as $buffer_line) {
1280
-		    $line = json_decode($buffer_line,true);
1280
+		    $line = json_decode($buffer_line, true);
1281 1281
 		    if (isset($line['time'])) {
1282 1282
 			$data = array();
1283 1283
 			$data['altitude'] = $line['alt']; // altitude
1284 1284
 			$data['latitude'] = $line['lat']; // lat
1285 1285
 			$data['longitude'] = $line['lon']; // long
1286
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1286
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1287 1287
 			$data['id_source'] = $id_source;
1288 1288
 			$data['format_source'] = 'blitzortung';
1289 1289
 			$SI->add($data);
1290 1290
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1291
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1291
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1292 1292
 			unset($data);
1293 1293
 		    }
1294 1294
 		}
@@ -1313,11 +1313,11 @@  discard block
 block discarded – undo
1313 1313
 		    //$value = $formats[$nb];
1314 1314
 		    $format = $globalSources[$nb]['format'];
1315 1315
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1316
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1316
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1317 1317
 		    } elseif ($format == 'vrstcp') {
1318 1318
 			$buffer = @socket_read($r, 6000);
1319 1319
 		    } else {
1320
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1320
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1321 1321
 		    }
1322 1322
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1323 1323
 		    //echo $buffer."\n";
@@ -1326,8 +1326,8 @@  discard block
 block discarded – undo
1326 1326
 		    $error = false;
1327 1327
 		    //$SI::del();
1328 1328
 		    if ($format == 'vrstcp') {
1329
-			$buffer = explode('},{',$buffer);
1330
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1329
+			$buffer = explode('},{', $buffer);
1330
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1331 1331
 		    // SBS format is CSV format
1332 1332
 		    if ($buffer !== FALSE && $buffer != '') {
1333 1333
 			$tt[$format] = 0;
@@ -1361,13 +1361,13 @@  discard block
 block discarded – undo
1361 1361
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1362 1362
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1363 1363
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1364
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1364
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1365 1365
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1366 1366
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1367 1367
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1368 1368
 
1369 1369
 			    if (isset($ais_data['timestamp'])) {
1370
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1370
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1371 1371
 			    } else {
1372 1372
 				$data['datetime'] = date('Y-m-d H:i:s');
1373 1373
 			    }
@@ -1378,10 +1378,10 @@  discard block
 block discarded – undo
1378 1378
                         } elseif ($format == 'flightgearsp') {
1379 1379
                     	    //echo $buffer."\n";
1380 1380
                     	    if (strlen($buffer) > 5) {
1381
-				$line = explode(',',$buffer);
1381
+				$line = explode(',', $buffer);
1382 1382
 				$data = array();
1383 1383
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1384
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1384
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1385 1385
 				$data['ident'] = $line[6];
1386 1386
 				$data['aircraft_name'] = $line[7];
1387 1387
 				$data['longitude'] = $line[1];
@@ -1398,16 +1398,16 @@  discard block
 block discarded – undo
1398 1398
                         } elseif ($format == 'acars') {
1399 1399
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1400 1400
 			    $ACARS->add(trim($buffer));
1401
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1401
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1402 1402
 			    $ACARS->deleteLiveAcarsData();
1403 1403
 			} elseif ($format == 'flightgearmp') {
1404
-			    if (substr($buffer,0,1) != '#') {
1404
+			    if (substr($buffer, 0, 1) != '#') {
1405 1405
 				$data = array();
1406 1406
 				//echo $buffer."\n";
1407
-				$line = explode(' ',$buffer);
1407
+				$line = explode(' ', $buffer);
1408 1408
 				if (count($line) == 11) {
1409
-				    $userserver = explode('@',$line[0]);
1410
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1409
+				    $userserver = explode('@', $line[0]);
1410
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1411 1411
 				    $data['ident'] = $userserver[0];
1412 1412
 				    $data['registration'] = $userserver[0];
1413 1413
 				    $data['latitude'] = $line[4];
@@ -1415,8 +1415,8 @@  discard block
 block discarded – undo
1415 1415
 				    $data['altitude'] = $line[6];
1416 1416
 				    $data['datetime'] = date('Y-m-d H:i:s');
1417 1417
 				    $aircraft_type = $line[10];
1418
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1419
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1418
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1419
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1420 1420
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1421 1421
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1422 1422
 				}
@@ -1425,8 +1425,8 @@  discard block
 block discarded – undo
1425 1425
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1426 1426
 			    die;
1427 1427
 			} elseif ($format == 'vrstcp') {
1428
-			    foreach($buffer as $all_data) {
1429
-				$line = json_decode('{'.$all_data.'}',true);
1428
+			    foreach ($buffer as $all_data) {
1429
+				$line = json_decode('{'.$all_data.'}', true);
1430 1430
 				$data = array();
1431 1431
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1432 1432
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1452,16 +1452,16 @@  discard block
 block discarded – undo
1452 1452
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1453 1453
 				unset($data);
1454 1454
 			    }
1455
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1455
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1456 1456
 			    $line = explode("\t", $buffer);
1457
-			    for($k = 0; $k < count($line); $k=$k+2) {
1457
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1458 1458
 				$key = $line[$k];
1459
-			        $lined[$key] = $line[$k+1];
1459
+			        $lined[$key] = $line[$k + 1];
1460 1460
 			    }
1461 1461
     			    if (count($lined) > 3) {
1462 1462
     				$data['hex'] = $lined['hexid'];
1463 1463
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1464
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1464
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1465 1465
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1466 1466
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1467 1467
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1480,22 +1480,22 @@  discard block
 block discarded – undo
1480 1480
     			    } else $error = true;
1481 1481
 			} elseif ($format == 'aprs' && $use_aprs) {
1482 1482
 			    if ($aprs_connect == 0) {
1483
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1483
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1484 1484
 				$aprs_connect = 1;
1485 1485
 			    }
1486 1486
 			    
1487
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1487
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1488 1488
 				$aprs_last_tx = time();
1489 1489
 				$data_aprs = "# Keep alive";
1490
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1490
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1491 1491
 			    }
1492 1492
 			    
1493 1493
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1494 1494
 			    //echo 'APRS data : '.$buffer."\n";
1495
-			    $buffer = str_replace('APRS <- ','',$buffer);
1496
-			    $buffer = str_replace('APRS -> ','',$buffer);
1495
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1496
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1497 1497
 			    //echo $buffer."\n";
1498
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1498
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1499 1499
 				$line = $APRS->parse($buffer);
1500 1500
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1501 1501
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1511 1511
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1512 1512
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1513
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1513
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1514 1514
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1515 1515
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1516 1516
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1592,29 +1592,29 @@  discard block
 block discarded – undo
1592 1592
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1593 1593
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1594 1594
 					$Source->deleteOldLocationByType('gs');
1595
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1596
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1595
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1596
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1597 1597
 					} else {
1598
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1598
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1599 1599
 					}
1600 1600
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1601 1601
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1602 1602
 					if ($globalDebug) echo '# Weather Station added'."\n";
1603 1603
 					$Source->deleteOldLocationByType('wx');
1604 1604
 					$weather_data = json_encode($line);
1605
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1606
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1605
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1606
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1607 1607
 					} else {
1608
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1608
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1609 1609
 					}
1610 1610
 				    } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1611 1611
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1612 1612
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1613 1613
 					$Source->deleteOldLocationByType('lightning');
1614
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1615
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1614
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1615
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1616 1616
 					} else {
1617
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1617
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1618 1618
 					}
1619 1619
 				    } elseif ($globalDebug) {
1620 1620
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
 				    unset($data);
1624 1624
 				}
1625 1625
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1626
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1626
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1627 1627
 				}
1628 1628
 				/*
1629 1629
 				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')) {
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
 				*/
1633 1633
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1634 1634
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1635
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1635
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1636 1636
 					$Source->deleteOldLocationByType('lightning');
1637 1637
 					$Source->deleteOldLocationByType('wx');
1638 1638
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
 				connect_all($sourceee);
1718 1718
 				$sourceee = array();
1719 1719
 				//connect_all($globalSources);
1720
-				$tt[$format]=0;
1720
+				$tt[$format] = 0;
1721 1721
 				break;
1722 1722
 			    }
1723 1723
 			}
@@ -1726,14 +1726,14 @@  discard block
 block discarded – undo
1726 1726
 	    } else {
1727 1727
 		$error = socket_strerror(socket_last_error());
1728 1728
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1729
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1729
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1730 1730
 			if (isset($globalDebug)) echo "Restarting...\n";
1731 1731
 			// Restart the script if possible
1732 1732
 			if (is_array($sockets)) {
1733 1733
 			    if ($globalDebug) echo "Shutdown all sockets...";
1734 1734
 			    
1735 1735
 			    foreach ($sockets as $sock) {
1736
-				@socket_shutdown($sock,2);
1736
+				@socket_shutdown($sock, 2);
1737 1737
 				@socket_close($sock);
1738 1738
 			    }
1739 1739
 			    
Please login to merge, or discard this patch.