Completed
Push — master ( c9fe9a...e66237 )
by Yannick
29:51
created
scripts/daemon-spotter.php 1 patch
Spacing   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
 	    die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
62
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
63 63
     }
64 64
 }
65 65
 
66
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
66
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70 70
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
71
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
72 72
     else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74 74
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
76 76
     else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115 115
     if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
116
+    $SI = new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
120 120
     $SI->connect();
121 121
 */
122
-} else $SI=new SpotterImport($Connection->db);
122
+} else $SI = new SpotterImport($Connection->db);
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
     $MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136
-$SBS=new SBS();
136
+$SBS = new SBS();
137 137
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
138
-	$ACARS=new ACARS($Connection->db,true);
139
-	$Source=new Source($Connection->db);
138
+	$ACARS = new ACARS($Connection->db, true);
139
+	$Source = new Source($Connection->db);
140 140
 }
141
-$Common=new Common();
141
+$Common = new Common();
142 142
 date_default_timezone_set('UTC');
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
146
+    pcntl_signal(SIGINT, function() {
147 147
         global $sockets;
148 148
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149 149
         die("Bye!\n");
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
 function connect_all($hosts) {
161 161
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
162
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
163 163
     $reset++;
164 164
     if ($globalDebug) echo 'Connect to all...'."\n";
165 165
     foreach ($hosts as $id => $value) {
@@ -167,33 +167,33 @@  discard block
 block discarded – undo
167 167
 	$udp = false;
168 168
 	$globalSources[$id]['last_exec'] = 0;
169 169
 	// Here we check type of source(s)
170
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
-            if (preg_match('/deltadb.txt$/i',$host)) {
170
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
+            if (preg_match('/deltadb.txt$/i', $host)) {
172 172
         	//$formats[$id] = 'deltadbtxt';
173 173
         	$globalSources[$id]['format'] = 'deltadbtxt';
174 174
         	//$last_exec['deltadbtxt'] = 0;
175 175
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
176
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
177 177
         	//$formats[$id] = 'vatsimtxt';
178 178
         	$globalSources[$id]['format'] = 'vatsimtxt';
179 179
         	//$last_exec['vatsimtxt'] = 0;
180 180
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
181
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
182 182
         	//$formats[$id] = 'aircraftlistjson';
183 183
         	$globalSources[$id]['format'] = 'aircraftlistjson';
184 184
         	//$last_exec['aircraftlistjson'] = 0;
185 185
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
186
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
187 187
         	//$formats[$id] = 'aircraftjson';
188 188
         	$globalSources[$id]['format'] = 'aircraftjson';
189 189
         	//$last_exec['aircraftlistjson'] = 0;
190 190
         	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
-    	    } else if (preg_match('/aircraft$/i',$host)) {
191
+    	    } else if (preg_match('/aircraft$/i', $host)) {
192 192
         	//$formats[$id] = 'planefinderclient';
193 193
         	$globalSources[$id]['format'] = 'planefinderclient';
194 194
         	//$last_exec['aircraftlistjson'] = 0;
195 195
         	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
-    	    } else if (preg_match('/opensky/i',$host)) {
196
+    	    } else if (preg_match('/opensky/i', $host)) {
197 197
         	//$formats[$id] = 'aircraftlistjson';
198 198
         	$globalSources[$id]['format'] = 'opensky';
199 199
         	//$last_exec['aircraftlistjson'] = 0;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         	    exit(0);
211 211
         	}
212 212
     	    */
213
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
213
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
214 214
         	//$formats[$id] = 'planeupdatefaa';
215 215
         	$globalSources[$id]['format'] = 'planeupdatefaa';
216 216
         	//$last_exec['planeupdatefaa'] = 0;
@@ -219,37 +219,37 @@  discard block
 block discarded – undo
219 219
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220 220
         	    exit(0);
221 221
         	}
222
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
222
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
223 223
         	//$formats[$id] = 'phpvmacars';
224 224
         	$globalSources[$id]['format'] = 'phpvmacars';
225 225
         	//$last_exec['phpvmacars'] = 0;
226 226
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
227
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
228 228
         	//$formats[$id] = 'phpvmacars';
229 229
         	$globalSources[$id]['format'] = 'vaos';
230 230
         	//$last_exec['phpvmacars'] = 0;
231 231
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
232
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
233 233
         	//$formats[$id] = 'phpvmacars';
234 234
         	$globalSources[$id]['format'] = 'vam';
235 235
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
-            } else if (preg_match('/whazzup/i',$host)) {
236
+            } else if (preg_match('/whazzup/i', $host)) {
237 237
         	//$formats[$id] = 'whazzup';
238 238
         	$globalSources[$id]['format'] = 'whazzup';
239 239
         	//$last_exec['whazzup'] = 0;
240 240
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
-            } else if (preg_match('/blitzortung/i',$host)) {
241
+            } else if (preg_match('/blitzortung/i', $host)) {
242 242
         	$globalSources[$id]['format'] = 'blitzortung';
243 243
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
-            } else if (preg_match('/airwhere/i',$host)) {
244
+            } else if (preg_match('/airwhere/i', $host)) {
245 245
         	$globalSources[$id]['format'] = 'airwhere';
246 246
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
-            } else if (preg_match('/recentpireps/i',$host)) {
247
+            } else if (preg_match('/recentpireps/i', $host)) {
248 248
         	//$formats[$id] = 'pirepsjson';
249 249
         	$globalSources[$id]['format'] = 'pirepsjson';
250 250
         	//$last_exec['pirepsjson'] = 0;
251 251
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
252
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
253 253
         	//$formats[$id] = 'fr24json';
254 254
         	$globalSources[$id]['format'] = 'fr24json';
255 255
         	//$last_exec['fr24json'] = 0;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259 259
         	    exit(0);
260 260
         	}
261
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
261
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
262 262
         	//$formats[$id] = 'fr24json';
263 263
         	$globalSources[$id]['format'] = 'myshiptracking';
264 264
         	//$last_exec['fr24json'] = 0;
@@ -268,22 +268,22 @@  discard block
 block discarded – undo
268 268
         	    exit(0);
269 269
         	}
270 270
             //} else if (preg_match('/10001/',$host)) {
271
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272 272
         	//$formats[$id] = 'tsv';
273 273
         	$globalSources[$id]['format'] = 'tsv';
274 274
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275 275
             }
276
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276
+        } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277 277
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
278
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
279 279
     		    if ($idf !== false) {
280 280
     			$httpfeeds[$id] = $idf;
281 281
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282 282
     		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283 283
     		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284 284
     		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
285
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
286
-	    $hostport = explode(':',$host);
285
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
286
+	    $hostport = explode(':', $host);
287 287
 	    if (isset($hostport[1])) {
288 288
 		$port = $hostport[1];
289 289
 		$hostn = $hostport[0];
@@ -293,20 +293,20 @@  discard block
 block discarded – undo
293 293
 	    }
294 294
 	    $Common = new Common();
295 295
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
296
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
296
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
297 297
     	    } else {
298 298
     		$udp = true;
299
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
299
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
300 300
 	    }
301 301
 	    if ($s) {
302 302
     	        $sockets[$id] = $s;
303 303
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
304
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
304
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
305 305
 			//$formats[$id] = 'aprs';
306 306
 			$globalSources[$id]['format'] = 'aprs';
307 307
 			//$aprs_connect = 0;
308 308
 			//$use_aprs = true;
309
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
309
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
310 310
 			$globalSources[$id]['format'] = 'vrstcp';
311 311
     		    } elseif ($port == '10001') {
312 312
         		//$formats[$id] = 'tsv';
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
349 349
 else $timeout = 20;
350 350
 $errno = '';
351
-$errstr='';
351
+$errstr = '';
352 352
 
353 353
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
354 354
 /* Initiate connections to all the hosts simultaneously */
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 //connect_all($globalSources);
357 357
 
358 358
 if (isset($globalProxy) && $globalProxy) {
359
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
359
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
360 360
 } else {
361 361
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
362 362
 }
@@ -386,16 +386,16 @@  discard block
 block discarded – undo
386 386
 
387 387
 if ($use_aprs) {
388 388
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
389
-	$APRS=new APRS();
389
+	$APRS = new APRS();
390 390
 	$aprs_connect = 0;
391 391
 	$aprs_keep = 120;
392 392
 	$aprs_last_tx = time();
393 393
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
394
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
394
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
395 395
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
396
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
396
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
397 397
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
398
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
398
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
399 399
 	if ($aprs_full) $aprs_filter = '';
400 400
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
401 401
 	else $aprs_pass = '-1';
@@ -409,12 +409,12 @@  discard block
 block discarded – undo
409 409
 sleep(1);
410 410
 if ($globalDebug) echo "SCAN MODE \n\n";
411 411
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
412
-$endtime = time()+$globalCronEnd;
412
+$endtime = time() + $globalCronEnd;
413 413
 $i = 1;
414 414
 $tt = array();
415 415
 // Delete all ATC
416 416
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
417
-	$ATC=new ATC($Connection->db);
417
+	$ATC = new ATC($Connection->db);
418 418
 }
419 419
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
420 420
 	$ATC->deleteAll();
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 while ($i > 0) {
425 425
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
426 426
 
427
-    if (!$globalDaemon) $i = $endtime-time();
427
+    if (!$globalDaemon) $i = $endtime - time();
428 428
     // Delete old ATC
429 429
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
430 430
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	}
439 439
 	if ($max < $globalMinFetch) {
440 440
 	    if ($globalDebug) echo 'Sleeping...'."\n";
441
-	    sleep($globalMinFetch-$max+2);
441
+	    sleep($globalMinFetch - $max + 2);
442 442
 	}
443 443
     }
444 444
 
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
             //$buffer = $Common->getData($hosts[$id]);
494 494
             $buffer = $Common->getData($value['host']);
495 495
             if ($buffer != '') {
496
-                $all_data = json_decode($buffer,true);
496
+                $all_data = json_decode($buffer, true);
497 497
                 foreach ($all_data as $line) {
498 498
                     $data = array();
499
-                    $data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
499
+                    $data['datetime'] = date('Y-m-d H:i:s', $line['uti']);
500 500
                     $data['hex'] = $line['hex']; // hex
501 501
                     $data['ident'] = $line['fli']; // ident
502 502
                     $data['altitude'] = $line['alt']; // altitude
@@ -531,11 +531,11 @@  discard block
 block discarded – undo
531 531
 	    )
532 532
 	) {
533 533
 	    date_default_timezone_set('CET');
534
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
534
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
535 535
 	    date_default_timezone_set('UTC');
536 536
 	    if ($buffer != '') $reset = 0;
537
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
538
-	    $buffer = explode('\n',$buffer);
537
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
538
+	    $buffer = explode('\n', $buffer);
539 539
 	    foreach ($buffer as $line) {
540 540
 		if ($line != '') {
541 541
 		    //echo "'".$line."'\n";
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 		    $ais_data = $AIS->parse_line(trim($line));
544 544
 		    $data = array();
545 545
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
546
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
546
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
547 547
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
548 548
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
549 549
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
556 556
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
557 557
 		    if (isset($ais_data['timestamp'])) {
558
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
558
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
559 559
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
560 560
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
561 561
 			    $add = true;
@@ -578,21 +578,21 @@  discard block
 block discarded – undo
578 578
 	    $w = $e = null;
579 579
 	    
580 580
 	    if (isset($arr[$id])) {
581
-		$nn = stream_select($arr,$w,$e,$timeout);
581
+		$nn = stream_select($arr, $w, $e, $timeout);
582 582
 		if ($nn > 0) {
583 583
 		    foreach ($httpfeeds as $feed) {
584
-			$buffer = stream_get_line($feed,2000,"\n");
584
+			$buffer = stream_get_line($feed, 2000, "\n");
585 585
 			if ($buffer === FALSE) {
586 586
 			    connect_all($globalSources);
587 587
 			}
588
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
589
-			$buffer = explode('\n',$buffer);
588
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
589
+			$buffer = explode('\n', $buffer);
590 590
 			foreach ($buffer as $line) {
591 591
 			    if ($line != '') {
592 592
 				$ais_data = $AIS->parse_line(trim($line));
593 593
 				$data = array();
594 594
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
595
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
595
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
596 596
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
597 597
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
598 598
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -604,9 +604,9 @@  discard block
 block discarded – undo
604 604
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
605 605
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
606 606
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
607
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
607
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
608 608
 				if (isset($ais_data['timestamp'])) {
609
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
609
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
610 610
 				} else {
611 611
 				    $data['datetime'] = date('Y-m-d H:i:s');
612 612
 				}
@@ -638,10 +638,10 @@  discard block
 block discarded – undo
638 638
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
639 639
 	    )
640 640
 	) {
641
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
641
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
642 642
 	    if ($buffer != '') {
643 643
 		//echo $buffer;
644
-		$all_data = json_decode($buffer,true);
644
+		$all_data = json_decode($buffer, true);
645 645
 		//print_r($all_data);
646 646
 		if (isset($all_data[0]['DATA'])) {
647 647
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 			    $data['ident'] = $line['NAME'];
651 651
 			    $data['mmsi'] = $line['MMSI'];
652 652
 			    if (strlen($data['mmsi']) > 9) {
653
-				$data['mmsi'] = substr($data['mmsi'],-9);
653
+				$data['mmsi'] = substr($data['mmsi'], -9);
654 654
 			    }
655 655
 			    $data['speed'] = $line['SOG'];
656 656
 			    $data['heading'] = $line['COG'];
@@ -660,8 +660,8 @@  discard block
 block discarded – undo
660 660
 			    //$data['type_id'] = $line['TYPE'];
661 661
 			    $data['imo'] = $line['IMO'];
662 662
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
663
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
664
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
663
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
664
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
665 665
 			    $data['format_source'] = 'myshiptracking';
666 666
 			    $data['id_source'] = $id_source;
667 667
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -678,16 +678,16 @@  discard block
 block discarded – undo
678 678
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
679 679
 	    )
680 680
 	) {
681
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
681
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
682 682
 	    if ($buffer != '') {
683
-		$all_data = json_decode($buffer,true);
683
+		$all_data = json_decode($buffer, true);
684 684
 		if (isset($all_data[0]['mmsi'])) {
685 685
 		    foreach ($all_data as $line) {
686 686
 			if ($line != '') {
687 687
 			    $data = array();
688 688
 			    $data['ident'] = $line['shipname'];
689 689
 			    $data['callsign'] = $line['callsign'];
690
-			    $data['mmsi'] = substr($line['mmsi'],-9);
690
+			    $data['mmsi'] = substr($line['mmsi'], -9);
691 691
 			    $data['speed'] = $line['sog'];
692 692
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
693 693
 			    $data['latitude'] = $line['latitude'];
@@ -714,14 +714,14 @@  discard block
 block discarded – undo
714 714
 	) {
715 715
 	    $buffer = $Common->getData($value['host']);
716 716
 	    if ($buffer != '') {
717
-		$all_data = json_decode($buffer,true);
717
+		$all_data = json_decode($buffer, true);
718 718
 		if (isset($all_data['features'][0]['id'])) {
719 719
 		    foreach ($all_data['features'] as $line) {
720 720
 			print_r($line);
721 721
 			$data = array();
722 722
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
723 723
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
724
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
724
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
725 725
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
726 726
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
727 727
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -748,31 +748,31 @@  discard block
 block discarded – undo
748 748
 	    )
749 749
 	) {
750 750
 	    if ($globalDebug) echo 'download...';
751
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
751
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
752 752
 	    if ($globalDebug) echo 'done !'."\n";
753 753
 	    // FIXME: Need more work
754 754
 	    if ($buffer != '') $reset = 0;
755
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
756
-	    $buffer = explode('\n',$buffer);
755
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
756
+	    $buffer = explode('\n', $buffer);
757 757
 	    foreach ($buffer as $line) {
758 758
 		if ($line != '') {
759 759
 		    $data = array();
760 760
 		    //echo $line."\n";
761
-		    $data['mmsi'] = (int)substr($line,0,9);
762
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
763
-		    $data['status_id'] = substr($line,21,2);
764
-		    $data['type_id'] = substr($line,24,3);
765
-		    $data['latitude'] = substr($line,29,9);
766
-		    $data['longitude'] = substr($line,41,9);
767
-		    $data['speed'] = round(substr($line,51,5));
761
+		    $data['mmsi'] = (int) substr($line, 0, 9);
762
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
763
+		    $data['status_id'] = substr($line, 21, 2);
764
+		    $data['type_id'] = substr($line, 24, 3);
765
+		    $data['latitude'] = substr($line, 29, 9);
766
+		    $data['longitude'] = substr($line, 41, 9);
767
+		    $data['speed'] = round(substr($line, 51, 5));
768 768
 		    //$data['course'] = substr($line,57,5);
769
-		    $data['heading'] = round(substr($line,63,3));
769
+		    $data['heading'] = round(substr($line, 63, 3));
770 770
 		    //$data['draft'] = substr($line,67,4);
771 771
 		    //$data['length'] = substr($line,72,3);
772 772
 		    //$data['beam'] = substr($line,76,2);
773
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
773
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
774 774
 		    //$data['callsign'] = trim(substr($line,100,7);
775
-		    $data['arrival_code'] = substr($line,108,20);
775
+		    $data['arrival_code'] = substr($line, 108, 20);
776 776
 		    //$data['etaDate'] = substr($line,129,5);
777 777
 		    //$data['etaTime'] = substr($line,135,5);
778 778
 		    $data['format_source'] = 'shipplotter';
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 	    )
793 793
 	) {
794 794
 	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
795
-		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
795
+		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl', 'post', array('submitlogin' => 'Login', 'email' => $globalSailaway['email'], 'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'), '', '', '', '', '', false, false, true);
796 796
 		//echo $authsailaway;
797 797
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
798 798
 		if (isset($setcookie[1][0])) {
@@ -801,18 +801,18 @@  discard block
 block discarded – undo
801 801
 	    }
802 802
 
803 803
 	    if ($globalDebug) echo '! Download... ';
804
-	    for ($i =0; $i <= 1; $i++) {
804
+	    for ($i = 0; $i <= 1; $i++) {
805 805
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
806 806
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
807 807
 	    if ($globalDebug) echo 'done'."\n";
808 808
 	    if ($buffer != '') {
809
-		$all_data = json_decode($buffer,true);
809
+		$all_data = json_decode($buffer, true);
810 810
 		if (isset($all_data['missions'])) {
811 811
 			foreach ($all_data['missions'] as $mission) {
812 812
 				$mission_user = $mission['usrname'];
813
-				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
814
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
815
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
813
+				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']));
814
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
815
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie);
816 816
 					else $racebuffer = '';
817 817
 					$bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
818 818
 				} else {
@@ -820,19 +820,19 @@  discard block
 block discarded – undo
820 820
 					$racebuffer = '';
821 821
 				}
822 822
 				if ($racebuffer != '') {
823
-					$race_data = json_decode($racebuffer,true);
823
+					$race_data = json_decode($racebuffer, true);
824 824
 					//print_r($race_data);
825 825
 					unset($racebuffer);
826 826
 					if (isset($race_data['mission'])) {
827 827
 					    $datar = array();
828 828
 					    $datar['id'] = $mission['misnr'];
829 829
 					    $datar['desc'] = $race_data['mission']['misdescr'];
830
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
831
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
830
+					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname'])));
831
+					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle'])));
832 832
 					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
833 833
 					    $markers = array();
834 834
 					    foreach ($race_data['mission']['course'] as $course) {
835
-						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
835
+						$markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']);
836 836
 					    }
837 837
 					    $datar['markers'] = json_encode($markers);
838 838
 					    //print_r($datar);
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 					}
841 841
 				}
842 842
 				if ($bufferm != '') {
843
-					$mission_data = json_decode($bufferm,true);
843
+					$mission_data = json_decode($bufferm, true);
844 844
 					unset($bufferm);
845 845
 					if (isset($mission_data['leaderboard'][0]['results'])) {
846 846
 						foreach ($mission_data['leaderboard'][0]['results'] as $sail) {
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 								//$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr'];
854 854
 								$data['id'] = $sail['misnr'].'-'.$sail['usrnr'];
855 855
 								$data['datetime'] = date('Y-m-d H:i:s');
856
-								$data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart']));
856
+								$data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart']));
857 857
 								$data['last_update'] = date('Y-m-d H:i:s');
858 858
 								$data['status'] = $sail['status'];
859 859
 								$data['type'] = $sail['btptype'];
@@ -864,16 +864,16 @@  discard block
 block discarded – undo
864 864
 									$data['longitude'] = $pos['longitude'];
865 865
 								}
866 866
 								if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') {
867
-									$resultdescr = explode(',',$sail['resultdescr']);
867
+									$resultdescr = explode(',', $sail['resultdescr']);
868 868
 									if (count($resultdescr) > 2) {
869
-										$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2);
870
-										$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1]));
869
+										$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2);
870
+										$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1]));
871 871
 										if (isset($resultdescr[3])) {
872
-											$data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3);
872
+											$data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3);
873 873
 										}
874 874
 									}
875 875
 								}
876
-								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
876
+								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
877 877
 								$data['captain_id'] = $sail['usrnr'];
878 878
 								$data['captain_name'] = $sail['usrname'];
879 879
 								$data['race_id'] = $sail['misnr'];
@@ -921,8 +921,8 @@  discard block
 block discarded – undo
921 921
 	) {
922 922
 	    //$buffer = $Common->getData($hosts[$id]);
923 923
 	    $buffer = $Common->getData($value['host']);
924
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
925
-	    $buffer = explode('\n',$buffer);
924
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
925
+	    $buffer = explode('\n', $buffer);
926 926
 	    $reset = 0;
927 927
 	    foreach ($buffer as $line) {
928 928
     		if ($line != '') {
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
934 934
 			$data['pilot_id'] = $line[1];
935 935
 			$data['pilot_name'] = $line[2];
936
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
936
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
937 937
 			$data['ident'] = $line[0]; // ident
938 938
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
939 939
 			$data['speed'] = $line[8]; // speed
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
950 950
 			//if (isset($line[37])) $data['last_update'] = $line[37];
951 951
 		        $data['departure_airport_icao'] = $line[11];
952
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
952
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
953 953
 		        $data['arrival_airport_icao'] = $line[13];
954 954
 			$data['frequency'] = $line[4];
955 955
 			$data['type'] = $line[18];
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
     			$data['id_source'] = $id_source;
959 959
 	    		//$data['arrival_airport_time'] = ;
960 960
 	    		if ($line[9] != '') {
961
-	    		    $aircraft_data = explode('/',$line[9]);
961
+	    		    $aircraft_data = explode('/', $line[9]);
962 962
 	    		    if (isset($aircraft_data[1])) {
963 963
 	    			$data['aircraft_icao'] = $aircraft_data[1];
964 964
 	    		    }
@@ -973,9 +973,9 @@  discard block
 block discarded – undo
973 973
     			if ($line[3] === 'PILOT') $SI->add($data);
974 974
 			elseif ($line[3] === 'ATC') {
975 975
 				//print_r($data);
976
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
977
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
978
-				$typec = substr($data['ident'],-3);
976
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
977
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
978
+				$typec = substr($data['ident'], -3);
979 979
 				if ($typec === 'APP') $data['type'] = 'Approach';
980 980
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
981 981
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -987,8 +987,8 @@  discard block
 block discarded – undo
987 987
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
988 988
 				if (!isset($data['source_name'])) $data['source_name'] = '';
989 989
 				if (isset($ATC)) {
990
-					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']);
991
-					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']);
990
+					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']);
991
+					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']);
992 992
 				}
993 993
 			}
994 994
     			unset($data);
@@ -1004,24 +1004,24 @@  discard block
 block discarded – undo
1004 1004
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1005 1005
     	    )
1006 1006
     	) {
1007
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1007
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
1008 1008
 	    if ($buffer != '') {
1009 1009
 		$all_data = simplexml_load_string($buffer);
1010
-		foreach($all_data->children() as $childdata) {
1010
+		foreach ($all_data->children() as $childdata) {
1011 1011
 			$data = array();
1012 1012
 			$line = $childdata;
1013 1013
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
1014
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
1015
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1016
-			$data['latitude'] = (float)$line['pktLatitude'];
1017
-			$data['longitude'] = (float)$line['pktLongitude'];
1018
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1019
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1020
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1014
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
1015
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
1016
+			$data['latitude'] = (float) $line['pktLatitude'];
1017
+			$data['longitude'] = (float) $line['pktLongitude'];
1018
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
1019
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
1020
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
1021 1021
 			$data['altitude_relative'] = 'AMSL';
1022
-			$data['pilot_id'] = (int)$line['pktPilotID'];
1022
+			$data['pilot_id'] = (int) $line['pktPilotID'];
1023 1023
 			$data['aircraft_icao'] = 'PARAGLIDER';
1024
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1024
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1025 1025
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1026 1026
 			$data['format_source'] = $value['format'];
1027 1027
 			$SI->add($data);
@@ -1029,22 +1029,22 @@  discard block
 block discarded – undo
1029 1029
 		}
1030 1030
 	    }
1031 1031
 	    $Source->deleteOldLocationByType('gs');
1032
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1032
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
1033 1033
 	    if ($buffer != '') {
1034 1034
 		$all_data = simplexml_load_string($buffer);
1035
-		foreach($all_data->children() as $childdata) {
1035
+		foreach ($all_data->children() as $childdata) {
1036 1036
 			$data = array();
1037 1037
 			$line = $childdata;
1038
-			$data['id'] = (int)$line['gsID'];
1039
-			$data['latitude'] = (float)$line['gsLatitude'];
1040
-			$data['longitude'] = (float)$line['gsLongitude'];
1041
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
1038
+			$data['id'] = (int) $line['gsID'];
1039
+			$data['latitude'] = (float) $line['gsLatitude'];
1040
+			$data['longitude'] = (float) $line['gsLongitude'];
1041
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
1042 1042
 			$data['altitude_relative'] = 'AMSL';
1043
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
1043
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
1044 1044
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
1045
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1045
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1046 1046
 			} else {
1047
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1047
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1048 1048
 			}
1049 1049
 			unset($data);
1050 1050
 		}
@@ -1062,9 +1062,9 @@  discard block
 block discarded – undo
1062 1062
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1063 1063
 	    )
1064 1064
 	) {
1065
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1065
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1066 1066
 	    if ($buffer != '') {
1067
-	        $all_data = json_decode($buffer,true);
1067
+	        $all_data = json_decode($buffer, true);
1068 1068
 		if (isset($all_data['acList'])) {
1069 1069
 		    $reset = 0;
1070 1070
 		    foreach ($all_data['acList'] as $line) {
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1081 1081
 			$data['emergency'] = ''; // emergency
1082 1082
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1083
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1083
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1084 1084
 			else $data['datetime'] = date('Y-m-d H:i:s');
1085 1085
 			//$data['datetime'] = date('Y-m-d H:i:s');
1086 1086
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1106 1106
 			$data['squawk'] = $line['squawk']; // squawk
1107 1107
 			$data['emergency'] = ''; // emergency
1108
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1108
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1109 1109
 			else $data['datetime'] = date('Y-m-d H:i:s');
1110 1110
 			$data['format_source'] = 'aircraftlistjson';
1111 1111
 			$data['id_source'] = $id_source;
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
     	    )
1127 1127
     	) {
1128 1128
 	    $buffer = $Common->getData($value['host']);
1129
-	    $all_data = json_decode($buffer,true);
1129
+	    $all_data = json_decode($buffer, true);
1130 1130
 	    if (isset($all_data['planes'])) {
1131 1131
 		$reset = 0;
1132 1132
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1143,12 +1143,12 @@  discard block
 block discarded – undo
1143 1143
 		    $data['emergency'] = ''; // emergency
1144 1144
 		    $data['registration'] = $line[2];
1145 1145
 		    $data['aircraft_icao'] = $line[0];
1146
-		    $deparr = explode('-',$line[1]);
1146
+		    $deparr = explode('-', $line[1]);
1147 1147
 		    if (count($deparr) === 2) {
1148 1148
 			$data['departure_airport_icao'] = $deparr[0];
1149 1149
 			$data['arrival_airport_icao'] = $deparr[1];
1150 1150
 		    }
1151
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1151
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1152 1152
 	    	    $data['format_source'] = 'planeupdatefaa';
1153 1153
     		    $data['id_source'] = $id_source;
1154 1154
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 	    )
1167 1167
 	) {
1168 1168
 	    $buffer = $Common->getData($value['host']);
1169
-	    $all_data = json_decode($buffer,true);
1169
+	    $all_data = json_decode($buffer, true);
1170 1170
 	    if (isset($all_data['states'])) {
1171 1171
 		$reset = 0;
1172 1172
 		foreach ($all_data['states'] as $key => $line) {
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
 		    //$data['emergency'] = ''; // emergency
1184 1184
 		    //$data['registration'] = $line[2];
1185 1185
 		    //$data['aircraft_icao'] = $line[0];
1186
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1186
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1187 1187
 		    $data['format_source'] = 'opensky';
1188 1188
 		    $data['id_source'] = $id_source;
1189 1189
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1200,8 +1200,8 @@  discard block
 block discarded – undo
1200 1200
 	    )
1201 1201
 	) {
1202 1202
 	    $buffer = $Common->getData($value['host']);
1203
-	    $all_data = json_decode($buffer,true);
1204
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1203
+	    $all_data = json_decode($buffer, true);
1204
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1205 1205
 		$reset = 0;
1206 1206
 		foreach ($all_data['aircraft'] as $key => $line) {
1207 1207
 		    $data = array();
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
 	    )
1240 1240
 	) {
1241 1241
 	    $buffer = $Common->getData($value['host']);
1242
-	    $all_data = json_decode($buffer,true);
1242
+	    $all_data = json_decode($buffer, true);
1243 1243
 	    if (isset($all_data['aircraft'])) {
1244 1244
 		$reset = 0;
1245 1245
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
 		    //$data['emergency'] = ''; // emergency
1257 1257
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1258 1258
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1259
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1259
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1260 1260
 		    $data['format_source'] = 'planefinderclient';
1261 1261
 		    $data['id_source'] = $id_source;
1262 1262
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
 	) {
1276 1276
 	    //$buffer = $Common->getData($hosts[$id]);
1277 1277
 	    $buffer = $Common->getData($value['host']);
1278
-	    $all_data = json_decode($buffer,true);
1278
+	    $all_data = json_decode($buffer, true);
1279 1279
 	    if (!empty($all_data)) $reset = 0;
1280 1280
 	    foreach ($all_data as $key => $line) {
1281 1281
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1313,11 +1313,11 @@  discard block
 block discarded – undo
1313 1313
 	    )
1314 1314
 	) {
1315 1315
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1316
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1316
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1317 1317
 	    //echo $buffer;
1318
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1319
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1320
-	    $all_data = json_decode($buffer,true);
1318
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1319
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1320
+	    $all_data = json_decode($buffer, true);
1321 1321
 	    if (json_last_error() != JSON_ERROR_NONE) {
1322 1322
 		die(json_last_error_msg());
1323 1323
 	    }
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
 			//$data['departure_airport_iata'] = $line[11];
1341 1341
 			//$data['arrival_airport_iata'] = $line[12];
1342 1342
 	    		//$data['emergency'] = ''; // emergency
1343
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1343
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1344 1344
 	    		$data['format_source'] = 'radarvirtueljson';
1345 1345
     			$data['id_source'] = $id_source;
1346 1346
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1361,14 +1361,14 @@  discard block
 block discarded – undo
1361 1361
 	) {
1362 1362
 	    //$buffer = $Common->getData($hosts[$id]);
1363 1363
 	    $buffer = $Common->getData($value['host'].'?'.time());
1364
-	    $all_data = json_decode(utf8_encode($buffer),true);
1364
+	    $all_data = json_decode(utf8_encode($buffer), true);
1365 1365
 	    
1366 1366
 	    if (isset($all_data['pireps'])) {
1367 1367
 		$reset = 0;
1368 1368
 	        foreach ($all_data['pireps'] as $line) {
1369 1369
 		    $data = array();
1370 1370
 		    $data['id'] = $line['id'];
1371
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1371
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1372 1372
 		    $data['ident'] = $line['callsign']; // ident
1373 1373
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1374 1374
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1398,9 +1398,9 @@  discard block
 block discarded – undo
1398 1398
 			$SI->add($data);
1399 1399
 		    //    print_r($data);
1400 1400
     		    } elseif ($line['icon'] === 'ct') {
1401
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1402
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1403
-			$typec = substr($data['ident'],-3);
1401
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1402
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1403
+			$typec = substr($data['ident'], -3);
1404 1404
 			$data['type'] = '';
1405 1405
 			if ($typec === 'APP') $data['type'] = 'Approach';
1406 1406
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1412 1412
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1413 1413
 			else $data['type'] = 'Observer';
1414
-			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']);
1414
+			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']);
1415 1415
 		    }
1416 1416
 		    unset($data);
1417 1417
 		}
@@ -1428,14 +1428,14 @@  discard block
 block discarded – undo
1428 1428
 	    //$buffer = $Common->getData($hosts[$id]);
1429 1429
 	    if ($globalDebug) echo 'Get Data...'."\n";
1430 1430
 	    $buffer = $Common->getData($value['host']);
1431
-	    $all_data = json_decode($buffer,true);
1431
+	    $all_data = json_decode($buffer, true);
1432 1432
 	    if ($buffer != '' && is_array($all_data)) {
1433 1433
 		$reset = 0;
1434 1434
 		foreach ($all_data as $line) {
1435 1435
 	    	    $data = array();
1436 1436
 	    	    //$data['id'] = $line['id']; // id not usable
1437 1437
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1438
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1438
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1439 1439
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1440 1440
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1441 1441
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1450,7 +1450,7 @@  discard block
 block discarded – undo
1450 1450
 	    	    //$data['datetime'] = $line['lastupdate'];
1451 1451
 	    	    //$data['last_update'] = $line['lastupdate'];
1452 1452
 	    	    if (isset($value['timezone'])) {
1453
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1453
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1454 1454
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1455 1455
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1456 1456
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1466,14 +1466,14 @@  discard block
 block discarded – undo
1466 1466
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1467 1467
 		    if (isset($line['aircraftname'])) {
1468 1468
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1469
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1470
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1469
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1470
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1471 1471
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1472 1472
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1473 1473
 	    		else {
1474
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1475
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1476
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1474
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1475
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1476
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1477 1477
 	    		}
1478 1478
 	    	    }
1479 1479
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1498,7 +1498,7 @@  discard block
 block discarded – undo
1498 1498
 	    //$buffer = $Common->getData($hosts[$id]);
1499 1499
 	    if ($globalDebug) echo 'Get Data...'."\n";
1500 1500
 	    $buffer = $Common->getData($value['host']);
1501
-	    $all_data = json_decode($buffer,true);
1501
+	    $all_data = json_decode($buffer, true);
1502 1502
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1503 1503
 		$reset = 0;
1504 1504
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1509,7 +1509,7 @@  discard block
 block discarded – undo
1509 1509
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1510 1510
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1511 1511
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1512
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1512
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1513 1513
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1514 1514
 	    	    $data['altitude'] = $line['altitude']; // altitude
1515 1515
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
 	    	    //$data['squawk'] = ''; // squawk
1521 1521
 	    	    //$data['emergency'] = ''; // emergency
1522 1522
 	    	    if (isset($value['timezone'])) {
1523
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1523
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1524 1524
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1525 1525
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1526 1526
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1556,14 +1556,14 @@  discard block
 block discarded – undo
1556 1556
 	    //$buffer = $Common->getData($hosts[$id]);
1557 1557
 	    if ($globalDebug) echo 'Get Data...'."\n";
1558 1558
 	    $buffer = $Common->getData($value['host']);
1559
-	    $all_data = json_decode($buffer,true);
1559
+	    $all_data = json_decode($buffer, true);
1560 1560
 	    if ($buffer != '' && is_array($all_data)) {
1561 1561
 		$reset = 0;
1562 1562
 		foreach ($all_data as $line) {
1563 1563
 	    	    $data = array();
1564 1564
 	    	    //$data['id'] = $line['id']; // id not usable
1565 1565
 	    	    $data['id'] = trim($line['flight_id']);
1566
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1566
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1567 1567
 	    	    $data['pilot_name'] = $line['pilot_name'];
1568 1568
 	    	    $data['pilot_id'] = $line['pilot_id'];
1569 1569
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1607,24 +1607,24 @@  discard block
 block discarded – undo
1607 1607
 	    //$buffer = $Common->getData($hosts[$id]);
1608 1608
 	    if ($globalDebug) echo 'Get Data...'."\n";
1609 1609
 	    $buffer = $Common->getData($value['host']);
1610
-	    $all_data = json_decode($buffer,true);
1610
+	    $all_data = json_decode($buffer, true);
1611 1611
 	    if ($buffer != '') {
1612 1612
 		$Source->deleteLocationBySource('blitzortung');
1613
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1614
-		$buffer = explode('\n',$buffer);
1613
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1614
+		$buffer = explode('\n', $buffer);
1615 1615
 		foreach ($buffer as $buffer_line) {
1616
-		    $line = json_decode($buffer_line,true);
1616
+		    $line = json_decode($buffer_line, true);
1617 1617
 		    if (isset($line['time'])) {
1618 1618
 			$data = array();
1619 1619
 			$data['altitude'] = $line['alt']; // altitude
1620 1620
 			$data['latitude'] = $line['lat']; // lat
1621 1621
 			$data['longitude'] = $line['lon']; // long
1622
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1622
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1623 1623
 			$data['id_source'] = $id_source;
1624 1624
 			$data['format_source'] = 'blitzortung';
1625 1625
 			$SI->add($data);
1626 1626
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1627
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1627
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1628 1628
 			unset($data);
1629 1629
 		    }
1630 1630
 		}
@@ -1636,15 +1636,15 @@  discard block
 block discarded – undo
1636 1636
         $arr = $httpfeeds;
1637 1637
         $w = $e = null;
1638 1638
         if (isset($arr[$id])) {
1639
-            $nn = stream_select($arr,$w,$e,$timeout);
1639
+            $nn = stream_select($arr, $w, $e, $timeout);
1640 1640
             if ($nn > 0) {
1641 1641
                 foreach ($httpfeeds as $feed) {
1642
-                    $buffer = stream_get_line($feed,2000,"\n");
1642
+                    $buffer = stream_get_line($feed, 2000, "\n");
1643 1643
                     if ($buffer === FALSE) {
1644 1644
                         connect_all($globalSources);
1645 1645
                     }
1646
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1647
-                    $buffer = explode('\n',$buffer);
1646
+                    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1647
+                    $buffer = explode('\n', $buffer);
1648 1648
                     foreach ($buffer as $line) {
1649 1649
                         if ($line != '') {
1650 1650
                             $line = json_decode($line, true);
@@ -1684,11 +1684,11 @@  discard block
 block discarded – undo
1684 1684
 		    //$value = $formats[$nb];
1685 1685
 		    $format = $globalSources[$nb]['format'];
1686 1686
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1687
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1687
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1688 1688
 		    } elseif ($format === 'vrstcp') {
1689 1689
 			$buffer = @socket_read($r, 6000);
1690 1690
 		    } else {
1691
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1691
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1692 1692
 		    }
1693 1693
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1694 1694
 		    //echo $buffer."\n";
@@ -1698,8 +1698,8 @@  discard block
 block discarded – undo
1698 1698
 		    //$SI::del();
1699 1699
 		    if ($buffer !== FALSE) {
1700 1700
 			if ($format === 'vrstcp') {
1701
-			    $buffer = explode('},{',$buffer);
1702
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1701
+			    $buffer = explode('},{', $buffer);
1702
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1703 1703
 		    }
1704 1704
 		    // SBS format is CSV format
1705 1705
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
 			    $ais_data = $AIS->parse_line(trim($buffer));
1727 1727
 			    $data = array();
1728 1728
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1729
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1729
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1730 1730
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1731 1731
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1732 1732
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1737,13 +1737,13 @@  discard block
 block discarded – undo
1737 1737
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1738 1738
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1739 1739
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1740
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1740
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1741 1741
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1742 1742
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1743 1743
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1744 1744
 
1745 1745
 			    if (isset($ais_data['timestamp'])) {
1746
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1746
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1747 1747
 			    } else {
1748 1748
 				$data['datetime'] = date('Y-m-d H:i:s');
1749 1749
 			    }
@@ -1754,10 +1754,10 @@  discard block
 block discarded – undo
1754 1754
                         } elseif ($format === 'flightgearsp') {
1755 1755
                     	    //echo $buffer."\n";
1756 1756
                     	    if (strlen($buffer) > 5) {
1757
-				$line = explode(',',$buffer);
1757
+				$line = explode(',', $buffer);
1758 1758
 				$data = array();
1759 1759
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1760
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1760
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1761 1761
 				$data['ident'] = $line[6];
1762 1762
 				$data['aircraft_name'] = $line[7];
1763 1763
 				$data['longitude'] = $line[1];
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
                         } elseif ($format === 'acars') {
1775 1775
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1776 1776
 			    $ACARS->add(trim($buffer));
1777
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1777
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1778 1778
 			    $ACARS->deleteLiveAcarsData();
1779 1779
 			} elseif ($format === 'acarsjsonudp') {
1780 1780
 			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
@@ -1783,15 +1783,15 @@  discard block
 block discarded – undo
1783 1783
                                 $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1784 1784
                                 $ACARS->deleteLiveAcarsData();
1785 1785
                             }
1786
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1786
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1787 1787
 			} elseif ($format === 'flightgearmp') {
1788
-			    if (substr($buffer,0,1) != '#') {
1788
+			    if (substr($buffer, 0, 1) != '#') {
1789 1789
 				$data = array();
1790 1790
 				//echo $buffer."\n";
1791
-				$line = explode(' ',$buffer);
1791
+				$line = explode(' ', $buffer);
1792 1792
 				if (count($line) === 11) {
1793
-				    $userserver = explode('@',$line[0]);
1794
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1793
+				    $userserver = explode('@', $line[0]);
1794
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1795 1795
 				    $data['ident'] = $userserver[0];
1796 1796
 				    $data['registration'] = $userserver[0];
1797 1797
 				    $data['latitude'] = $line[4];
@@ -1799,8 +1799,8 @@  discard block
 block discarded – undo
1799 1799
 				    $data['altitude'] = $line[6];
1800 1800
 				    $data['datetime'] = date('Y-m-d H:i:s');
1801 1801
 				    $aircraft_type = $line[10];
1802
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1803
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1802
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1803
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1804 1804
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1805 1805
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1806 1806
 				}
@@ -1809,8 +1809,8 @@  discard block
 block discarded – undo
1809 1809
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1810 1810
 			    die;
1811 1811
 			} elseif ($format === 'vrstcp') {
1812
-			    foreach($buffer as $all_data) {
1813
-				$line = json_decode('{'.$all_data.'}',true);
1812
+			    foreach ($buffer as $all_data) {
1813
+				$line = json_decode('{'.$all_data.'}', true);
1814 1814
 				$data = array();
1815 1815
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1816 1816
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1836,16 +1836,16 @@  discard block
 block discarded – undo
1836 1836
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1837 1837
 				unset($data);
1838 1838
 			    }
1839
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1839
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1840 1840
 			    $line = explode("\t", $buffer);
1841
-			    for($k = 0; $k < count($line); $k=$k+2) {
1841
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1842 1842
 				$key = $line[$k];
1843
-			        $lined[$key] = $line[$k+1];
1843
+			        $lined[$key] = $line[$k + 1];
1844 1844
 			    }
1845 1845
     			    if (count($lined) > 3) {
1846 1846
     				$data['hex'] = $lined['hexid'];
1847 1847
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1848
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1848
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1849 1849
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1850 1850
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1851 1851
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1864,23 +1864,23 @@  discard block
 block discarded – undo
1864 1864
     			    } else $error = true;
1865 1865
 			} elseif ($format === 'aprs' && $use_aprs) {
1866 1866
 			    if ($aprs_connect === 0) {
1867
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1867
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1868 1868
 				$aprs_connect = 1;
1869 1869
 			    }
1870 1870
 			    
1871
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1871
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1872 1872
 				$aprs_last_tx = time();
1873 1873
 				$data_aprs = "# Keep alive";
1874
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1874
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1875 1875
 			    }
1876 1876
 			    
1877 1877
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1878 1878
 			    //echo 'APRS data : '.$buffer."\n";
1879
-			    $buffer = str_replace('APRS <- ','',$buffer);
1880
-			    $buffer = str_replace('APRS -> ','',$buffer);
1879
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1880
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1881 1881
 			    //echo $buffer."\n";
1882 1882
 			    date_default_timezone_set('UTC');
1883
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1883
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1884 1884
 				$line = $APRS->parse($buffer);
1885 1885
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1886 1886
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1895,7 +1895,7 @@  discard block
 block discarded – undo
1895 1895
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1896 1896
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1897 1897
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1898
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1898
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1899 1899
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1900 1900
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1901 1901
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1983,29 +1983,29 @@  discard block
 block discarded – undo
1983 1983
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1984 1984
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1985 1985
 					$Source->deleteOldLocationByType('gs');
1986
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1987
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1986
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1987
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1988 1988
 					} else {
1989
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1989
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1990 1990
 					}
1991 1991
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1992 1992
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1993 1993
 					if ($globalDebug) echo '# Weather Station added'."\n";
1994 1994
 					$Source->deleteOldLocationByType('wx');
1995 1995
 					$weather_data = json_encode($line);
1996
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1997
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1996
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1997
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1998 1998
 					} else {
1999
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1999
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2000 2000
 					}
2001 2001
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2002 2002
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2003 2003
 					if ($globalDebug) echo '☈ Lightning added'."\n";
2004 2004
 					$Source->deleteOldLocationByType('lightning');
2005
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
2006
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2005
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
2006
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2007 2007
 					} else {
2008
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2008
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2009 2009
 					}
2010 2010
 				    } elseif ($globalDebug) {
2011 2011
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -2014,7 +2014,7 @@  discard block
 block discarded – undo
2014 2014
 				    unset($data);
2015 2015
 				}
2016 2016
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2017
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2017
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
2018 2018
 				}
2019 2019
 				/*
2020 2020
 				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')) {
@@ -2023,7 +2023,7 @@  discard block
 block discarded – undo
2023 2023
 				*/
2024 2024
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2025 2025
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2026
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2026
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
2027 2027
 					$Source->deleteOldLocationByType('lightning');
2028 2028
 					$Source->deleteOldLocationByType('wx');
2029 2029
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2110,7 +2110,7 @@  discard block
 block discarded – undo
2110 2110
 				connect_all($sourceee);
2111 2111
 				$sourceee = array();
2112 2112
 				//connect_all($globalSources);
2113
-				$tt[$format]=0;
2113
+				$tt[$format] = 0;
2114 2114
 				break;
2115 2115
 			    } 
2116 2116
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2120,14 +2120,14 @@  discard block
 block discarded – undo
2120 2120
 	    } else {
2121 2121
 		$error = socket_strerror(socket_last_error());
2122 2122
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2123
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2123
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2124 2124
 			if (isset($globalDebug)) echo "Restarting...\n";
2125 2125
 			// Restart the script if possible
2126 2126
 			if (is_array($sockets)) {
2127 2127
 			    if ($globalDebug) echo "Shutdown all sockets...";
2128 2128
 			    
2129 2129
 			    foreach ($sockets as $sock) {
2130
-				@socket_shutdown($sock,2);
2130
+				@socket_shutdown($sock, 2);
2131 2131
 				@socket_close($sock);
2132 2132
 			    }
2133 2133
 			    
Please login to merge, or discard this patch.