Completed
Push — master ( 7c25a0...e3e251 )
by Yannick
29:02
created
scripts/daemon-spotter.php 1 patch
Spacing   +182 added lines, -182 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'));
57
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver'));
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'])) {
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 else $id_source = 1;
87 87
 if (isset($globalServer) && $globalServer) {
88 88
     if ($globalDebug) echo "Using Server Mode\n";
89
-    $SI=new SpotterServer();
89
+    $SI = new SpotterServer();
90 90
 /*
91 91
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
92 92
     $SI = new adsb2aprs();
93 93
     $SI->connect();
94 94
 */
95
-} else $SI=new SpotterImport($Connection->db);
95
+} else $SI = new SpotterImport($Connection->db);
96 96
 
97 97
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
98 98
 if (isset($globalMarine) && $globalMarine) {
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
     $MI = new MarineImport($Connection->db);
107 107
 }
108 108
 //$APRS=new APRS($Connection->db);
109
-$SBS=new SBS();
110
-$ACARS=new ACARS($Connection->db,true);
111
-$Source=new Source($Connection->db);
112
-$Common=new Common();
109
+$SBS = new SBS();
110
+$ACARS = new ACARS($Connection->db, true);
111
+$Source = new Source($Connection->db);
112
+$Common = new Common();
113 113
 date_default_timezone_set('UTC');
114 114
 //$servertz = system('date +%Z');
115 115
 // signal handler - playing nice with sockets and dump1090
116 116
 if (function_exists('pcntl_fork')) {
117
-    pcntl_signal(SIGINT,  function() {
117
+    pcntl_signal(SIGINT, function() {
118 118
         global $sockets;
119 119
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
120 120
         die("Bye!\n");
@@ -130,30 +130,30 @@  discard block
 block discarded – undo
130 130
 
131 131
 function connect_all($hosts) {
132 132
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
133
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
133
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
134 134
     $reset++;
135 135
     if ($globalDebug) echo 'Connect to all...'."\n";
136 136
     foreach ($hosts as $id => $value) {
137 137
 	$host = $value['host'];
138 138
 	$globalSources[$id]['last_exec'] = 0;
139 139
 	// Here we check type of source(s)
140
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
141
-            if (preg_match('/deltadb.txt$/i',$host)) {
140
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
141
+            if (preg_match('/deltadb.txt$/i', $host)) {
142 142
         	//$formats[$id] = 'deltadbtxt';
143 143
         	$globalSources[$id]['format'] = 'deltadbtxt';
144 144
         	//$last_exec['deltadbtxt'] = 0;
145 145
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
146
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
146
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
147 147
         	//$formats[$id] = 'vatsimtxt';
148 148
         	$globalSources[$id]['format'] = 'vatsimtxt';
149 149
         	//$last_exec['vatsimtxt'] = 0;
150 150
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
151
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
151
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
152 152
         	//$formats[$id] = 'aircraftlistjson';
153 153
         	$globalSources[$id]['format'] = 'aircraftlistjson';
154 154
         	//$last_exec['aircraftlistjson'] = 0;
155 155
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
156
-    	    } else if (preg_match('/opensky/i',$host)) {
156
+    	    } else if (preg_match('/opensky/i', $host)) {
157 157
         	//$formats[$id] = 'aircraftlistjson';
158 158
         	$globalSources[$id]['format'] = 'opensky';
159 159
         	//$last_exec['aircraftlistjson'] = 0;
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         	    exit(0);
171 171
         	}
172 172
     	    */
173
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
173
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
174 174
         	//$formats[$id] = 'planeupdatefaa';
175 175
         	$globalSources[$id]['format'] = 'planeupdatefaa';
176 176
         	//$last_exec['planeupdatefaa'] = 0;
@@ -179,32 +179,32 @@  discard block
 block discarded – undo
179 179
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
180 180
         	    exit(0);
181 181
         	}
182
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
182
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
183 183
         	//$formats[$id] = 'phpvmacars';
184 184
         	$globalSources[$id]['format'] = 'phpvmacars';
185 185
         	//$last_exec['phpvmacars'] = 0;
186 186
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
187
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
187
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
188 188
         	//$formats[$id] = 'phpvmacars';
189 189
         	$globalSources[$id]['format'] = 'vam';
190 190
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
191
-            } else if (preg_match('/whazzup/i',$host)) {
191
+            } else if (preg_match('/whazzup/i', $host)) {
192 192
         	//$formats[$id] = 'whazzup';
193 193
         	$globalSources[$id]['format'] = 'whazzup';
194 194
         	//$last_exec['whazzup'] = 0;
195 195
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
196
-            } else if (preg_match('/blitzortung/i',$host)) {
196
+            } else if (preg_match('/blitzortung/i', $host)) {
197 197
         	$globalSources[$id]['format'] = 'blitzortung';
198 198
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
199
-            } else if (preg_match('/airwhere/i',$host)) {
199
+            } else if (preg_match('/airwhere/i', $host)) {
200 200
         	$globalSources[$id]['format'] = 'airwhere';
201 201
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
202
-            } else if (preg_match('/recentpireps/i',$host)) {
202
+            } else if (preg_match('/recentpireps/i', $host)) {
203 203
         	//$formats[$id] = 'pirepsjson';
204 204
         	$globalSources[$id]['format'] = 'pirepsjson';
205 205
         	//$last_exec['pirepsjson'] = 0;
206 206
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
207
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
207
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
208 208
         	//$formats[$id] = 'fr24json';
209 209
         	$globalSources[$id]['format'] = 'fr24json';
210 210
         	//$last_exec['fr24json'] = 0;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
214 214
         	    exit(0);
215 215
         	}
216
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
216
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
217 217
         	//$formats[$id] = 'fr24json';
218 218
         	$globalSources[$id]['format'] = 'myshiptracking';
219 219
         	//$last_exec['fr24json'] = 0;
@@ -223,22 +223,22 @@  discard block
 block discarded – undo
223 223
         	    exit(0);
224 224
         	}
225 225
             //} else if (preg_match('/10001/',$host)) {
226
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
226
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
227 227
         	//$formats[$id] = 'tsv';
228 228
         	$globalSources[$id]['format'] = 'tsv';
229 229
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
230 230
             }
231
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
231
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
232 232
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
233
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
233
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
234 234
     		    if ($idf !== false) {
235 235
     			$httpfeeds[$id] = $idf;
236 236
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
237 237
     		    }
238 238
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
239 239
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
240
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
241
-	    $hostport = explode(':',$host);
240
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
241
+	    $hostport = explode(':', $host);
242 242
 	    if (isset($hostport[1])) {
243 243
 		$port = $hostport[1];
244 244
 		$hostn = $hostport[0];
@@ -248,19 +248,19 @@  discard block
 block discarded – undo
248 248
 	    }
249 249
 	    $Common = new Common();
250 250
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
251
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
251
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
252 252
     	    } else {
253
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
253
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
254 254
 	    }
255 255
 	    if ($s) {
256 256
     	        $sockets[$id] = $s;
257 257
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
258
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
258
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
259 259
 			//$formats[$id] = 'aprs';
260 260
 			$globalSources[$id]['format'] = 'aprs';
261 261
 			//$aprs_connect = 0;
262 262
 			//$use_aprs = true;
263
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
263
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
264 264
 			$globalSources[$id]['format'] = 'vrstcp';
265 265
     		    } elseif ($port == '10001') {
266 266
         		//$formats[$id] = 'tsv';
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
300 300
 else $timeout = 20;
301 301
 $errno = '';
302
-$errstr='';
302
+$errstr = '';
303 303
 
304 304
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
305 305
 /* Initiate connections to all the hosts simultaneously */
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 //connect_all($globalSources);
308 308
 
309 309
 if (isset($globalProxy) && $globalProxy) {
310
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
310
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
311 311
 } else {
312 312
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
313 313
 }
@@ -337,16 +337,16 @@  discard block
 block discarded – undo
337 337
 
338 338
 if ($use_aprs) {
339 339
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
340
-	$APRS=new APRS();
340
+	$APRS = new APRS();
341 341
 	$aprs_connect = 0;
342 342
 	$aprs_keep = 120;
343 343
 	$aprs_last_tx = time();
344 344
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
345
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
345
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
346 346
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
347
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
347
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
348 348
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
349
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
349
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
350 350
 	if ($aprs_full) $aprs_filter = '';
351 351
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
352 352
 	else $aprs_pass = '-1';
@@ -360,12 +360,12 @@  discard block
 block discarded – undo
360 360
 sleep(1);
361 361
 if ($globalDebug) echo "SCAN MODE \n\n";
362 362
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
363
-$endtime = time()+$globalCronEnd;
363
+$endtime = time() + $globalCronEnd;
364 364
 $i = 1;
365 365
 $tt = array();
366 366
 // Delete all ATC
367 367
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
368
-	$ATC=new ATC($Connection->db);
368
+	$ATC = new ATC($Connection->db);
369 369
 }
370 370
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
371 371
 	$ATC->deleteAll();
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 
374 374
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
375 375
 while ($i > 0) {
376
-    if (!$globalDaemon) $i = $endtime-time();
376
+    if (!$globalDaemon) $i = $endtime - time();
377 377
     // Delete old ATC
378 378
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
379 379
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	}
388 388
 	if ($max != $globalMinFetch) {
389 389
 	    if ($globalDebug) echo 'Sleeping...'."\n";
390
-	    sleep($globalMinFetch-$max+2);
390
+	    sleep($globalMinFetch - $max + 2);
391 391
 	}
392 392
     }
393 393
 
@@ -406,8 +406,8 @@  discard block
 block discarded – undo
406 406
 	    //$buffer = $Common->getData($hosts[$id]);
407 407
 	    $buffer = $Common->getData($value['host']);
408 408
 	    if ($buffer != '') $reset = 0;
409
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
410
-	    $buffer = explode('\n',$buffer);
409
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
410
+	    $buffer = explode('\n', $buffer);
411 411
 	    foreach ($buffer as $line) {
412 412
     		if ($line != '' && count($line) > 7) {
413 413
     		    $line = explode(',', $line);
@@ -440,11 +440,11 @@  discard block
 block discarded – undo
440 440
 	    )
441 441
 	) {
442 442
 	    date_default_timezone_set('CET');
443
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
443
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
444 444
 	    date_default_timezone_set('UTC');
445 445
 	    if ($buffer != '') $reset = 0;
446
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
447
-	    $buffer = explode('\n',$buffer);
446
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
447
+	    $buffer = explode('\n', $buffer);
448 448
 	    foreach ($buffer as $line) {
449 449
 		if ($line != '') {
450 450
 		    //echo "'".$line."'\n";
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
463 463
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
464 464
 		    if (isset($ais_data['timestamp'])) {
465
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
465
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
466 466
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
467 467
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
468 468
 			    $add = true;
@@ -485,12 +485,12 @@  discard block
 block discarded – undo
485 485
 	    $w = $e = null;
486 486
 	    
487 487
 	    if (isset($arr[$id])) {
488
-		$nn = stream_select($arr,$w,$e,$timeout);
488
+		$nn = stream_select($arr, $w, $e, $timeout);
489 489
 		if ($nn > 0) {
490 490
 		    foreach ($httpfeeds as $feed) {
491
-			$buffer = stream_get_line($feed,2000,"\n");
492
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
493
-			$buffer = explode('\n',$buffer);
491
+			$buffer = stream_get_line($feed, 2000, "\n");
492
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
493
+			$buffer = explode('\n', $buffer);
494 494
 			foreach ($buffer as $line) {
495 495
 			    if ($line != '') {
496 496
 				$ais_data = $AIS->parse_line(trim($line));
@@ -508,9 +508,9 @@  discard block
 block discarded – undo
508 508
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
509 509
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
510 510
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
511
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
511
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
512 512
 				if (isset($ais_data['timestamp'])) {
513
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
513
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
514 514
 				} else {
515 515
 				    $data['datetime'] = date('Y-m-d H:i:s');
516 516
 				}
@@ -541,10 +541,10 @@  discard block
 block discarded – undo
541 541
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
542 542
 	    )
543 543
 	) {
544
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
544
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
545 545
 	    if ($buffer != '') {
546 546
 		//echo $buffer;
547
-		$all_data = json_decode($buffer,true);
547
+		$all_data = json_decode($buffer, true);
548 548
 		//print_r($all_data);
549 549
 		if (isset($all_data[0]['DATA'])) {
550 550
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
560 560
 			    $data['imo'] = $line['IMO'];
561 561
 			    //$data['arrival_code'] = $ais_data['destination'];
562
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
562
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
563 563
 			    $data['format_source'] = 'myshiptracking';
564 564
 			    $data['id_source'] = $id_source;
565 565
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -576,9 +576,9 @@  discard block
 block discarded – undo
576 576
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
577 577
 	    )
578 578
 	) {
579
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
579
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
580 580
 	    if ($buffer != '') {
581
-		$all_data = json_decode($buffer,true);
581
+		$all_data = json_decode($buffer, true);
582 582
 		if (isset($all_data[0]['mmsi'])) {
583 583
 		    foreach ($all_data as $line) {
584 584
 			if ($line != '') {
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	) {
613 613
 	    $buffer = $Common->getData($value['host']);
614 614
 	    if ($buffer != '') {
615
-		$all_data = json_decode($buffer,true);
615
+		$all_data = json_decode($buffer, true);
616 616
 		if (isset($all_data['features'][0]['id'])) {
617 617
 		    foreach ($all_data['features'] as $line) {
618 618
 			$data = array();
@@ -645,27 +645,27 @@  discard block
 block discarded – undo
645 645
 	    )
646 646
 	) {
647 647
 	    echo 'download...';
648
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
648
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
649 649
 	    echo 'done !'."\n";
650 650
 	    if ($buffer != '') $reset = 0;
651
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
652
-	    $buffer = explode('\n',$buffer);
651
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
652
+	    $buffer = explode('\n', $buffer);
653 653
 	    foreach ($buffer as $line) {
654 654
 		if ($line != '') {
655 655
 		    $data = array();
656
-		    $data['mmsi'] = (int)substr($line,0,9);
657
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
656
+		    $data['mmsi'] = (int) substr($line, 0, 9);
657
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
658 658
 		    //$data['status'] = substr($line,21,2);
659 659
 		    //$data['type'] = substr($line,24,3);
660
-		    $data['latitude'] = substr($line,29,9);
661
-		    $data['longitude'] = substr($line,41,9);
662
-		    $data['speed'] = round(substr($line,51,5));
660
+		    $data['latitude'] = substr($line, 29, 9);
661
+		    $data['longitude'] = substr($line, 41, 9);
662
+		    $data['speed'] = round(substr($line, 51, 5));
663 663
 		    //$data['course'] = substr($line,57,5);
664
-		    $data['heading'] = round(substr($line,63,3));
664
+		    $data['heading'] = round(substr($line, 63, 3));
665 665
 		    //$data['draft'] = substr($line,67,4);
666 666
 		    //$data['length'] = substr($line,72,3);
667 667
 		    //$data['beam'] = substr($line,76,2);
668
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
668
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
669 669
 		    //$data['callsign'] = trim(substr($line,100,7);
670 670
 		    //$data['dest'] = substr($line,108,20);
671 671
 		    //$data['etaDate'] = substr($line,129,5);
@@ -698,8 +698,8 @@  discard block
 block discarded – undo
698 698
 	) {
699 699
 	    //$buffer = $Common->getData($hosts[$id]);
700 700
 	    $buffer = $Common->getData($value['host']);
701
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
702
-	    $buffer = explode('\n',$buffer);
701
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
702
+	    $buffer = explode('\n', $buffer);
703 703
 	    $reset = 0;
704 704
 	    foreach ($buffer as $line) {
705 705
     		if ($line != '') {
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
711 711
 			$data['pilot_id'] = $line[1];
712 712
 			$data['pilot_name'] = $line[2];
713
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
713
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
714 714
 			$data['ident'] = $line[0]; // ident
715 715
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
716 716
 			$data['speed'] = $line[8]; // speed
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
727 727
 			//if (isset($line[37])) $data['last_update'] = $line[37];
728 728
 		        $data['departure_airport_icao'] = $line[11];
729
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
729
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
730 730
 		        $data['arrival_airport_icao'] = $line[13];
731 731
 			$data['frequency'] = $line[4];
732 732
 			$data['type'] = $line[18];
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
     			$data['id_source'] = $id_source;
736 736
 	    		//$data['arrival_airport_time'] = ;
737 737
 	    		if ($line[9] != '') {
738
-	    		    $aircraft_data = explode('/',$line[9]);
738
+	    		    $aircraft_data = explode('/', $line[9]);
739 739
 	    		    if (isset($aircraft_data[1])) {
740 740
 	    			$data['aircraft_icao'] = $aircraft_data[1];
741 741
 	    		    }
@@ -750,9 +750,9 @@  discard block
 block discarded – undo
750 750
     			if ($line[3] == 'PILOT') $SI->add($data);
751 751
 			elseif ($line[3] == 'ATC') {
752 752
 				//print_r($data);
753
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
754
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
755
-				$typec = substr($data['ident'],-3);
753
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
754
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
755
+				$typec = substr($data['ident'], -3);
756 756
 				if ($typec == 'APP') $data['type'] = 'Approach';
757 757
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
758 758
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -764,8 +764,8 @@  discard block
 block discarded – undo
764 764
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
765 765
 				if (!isset($data['source_name'])) $data['source_name'] = '';
766 766
 				if (isset($ATC)) {
767
-					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']);
768
-					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']);
767
+					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']);
768
+					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']);
769 769
 				}
770 770
 			}
771 771
     			unset($data);
@@ -781,24 +781,24 @@  discard block
 block discarded – undo
781 781
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
782 782
     	    )
783 783
     	) {
784
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
784
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
785 785
 	    if ($buffer != '') {
786 786
 		$all_data = simplexml_load_string($buffer);
787
-		foreach($all_data->children() as $childdata) {
787
+		foreach ($all_data->children() as $childdata) {
788 788
 			$data = array();
789 789
 			$line = $childdata;
790 790
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
791
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
792
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
793
-			$data['latitude'] = (float)$line['pktLatitude'];
794
-			$data['longitude'] = (float)$line['pktLongitude'];
795
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
796
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
797
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
791
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
792
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
793
+			$data['latitude'] = (float) $line['pktLatitude'];
794
+			$data['longitude'] = (float) $line['pktLongitude'];
795
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
796
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
797
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
798 798
 			$data['altitude_relative'] = 'AMSL';
799
-			$data['pilot_id'] = (int)$line['pktPilotID'];
799
+			$data['pilot_id'] = (int) $line['pktPilotID'];
800 800
 			$data['aircraft_icao'] = 'PARAGLIDER';
801
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
801
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
802 802
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
803 803
 			$data['format_source'] = $value['format'];
804 804
 			$SI->add($data);
@@ -806,22 +806,22 @@  discard block
 block discarded – undo
806 806
 		}
807 807
 	    }
808 808
 	    $Source->deleteOldLocationByType('gs');
809
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
809
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
810 810
 	    if ($buffer != '') {
811 811
 		$all_data = simplexml_load_string($buffer);
812
-		foreach($all_data->children() as $childdata) {
812
+		foreach ($all_data->children() as $childdata) {
813 813
 			$data = array();
814 814
 			$line = $childdata;
815
-			$data['id'] = (int)$line['gsID'];
816
-			$data['latitude'] = (float)$line['gsLatitude'];
817
-			$data['longitude'] = (float)$line['gsLongitude'];
818
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
815
+			$data['id'] = (int) $line['gsID'];
816
+			$data['latitude'] = (float) $line['gsLatitude'];
817
+			$data['longitude'] = (float) $line['gsLongitude'];
818
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
819 819
 			$data['altitude_relative'] = 'AMSL';
820
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
820
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
821 821
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
822
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
822
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
823 823
 			} else {
824
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
824
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
825 825
 			}
826 826
 			unset($data);
827 827
 		}
@@ -839,9 +839,9 @@  discard block
 block discarded – undo
839 839
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
840 840
 	    )
841 841
 	) {
842
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
842
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
843 843
 	    if ($buffer != '') {
844
-	        $all_data = json_decode($buffer,true);
844
+	        $all_data = json_decode($buffer, true);
845 845
 		if (isset($all_data['acList'])) {
846 846
 		    $reset = 0;
847 847
 		    foreach ($all_data['acList'] as $line) {
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
858 858
 			$data['emergency'] = ''; // emergency
859 859
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
860
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
860
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
861 861
 			else $data['datetime'] = date('Y-m-d H:i:s');
862 862
 			//$data['datetime'] = date('Y-m-d H:i:s');
863 863
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 			$data['verticalrate'] = $line['vrt']; // verticale rate
883 883
 			$data['squawk'] = $line['squawk']; // squawk
884 884
 			$data['emergency'] = ''; // emergency
885
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
885
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
886 886
 			else $data['datetime'] = date('Y-m-d H:i:s');
887 887
 			$data['format_source'] = 'aircraftlistjson';
888 888
 			$data['id_source'] = $id_source;
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
     	    )
904 904
     	) {
905 905
 	    $buffer = $Common->getData($value['host']);
906
-	    $all_data = json_decode($buffer,true);
906
+	    $all_data = json_decode($buffer, true);
907 907
 	    if (isset($all_data['planes'])) {
908 908
 		$reset = 0;
909 909
 		foreach ($all_data['planes'] as $key => $line) {
@@ -920,12 +920,12 @@  discard block
 block discarded – undo
920 920
 		    $data['emergency'] = ''; // emergency
921 921
 		    $data['registration'] = $line[2];
922 922
 		    $data['aircraft_icao'] = $line[0];
923
-		    $deparr = explode('-',$line[1]);
923
+		    $deparr = explode('-', $line[1]);
924 924
 		    if (count($deparr) == 2) {
925 925
 			$data['departure_airport_icao'] = $deparr[0];
926 926
 			$data['arrival_airport_icao'] = $deparr[1];
927 927
 		    }
928
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
928
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
929 929
 	    	    $data['format_source'] = 'planeupdatefaa';
930 930
     		    $data['id_source'] = $id_source;
931 931
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 	    )
944 944
 	) {
945 945
 	    $buffer = $Common->getData($value['host']);
946
-	    $all_data = json_decode($buffer,true);
946
+	    $all_data = json_decode($buffer, true);
947 947
 	    if (isset($all_data['states'])) {
948 948
 		$reset = 0;
949 949
 		foreach ($all_data['states'] as $key => $line) {
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
 		    //$data['emergency'] = ''; // emergency
961 961
 		    //$data['registration'] = $line[2];
962 962
 		    //$data['aircraft_icao'] = $line[0];
963
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
963
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
964 964
 		    $data['format_source'] = 'opensky';
965 965
 		    $data['id_source'] = $id_source;
966 966
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 	) {
980 980
 	    //$buffer = $Common->getData($hosts[$id]);
981 981
 	    $buffer = $Common->getData($value['host']);
982
-	    $all_data = json_decode($buffer,true);
982
+	    $all_data = json_decode($buffer, true);
983 983
 	    if (!empty($all_data)) $reset = 0;
984 984
 	    foreach ($all_data as $key => $line) {
985 985
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1017,11 +1017,11 @@  discard block
 block discarded – undo
1017 1017
 	    )
1018 1018
 	) {
1019 1019
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1020
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1020
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1021 1021
 	    //echo $buffer;
1022
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1023
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1024
-	    $all_data = json_decode($buffer,true);
1022
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1023
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1024
+	    $all_data = json_decode($buffer, true);
1025 1025
 	    if (json_last_error() != JSON_ERROR_NONE) {
1026 1026
 		die(json_last_error_msg());
1027 1027
 	    }
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 			//$data['departure_airport_iata'] = $line[11];
1045 1045
 			//$data['arrival_airport_iata'] = $line[12];
1046 1046
 	    		//$data['emergency'] = ''; // emergency
1047
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1047
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1048 1048
 	    		$data['format_source'] = 'radarvirtueljson';
1049 1049
     			$data['id_source'] = $id_source;
1050 1050
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1065,14 +1065,14 @@  discard block
 block discarded – undo
1065 1065
 	) {
1066 1066
 	    //$buffer = $Common->getData($hosts[$id]);
1067 1067
 	    $buffer = $Common->getData($value['host'].'?'.time());
1068
-	    $all_data = json_decode(utf8_encode($buffer),true);
1068
+	    $all_data = json_decode(utf8_encode($buffer), true);
1069 1069
 	    
1070 1070
 	    if (isset($all_data['pireps'])) {
1071 1071
 		$reset = 0;
1072 1072
 	        foreach ($all_data['pireps'] as $line) {
1073 1073
 		    $data = array();
1074 1074
 		    $data['id'] = $line['id'];
1075
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1075
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1076 1076
 		    $data['ident'] = $line['callsign']; // ident
1077 1077
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1078 1078
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1102,9 +1102,9 @@  discard block
 block discarded – undo
1102 1102
 			$SI->add($data);
1103 1103
 		    //    print_r($data);
1104 1104
     		    } elseif ($line['icon'] == 'ct') {
1105
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1106
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1107
-			$typec = substr($data['ident'],-3);
1105
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1106
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1107
+			$typec = substr($data['ident'], -3);
1108 1108
 			$data['type'] = '';
1109 1109
 			if ($typec == 'APP') $data['type'] = 'Approach';
1110 1110
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1116 1116
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1117 1117
 			else $data['type'] = 'Observer';
1118
-			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']);
1118
+			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']);
1119 1119
 		    }
1120 1120
 		    unset($data);
1121 1121
 		}
@@ -1132,14 +1132,14 @@  discard block
 block discarded – undo
1132 1132
 	    //$buffer = $Common->getData($hosts[$id]);
1133 1133
 	    if ($globalDebug) echo 'Get Data...'."\n";
1134 1134
 	    $buffer = $Common->getData($value['host']);
1135
-	    $all_data = json_decode($buffer,true);
1135
+	    $all_data = json_decode($buffer, true);
1136 1136
 	    if ($buffer != '' && is_array($all_data)) {
1137 1137
 		$reset = 0;
1138 1138
 		foreach ($all_data as $line) {
1139 1139
 	    	    $data = array();
1140 1140
 	    	    //$data['id'] = $line['id']; // id not usable
1141 1141
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1142
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1142
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1143 1143
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1144 1144
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1145 1145
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 	    	    //$data['datetime'] = $line['lastupdate'];
1155 1155
 	    	    //$data['last_update'] = $line['lastupdate'];
1156 1156
 	    	    if (isset($value['timezone'])) {
1157
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1157
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1158 1158
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1159 1159
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1160 1160
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1167,14 +1167,14 @@  discard block
 block discarded – undo
1167 1167
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1168 1168
 		    if (isset($line['aircraftname'])) {
1169 1169
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1170
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1171
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1170
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1171
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1172 1172
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1173 1173
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1174 1174
 	    		else {
1175
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1176
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1177
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1175
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1176
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1177
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1178 1178
 	    		}
1179 1179
 	    	    }
1180 1180
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1199,14 +1199,14 @@  discard block
 block discarded – undo
1199 1199
 	    //$buffer = $Common->getData($hosts[$id]);
1200 1200
 	    if ($globalDebug) echo 'Get Data...'."\n";
1201 1201
 	    $buffer = $Common->getData($value['host']);
1202
-	    $all_data = json_decode($buffer,true);
1202
+	    $all_data = json_decode($buffer, true);
1203 1203
 	    if ($buffer != '' && is_array($all_data)) {
1204 1204
 		$reset = 0;
1205 1205
 		foreach ($all_data as $line) {
1206 1206
 	    	    $data = array();
1207 1207
 	    	    //$data['id'] = $line['id']; // id not usable
1208 1208
 	    	    $data['id'] = trim($line['flight_id']);
1209
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1209
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1210 1210
 	    	    $data['pilot_name'] = $line['pilot_name'];
1211 1211
 	    	    $data['pilot_id'] = $line['pilot_id'];
1212 1212
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1250,24 +1250,24 @@  discard block
 block discarded – undo
1250 1250
 	    //$buffer = $Common->getData($hosts[$id]);
1251 1251
 	    if ($globalDebug) echo 'Get Data...'."\n";
1252 1252
 	    $buffer = $Common->getData($value['host']);
1253
-	    $all_data = json_decode($buffer,true);
1253
+	    $all_data = json_decode($buffer, true);
1254 1254
 	    if ($buffer != '') {
1255 1255
 		$Source->deleteLocationBySource('blitzortung');
1256
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1257
-		$buffer = explode('\n',$buffer);
1256
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1257
+		$buffer = explode('\n', $buffer);
1258 1258
 		foreach ($buffer as $buffer_line) {
1259
-		    $line = json_decode($buffer_line,true);
1259
+		    $line = json_decode($buffer_line, true);
1260 1260
 		    if (isset($line['time'])) {
1261 1261
 			$data = array();
1262 1262
 			$data['altitude'] = $line['alt']; // altitude
1263 1263
 			$data['latitude'] = $line['lat']; // lat
1264 1264
 			$data['longitude'] = $line['lon']; // long
1265
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1265
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1266 1266
 			$data['id_source'] = $id_source;
1267 1267
 			$data['format_source'] = 'blitzortung';
1268 1268
 			$SI->add($data);
1269 1269
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1270
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1270
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1271 1271
 			unset($data);
1272 1272
 		    }
1273 1273
 		}
@@ -1292,11 +1292,11 @@  discard block
 block discarded – undo
1292 1292
 		    //$value = $formats[$nb];
1293 1293
 		    $format = $globalSources[$nb]['format'];
1294 1294
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1295
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1295
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1296 1296
 		    } elseif ($format == 'vrstcp') {
1297 1297
 			$buffer = @socket_read($r, 6000);
1298 1298
 		    } else {
1299
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1299
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1300 1300
 		    }
1301 1301
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1302 1302
 		    //echo $buffer."\n";
@@ -1305,8 +1305,8 @@  discard block
 block discarded – undo
1305 1305
 		    $error = false;
1306 1306
 		    //$SI::del();
1307 1307
 		    if ($format == 'vrstcp') {
1308
-			$buffer = explode('},{',$buffer);
1309
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1308
+			$buffer = explode('},{', $buffer);
1309
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1310 1310
 		    // SBS format is CSV format
1311 1311
 		    if ($buffer !== FALSE && $buffer != '') {
1312 1312
 			$tt[$format] = 0;
@@ -1340,13 +1340,13 @@  discard block
 block discarded – undo
1340 1340
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1341 1341
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1342 1342
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1343
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1343
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1344 1344
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1345 1345
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1346 1346
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1347 1347
 
1348 1348
 			    if (isset($ais_data['timestamp'])) {
1349
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1349
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1350 1350
 			    } else {
1351 1351
 				$data['datetime'] = date('Y-m-d H:i:s');
1352 1352
 			    }
@@ -1357,10 +1357,10 @@  discard block
 block discarded – undo
1357 1357
                         } elseif ($format == 'flightgearsp') {
1358 1358
                     	    //echo $buffer."\n";
1359 1359
                     	    if (strlen($buffer) > 5) {
1360
-				$line = explode(',',$buffer);
1360
+				$line = explode(',', $buffer);
1361 1361
 				$data = array();
1362 1362
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1363
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1363
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1364 1364
 				$data['ident'] = $line[6];
1365 1365
 				$data['aircraft_name'] = $line[7];
1366 1366
 				$data['longitude'] = $line[1];
@@ -1377,16 +1377,16 @@  discard block
 block discarded – undo
1377 1377
                         } elseif ($format == 'acars') {
1378 1378
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1379 1379
 			    $ACARS->add(trim($buffer));
1380
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1380
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1381 1381
 			    $ACARS->deleteLiveAcarsData();
1382 1382
 			} elseif ($format == 'flightgearmp') {
1383
-			    if (substr($buffer,0,1) != '#') {
1383
+			    if (substr($buffer, 0, 1) != '#') {
1384 1384
 				$data = array();
1385 1385
 				//echo $buffer."\n";
1386
-				$line = explode(' ',$buffer);
1386
+				$line = explode(' ', $buffer);
1387 1387
 				if (count($line) == 11) {
1388
-				    $userserver = explode('@',$line[0]);
1389
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1388
+				    $userserver = explode('@', $line[0]);
1389
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1390 1390
 				    $data['ident'] = $userserver[0];
1391 1391
 				    $data['registration'] = $userserver[0];
1392 1392
 				    $data['latitude'] = $line[4];
@@ -1394,8 +1394,8 @@  discard block
 block discarded – undo
1394 1394
 				    $data['altitude'] = $line[6];
1395 1395
 				    $data['datetime'] = date('Y-m-d H:i:s');
1396 1396
 				    $aircraft_type = $line[10];
1397
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1398
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1397
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1398
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1399 1399
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1400 1400
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1401 1401
 				}
@@ -1404,8 +1404,8 @@  discard block
 block discarded – undo
1404 1404
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1405 1405
 			    die;
1406 1406
 			} elseif ($format == 'vrstcp') {
1407
-			    foreach($buffer as $all_data) {
1408
-				$line = json_decode('{'.$all_data.'}',true);
1407
+			    foreach ($buffer as $all_data) {
1408
+				$line = json_decode('{'.$all_data.'}', true);
1409 1409
 				$data = array();
1410 1410
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1411 1411
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1431,16 +1431,16 @@  discard block
 block discarded – undo
1431 1431
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1432 1432
 				unset($data);
1433 1433
 			    }
1434
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1434
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1435 1435
 			    $line = explode("\t", $buffer);
1436
-			    for($k = 0; $k < count($line); $k=$k+2) {
1436
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1437 1437
 				$key = $line[$k];
1438
-			        $lined[$key] = $line[$k+1];
1438
+			        $lined[$key] = $line[$k + 1];
1439 1439
 			    }
1440 1440
     			    if (count($lined) > 3) {
1441 1441
     				$data['hex'] = $lined['hexid'];
1442 1442
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1443
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1443
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1444 1444
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1445 1445
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1446 1446
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1459,22 +1459,22 @@  discard block
 block discarded – undo
1459 1459
     			    } else $error = true;
1460 1460
 			} elseif ($format == 'aprs' && $use_aprs) {
1461 1461
 			    if ($aprs_connect == 0) {
1462
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1462
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1463 1463
 				$aprs_connect = 1;
1464 1464
 			    }
1465 1465
 			    
1466
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1466
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1467 1467
 				$aprs_last_tx = time();
1468 1468
 				$data_aprs = "# Keep alive";
1469
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1469
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1470 1470
 			    }
1471 1471
 			    
1472 1472
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1473 1473
 			    //echo 'APRS data : '.$buffer."\n";
1474
-			    $buffer = str_replace('APRS <- ','',$buffer);
1475
-			    $buffer = str_replace('APRS -> ','',$buffer);
1474
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1475
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1476 1476
 			    //echo $buffer."\n";
1477
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1477
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1478 1478
 				$line = $APRS->parse($buffer);
1479 1479
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1480 1480
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1489,7 +1489,7 @@  discard block
 block discarded – undo
1489 1489
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1490 1490
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1491 1491
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1492
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1492
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1493 1493
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1494 1494
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1495 1495
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1571,29 +1571,29 @@  discard block
 block discarded – undo
1571 1571
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1572 1572
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1573 1573
 					$Source->deleteOldLocationByType('gs');
1574
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1575
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1574
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1575
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1576 1576
 					} else {
1577
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1577
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1578 1578
 					}
1579 1579
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1580 1580
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1581 1581
 					if ($globalDebug) echo '# Weather Station added'."\n";
1582 1582
 					$Source->deleteOldLocationByType('wx');
1583 1583
 					$weather_data = json_encode($line);
1584
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1585
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1584
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1585
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1586 1586
 					} else {
1587
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1587
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1588 1588
 					}
1589 1589
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1590 1590
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1591 1591
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1592 1592
 					$Source->deleteOldLocationByType('lightning');
1593
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1594
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1593
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1594
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1595 1595
 					} else {
1596
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1596
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1597 1597
 					}
1598 1598
 				    } elseif ($globalDebug) {
1599 1599
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1602,7 +1602,7 @@  discard block
 block discarded – undo
1602 1602
 				    unset($data);
1603 1603
 				}
1604 1604
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1605
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1605
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1606 1606
 				}
1607 1607
 				/*
1608 1608
 				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')) {
@@ -1611,7 +1611,7 @@  discard block
 block discarded – undo
1611 1611
 				*/
1612 1612
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1613 1613
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1614
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1614
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1615 1615
 					$Source->deleteOldLocationByType('lightning');
1616 1616
 					$Source->deleteOldLocationByType('wx');
1617 1617
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1696,7 +1696,7 @@  discard block
 block discarded – undo
1696 1696
 				connect_all($sourceee);
1697 1697
 				$sourceee = array();
1698 1698
 				//connect_all($globalSources);
1699
-				$tt[$format]=0;
1699
+				$tt[$format] = 0;
1700 1700
 				break;
1701 1701
 			    }
1702 1702
 			}
@@ -1705,14 +1705,14 @@  discard block
 block discarded – undo
1705 1705
 	    } else {
1706 1706
 		$error = socket_strerror(socket_last_error());
1707 1707
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1708
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1708
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1709 1709
 			if (isset($globalDebug)) echo "Restarting...\n";
1710 1710
 			// Restart the script if possible
1711 1711
 			if (is_array($sockets)) {
1712 1712
 			    if ($globalDebug) echo "Shutdown all sockets...";
1713 1713
 			    
1714 1714
 			    foreach ($sockets as $sock) {
1715
-				@socket_shutdown($sock,2);
1715
+				@socket_shutdown($sock, 2);
1716 1716
 				@socket_close($sock);
1717 1717
 			    }
1718 1718
 			    
Please login to merge, or discard this patch.