Completed
Push — master ( 745612...a1100a )
by Yannick
36:13
created
scripts/daemon-spotter.php 1 patch
Spacing   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
 	    die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
62
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
63 63
     }
64 64
 }
65 65
 
66
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
66
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70 70
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
71
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
72 72
     else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74 74
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
76 76
     else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115 115
     if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
116
+    $SI = new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
120 120
     $SI->connect();
121 121
 */
122
-} else $SI=new SpotterImport($Connection->db);
122
+} else $SI = new SpotterImport($Connection->db);
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
     $MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136
-$SBS=new SBS();
136
+$SBS = new SBS();
137 137
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
138
-	$ACARS=new ACARS($Connection->db,true);
139
-	$Source=new Source($Connection->db);
138
+	$ACARS = new ACARS($Connection->db, true);
139
+	$Source = new Source($Connection->db);
140 140
 }
141
-$Common=new Common();
141
+$Common = new Common();
142 142
 date_default_timezone_set('UTC');
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
146
+    pcntl_signal(SIGINT, function() {
147 147
         global $sockets;
148 148
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149 149
         die("Bye!\n");
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
 function connect_all($hosts) {
161 161
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
162
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
163 163
     $reset++;
164 164
     if ($globalDebug) echo 'Connect to all...'."\n";
165 165
     foreach ($hosts as $id => $value) {
@@ -167,33 +167,33 @@  discard block
 block discarded – undo
167 167
 	$udp = false;
168 168
 	$globalSources[$id]['last_exec'] = 0;
169 169
 	// Here we check type of source(s)
170
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
-            if (preg_match('/deltadb.txt$/i',$host)) {
170
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
+            if (preg_match('/deltadb.txt$/i', $host)) {
172 172
         	//$formats[$id] = 'deltadbtxt';
173 173
         	$globalSources[$id]['format'] = 'deltadbtxt';
174 174
         	//$last_exec['deltadbtxt'] = 0;
175 175
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
176
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
177 177
         	//$formats[$id] = 'vatsimtxt';
178 178
         	$globalSources[$id]['format'] = 'vatsimtxt';
179 179
         	//$last_exec['vatsimtxt'] = 0;
180 180
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
181
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
182 182
         	//$formats[$id] = 'aircraftlistjson';
183 183
         	$globalSources[$id]['format'] = 'aircraftlistjson';
184 184
         	//$last_exec['aircraftlistjson'] = 0;
185 185
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
186
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
187 187
         	//$formats[$id] = 'aircraftjson';
188 188
         	$globalSources[$id]['format'] = 'aircraftjson';
189 189
         	//$last_exec['aircraftlistjson'] = 0;
190 190
         	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
-    	    } else if (preg_match('/aircraft$/i',$host)) {
191
+    	    } else if (preg_match('/aircraft$/i', $host)) {
192 192
         	//$formats[$id] = 'planefinderclient';
193 193
         	$globalSources[$id]['format'] = 'planefinderclient';
194 194
         	//$last_exec['aircraftlistjson'] = 0;
195 195
         	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
-    	    } else if (preg_match('/opensky/i',$host)) {
196
+    	    } else if (preg_match('/opensky/i', $host)) {
197 197
         	//$formats[$id] = 'aircraftlistjson';
198 198
         	$globalSources[$id]['format'] = 'opensky';
199 199
         	//$last_exec['aircraftlistjson'] = 0;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         	    exit(0);
211 211
         	}
212 212
     	    */
213
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
213
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
214 214
         	//$formats[$id] = 'planeupdatefaa';
215 215
         	$globalSources[$id]['format'] = 'planeupdatefaa';
216 216
         	//$last_exec['planeupdatefaa'] = 0;
@@ -219,37 +219,37 @@  discard block
 block discarded – undo
219 219
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220 220
         	    exit(0);
221 221
         	}
222
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
222
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
223 223
         	//$formats[$id] = 'phpvmacars';
224 224
         	$globalSources[$id]['format'] = 'phpvmacars';
225 225
         	//$last_exec['phpvmacars'] = 0;
226 226
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
227
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
228 228
         	//$formats[$id] = 'phpvmacars';
229 229
         	$globalSources[$id]['format'] = 'vaos';
230 230
         	//$last_exec['phpvmacars'] = 0;
231 231
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
232
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
233 233
         	//$formats[$id] = 'phpvmacars';
234 234
         	$globalSources[$id]['format'] = 'vam';
235 235
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
-            } else if (preg_match('/whazzup/i',$host)) {
236
+            } else if (preg_match('/whazzup/i', $host)) {
237 237
         	//$formats[$id] = 'whazzup';
238 238
         	$globalSources[$id]['format'] = 'whazzup';
239 239
         	//$last_exec['whazzup'] = 0;
240 240
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
-            } else if (preg_match('/blitzortung/i',$host)) {
241
+            } else if (preg_match('/blitzortung/i', $host)) {
242 242
         	$globalSources[$id]['format'] = 'blitzortung';
243 243
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
-            } else if (preg_match('/airwhere/i',$host)) {
244
+            } else if (preg_match('/airwhere/i', $host)) {
245 245
         	$globalSources[$id]['format'] = 'airwhere';
246 246
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
-            } else if (preg_match('/recentpireps/i',$host)) {
247
+            } else if (preg_match('/recentpireps/i', $host)) {
248 248
         	//$formats[$id] = 'pirepsjson';
249 249
         	$globalSources[$id]['format'] = 'pirepsjson';
250 250
         	//$last_exec['pirepsjson'] = 0;
251 251
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
252
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
253 253
         	//$formats[$id] = 'fr24json';
254 254
         	$globalSources[$id]['format'] = 'fr24json';
255 255
         	//$last_exec['fr24json'] = 0;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259 259
         	    exit(0);
260 260
         	}
261
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
261
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
262 262
         	//$formats[$id] = 'fr24json';
263 263
         	$globalSources[$id]['format'] = 'myshiptracking';
264 264
         	//$last_exec['fr24json'] = 0;
@@ -268,14 +268,14 @@  discard block
 block discarded – undo
268 268
         	    exit(0);
269 269
         	}
270 270
             //} else if (preg_match('/10001/',$host)) {
271
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272 272
         	//$formats[$id] = 'tsv';
273 273
         	$globalSources[$id]['format'] = 'tsv';
274 274
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275 275
             }
276
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276
+        } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277 277
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
278
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
279 279
     		    if ($idf !== false) {
280 280
     			$httpfeeds[$id] = $idf;
281 281
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
     		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284 284
     		elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n";
285 285
     		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
286
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
287
-	    $hostport = explode(':',$host);
286
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
287
+	    $hostport = explode(':', $host);
288 288
 	    if (isset($hostport[1])) {
289 289
 		$port = $hostport[1];
290 290
 		$hostn = $hostport[0];
@@ -294,20 +294,20 @@  discard block
 block discarded – undo
294 294
 	    }
295 295
 	    $Common = new Common();
296 296
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
297
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
297
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
298 298
     	    } else {
299 299
     		$udp = true;
300
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
300
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
301 301
 	    }
302 302
 	    if ($s) {
303 303
     	        $sockets[$id] = $s;
304 304
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
305
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
305
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
306 306
 			//$formats[$id] = 'aprs';
307 307
 			$globalSources[$id]['format'] = 'aprs';
308 308
 			//$aprs_connect = 0;
309 309
 			//$use_aprs = true;
310
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
310
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
311 311
 			$globalSources[$id]['format'] = 'vrstcp';
312 312
     		    } elseif ($port == '10001') {
313 313
         		//$formats[$id] = 'tsv';
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
350 350
 else $timeout = 20;
351 351
 $errno = '';
352
-$errstr='';
352
+$errstr = '';
353 353
 
354 354
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
355 355
 /* Initiate connections to all the hosts simultaneously */
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 //connect_all($globalSources);
358 358
 
359 359
 if (isset($globalProxy) && $globalProxy) {
360
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
360
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
361 361
 } else {
362 362
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
363 363
 }
@@ -387,16 +387,16 @@  discard block
 block discarded – undo
387 387
 
388 388
 if ($use_aprs) {
389 389
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
390
-	$APRS=new APRS();
390
+	$APRS = new APRS();
391 391
 	$aprs_connect = 0;
392 392
 	$aprs_keep = 120;
393 393
 	$aprs_last_tx = time();
394 394
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
395
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
395
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
396 396
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
397
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
397
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
398 398
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
399
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
399
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
400 400
 	if ($aprs_full) $aprs_filter = '';
401 401
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
402 402
 	else $aprs_pass = '-1';
@@ -410,12 +410,12 @@  discard block
 block discarded – undo
410 410
 sleep(1);
411 411
 if ($globalDebug) echo "SCAN MODE \n\n";
412 412
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
413
-$endtime = time()+$globalCronEnd;
413
+$endtime = time() + $globalCronEnd;
414 414
 $i = 1;
415 415
 $tt = array();
416 416
 // Delete all ATC
417 417
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
418
-	$ATC=new ATC($Connection->db);
418
+	$ATC = new ATC($Connection->db);
419 419
 }
420 420
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
421 421
 	$ATC->deleteAll();
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 while ($i > 0) {
426 426
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
427 427
 
428
-    if (!$globalDaemon) $i = $endtime-time();
428
+    if (!$globalDaemon) $i = $endtime - time();
429 429
     // Delete old ATC
430 430
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
431 431
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	}
440 440
 	if ($max < $globalMinFetch) {
441 441
 	    if ($globalDebug) echo 'Sleeping...'."\n";
442
-	    sleep($globalMinFetch-$max+2);
442
+	    sleep($globalMinFetch - $max + 2);
443 443
 	}
444 444
     }
445 445
 
@@ -494,10 +494,10 @@  discard block
 block discarded – undo
494 494
             //$buffer = $Common->getData($hosts[$id]);
495 495
             $buffer = $Common->getData($value['host']);
496 496
             if ($buffer != '') {
497
-                $all_data = json_decode($buffer,true);
497
+                $all_data = json_decode($buffer, true);
498 498
                 foreach ($all_data as $line) {
499 499
                     $data = array();
500
-                    $data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
500
+                    $data['datetime'] = date('Y-m-d H:i:s', $line['uti']);
501 501
                     $data['hex'] = $line['hex']; // hex
502 502
                     $data['ident'] = $line['fli']; // ident
503 503
                     $data['altitude'] = $line['alt']; // altitude
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
 	    )
533 533
 	) {
534 534
 	    date_default_timezone_set('CET');
535
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
535
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
536 536
 	    date_default_timezone_set('UTC');
537 537
 	    if ($buffer != '') $reset = 0;
538
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539
-	    $buffer = explode('\n',$buffer);
538
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
539
+	    $buffer = explode('\n', $buffer);
540 540
 	    foreach ($buffer as $line) {
541 541
 		if ($line != '') {
542 542
 		    //echo "'".$line."'\n";
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 		    $ais_data = $AIS->parse_line(trim($line));
545 545
 		    $data = array();
546 546
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
547
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
547
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
548 548
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
549 549
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
550 550
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
557 557
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
558 558
 		    if (isset($ais_data['timestamp'])) {
559
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
559
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
560 560
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
561 561
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
562 562
 			    $add = true;
@@ -579,21 +579,21 @@  discard block
 block discarded – undo
579 579
 	    $w = $e = null;
580 580
 	    
581 581
 	    if (isset($arr[$id])) {
582
-		$nn = stream_select($arr,$w,$e,$timeout);
582
+		$nn = stream_select($arr, $w, $e, $timeout);
583 583
 		if ($nn > 0) {
584 584
 		    foreach ($httpfeeds as $feed) {
585
-			$buffer = stream_get_line($feed,2000,"\n");
585
+			$buffer = stream_get_line($feed, 2000, "\n");
586 586
 			if ($buffer === FALSE) {
587 587
 			    connect_all($globalSources);
588 588
 			}
589
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
590
-			$buffer = explode('\n',$buffer);
589
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
590
+			$buffer = explode('\n', $buffer);
591 591
 			foreach ($buffer as $line) {
592 592
 			    if ($line != '') {
593 593
 				$ais_data = $AIS->parse_line(trim($line));
594 594
 				$data = array();
595 595
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
596
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
596
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
597 597
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
598 598
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
599 599
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -605,9 +605,9 @@  discard block
 block discarded – undo
605 605
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
606 606
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
607 607
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
608
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
608
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
609 609
 				if (isset($ais_data['timestamp'])) {
610
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
610
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
611 611
 				} else {
612 612
 				    $data['datetime'] = date('Y-m-d H:i:s');
613 613
 				}
@@ -639,10 +639,10 @@  discard block
 block discarded – undo
639 639
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
640 640
 	    )
641 641
 	) {
642
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
642
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
643 643
 	    if ($buffer != '') {
644 644
 		//echo $buffer;
645
-		$all_data = json_decode($buffer,true);
645
+		$all_data = json_decode($buffer, true);
646 646
 		//print_r($all_data);
647 647
 		if (isset($all_data[0]['DATA'])) {
648 648
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 			    $data['ident'] = $line['NAME'];
652 652
 			    $data['mmsi'] = $line['MMSI'];
653 653
 			    if (strlen($data['mmsi']) > 9) {
654
-				$data['mmsi'] = substr($data['mmsi'],-9);
654
+				$data['mmsi'] = substr($data['mmsi'], -9);
655 655
 			    }
656 656
 			    $data['speed'] = $line['SOG'];
657 657
 			    $data['heading'] = $line['COG'];
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
 			    //$data['type_id'] = $line['TYPE'];
662 662
 			    $data['imo'] = $line['IMO'];
663 663
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
664
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
665
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
664
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
665
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
666 666
 			    $data['format_source'] = 'myshiptracking';
667 667
 			    $data['id_source'] = $id_source;
668 668
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -679,16 +679,16 @@  discard block
 block discarded – undo
679 679
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
680 680
 	    )
681 681
 	) {
682
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
682
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
683 683
 	    if ($buffer != '') {
684
-		$all_data = json_decode($buffer,true);
684
+		$all_data = json_decode($buffer, true);
685 685
 		if (isset($all_data[0]['mmsi'])) {
686 686
 		    foreach ($all_data as $line) {
687 687
 			if ($line != '') {
688 688
 			    $data = array();
689 689
 			    $data['ident'] = $line['shipname'];
690 690
 			    $data['callsign'] = $line['callsign'];
691
-			    $data['mmsi'] = substr($line['mmsi'],-9);
691
+			    $data['mmsi'] = substr($line['mmsi'], -9);
692 692
 			    $data['speed'] = $line['sog'];
693 693
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
694 694
 			    $data['latitude'] = $line['latitude'];
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
 	) {
716 716
 	    $buffer = $Common->getData($value['host']);
717 717
 	    if ($buffer != '') {
718
-		$all_data = json_decode($buffer,true);
718
+		$all_data = json_decode($buffer, true);
719 719
 		if (isset($all_data['features'][0]['id'])) {
720 720
 		    foreach ($all_data['features'] as $line) {
721 721
 			print_r($line);
722 722
 			$data = array();
723 723
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
724 724
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
725
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
725
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
726 726
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
727 727
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
728 728
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -749,31 +749,31 @@  discard block
 block discarded – undo
749 749
 	    )
750 750
 	) {
751 751
 	    if ($globalDebug) echo 'download...';
752
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
752
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
753 753
 	    if ($globalDebug) echo 'done !'."\n";
754 754
 	    // FIXME: Need more work
755 755
 	    if ($buffer != '') $reset = 0;
756
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
757
-	    $buffer = explode('\n',$buffer);
756
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
757
+	    $buffer = explode('\n', $buffer);
758 758
 	    foreach ($buffer as $line) {
759 759
 		if ($line != '') {
760 760
 		    $data = array();
761 761
 		    //echo $line."\n";
762
-		    $data['mmsi'] = (int)substr($line,0,9);
763
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
764
-		    $data['status_id'] = substr($line,21,2);
765
-		    $data['type_id'] = substr($line,24,3);
766
-		    $data['latitude'] = substr($line,29,9);
767
-		    $data['longitude'] = substr($line,41,9);
768
-		    $data['speed'] = round(substr($line,51,5));
762
+		    $data['mmsi'] = (int) substr($line, 0, 9);
763
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
764
+		    $data['status_id'] = substr($line, 21, 2);
765
+		    $data['type_id'] = substr($line, 24, 3);
766
+		    $data['latitude'] = substr($line, 29, 9);
767
+		    $data['longitude'] = substr($line, 41, 9);
768
+		    $data['speed'] = round(substr($line, 51, 5));
769 769
 		    //$data['course'] = substr($line,57,5);
770
-		    $data['heading'] = round(substr($line,63,3));
770
+		    $data['heading'] = round(substr($line, 63, 3));
771 771
 		    //$data['draft'] = substr($line,67,4);
772 772
 		    //$data['length'] = substr($line,72,3);
773 773
 		    //$data['beam'] = substr($line,76,2);
774
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
774
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
775 775
 		    //$data['callsign'] = trim(substr($line,100,7);
776
-		    $data['arrival_code'] = substr($line,108,20);
776
+		    $data['arrival_code'] = substr($line, 108, 20);
777 777
 		    //$data['etaDate'] = substr($line,129,5);
778 778
 		    //$data['etaTime'] = substr($line,135,5);
779 779
 		    $data['format_source'] = 'shipplotter';
@@ -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,19 +801,19 @@  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']))) {
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 815
 					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') {
816
-						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
816
+						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie);
817 817
 						sleep(30);
818 818
 					} else $racebuffer = '';
819 819
 					$bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
@@ -822,19 +822,19 @@  discard block
 block discarded – undo
822 822
 					$racebuffer = '';
823 823
 				}
824 824
 				if ($racebuffer != '') {
825
-					$race_data = json_decode($racebuffer,true);
825
+					$race_data = json_decode($racebuffer, true);
826 826
 					//print_r($race_data);
827 827
 					unset($racebuffer);
828 828
 					if (isset($race_data['mission'])) {
829 829
 					    $datar = array();
830 830
 					    $datar['id'] = $mission['misnr'];
831 831
 					    $datar['desc'] = $race_data['mission']['misdescr'];
832
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
833
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
832
+					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname'])));
833
+					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle'])));
834 834
 					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
835 835
 					    $markers = array();
836 836
 					    foreach ($race_data['mission']['course'] as $course) {
837
-						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
837
+						$markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']);
838 838
 					    }
839 839
 					    $datar['markers'] = json_encode($markers);
840 840
 					    //print_r($datar);
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 					}
843 843
 				}
844 844
 				if ($bufferm != '') {
845
-					$mission_data = json_decode($bufferm,true);
845
+					$mission_data = json_decode($bufferm, true);
846 846
 					unset($bufferm);
847 847
 					if (isset($mission_data['leaderboard'][0]['results'])) {
848 848
 						foreach ($mission_data['leaderboard'][0]['results'] as $sail) {
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 								//$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr'];
856 856
 								$data['id'] = $sail['misnr'].'-'.$sail['usrnr'];
857 857
 								$data['datetime'] = date('Y-m-d H:i:s');
858
-								$data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart']));
858
+								$data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart']));
859 859
 								$data['last_update'] = date('Y-m-d H:i:s');
860 860
 								$data['status'] = $sail['status'];
861 861
 								$data['type'] = $sail['btptype'];
@@ -866,16 +866,16 @@  discard block
 block discarded – undo
866 866
 									$data['longitude'] = $pos['longitude'];
867 867
 								}
868 868
 								if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') {
869
-									$resultdescr = explode(',',$sail['resultdescr']);
869
+									$resultdescr = explode(',', $sail['resultdescr']);
870 870
 									if (count($resultdescr) > 2) {
871
-										$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2);
872
-										$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1]));
871
+										$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2);
872
+										$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1]));
873 873
 										if (isset($resultdescr[3])) {
874
-											$data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3);
874
+											$data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3);
875 875
 										}
876 876
 									}
877 877
 								}
878
-								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
878
+								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
879 879
 								$data['captain_id'] = $sail['usrnr'];
880 880
 								$data['captain_name'] = $sail['usrname'];
881 881
 								$data['race_id'] = $sail['misnr'];
@@ -929,11 +929,11 @@  discard block
 block discarded – undo
929 929
 	    }
930 930
 	    if ($globalDebug) echo '! Download... ';
931 931
 	    $sailawayoption = array('key' => $globalSailaway['key']);
932
-	    if (isset($globalSailaway['usrnr'])) $sailwayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr']));
933
-	    if (isset($globalSailaway['ubtnr'])) $sailwayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr']));
934
-	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30);
932
+	    if (isset($globalSailaway['usrnr'])) $sailwayoption = array_merge($sailawayoption, array('usrnr' => $globalSailaway['usrnr']));
933
+	    if (isset($globalSailaway['ubtnr'])) $sailwayoption = array_merge($sailawayoption, array('ubtnr' => $globalSailaway['ubtnr']));
934
+	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption), 'get', '', '', '', '', 30);
935 935
 	    if ($buffer != '') {
936
-		$data = json_decode($buffer,true);
936
+		$data = json_decode($buffer, true);
937 937
 		//print_r($data);
938 938
 		if (isset($data['boats'])) {
939 939
 		    foreach ($data['boats'] as $sail) {
@@ -945,12 +945,12 @@  discard block
 block discarded – undo
945 945
 			$data['longitude'] = $sail['ubtlon'];
946 946
 			$data['type_id'] = 36;
947 947
 			$data['heading'] = $sail['ubtheading'];
948
-			$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
948
+			$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
949 949
 			$data['captain_name'] = $sail['usrname'];
950
-			$allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52&#39; Cruising Cat','50&#39; Performance Cruiser','Nordic Folkboat');
950
+			$allboats = array('Sailaway Cruiser 38', 'Mini Transat', 'Caribbean Rose', '52&#39; Cruising Cat', '50&#39; Performance Cruiser', 'Nordic Folkboat');
951 951
 			$boattype = $sail['ubtbtpnr'];
952
-			if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1];
953
-			$data['speed'] = round($sail['ubtspeed']*3.6,2);
952
+			if (isset($allboats[$boattype - 1])) $data['type'] = $allboats[$boattype - 1];
953
+			$data['speed'] = round($sail['ubtspeed']*3.6, 2);
954 954
 			$data['format_source'] = 'sailaway';
955 955
 			$data['id_source'] = $id_source;
956 956
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -978,8 +978,8 @@  discard block
 block discarded – undo
978 978
 	) {
979 979
 	    //$buffer = $Common->getData($hosts[$id]);
980 980
 	    $buffer = $Common->getData($value['host']);
981
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
982
-	    $buffer = explode('\n',$buffer);
981
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
982
+	    $buffer = explode('\n', $buffer);
983 983
 	    $reset = 0;
984 984
 	    foreach ($buffer as $line) {
985 985
     		if ($line != '') {
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
991 991
 			$data['pilot_id'] = $line[1];
992 992
 			$data['pilot_name'] = $line[2];
993
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
993
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
994 994
 			$data['ident'] = $line[0]; // ident
995 995
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
996 996
 			$data['speed'] = $line[8]; // speed
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
1007 1007
 			//if (isset($line[37])) $data['last_update'] = $line[37];
1008 1008
 		        $data['departure_airport_icao'] = $line[11];
1009
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
1009
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
1010 1010
 		        $data['arrival_airport_icao'] = $line[13];
1011 1011
 			$data['frequency'] = $line[4];
1012 1012
 			$data['type'] = $line[18];
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
     			$data['id_source'] = $id_source;
1016 1016
 	    		//$data['arrival_airport_time'] = ;
1017 1017
 	    		if ($line[9] != '') {
1018
-	    		    $aircraft_data = explode('/',$line[9]);
1018
+	    		    $aircraft_data = explode('/', $line[9]);
1019 1019
 	    		    if (isset($aircraft_data[1])) {
1020 1020
 	    			$data['aircraft_icao'] = $aircraft_data[1];
1021 1021
 	    		    }
@@ -1030,9 +1030,9 @@  discard block
 block discarded – undo
1030 1030
     			if ($line[3] === 'PILOT') $SI->add($data);
1031 1031
 			elseif ($line[3] === 'ATC') {
1032 1032
 				//print_r($data);
1033
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1034
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
1035
-				$typec = substr($data['ident'],-3);
1033
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1034
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1035
+				$typec = substr($data['ident'], -3);
1036 1036
 				if ($typec === 'APP') $data['type'] = 'Approach';
1037 1037
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
1038 1038
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -1044,8 +1044,8 @@  discard block
 block discarded – undo
1044 1044
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
1045 1045
 				if (!isset($data['source_name'])) $data['source_name'] = '';
1046 1046
 				if (isset($ATC)) {
1047
-					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']);
1048
-					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']);
1047
+					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']);
1048
+					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']);
1049 1049
 				}
1050 1050
 			}
1051 1051
     			unset($data);
@@ -1061,24 +1061,24 @@  discard block
 block discarded – undo
1061 1061
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1062 1062
     	    )
1063 1063
     	) {
1064
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1064
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
1065 1065
 	    if ($buffer != '') {
1066 1066
 		$all_data = simplexml_load_string($buffer);
1067
-		foreach($all_data->children() as $childdata) {
1067
+		foreach ($all_data->children() as $childdata) {
1068 1068
 			$data = array();
1069 1069
 			$line = $childdata;
1070 1070
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
1071
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
1072
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1073
-			$data['latitude'] = (float)$line['pktLatitude'];
1074
-			$data['longitude'] = (float)$line['pktLongitude'];
1075
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1076
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1077
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1071
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
1072
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
1073
+			$data['latitude'] = (float) $line['pktLatitude'];
1074
+			$data['longitude'] = (float) $line['pktLongitude'];
1075
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
1076
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
1077
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
1078 1078
 			$data['altitude_relative'] = 'AMSL';
1079
-			$data['pilot_id'] = (int)$line['pktPilotID'];
1079
+			$data['pilot_id'] = (int) $line['pktPilotID'];
1080 1080
 			$data['aircraft_icao'] = 'PARAGLIDER';
1081
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1081
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1082 1082
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1083 1083
 			$data['format_source'] = $value['format'];
1084 1084
 			$SI->add($data);
@@ -1086,22 +1086,22 @@  discard block
 block discarded – undo
1086 1086
 		}
1087 1087
 	    }
1088 1088
 	    $Source->deleteOldLocationByType('gs');
1089
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1089
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
1090 1090
 	    if ($buffer != '') {
1091 1091
 		$all_data = simplexml_load_string($buffer);
1092
-		foreach($all_data->children() as $childdata) {
1092
+		foreach ($all_data->children() as $childdata) {
1093 1093
 			$data = array();
1094 1094
 			$line = $childdata;
1095
-			$data['id'] = (int)$line['gsID'];
1096
-			$data['latitude'] = (float)$line['gsLatitude'];
1097
-			$data['longitude'] = (float)$line['gsLongitude'];
1098
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
1095
+			$data['id'] = (int) $line['gsID'];
1096
+			$data['latitude'] = (float) $line['gsLatitude'];
1097
+			$data['longitude'] = (float) $line['gsLongitude'];
1098
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
1099 1099
 			$data['altitude_relative'] = 'AMSL';
1100
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
1100
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
1101 1101
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
1102
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1102
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1103 1103
 			} else {
1104
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1104
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1105 1105
 			}
1106 1106
 			unset($data);
1107 1107
 		}
@@ -1119,9 +1119,9 @@  discard block
 block discarded – undo
1119 1119
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1120 1120
 	    )
1121 1121
 	) {
1122
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1122
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1123 1123
 	    if ($buffer != '') {
1124
-	        $all_data = json_decode($buffer,true);
1124
+	        $all_data = json_decode($buffer, true);
1125 1125
 		if (isset($all_data['acList'])) {
1126 1126
 		    $reset = 0;
1127 1127
 		    foreach ($all_data['acList'] as $line) {
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1138 1138
 			$data['emergency'] = ''; // emergency
1139 1139
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1140
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1140
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1141 1141
 			else $data['datetime'] = date('Y-m-d H:i:s');
1142 1142
 			//$data['datetime'] = date('Y-m-d H:i:s');
1143 1143
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1163 1163
 			$data['squawk'] = $line['squawk']; // squawk
1164 1164
 			$data['emergency'] = ''; // emergency
1165
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1165
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1166 1166
 			else $data['datetime'] = date('Y-m-d H:i:s');
1167 1167
 			$data['format_source'] = 'aircraftlistjson';
1168 1168
 			$data['id_source'] = $id_source;
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
     	    )
1184 1184
     	) {
1185 1185
 	    $buffer = $Common->getData($value['host']);
1186
-	    $all_data = json_decode($buffer,true);
1186
+	    $all_data = json_decode($buffer, true);
1187 1187
 	    if (isset($all_data['planes'])) {
1188 1188
 		$reset = 0;
1189 1189
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1200,12 +1200,12 @@  discard block
 block discarded – undo
1200 1200
 		    $data['emergency'] = ''; // emergency
1201 1201
 		    $data['registration'] = $line[2];
1202 1202
 		    $data['aircraft_icao'] = $line[0];
1203
-		    $deparr = explode('-',$line[1]);
1203
+		    $deparr = explode('-', $line[1]);
1204 1204
 		    if (count($deparr) === 2) {
1205 1205
 			$data['departure_airport_icao'] = $deparr[0];
1206 1206
 			$data['arrival_airport_icao'] = $deparr[1];
1207 1207
 		    }
1208
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1208
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1209 1209
 	    	    $data['format_source'] = 'planeupdatefaa';
1210 1210
     		    $data['id_source'] = $id_source;
1211 1211
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 	    )
1224 1224
 	) {
1225 1225
 	    $buffer = $Common->getData($value['host']);
1226
-	    $all_data = json_decode($buffer,true);
1226
+	    $all_data = json_decode($buffer, true);
1227 1227
 	    if (isset($all_data['states'])) {
1228 1228
 		$reset = 0;
1229 1229
 		foreach ($all_data['states'] as $key => $line) {
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
 		    //$data['emergency'] = ''; // emergency
1241 1241
 		    //$data['registration'] = $line[2];
1242 1242
 		    //$data['aircraft_icao'] = $line[0];
1243
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1243
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1244 1244
 		    $data['format_source'] = 'opensky';
1245 1245
 		    $data['id_source'] = $id_source;
1246 1246
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1257,8 +1257,8 @@  discard block
 block discarded – undo
1257 1257
 	    )
1258 1258
 	) {
1259 1259
 	    $buffer = $Common->getData($value['host']);
1260
-	    $all_data = json_decode($buffer,true);
1261
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1260
+	    $all_data = json_decode($buffer, true);
1261
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1262 1262
 		$reset = 0;
1263 1263
 		foreach ($all_data['aircraft'] as $key => $line) {
1264 1264
 		    $data = array();
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
 	    )
1297 1297
 	) {
1298 1298
 	    $buffer = $Common->getData($value['host']);
1299
-	    $all_data = json_decode($buffer,true);
1299
+	    $all_data = json_decode($buffer, true);
1300 1300
 	    if (isset($all_data['aircraft'])) {
1301 1301
 		$reset = 0;
1302 1302
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1313,7 +1313,7 @@  discard block
 block discarded – undo
1313 1313
 		    //$data['emergency'] = ''; // emergency
1314 1314
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1315 1315
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1316
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1316
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1317 1317
 		    $data['format_source'] = 'planefinderclient';
1318 1318
 		    $data['id_source'] = $id_source;
1319 1319
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1332,7 +1332,7 @@  discard block
 block discarded – undo
1332 1332
 	) {
1333 1333
 	    //$buffer = $Common->getData($hosts[$id]);
1334 1334
 	    $buffer = $Common->getData($value['host']);
1335
-	    $all_data = json_decode($buffer,true);
1335
+	    $all_data = json_decode($buffer, true);
1336 1336
 	    if (!empty($all_data)) $reset = 0;
1337 1337
 	    foreach ($all_data as $key => $line) {
1338 1338
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1370,11 +1370,11 @@  discard block
 block discarded – undo
1370 1370
 	    )
1371 1371
 	) {
1372 1372
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1373
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1373
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1374 1374
 	    //echo $buffer;
1375
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1376
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1377
-	    $all_data = json_decode($buffer,true);
1375
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1376
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1377
+	    $all_data = json_decode($buffer, true);
1378 1378
 	    if (json_last_error() != JSON_ERROR_NONE) {
1379 1379
 		die(json_last_error_msg());
1380 1380
 	    }
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
 			//$data['departure_airport_iata'] = $line[11];
1398 1398
 			//$data['arrival_airport_iata'] = $line[12];
1399 1399
 	    		//$data['emergency'] = ''; // emergency
1400
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1400
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1401 1401
 	    		$data['format_source'] = 'radarvirtueljson';
1402 1402
     			$data['id_source'] = $id_source;
1403 1403
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1418,14 +1418,14 @@  discard block
 block discarded – undo
1418 1418
 	) {
1419 1419
 	    //$buffer = $Common->getData($hosts[$id]);
1420 1420
 	    $buffer = $Common->getData($value['host'].'?'.time());
1421
-	    $all_data = json_decode(utf8_encode($buffer),true);
1421
+	    $all_data = json_decode(utf8_encode($buffer), true);
1422 1422
 	    
1423 1423
 	    if (isset($all_data['pireps'])) {
1424 1424
 		$reset = 0;
1425 1425
 	        foreach ($all_data['pireps'] as $line) {
1426 1426
 		    $data = array();
1427 1427
 		    $data['id'] = $line['id'];
1428
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1428
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1429 1429
 		    $data['ident'] = $line['callsign']; // ident
1430 1430
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1431 1431
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1455,9 +1455,9 @@  discard block
 block discarded – undo
1455 1455
 			$SI->add($data);
1456 1456
 		    //    print_r($data);
1457 1457
     		    } elseif ($line['icon'] === 'ct') {
1458
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1459
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1460
-			$typec = substr($data['ident'],-3);
1458
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1459
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1460
+			$typec = substr($data['ident'], -3);
1461 1461
 			$data['type'] = '';
1462 1462
 			if ($typec === 'APP') $data['type'] = 'Approach';
1463 1463
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1468,7 +1468,7 @@  discard block
 block discarded – undo
1468 1468
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1469 1469
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1470 1470
 			else $data['type'] = 'Observer';
1471
-			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']);
1471
+			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']);
1472 1472
 		    }
1473 1473
 		    unset($data);
1474 1474
 		}
@@ -1485,14 +1485,14 @@  discard block
 block discarded – undo
1485 1485
 	    //$buffer = $Common->getData($hosts[$id]);
1486 1486
 	    if ($globalDebug) echo 'Get Data...'."\n";
1487 1487
 	    $buffer = $Common->getData($value['host']);
1488
-	    $all_data = json_decode($buffer,true);
1488
+	    $all_data = json_decode($buffer, true);
1489 1489
 	    if ($buffer != '' && is_array($all_data)) {
1490 1490
 		$reset = 0;
1491 1491
 		foreach ($all_data as $line) {
1492 1492
 	    	    $data = array();
1493 1493
 	    	    //$data['id'] = $line['id']; // id not usable
1494 1494
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1495
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1495
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1496 1496
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1497 1497
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1498 1498
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
 	    	    //$data['datetime'] = $line['lastupdate'];
1508 1508
 	    	    //$data['last_update'] = $line['lastupdate'];
1509 1509
 	    	    if (isset($value['timezone'])) {
1510
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1510
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1511 1511
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1512 1512
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1513 1513
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1523,14 +1523,14 @@  discard block
 block discarded – undo
1523 1523
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1524 1524
 		    if (isset($line['aircraftname'])) {
1525 1525
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1526
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1527
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1526
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1527
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1528 1528
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1529 1529
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1530 1530
 	    		else {
1531
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1532
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1533
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1531
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1532
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1533
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1534 1534
 	    		}
1535 1535
 	    	    }
1536 1536
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1555,7 +1555,7 @@  discard block
 block discarded – undo
1555 1555
 	    //$buffer = $Common->getData($hosts[$id]);
1556 1556
 	    if ($globalDebug) echo 'Get Data...'."\n";
1557 1557
 	    $buffer = $Common->getData($value['host']);
1558
-	    $all_data = json_decode($buffer,true);
1558
+	    $all_data = json_decode($buffer, true);
1559 1559
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1560 1560
 		$reset = 0;
1561 1561
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1566,7 +1566,7 @@  discard block
 block discarded – undo
1566 1566
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1567 1567
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1568 1568
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1569
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1569
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1570 1570
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1571 1571
 	    	    $data['altitude'] = $line['altitude']; // altitude
1572 1572
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1577,7 +1577,7 @@  discard block
 block discarded – undo
1577 1577
 	    	    //$data['squawk'] = ''; // squawk
1578 1578
 	    	    //$data['emergency'] = ''; // emergency
1579 1579
 	    	    if (isset($value['timezone'])) {
1580
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1580
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1581 1581
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1582 1582
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1583 1583
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1613,14 +1613,14 @@  discard block
 block discarded – undo
1613 1613
 	    //$buffer = $Common->getData($hosts[$id]);
1614 1614
 	    if ($globalDebug) echo 'Get Data...'."\n";
1615 1615
 	    $buffer = $Common->getData($value['host']);
1616
-	    $all_data = json_decode($buffer,true);
1616
+	    $all_data = json_decode($buffer, true);
1617 1617
 	    if ($buffer != '' && is_array($all_data)) {
1618 1618
 		$reset = 0;
1619 1619
 		foreach ($all_data as $line) {
1620 1620
 	    	    $data = array();
1621 1621
 	    	    //$data['id'] = $line['id']; // id not usable
1622 1622
 	    	    $data['id'] = trim($line['flight_id']);
1623
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1623
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1624 1624
 	    	    $data['pilot_name'] = $line['pilot_name'];
1625 1625
 	    	    $data['pilot_id'] = $line['pilot_id'];
1626 1626
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1664,24 +1664,24 @@  discard block
 block discarded – undo
1664 1664
 	    //$buffer = $Common->getData($hosts[$id]);
1665 1665
 	    if ($globalDebug) echo 'Get Data...'."\n";
1666 1666
 	    $buffer = $Common->getData($value['host']);
1667
-	    $all_data = json_decode($buffer,true);
1667
+	    $all_data = json_decode($buffer, true);
1668 1668
 	    if ($buffer != '') {
1669 1669
 		$Source->deleteLocationBySource('blitzortung');
1670
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1671
-		$buffer = explode('\n',$buffer);
1670
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1671
+		$buffer = explode('\n', $buffer);
1672 1672
 		foreach ($buffer as $buffer_line) {
1673
-		    $line = json_decode($buffer_line,true);
1673
+		    $line = json_decode($buffer_line, true);
1674 1674
 		    if (isset($line['time'])) {
1675 1675
 			$data = array();
1676 1676
 			$data['altitude'] = $line['alt']; // altitude
1677 1677
 			$data['latitude'] = $line['lat']; // lat
1678 1678
 			$data['longitude'] = $line['lon']; // long
1679
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1679
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1680 1680
 			$data['id_source'] = $id_source;
1681 1681
 			$data['format_source'] = 'blitzortung';
1682 1682
 			$SI->add($data);
1683 1683
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1684
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1684
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1685 1685
 			unset($data);
1686 1686
 		    }
1687 1687
 		}
@@ -1693,15 +1693,15 @@  discard block
 block discarded – undo
1693 1693
         $arr = $httpfeeds;
1694 1694
         $w = $e = null;
1695 1695
         if (isset($arr[$id])) {
1696
-            $nn = stream_select($arr,$w,$e,$timeout);
1696
+            $nn = stream_select($arr, $w, $e, $timeout);
1697 1697
             if ($nn > 0) {
1698 1698
                 foreach ($httpfeeds as $feed) {
1699
-                    $buffer = stream_get_line($feed,2000,"\n");
1699
+                    $buffer = stream_get_line($feed, 2000, "\n");
1700 1700
                     if ($buffer === FALSE) {
1701 1701
                         connect_all($globalSources);
1702 1702
                     }
1703
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1704
-                    $buffer = explode('\n',$buffer);
1703
+                    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1704
+                    $buffer = explode('\n', $buffer);
1705 1705
                     foreach ($buffer as $line) {
1706 1706
                         if ($line != '') {
1707 1707
                             $line = json_decode($line, true);
@@ -1741,11 +1741,11 @@  discard block
 block discarded – undo
1741 1741
 		    //$value = $formats[$nb];
1742 1742
 		    $format = $globalSources[$nb]['format'];
1743 1743
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1744
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1744
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1745 1745
 		    } elseif ($format === 'vrstcp') {
1746 1746
 			$buffer = @socket_read($r, 6000);
1747 1747
 		    } else {
1748
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1748
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1749 1749
 		    }
1750 1750
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1751 1751
 		    //echo $buffer."\n";
@@ -1755,8 +1755,8 @@  discard block
 block discarded – undo
1755 1755
 		    //$SI::del();
1756 1756
 		    if ($buffer !== FALSE) {
1757 1757
 			if ($format === 'vrstcp') {
1758
-			    $buffer = explode('},{',$buffer);
1759
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1758
+			    $buffer = explode('},{', $buffer);
1759
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1760 1760
 		    }
1761 1761
 		    // SBS format is CSV format
1762 1762
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1783,7 +1783,7 @@  discard block
 block discarded – undo
1783 1783
 			    $ais_data = $AIS->parse_line(trim($buffer));
1784 1784
 			    $data = array();
1785 1785
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1786
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1786
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1787 1787
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1788 1788
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1789 1789
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1794,13 +1794,13 @@  discard block
 block discarded – undo
1794 1794
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1795 1795
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1796 1796
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1797
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1797
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1798 1798
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1799 1799
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1800 1800
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1801 1801
 
1802 1802
 			    if (isset($ais_data['timestamp'])) {
1803
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1803
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1804 1804
 			    } else {
1805 1805
 				$data['datetime'] = date('Y-m-d H:i:s');
1806 1806
 			    }
@@ -1811,10 +1811,10 @@  discard block
 block discarded – undo
1811 1811
                         } elseif ($format === 'flightgearsp') {
1812 1812
                     	    //echo $buffer."\n";
1813 1813
                     	    if (strlen($buffer) > 5) {
1814
-				$line = explode(',',$buffer);
1814
+				$line = explode(',', $buffer);
1815 1815
 				$data = array();
1816 1816
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1817
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1817
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1818 1818
 				$data['ident'] = $line[6];
1819 1819
 				$data['aircraft_name'] = $line[7];
1820 1820
 				$data['longitude'] = $line[1];
@@ -1831,25 +1831,25 @@  discard block
 block discarded – undo
1831 1831
                         } elseif ($format === 'acars') {
1832 1832
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1833 1833
 			    $ACARS->add(trim($buffer));
1834
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1834
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1835 1835
 			    $ACARS->deleteLiveAcarsData();
1836 1836
 			} elseif ($format === 'acarsjsonudp') {
1837 1837
 			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1838 1838
                             $line = json_decode(trim($buffer), true);
1839 1839
                             if (!empty($line)) {
1840
-				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line);
1840
+				$line = array_merge(array('text' => '', 'tail' => '', 'label' => '', 'block_id' => '', 'flight' => '', 'msgno' => ''), $line);
1841 1841
                                 $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'] : '')));
1842 1842
                                 $ACARS->deleteLiveAcarsData();
1843 1843
                             }
1844
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1844
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1845 1845
 			} elseif ($format === 'flightgearmp') {
1846
-			    if (substr($buffer,0,1) != '#') {
1846
+			    if (substr($buffer, 0, 1) != '#') {
1847 1847
 				$data = array();
1848 1848
 				//echo $buffer."\n";
1849
-				$line = explode(' ',$buffer);
1849
+				$line = explode(' ', $buffer);
1850 1850
 				if (count($line) === 11) {
1851
-				    $userserver = explode('@',$line[0]);
1852
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1851
+				    $userserver = explode('@', $line[0]);
1852
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1853 1853
 				    $data['ident'] = $userserver[0];
1854 1854
 				    $data['registration'] = $userserver[0];
1855 1855
 				    $data['latitude'] = $line[4];
@@ -1857,8 +1857,8 @@  discard block
 block discarded – undo
1857 1857
 				    $data['altitude'] = $line[6];
1858 1858
 				    $data['datetime'] = date('Y-m-d H:i:s');
1859 1859
 				    $aircraft_type = $line[10];
1860
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1861
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1860
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1861
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1862 1862
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1863 1863
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1864 1864
 				}
@@ -1867,8 +1867,8 @@  discard block
 block discarded – undo
1867 1867
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1868 1868
 			    die;
1869 1869
 			} elseif ($format === 'vrstcp') {
1870
-			    foreach($buffer as $all_data) {
1871
-				$line = json_decode('{'.$all_data.'}',true);
1870
+			    foreach ($buffer as $all_data) {
1871
+				$line = json_decode('{'.$all_data.'}', true);
1872 1872
 				$data = array();
1873 1873
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1874 1874
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1894,16 +1894,16 @@  discard block
 block discarded – undo
1894 1894
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1895 1895
 				unset($data);
1896 1896
 			    }
1897
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1897
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1898 1898
 			    $line = explode("\t", $buffer);
1899
-			    for($k = 0; $k < count($line); $k=$k+2) {
1899
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1900 1900
 				$key = $line[$k];
1901
-			        $lined[$key] = $line[$k+1];
1901
+			        $lined[$key] = $line[$k + 1];
1902 1902
 			    }
1903 1903
     			    if (count($lined) > 3) {
1904 1904
     				$data['hex'] = $lined['hexid'];
1905 1905
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1906
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1906
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1907 1907
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1908 1908
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1909 1909
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1922,23 +1922,23 @@  discard block
 block discarded – undo
1922 1922
     			    } else $error = true;
1923 1923
 			} elseif ($format === 'aprs' && $use_aprs) {
1924 1924
 			    if ($aprs_connect === 0) {
1925
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1925
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1926 1926
 				$aprs_connect = 1;
1927 1927
 			    }
1928 1928
 			    
1929
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1929
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1930 1930
 				$aprs_last_tx = time();
1931 1931
 				$data_aprs = "# Keep alive";
1932
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1932
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1933 1933
 			    }
1934 1934
 			    
1935 1935
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1936 1936
 			    //echo 'APRS data : '.$buffer."\n";
1937
-			    $buffer = str_replace('APRS <- ','',$buffer);
1938
-			    $buffer = str_replace('APRS -> ','',$buffer);
1937
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1938
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1939 1939
 			    //echo $buffer."\n";
1940 1940
 			    date_default_timezone_set('UTC');
1941
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1941
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1942 1942
 				$line = $APRS->parse($buffer);
1943 1943
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1944 1944
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1953,7 +1953,7 @@  discard block
 block discarded – undo
1953 1953
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1954 1954
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1955 1955
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1956
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1956
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1957 1957
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1958 1958
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1959 1959
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -2041,29 +2041,29 @@  discard block
 block discarded – undo
2041 2041
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
2042 2042
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
2043 2043
 					$Source->deleteOldLocationByType('gs');
2044
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
2045
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
2044
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
2045
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
2046 2046
 					} else {
2047
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
2047
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
2048 2048
 					}
2049 2049
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
2050 2050
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2051 2051
 					if ($globalDebug) echo '# Weather Station added'."\n";
2052 2052
 					$Source->deleteOldLocationByType('wx');
2053 2053
 					$weather_data = json_encode($line);
2054
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
2055
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2054
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
2055
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2056 2056
 					} else {
2057
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2057
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2058 2058
 					}
2059 2059
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2060 2060
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2061 2061
 					if ($globalDebug) echo '☈ Lightning added'."\n";
2062 2062
 					$Source->deleteOldLocationByType('lightning');
2063
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
2064
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2063
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
2064
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2065 2065
 					} else {
2066
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2066
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2067 2067
 					}
2068 2068
 				    } elseif ($globalDebug) {
2069 2069
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -2072,7 +2072,7 @@  discard block
 block discarded – undo
2072 2072
 				    unset($data);
2073 2073
 				}
2074 2074
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2075
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2075
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
2076 2076
 				}
2077 2077
 				/*
2078 2078
 				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')) {
@@ -2081,7 +2081,7 @@  discard block
 block discarded – undo
2081 2081
 				*/
2082 2082
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2083 2083
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2084
-				if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2084
+				if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
2085 2085
 					$Source->deleteOldLocationByType('lightning');
2086 2086
 					$Source->deleteOldLocationByType('wx');
2087 2087
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2168,7 +2168,7 @@  discard block
 block discarded – undo
2168 2168
 				connect_all($sourceee);
2169 2169
 				$sourceee = array();
2170 2170
 				//connect_all($globalSources);
2171
-				$tt[$format]=0;
2171
+				$tt[$format] = 0;
2172 2172
 				break;
2173 2173
 			    } 
2174 2174
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2178,14 +2178,14 @@  discard block
 block discarded – undo
2178 2178
 	    } else {
2179 2179
 		$error = socket_strerror(socket_last_error());
2180 2180
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2181
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2181
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2182 2182
 			if (isset($globalDebug)) echo "Restarting...\n";
2183 2183
 			// Restart the script if possible
2184 2184
 			if (is_array($sockets)) {
2185 2185
 			    if ($globalDebug) echo "Shutdown all sockets...";
2186 2186
 			    
2187 2187
 			    foreach ($sockets as $sock) {
2188
-				@socket_shutdown($sock,2);
2188
+				@socket_shutdown($sock, 2);
2189 2189
 				@socket_close($sock);
2190 2190
 			    }
2191 2191
 			    
Please login to merge, or discard this patch.