Completed
Push — master ( 8dc4cc...f2b14e )
by Yannick
33:46
created
scripts/daemon-spotter.php 1 patch
Spacing   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
 	    die;
47 47
 	}
48 48
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
49
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
49
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
50 50
     }
51 51
 }
52 52
 
53
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
53
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver'));
54 54
 //if (isset($options['s'])) $hosts = array($options['s']);
55 55
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 56
 if (isset($options['s'])) {
57 57
     $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
59 59
     else $globalSources[] = array('host' => $options['s']);
60 60
 } elseif (isset($options['source'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['source']);
64 64
 }
65 65
 if (isset($options['aprsserverhost'])) {
@@ -76,28 +76,28 @@  discard block
 block discarded – undo
76 76
 else $id_source = 1;
77 77
 if (isset($globalServer) && $globalServer) {
78 78
     if ($globalDebug) echo "Using Server Mode\n";
79
-    $SI=new SpotterServer();
79
+    $SI = new SpotterServer();
80 80
 /*
81 81
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 82
     $SI = new adsb2aprs();
83 83
     $SI->connect();
84 84
 */
85
-} else $SI=new SpotterImport($Connection->db);
85
+} else $SI = new SpotterImport($Connection->db);
86 86
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
87 87
 if (isset($globalMarine) && $globalMarine) {
88 88
     $AIS = new AIS();
89 89
     $MI = new MarineImport($Connection->db);
90 90
 }
91 91
 //$APRS=new APRS($Connection->db);
92
-$SBS=new SBS();
93
-$ACARS=new ACARS($Connection->db);
94
-$Source=new Source($Connection->db);
95
-$Common=new Common();
92
+$SBS = new SBS();
93
+$ACARS = new ACARS($Connection->db);
94
+$Source = new Source($Connection->db);
95
+$Common = new Common();
96 96
 date_default_timezone_set('UTC');
97 97
 //$servertz = system('date +%Z');
98 98
 // signal handler - playing nice with sockets and dump1090
99 99
 if (function_exists('pcntl_fork')) {
100
-    pcntl_signal(SIGINT,  function() {
100
+    pcntl_signal(SIGINT, function() {
101 101
         global $sockets;
102 102
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103 103
         die("Bye!\n");
@@ -113,30 +113,30 @@  discard block
 block discarded – undo
113 113
 
114 114
 function connect_all($hosts) {
115 115
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
116
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
117 117
     $reset++;
118 118
     if ($globalDebug) echo 'Connect to all...'."\n";
119 119
     foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
+            if (preg_match('/deltadb.txt$/i', $host)) {
125 125
         	//$formats[$id] = 'deltadbtxt';
126 126
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 127
         	//$last_exec['deltadbtxt'] = 0;
128 128
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
129
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
130 130
         	//$formats[$id] = 'vatsimtxt';
131 131
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 132
         	//$last_exec['vatsimtxt'] = 0;
133 133
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
134
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
135 135
         	//$formats[$id] = 'aircraftlistjson';
136 136
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 137
         	//$last_exec['aircraftlistjson'] = 0;
138 138
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
139
+    	    } else if (preg_match('/opensky/i', $host)) {
140 140
         	//$formats[$id] = 'aircraftlistjson';
141 141
         	$globalSources[$id]['format'] = 'opensky';
142 142
         	//$last_exec['aircraftlistjson'] = 0;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         	    exit(0);
154 154
         	}
155 155
     	    */
156
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
156
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
157 157
         	//$formats[$id] = 'planeupdatefaa';
158 158
         	$globalSources[$id]['format'] = 'planeupdatefaa';
159 159
         	//$last_exec['planeupdatefaa'] = 0;
@@ -162,32 +162,32 @@  discard block
 block discarded – undo
162 162
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163 163
         	    exit(0);
164 164
         	}
165
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
165
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
166 166
         	//$formats[$id] = 'phpvmacars';
167 167
         	$globalSources[$id]['format'] = 'phpvmacars';
168 168
         	//$last_exec['phpvmacars'] = 0;
169 169
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
170
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
171 171
         	//$formats[$id] = 'phpvmacars';
172 172
         	$globalSources[$id]['format'] = 'vam';
173 173
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
-            } else if (preg_match('/whazzup/i',$host)) {
174
+            } else if (preg_match('/whazzup/i', $host)) {
175 175
         	//$formats[$id] = 'whazzup';
176 176
         	$globalSources[$id]['format'] = 'whazzup';
177 177
         	//$last_exec['whazzup'] = 0;
178 178
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
-            } else if (preg_match('/blitzortung/i',$host)) {
179
+            } else if (preg_match('/blitzortung/i', $host)) {
180 180
         	$globalSources[$id]['format'] = 'blitzortung';
181 181
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
182
-            } else if (preg_match('/airwhere/i',$host)) {
182
+            } else if (preg_match('/airwhere/i', $host)) {
183 183
         	$globalSources[$id]['format'] = 'airwhere';
184 184
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
185
-            } else if (preg_match('/recentpireps/i',$host)) {
185
+            } else if (preg_match('/recentpireps/i', $host)) {
186 186
         	//$formats[$id] = 'pirepsjson';
187 187
         	$globalSources[$id]['format'] = 'pirepsjson';
188 188
         	//$last_exec['pirepsjson'] = 0;
189 189
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
190
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
190
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
191 191
         	//$formats[$id] = 'fr24json';
192 192
         	$globalSources[$id]['format'] = 'fr24json';
193 193
         	//$last_exec['fr24json'] = 0;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
197 197
         	    exit(0);
198 198
         	}
199
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
199
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
200 200
         	//$formats[$id] = 'fr24json';
201 201
         	$globalSources[$id]['format'] = 'myshiptracking';
202 202
         	//$last_exec['fr24json'] = 0;
@@ -206,22 +206,22 @@  discard block
 block discarded – undo
206 206
         	    exit(0);
207 207
         	}
208 208
             //} else if (preg_match('/10001/',$host)) {
209
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
209
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
210 210
         	//$formats[$id] = 'tsv';
211 211
         	$globalSources[$id]['format'] = 'tsv';
212 212
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
213 213
             }
214
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
214
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
215 215
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
216
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
216
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
217 217
     		    if ($idf !== false) {
218 218
     			$httpfeeds[$id] = $idf;
219 219
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
220 220
     		    }
221 221
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
222 222
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
223
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
224
-	    $hostport = explode(':',$host);
223
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
224
+	    $hostport = explode(':', $host);
225 225
 	    if (isset($hostport[1])) {
226 226
 		$port = $hostport[1];
227 227
 		$hostn = $hostport[0];
@@ -231,19 +231,19 @@  discard block
 block discarded – undo
231 231
 	    }
232 232
 	    $Common = new Common();
233 233
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
234
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
234
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
235 235
     	    } else {
236
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
236
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
237 237
 	    }
238 238
 	    if ($s) {
239 239
     	        $sockets[$id] = $s;
240 240
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
241
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
241
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
242 242
 			//$formats[$id] = 'aprs';
243 243
 			$globalSources[$id]['format'] = 'aprs';
244 244
 			//$aprs_connect = 0;
245 245
 			//$use_aprs = true;
246
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
246
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
247 247
 			$globalSources[$id]['format'] = 'vrstcp';
248 248
     		    } elseif ($port == '10001') {
249 249
         		//$formats[$id] = 'tsv';
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
283 283
 else $timeout = 20;
284 284
 $errno = '';
285
-$errstr='';
285
+$errstr = '';
286 286
 
287 287
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
288 288
 /* Initiate connections to all the hosts simultaneously */
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 //connect_all($globalSources);
291 291
 
292 292
 if (isset($globalProxy) && $globalProxy) {
293
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
293
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
294 294
 } else {
295 295
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
296 296
 }
@@ -320,16 +320,16 @@  discard block
 block discarded – undo
320 320
 
321 321
 if ($use_aprs) {
322 322
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
323
-	$APRS=new APRS();
323
+	$APRS = new APRS();
324 324
 	$aprs_connect = 0;
325 325
 	$aprs_keep = 120;
326 326
 	$aprs_last_tx = time();
327 327
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
328
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
328
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
329 329
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
330
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
330
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
331 331
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
332
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
332
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
333 333
 	if ($aprs_full) $aprs_filter = '';
334 334
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
335 335
 	else $aprs_pass = '-1';
@@ -343,12 +343,12 @@  discard block
 block discarded – undo
343 343
 sleep(1);
344 344
 if ($globalDebug) echo "SCAN MODE \n\n";
345 345
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
346
-$endtime = time()+$globalCronEnd;
346
+$endtime = time() + $globalCronEnd;
347 347
 $i = 1;
348 348
 $tt = array();
349 349
 // Delete all ATC
350 350
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
351
-	$ATC=new ATC($Connection->db);
351
+	$ATC = new ATC($Connection->db);
352 352
 }
353 353
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
354 354
 	$ATC->deleteAll();
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 
357 357
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
358 358
 while ($i > 0) {
359
-    if (!$globalDaemon) $i = $endtime-time();
359
+    if (!$globalDaemon) $i = $endtime - time();
360 360
     // Delete old ATC
361 361
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
362 362
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 	}
371 371
 	if ($max != $globalMinFetch) {
372 372
 	    if ($globalDebug) echo 'Sleeping...'."\n";
373
-	    sleep($globalMinFetch-$max+2);
373
+	    sleep($globalMinFetch - $max + 2);
374 374
 	}
375 375
     }
376 376
 
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
 	    //$buffer = $Common->getData($hosts[$id]);
390 390
 	    $buffer = $Common->getData($value['host']);
391 391
 	    if ($buffer != '') $reset = 0;
392
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
393
-	    $buffer = explode('\n',$buffer);
392
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
393
+	    $buffer = explode('\n', $buffer);
394 394
 	    foreach ($buffer as $line) {
395 395
     		if ($line != '' && count($line) > 7) {
396 396
     		    $line = explode(',', $line);
@@ -423,11 +423,11 @@  discard block
 block discarded – undo
423 423
 	    )
424 424
 	) {
425 425
 	    date_default_timezone_set('CET');
426
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
426
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
427 427
 	    date_default_timezone_set('UTC');
428 428
 	    if ($buffer != '') $reset = 0;
429
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
430
-	    $buffer = explode('\n',$buffer);
429
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
430
+	    $buffer = explode('\n', $buffer);
431 431
 	    foreach ($buffer as $line) {
432 432
 		if ($line != '') {
433 433
 		    //echo "'".$line."'\n";
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
446 446
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
447 447
 		    if (isset($ais_data['timestamp'])) {
448
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
448
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
449 449
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
450 450
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
451 451
 			    $add = true;
@@ -468,12 +468,12 @@  discard block
 block discarded – undo
468 468
 	    $w = $e = null;
469 469
 	    
470 470
 	    if (isset($arr[$id])) {
471
-		$nn = stream_select($arr,$w,$e,$timeout);
471
+		$nn = stream_select($arr, $w, $e, $timeout);
472 472
 		if ($nn > 0) {
473 473
 		    foreach ($httpfeeds as $feed) {
474
-			$buffer = stream_get_line($feed,2000,"\n");
475
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
476
-			$buffer = explode('\n',$buffer);
474
+			$buffer = stream_get_line($feed, 2000, "\n");
475
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
476
+			$buffer = explode('\n', $buffer);
477 477
 			foreach ($buffer as $line) {
478 478
 			    if ($line != '') {
479 479
 				$ais_data = $AIS->parse_line(trim($line));
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
492 492
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
493 493
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
494
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
494
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
495 495
 				if (isset($ais_data['timestamp'])) {
496
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
496
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
497 497
 				} else {
498 498
 				    $data['datetime'] = date('Y-m-d H:i:s');
499 499
 				}
@@ -524,10 +524,10 @@  discard block
 block discarded – undo
524 524
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
525 525
 	    )
526 526
 	) {
527
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
527
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
528 528
 	    if ($buffer != '') {
529 529
 		//echo $buffer;
530
-		$all_data = json_decode($buffer,true);
530
+		$all_data = json_decode($buffer, true);
531 531
 		//print_r($all_data);
532 532
 		if (isset($all_data[0]['DATA'])) {
533 533
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
543 543
 			    $data['imo'] = $line['IMO'];
544 544
 			    //$data['arrival_code'] = $ais_data['destination'];
545
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
545
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
546 546
 			    $data['format_source'] = 'myshiptracking';
547 547
 			    $data['id_source'] = $id_source;
548 548
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
560 560
 	    )
561 561
 	) {
562
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
562
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
563 563
 	    if ($buffer != '') {
564
-		$all_data = json_decode($buffer,true);
564
+		$all_data = json_decode($buffer, true);
565 565
 		if (isset($all_data[0]['mmsi'])) {
566 566
 		    foreach ($all_data as $line) {
567 567
 			if ($line != '') {
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 	) {
596 596
 	    $buffer = $Common->getData($value['host']);
597 597
 	    if ($buffer != '') {
598
-		$all_data = json_decode($buffer,true);
598
+		$all_data = json_decode($buffer, true);
599 599
 		if (isset($all_data['features'][0]['id'])) {
600 600
 		    foreach ($all_data['features'] as $line) {
601 601
 			$data = array();
@@ -628,27 +628,27 @@  discard block
 block discarded – undo
628 628
 	    )
629 629
 	) {
630 630
 	    echo 'download...';
631
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
631
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
632 632
 	    echo 'done !'."\n";
633 633
 	    if ($buffer != '') $reset = 0;
634
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
635
-	    $buffer = explode('\n',$buffer);
634
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
635
+	    $buffer = explode('\n', $buffer);
636 636
 	    foreach ($buffer as $line) {
637 637
 		if ($line != '') {
638 638
 		    $data = array();
639
-		    $data['mmsi'] = (int)substr($line,0,9);
640
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
639
+		    $data['mmsi'] = (int) substr($line, 0, 9);
640
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
641 641
 		    //$data['status'] = substr($line,21,2);
642 642
 		    //$data['type'] = substr($line,24,3);
643
-		    $data['latitude'] = substr($line,29,9);
644
-		    $data['longitude'] = substr($line,41,9);
645
-		    $data['speed'] = round(substr($line,51,5));
643
+		    $data['latitude'] = substr($line, 29, 9);
644
+		    $data['longitude'] = substr($line, 41, 9);
645
+		    $data['speed'] = round(substr($line, 51, 5));
646 646
 		    //$data['course'] = substr($line,57,5);
647
-		    $data['heading'] = round(substr($line,63,3));
647
+		    $data['heading'] = round(substr($line, 63, 3));
648 648
 		    //$data['draft'] = substr($line,67,4);
649 649
 		    //$data['length'] = substr($line,72,3);
650 650
 		    //$data['beam'] = substr($line,76,2);
651
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
651
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
652 652
 		    //$data['callsign'] = trim(substr($line,100,7);
653 653
 		    //$data['dest'] = substr($line,108,20);
654 654
 		    //$data['etaDate'] = substr($line,129,5);
@@ -681,8 +681,8 @@  discard block
 block discarded – undo
681 681
 	) {
682 682
 	    //$buffer = $Common->getData($hosts[$id]);
683 683
 	    $buffer = $Common->getData($value['host']);
684
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
685
-	    $buffer = explode('\n',$buffer);
684
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
685
+	    $buffer = explode('\n', $buffer);
686 686
 	    $reset = 0;
687 687
 	    foreach ($buffer as $line) {
688 688
     		if ($line != '') {
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
694 694
 			$data['pilot_id'] = $line[1];
695 695
 			$data['pilot_name'] = $line[2];
696
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
696
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
697 697
 			$data['ident'] = $line[0]; // ident
698 698
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
699 699
 			$data['speed'] = $line[8]; // speed
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
710 710
 			//if (isset($line[37])) $data['last_update'] = $line[37];
711 711
 		        $data['departure_airport_icao'] = $line[11];
712
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
712
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
713 713
 		        $data['arrival_airport_icao'] = $line[13];
714 714
 			$data['frequency'] = $line[4];
715 715
 			$data['type'] = $line[18];
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
     			$data['id_source'] = $id_source;
719 719
 	    		//$data['arrival_airport_time'] = ;
720 720
 	    		if ($line[9] != '') {
721
-	    		    $aircraft_data = explode('/',$line[9]);
721
+	    		    $aircraft_data = explode('/', $line[9]);
722 722
 	    		    if (isset($aircraft_data[1])) {
723 723
 	    			$data['aircraft_icao'] = $aircraft_data[1];
724 724
 	    		    }
@@ -733,9 +733,9 @@  discard block
 block discarded – undo
733 733
     			if ($line[3] == 'PILOT') $SI->add($data);
734 734
 			elseif ($line[3] == 'ATC') {
735 735
 				//print_r($data);
736
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
737
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
738
-				$typec = substr($data['ident'],-3);
736
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
737
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
738
+				$typec = substr($data['ident'], -3);
739 739
 				if ($typec == 'APP') $data['type'] = 'Approach';
740 740
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
741 741
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -747,8 +747,8 @@  discard block
 block discarded – undo
747 747
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
748 748
 				if (!isset($data['source_name'])) $data['source_name'] = '';
749 749
 				if (isset($ATC)) {
750
-					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']);
751
-					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']);
750
+					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']);
751
+					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']);
752 752
 				}
753 753
 			}
754 754
     			unset($data);
@@ -764,24 +764,24 @@  discard block
 block discarded – undo
764 764
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
765 765
     	    )
766 766
     	) {
767
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
767
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
768 768
 	    if ($buffer != '') {
769 769
 		$all_data = simplexml_load_string($buffer);
770
-		foreach($all_data->children() as $childdata) {
770
+		foreach ($all_data->children() as $childdata) {
771 771
 			$data = array();
772 772
 			$line = $childdata;
773 773
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
774
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
775
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
776
-			$data['latitude'] = (float)$line['pktLatitude'];
777
-			$data['longitude'] = (float)$line['pktLongitude'];
778
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
779
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
780
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
774
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
775
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
776
+			$data['latitude'] = (float) $line['pktLatitude'];
777
+			$data['longitude'] = (float) $line['pktLongitude'];
778
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
779
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
780
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
781 781
 			$data['altitude_relative'] = 'AMSL';
782
-			$data['pilot_id'] = (int)$line['pktPilotID'];
782
+			$data['pilot_id'] = (int) $line['pktPilotID'];
783 783
 			$data['aircraft_icao'] = 'PARAGLIDER';
784
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
784
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
785 785
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
786 786
 			$data['format_source'] = $value['format'];
787 787
 			$SI->add($data);
@@ -789,22 +789,22 @@  discard block
 block discarded – undo
789 789
 		}
790 790
 	    }
791 791
 	    $Source->deleteOldLocationByType('gs');
792
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
792
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
793 793
 	    if ($buffer != '') {
794 794
 		$all_data = simplexml_load_string($buffer);
795
-		foreach($all_data->children() as $childdata) {
795
+		foreach ($all_data->children() as $childdata) {
796 796
 			$data = array();
797 797
 			$line = $childdata;
798
-			$data['id'] = (int)$line['gsID'];
799
-			$data['latitude'] = (float)$line['gsLatitude'];
800
-			$data['longitude'] = (float)$line['gsLongitude'];
801
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
798
+			$data['id'] = (int) $line['gsID'];
799
+			$data['latitude'] = (float) $line['gsLatitude'];
800
+			$data['longitude'] = (float) $line['gsLongitude'];
801
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
802 802
 			$data['altitude_relative'] = 'AMSL';
803
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
803
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
804 804
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
805
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
805
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
806 806
 			} else {
807
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
807
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
808 808
 			}
809 809
 			unset($data);
810 810
 		}
@@ -822,9 +822,9 @@  discard block
 block discarded – undo
822 822
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
823 823
 	    )
824 824
 	) {
825
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
825
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
826 826
 	    if ($buffer != '') {
827
-	        $all_data = json_decode($buffer,true);
827
+	        $all_data = json_decode($buffer, true);
828 828
 		if (isset($all_data['acList'])) {
829 829
 		    $reset = 0;
830 830
 		    foreach ($all_data['acList'] as $line) {
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
841 841
 			$data['emergency'] = ''; // emergency
842 842
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
843
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
843
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
844 844
 			else $data['datetime'] = date('Y-m-d H:i:s');
845 845
 			//$data['datetime'] = date('Y-m-d H:i:s');
846 846
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 			$data['verticalrate'] = $line['vrt']; // verticale rate
866 866
 			$data['squawk'] = $line['squawk']; // squawk
867 867
 			$data['emergency'] = ''; // emergency
868
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
868
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
869 869
 			else $data['datetime'] = date('Y-m-d H:i:s');
870 870
 			$data['format_source'] = 'aircraftlistjson';
871 871
 			$data['id_source'] = $id_source;
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
     	    )
887 887
     	) {
888 888
 	    $buffer = $Common->getData($value['host']);
889
-	    $all_data = json_decode($buffer,true);
889
+	    $all_data = json_decode($buffer, true);
890 890
 	    if (isset($all_data['planes'])) {
891 891
 		$reset = 0;
892 892
 		foreach ($all_data['planes'] as $key => $line) {
@@ -903,12 +903,12 @@  discard block
 block discarded – undo
903 903
 		    $data['emergency'] = ''; // emergency
904 904
 		    $data['registration'] = $line[2];
905 905
 		    $data['aircraft_icao'] = $line[0];
906
-		    $deparr = explode('-',$line[1]);
906
+		    $deparr = explode('-', $line[1]);
907 907
 		    if (count($deparr) == 2) {
908 908
 			$data['departure_airport_icao'] = $deparr[0];
909 909
 			$data['arrival_airport_icao'] = $deparr[1];
910 910
 		    }
911
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
911
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
912 912
 	    	    $data['format_source'] = 'planeupdatefaa';
913 913
     		    $data['id_source'] = $id_source;
914 914
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 	    )
927 927
 	) {
928 928
 	    $buffer = $Common->getData($value['host']);
929
-	    $all_data = json_decode($buffer,true);
929
+	    $all_data = json_decode($buffer, true);
930 930
 	    if (isset($all_data['states'])) {
931 931
 		$reset = 0;
932 932
 		foreach ($all_data['states'] as $key => $line) {
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 		    //$data['emergency'] = ''; // emergency
944 944
 		    //$data['registration'] = $line[2];
945 945
 		    //$data['aircraft_icao'] = $line[0];
946
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
946
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
947 947
 		    $data['format_source'] = 'opensky';
948 948
 		    $data['id_source'] = $id_source;
949 949
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
 	) {
963 963
 	    //$buffer = $Common->getData($hosts[$id]);
964 964
 	    $buffer = $Common->getData($value['host']);
965
-	    $all_data = json_decode($buffer,true);
965
+	    $all_data = json_decode($buffer, true);
966 966
 	    if (!empty($all_data)) $reset = 0;
967 967
 	    foreach ($all_data as $key => $line) {
968 968
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1000,11 +1000,11 @@  discard block
 block discarded – undo
1000 1000
 	    )
1001 1001
 	) {
1002 1002
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1003
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1003
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1004 1004
 	    //echo $buffer;
1005
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1006
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1007
-	    $all_data = json_decode($buffer,true);
1005
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1006
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1007
+	    $all_data = json_decode($buffer, true);
1008 1008
 	    if (json_last_error() != JSON_ERROR_NONE) {
1009 1009
 		die(json_last_error_msg());
1010 1010
 	    }
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 			//$data['departure_airport_iata'] = $line[11];
1028 1028
 			//$data['arrival_airport_iata'] = $line[12];
1029 1029
 	    		//$data['emergency'] = ''; // emergency
1030
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1030
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1031 1031
 	    		$data['format_source'] = 'radarvirtueljson';
1032 1032
     			$data['id_source'] = $id_source;
1033 1033
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1048,14 +1048,14 @@  discard block
 block discarded – undo
1048 1048
 	) {
1049 1049
 	    //$buffer = $Common->getData($hosts[$id]);
1050 1050
 	    $buffer = $Common->getData($value['host'].'?'.time());
1051
-	    $all_data = json_decode(utf8_encode($buffer),true);
1051
+	    $all_data = json_decode(utf8_encode($buffer), true);
1052 1052
 	    
1053 1053
 	    if (isset($all_data['pireps'])) {
1054 1054
 		$reset = 0;
1055 1055
 	        foreach ($all_data['pireps'] as $line) {
1056 1056
 		    $data = array();
1057 1057
 		    $data['id'] = $line['id'];
1058
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1058
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1059 1059
 		    $data['ident'] = $line['callsign']; // ident
1060 1060
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1061 1061
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1085,9 +1085,9 @@  discard block
 block discarded – undo
1085 1085
 			$SI->add($data);
1086 1086
 		    //    print_r($data);
1087 1087
     		    } elseif ($line['icon'] == 'ct') {
1088
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1089
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1090
-			$typec = substr($data['ident'],-3);
1088
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1089
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1090
+			$typec = substr($data['ident'], -3);
1091 1091
 			$data['type'] = '';
1092 1092
 			if ($typec == 'APP') $data['type'] = 'Approach';
1093 1093
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1099 1099
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1100 1100
 			else $data['type'] = 'Observer';
1101
-			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']);
1101
+			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']);
1102 1102
 		    }
1103 1103
 		    unset($data);
1104 1104
 		}
@@ -1115,14 +1115,14 @@  discard block
 block discarded – undo
1115 1115
 	    //$buffer = $Common->getData($hosts[$id]);
1116 1116
 	    if ($globalDebug) echo 'Get Data...'."\n";
1117 1117
 	    $buffer = $Common->getData($value['host']);
1118
-	    $all_data = json_decode($buffer,true);
1118
+	    $all_data = json_decode($buffer, true);
1119 1119
 	    if ($buffer != '' && is_array($all_data)) {
1120 1120
 		$reset = 0;
1121 1121
 		foreach ($all_data as $line) {
1122 1122
 	    	    $data = array();
1123 1123
 	    	    //$data['id'] = $line['id']; // id not usable
1124 1124
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1125
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1125
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1126 1126
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1127 1127
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1128 1128
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 	    	    //$data['datetime'] = $line['lastupdate'];
1138 1138
 	    	    //$data['last_update'] = $line['lastupdate'];
1139 1139
 	    	    if (isset($value['timezone'])) {
1140
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1140
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1141 1141
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1142 1142
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1143 1143
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1150,14 +1150,14 @@  discard block
 block discarded – undo
1150 1150
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1151 1151
 		    if (isset($line['aircraftname'])) {
1152 1152
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1153
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1154
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1153
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1154
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1155 1155
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1156 1156
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1157 1157
 	    		else {
1158
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1159
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1160
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1158
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1159
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1160
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1161 1161
 	    		}
1162 1162
 	    	    }
1163 1163
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1182,14 +1182,14 @@  discard block
 block discarded – undo
1182 1182
 	    //$buffer = $Common->getData($hosts[$id]);
1183 1183
 	    if ($globalDebug) echo 'Get Data...'."\n";
1184 1184
 	    $buffer = $Common->getData($value['host']);
1185
-	    $all_data = json_decode($buffer,true);
1185
+	    $all_data = json_decode($buffer, true);
1186 1186
 	    if ($buffer != '' && is_array($all_data)) {
1187 1187
 		$reset = 0;
1188 1188
 		foreach ($all_data as $line) {
1189 1189
 	    	    $data = array();
1190 1190
 	    	    //$data['id'] = $line['id']; // id not usable
1191 1191
 	    	    $data['id'] = trim($line['flight_id']);
1192
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1192
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1193 1193
 	    	    $data['pilot_name'] = $line['pilot_name'];
1194 1194
 	    	    $data['pilot_id'] = $line['pilot_id'];
1195 1195
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1233,24 +1233,24 @@  discard block
 block discarded – undo
1233 1233
 	    //$buffer = $Common->getData($hosts[$id]);
1234 1234
 	    if ($globalDebug) echo 'Get Data...'."\n";
1235 1235
 	    $buffer = $Common->getData($value['host']);
1236
-	    $all_data = json_decode($buffer,true);
1236
+	    $all_data = json_decode($buffer, true);
1237 1237
 	    if ($buffer != '') {
1238 1238
 		$Source->deleteLocationBySource('blitzortung');
1239
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1240
-		$buffer = explode('\n',$buffer);
1239
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1240
+		$buffer = explode('\n', $buffer);
1241 1241
 		foreach ($buffer as $buffer_line) {
1242
-		    $line = json_decode($buffer_line,true);
1242
+		    $line = json_decode($buffer_line, true);
1243 1243
 		    if (isset($line['time'])) {
1244 1244
 			$data = array();
1245 1245
 			$data['altitude'] = $line['alt']; // altitude
1246 1246
 			$data['latitude'] = $line['lat']; // lat
1247 1247
 			$data['longitude'] = $line['lon']; // long
1248
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1248
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1249 1249
 			$data['id_source'] = $id_source;
1250 1250
 			$data['format_source'] = 'blitzortung';
1251 1251
 			$SI->add($data);
1252 1252
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1253
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1253
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1254 1254
 			unset($data);
1255 1255
 		    }
1256 1256
 		}
@@ -1275,11 +1275,11 @@  discard block
 block discarded – undo
1275 1275
 		    //$value = $formats[$nb];
1276 1276
 		    $format = $globalSources[$nb]['format'];
1277 1277
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1278
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1278
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1279 1279
 		    } elseif ($format == 'vrstcp') {
1280 1280
 			$buffer = @socket_read($r, 6000);
1281 1281
 		    } else {
1282
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1282
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1283 1283
 		    }
1284 1284
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1285 1285
 		    //echo $buffer."\n";
@@ -1288,8 +1288,8 @@  discard block
 block discarded – undo
1288 1288
 		    $error = false;
1289 1289
 		    //$SI::del();
1290 1290
 		    if ($format == 'vrstcp') {
1291
-			$buffer = explode('},{',$buffer);
1292
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1291
+			$buffer = explode('},{', $buffer);
1292
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1293 1293
 		    // SBS format is CSV format
1294 1294
 		    if ($buffer !== FALSE && $buffer != '') {
1295 1295
 			$tt[$format] = 0;
@@ -1323,13 +1323,13 @@  discard block
 block discarded – undo
1323 1323
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1324 1324
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1325 1325
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1326
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1326
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1327 1327
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1328 1328
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1329 1329
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1330 1330
 
1331 1331
 			    if (isset($ais_data['timestamp'])) {
1332
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1332
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1333 1333
 			    } else {
1334 1334
 				$data['datetime'] = date('Y-m-d H:i:s');
1335 1335
 			    }
@@ -1340,10 +1340,10 @@  discard block
 block discarded – undo
1340 1340
                         } elseif ($format == 'flightgearsp') {
1341 1341
                     	    //echo $buffer."\n";
1342 1342
                     	    if (strlen($buffer) > 5) {
1343
-				$line = explode(',',$buffer);
1343
+				$line = explode(',', $buffer);
1344 1344
 				$data = array();
1345 1345
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1346
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1346
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1347 1347
 				$data['ident'] = $line[6];
1348 1348
 				$data['aircraft_name'] = $line[7];
1349 1349
 				$data['longitude'] = $line[1];
@@ -1360,16 +1360,16 @@  discard block
 block discarded – undo
1360 1360
                         } elseif ($format == 'acars') {
1361 1361
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1362 1362
 			    $ACARS->add(trim($buffer));
1363
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1363
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1364 1364
 			    $ACARS->deleteLiveAcarsData();
1365 1365
 			} elseif ($format == 'flightgearmp') {
1366
-			    if (substr($buffer,0,1) != '#') {
1366
+			    if (substr($buffer, 0, 1) != '#') {
1367 1367
 				$data = array();
1368 1368
 				//echo $buffer."\n";
1369
-				$line = explode(' ',$buffer);
1369
+				$line = explode(' ', $buffer);
1370 1370
 				if (count($line) == 11) {
1371
-				    $userserver = explode('@',$line[0]);
1372
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1371
+				    $userserver = explode('@', $line[0]);
1372
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1373 1373
 				    $data['ident'] = $userserver[0];
1374 1374
 				    $data['registration'] = $userserver[0];
1375 1375
 				    $data['latitude'] = $line[4];
@@ -1377,8 +1377,8 @@  discard block
 block discarded – undo
1377 1377
 				    $data['altitude'] = $line[6];
1378 1378
 				    $data['datetime'] = date('Y-m-d H:i:s');
1379 1379
 				    $aircraft_type = $line[10];
1380
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1381
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1380
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1381
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1382 1382
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1383 1383
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1384 1384
 				}
@@ -1387,8 +1387,8 @@  discard block
 block discarded – undo
1387 1387
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1388 1388
 			    die;
1389 1389
 			} elseif ($format == 'vrstcp') {
1390
-			    foreach($buffer as $all_data) {
1391
-				$line = json_decode('{'.$all_data.'}',true);
1390
+			    foreach ($buffer as $all_data) {
1391
+				$line = json_decode('{'.$all_data.'}', true);
1392 1392
 				$data = array();
1393 1393
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1394 1394
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1414,16 +1414,16 @@  discard block
 block discarded – undo
1414 1414
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1415 1415
 				unset($data);
1416 1416
 			    }
1417
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1417
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1418 1418
 			    $line = explode("\t", $buffer);
1419
-			    for($k = 0; $k < count($line); $k=$k+2) {
1419
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1420 1420
 				$key = $line[$k];
1421
-			        $lined[$key] = $line[$k+1];
1421
+			        $lined[$key] = $line[$k + 1];
1422 1422
 			    }
1423 1423
     			    if (count($lined) > 3) {
1424 1424
     				$data['hex'] = $lined['hexid'];
1425 1425
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1426
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1426
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1427 1427
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1428 1428
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1429 1429
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1442,22 +1442,22 @@  discard block
 block discarded – undo
1442 1442
     			    } else $error = true;
1443 1443
 			} elseif ($format == 'aprs' && $use_aprs) {
1444 1444
 			    if ($aprs_connect == 0) {
1445
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1445
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1446 1446
 				$aprs_connect = 1;
1447 1447
 			    }
1448 1448
 			    
1449
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1449
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1450 1450
 				$aprs_last_tx = time();
1451 1451
 				$data_aprs = "# Keep alive";
1452
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1452
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1453 1453
 			    }
1454 1454
 			    
1455 1455
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1456 1456
 			    //echo 'APRS data : '.$buffer."\n";
1457
-			    $buffer = str_replace('APRS <- ','',$buffer);
1458
-			    $buffer = str_replace('APRS -> ','',$buffer);
1457
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1458
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1459 1459
 			    //echo $buffer."\n";
1460
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1460
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1461 1461
 				$line = $APRS->parse($buffer);
1462 1462
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1463 1463
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1472,7 +1472,7 @@  discard block
 block discarded – undo
1472 1472
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1473 1473
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1474 1474
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1475
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1475
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1476 1476
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1477 1477
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1478 1478
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1551,29 +1551,29 @@  discard block
 block discarded – undo
1551 1551
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1552 1552
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1553 1553
 					$Source->deleteOldLocationByType('gs');
1554
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1555
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1554
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1555
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1556 1556
 					} else {
1557
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1557
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1558 1558
 					}
1559 1559
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1560 1560
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1561 1561
 					if ($globalDebug) echo '# Weather Station added'."\n";
1562 1562
 					$Source->deleteOldLocationByType('wx');
1563 1563
 					$weather_data = json_encode($line);
1564
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1565
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1564
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1565
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1566 1566
 					} else {
1567
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1567
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1568 1568
 					}
1569 1569
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1570 1570
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1571 1571
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1572 1572
 					$Source->deleteOldLocationByType('lightning');
1573
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1574
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1573
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1574
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1575 1575
 					} else {
1576
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1576
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1577 1577
 					}
1578 1578
 				    } elseif ($globalDebug) {
1579 1579
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
 				    unset($data);
1583 1583
 				}
1584 1584
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1585
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1585
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1586 1586
 				}
1587 1587
 				/*
1588 1588
 				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')) {
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
 				*/
1592 1592
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1593 1593
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1594
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1594
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1595 1595
 					$Source->deleteOldLocationByType('lightning');
1596 1596
 					$Source->deleteOldLocationByType('wx');
1597 1597
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
 				connect_all($sourceee);
1677 1677
 				$sourceee = array();
1678 1678
 				//connect_all($globalSources);
1679
-				$tt[$format]=0;
1679
+				$tt[$format] = 0;
1680 1680
 				break;
1681 1681
 			    }
1682 1682
 			}
@@ -1685,14 +1685,14 @@  discard block
 block discarded – undo
1685 1685
 	    } else {
1686 1686
 		$error = socket_strerror(socket_last_error());
1687 1687
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1688
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1688
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1689 1689
 			if (isset($globalDebug)) echo "Restarting...\n";
1690 1690
 			// Restart the script if possible
1691 1691
 			if (is_array($sockets)) {
1692 1692
 			    if ($globalDebug) echo "Shutdown all sockets...";
1693 1693
 			    
1694 1694
 			    foreach ($sockets as $sock) {
1695
-				@socket_shutdown($sock,2);
1695
+				@socket_shutdown($sock, 2);
1696 1696
 				@socket_close($sock);
1697 1697
 			    }
1698 1698
 			    
Please login to merge, or discard this patch.
require/class.APRS.php 1 patch
Spacing   +157 added lines, -158 removed lines patch added patch discarded remove patch
@@ -167,8 +167,7 @@  discard block
 block discarded – undo
167 167
 	
168 168
 
169 169
     private function urshift($n, $s) {
170
-	return ($n >= 0) ? ($n >> $s) :
171
-	    (($n & 0x7fffffff) >> $s) | 
170
+	return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
172 171
 		(0x40000000 >> ($s - 1));
173 172
     }
174 173
 
@@ -180,7 +179,7 @@  discard block
 block discarded – undo
180 179
 	//$split_input = str_split($input);
181 180
 
182 181
 	/* Find the end of header checking for NULL bytes while doing it. */
183
-	$splitpos = strpos($input,':');
182
+	$splitpos = strpos($input, ':');
184 183
 	
185 184
 	/* Check that end was found and body has at least one byte. */
186 185
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -190,15 +189,15 @@  discard block
 block discarded – undo
190 189
 	
191 190
 	if ($debug) echo 'input : '.$input."\n";
192 191
 	/* Save header and body. */
193
-	$body = substr($input,$splitpos+1,$input_len);
192
+	$body = substr($input, $splitpos + 1, $input_len);
194 193
 	$body_len = strlen($body);
195
-	$header = substr($input,0,$splitpos);
194
+	$header = substr($input, 0, $splitpos);
196 195
 	//$header_len = strlen($header);
197 196
 	if ($debug) echo 'header : '.$header."\n";
198 197
 	
199 198
 	/* Parse source, target and path. */
200 199
 	//FLRDF0A52>APRS,qAS,LSTB
201
-	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
200
+	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
202 201
 	    $ident = $matches[1];
203 202
 	    $all_elements = $matches[2];
204 203
 	    if ($ident == 'AIRCRAFT') {
@@ -215,14 +214,14 @@  discard block
 block discarded – undo
215 214
 	    if ($debug) 'No ident'."\n";
216 215
 	    return false;
217 216
 	}
218
-	$elements = explode(',',$all_elements);
217
+	$elements = explode(',', $all_elements);
219 218
 	$source = end($elements);
220 219
 	$result['source'] = $source;
221 220
 	foreach ($elements as $element) {
222
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
221
+	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
223 222
 	        //echo "ok";
224 223
 	        //if ($element == 'TCPIP*') return false;
225
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
224
+	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
226 225
 		if ($debug) echo 'element : '.$element."\n";
227 226
 		return false;
228 227
 	    }
@@ -235,14 +234,14 @@  discard block
 block discarded – undo
235 234
 	    */
236 235
 	}
237 236
 	
238
-	$type = substr($body,0,1);
237
+	$type = substr($body, 0, 1);
239 238
 	if ($debug) echo 'type : '.$type."\n";
240 239
 	if ($type == ';') {
241 240
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
242
-			$result['address'] = trim(substr($body,1,9));
241
+			$result['address'] = trim(substr($body, 1, 9));
243 242
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
244
-			$result['mmsi'] = trim(substr($body,1,9));
245
-		} else $result['ident'] = trim(substr($body,1,9));
243
+			$result['mmsi'] = trim(substr($body, 1, 9));
244
+		} else $result['ident'] = trim(substr($body, 1, 9));
246 245
 	} elseif ($type == ',') {
247 246
 		// Invalid data or test data
248 247
 		return false;
@@ -250,24 +249,24 @@  discard block
 block discarded – undo
250 249
 	
251 250
 	// Check for Timestamp
252 251
 	$find = false;
253
-	$body_parse = substr($body,1);
252
+	$body_parse = substr($body, 1);
254 253
 	//echo 'Body : '.$body."\n";
255
-	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
256
-	    $body_parse = substr($body_parse,10);
254
+	if (preg_match('/^;(.){9}\*/', $body, $matches)) {
255
+	    $body_parse = substr($body_parse, 10);
257 256
 	    $find = true;
258 257
 	    //echo $body_parse."\n";
259 258
 	}
260
-	if (preg_match('/^`(.*)\//',$body,$matches)) {
261
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
259
+	if (preg_match('/^`(.*)\//', $body, $matches)) {
260
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
262 261
 	    $find = true;
263 262
 	    //echo $body_parse."\n";
264 263
 	}
265
-	if (preg_match("/^'(.*)\//",$body,$matches)) {
266
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
264
+	if (preg_match("/^'(.*)\//", $body, $matches)) {
265
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
267 266
 	    $find = true;
268 267
 	    //echo $body_parse."\n";
269 268
 	}
270
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
269
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
271 270
 	    $find = true;
272 271
 	    //print_r($matches);
273 272
 	    $timestamp = $matches[0];
@@ -282,19 +281,19 @@  discard block
 block discarded – undo
282 281
 		// This work or not ?
283 282
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
284 283
 	    }
285
-	    $body_parse = substr($body_parse,7);
284
+	    $body_parse = substr($body_parse, 7);
286 285
 	    $result['timestamp'] = $timestamp;
287 286
 	    //echo date('Ymd H:i:s',$timestamp);
288 287
 	}
289
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
288
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
290 289
 	    $find = true;
291 290
 	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
292
-	    $body_parse = substr($body_parse,8);
291
+	    $body_parse = substr($body_parse, 8);
293 292
 	    $result['timestamp'] = $timestamp;
294 293
 	    //echo date('Ymd H:i:s',$timestamp);
295 294
 	}
296 295
 	//if (strlen($body_parse) > 19) {
297
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
296
+	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
298 297
 		$find = true;
299 298
 		// 4658.70N/00707.78Ez
300 299
 		//print_r(str_split($body_parse));
@@ -321,11 +320,11 @@  discard block
 block discarded – undo
321 320
 	    */
322 321
 		$latitude = $lat + floatval($lat_min)/60;
323 322
 		$longitude = $lon + floatval($lon_min)/60;
324
-		if ($sind == 'S') $latitude = 0-$latitude;
325
-		if ($wind == 'W') $longitude = 0-$longitude;
323
+		if ($sind == 'S') $latitude = 0 - $latitude;
324
+		if ($wind == 'W') $longitude = 0 - $longitude;
326 325
 		$result['latitude'] = $latitude;
327 326
 		$result['longitude'] = $longitude;
328
-		$body_parse = substr($body_parse,18);
327
+		$body_parse = substr($body_parse, 18);
329 328
 		$body_parse_len = strlen($body_parse);
330 329
 	    }
331 330
 	    $body_parse_len = strlen($body_parse);
@@ -357,7 +356,7 @@  discard block
 block discarded – undo
357 356
 		//echo $body_parse;
358 357
 			//if ($type != ';' && $type != '>') {
359 358
 			if ($type != '') {
360
-			$body_parse = substr($body_parse,1);
359
+			$body_parse = substr($body_parse, 1);
361 360
 			$body_parse_len = strlen($body_parse);
362 361
 			$result['symbol_code'] = $symbol_code;
363 362
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
@@ -368,16 +367,16 @@  discard block
 block discarded – undo
368 367
 		    //$body_parse_len = strlen($body_parse);
369 368
 		    if ($body_parse_len >= 7) {
370 369
 			
371
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
372
-		    	    $course = substr($body_parse,0,3);
370
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
371
+		    	    $course = substr($body_parse, 0, 3);
373 372
 		    	    $tmp_s = intval($course);
374 373
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
375
-		    	    $speed = substr($body_parse,4,3);
374
+		    	    $speed = substr($body_parse, 4, 3);
376 375
 		    	    if ($speed != '...') {
377 376
 		    		//$result['speed'] = round($speed*1.852);
378 377
 		    		$result['speed'] = intval($speed);
379 378
 		    	    }
380
-		    	    $body_parse = substr($body_parse,7);
379
+		    	    $body_parse = substr($body_parse, 7);
381 380
 		        }
382 381
 		        // Check PHGR, PHG, RNG
383 382
 		    } 
@@ -387,12 +386,12 @@  discard block
 block discarded – undo
387 386
 		    }
388 387
 		    */
389 388
 		    if (strlen($body_parse) > 0) {
390
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
389
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
391 390
 		            $altitude = intval($matches[1]);
392 391
 		            //$result['altitude'] = round($altitude*0.3048);
393 392
 		            $result['altitude'] = $altitude;
394 393
 		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
395
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
394
+		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse));
396 395
 		        }
397 396
 		    }
398 397
 		    
@@ -404,13 +403,13 @@  discard block
 block discarded – undo
404 403
 		    */
405 404
 		    // DAO
406 405
 		    
407
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
406
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
408 407
 			    
409 408
 			    $dao = $matches[1];
410
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
409
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
411 410
 				$dao_split = str_split($dao);
412
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
413
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
411
+			        $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
412
+			        $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
414 413
 			    
415 414
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
416 415
 				else $result['latitude'] += $lat_off;
@@ -418,50 +417,50 @@  discard block
 block discarded – undo
418 417
 				else $result['longitude'] += $lon_off;
419 418
 			    }
420 419
 			    
421
-		            $body_parse = substr($body_parse,6);
420
+		            $body_parse = substr($body_parse, 6);
422 421
 		    }
423 422
 		    
424
-		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
425
-			$result['ident'] = str_replace('_',' ',$matches[1]);
423
+		    if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) {
424
+			$result['ident'] = str_replace('_', ' ', $matches[1]);
426 425
 		    }
427
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
426
+		    if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) {
428 427
 			$result['squawk'] = $matches[1];
429 428
 		    }
430
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
429
+		    if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) {
431 430
 			$result['aircraft_icao'] = $matches[1];
432 431
 		    }
433
-		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
432
+		    if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) {
434 433
 			$result['verticalrate'] = $matches[1];
435 434
 		    }
436
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
435
+		    if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) {
437 436
 			$result['typeid'] = $matches[1];
438 437
 		    }
439
-		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
438
+		    if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) {
440 439
 			$result['statusid'] = $matches[1];
441 440
 		    }
442
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
441
+		    if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) {
443 442
 			$result['imo'] = $matches[1];
444 443
 		    }
445
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
444
+		    if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) {
446 445
 			$result['arrival_date'] = $matches[1];
447 446
 		    }
448
-		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
449
-			$result['arrival_code'] = str_replace('_',' ',$matches[1]);
447
+		    if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) {
448
+			$result['arrival_code'] = str_replace('_', ' ', $matches[1]);
450 449
 		    }
451 450
 		    // OGN comment
452 451
 		   // echo "Before OGN : ".$body_parse."\n";
453 452
 		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
454
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
453
+		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
455 454
 			$id = $matches[1];
456 455
 			//$mode = substr($id,0,2);
457
-			$address = substr($id,2);
456
+			$address = substr($id, 2);
458 457
 			//print_r($matches);
459
-			$addressType = (intval(substr($id,0,2),16))&3;
458
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
460 459
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
461 460
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
462 461
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
463 462
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
464
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
463
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
465 464
 			$result['aircrafttype_code'] = $aircraftType;
466 465
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
467 466
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -478,7 +477,7 @@  discard block
 block discarded – undo
478 477
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
479 478
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
480 479
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
481
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
480
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
482 481
 			$result['stealth'] = $stealth;
483 482
 			$result['address'] = $address;
484 483
 		    }
@@ -490,96 +489,96 @@  discard block
 block discarded – undo
490 489
 		    //$body_parse = substr($body_parse,1);
491 490
 		    //$body_parse_len = strlen($body_parse);
492 491
 		    //echo 'weather'."\n";
493
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
492
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
494 493
 			    $result['wind_dir'] = intval($matches[1]);
495
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
496
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
497
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
498
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
499
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
494
+			    $result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
495
+			    $result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
496
+			    $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1);
497
+		    	    $body_parse = substr($body_parse, strlen($matches[0]) + 1);
498
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
500 499
 			$result['wind_dir'] = intval($matches[1]);
501
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
502
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
503
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
504
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
505
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
500
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
501
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
502
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
503
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
504
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
506 505
 			$result['wind_dir'] = intval($matches[1]);
507
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
508
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
509
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
510
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
506
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
507
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
508
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
509
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
511 510
 			$result['wind_dir'] = intval($matches[1]);
512
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
513
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
514
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
511
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
512
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
513
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
515 514
 		    }
516 515
 		    //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
517 516
 		    //g012t088r000p000P000h38b10110
518 517
 		    //g011t086r000p000P000h29b10198
519
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
520
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
521
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
522
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
523
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
524
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
518
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
519
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
520
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
521
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
522
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
523
+			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
525 524
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
526
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
527
-		        $body_parse = substr($body_parse,strlen($matches[0]));
528
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
529
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
530
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
531
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
532
-			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
533
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
525
+			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
526
+		        $body_parse = substr($body_parse, strlen($matches[0]));
527
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
528
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
529
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
530
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
531
+			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1);
532
+			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
534 533
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
535
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
536
-		        $body_parse = substr($body_parse,strlen($matches[0]));
537
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
538
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
539
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
540
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
541
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
542
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
534
+			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
535
+		        $body_parse = substr($body_parse, strlen($matches[0]));
536
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
537
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
538
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
539
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
540
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
541
+			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
543 542
 			if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
544
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
545
-		        $body_parse = substr($body_parse,strlen($matches[0]));
546
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
547
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
548
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
549
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
550
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
543
+			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
544
+		        $body_parse = substr($body_parse, strlen($matches[0]));
545
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
546
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
547
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
548
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
549
+			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
551 550
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
552
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
553
-		        $body_parse = substr($body_parse,strlen($matches[0]));
554
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
555
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
556
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
557
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
558
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
551
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
552
+		        $body_parse = substr($body_parse, strlen($matches[0]));
553
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
554
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
555
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
556
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
557
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
559 558
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
560
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
561
-		        $body_parse = substr($body_parse,strlen($matches[0]));
562
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
563
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
564
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
565
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
566
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
559
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
560
+		        $body_parse = substr($body_parse, strlen($matches[0]));
561
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
562
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
563
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
564
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
565
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
567 566
 			if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
568
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
569
-		        $body_parse = substr($body_parse,strlen($matches[0]));
570
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
571
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
572
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
567
+			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
568
+		        $body_parse = substr($body_parse, strlen($matches[0]));
569
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
570
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
571
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
573 572
 			if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
574
-			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
575
-		        $body_parse = substr($body_parse,strlen($matches[0]));
576
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
577
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
578
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
579
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
573
+			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1);
574
+		        $body_parse = substr($body_parse, strlen($matches[0]));
575
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
576
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
577
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
578
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
580 579
 			if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
581
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
582
-		        $body_parse = substr($body_parse,strlen($matches[0]));
580
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
581
+		        $body_parse = substr($body_parse, strlen($matches[0]));
583 582
 		    }
584 583
 		    $result['comment'] = trim($body_parse);
585 584
 		}
@@ -587,42 +586,42 @@  discard block
 block discarded – undo
587 586
 
588 587
 	    }
589 588
 	//}
590
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
591
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
589
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
590
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
592 591
 	if ($debug) print_r($result);
593 592
 	return $result;
594 593
     }
595 594
     
596 595
     public function connect() {
597
-	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
596
+	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport;
598 597
 	$aprs_connect = 0;
599 598
 	$aprs_keep = 120;
600 599
 	$aprs_last_tx = time();
601 600
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
602
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
601
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
603 602
 	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
604
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
603
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
605 604
 	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
606 605
 	else $aprs_pass = '-1';
607 606
 	
608
-	$aprs_filter  = '';
607
+	$aprs_filter = '';
609 608
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
610 609
 	$Common = new Common();
611
-	$s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr);
610
+	$s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr);
612 611
 	if ($s !== false) {
613 612
 		echo 'Connected to APRS server! '."\n";
614 613
 		$authstart = time();
615 614
 		$this->socket = $s;
616
-		$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
617
-		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1);
618
-		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
615
+		$send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0);
616
+		socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1);
617
+		while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) {
619 618
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
620 619
 			    echo 'APRS user verified !'."\n";
621 620
 			    $this->connected = true;
622 621
 			    return true;
623 622
 			    break;
624 623
 			}
625
-			if (time()-$authstart > 5) {
624
+			if (time() - $authstart > 5) {
626 625
 			    echo 'APRS timeout'."\n";
627 626
 			    break;
628 627
 			}
@@ -637,7 +636,7 @@  discard block
 block discarded – undo
637 636
     public function send($data) {
638 637
 	global $globalDebug;
639 638
 	if ($this->connected === false) $this->connect();
640
-	$send = socket_send( $this->socket  , $data , strlen($data),0);
639
+	$send = socket_send($this->socket, $data, strlen($data), 0);
641 640
 	if ($send === FALSE) {
642 641
 		if ($globalDebug) echo 'Reconnect...';
643 642
 		socket_close($this->socket);
@@ -647,16 +646,16 @@  discard block
 block discarded – undo
647 646
 }
648 647
 
649 648
 class APRSSpotter extends APRS {
650
-	public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) {
649
+	public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) {
651 650
 		$Common = new Common();
652 651
 		if ($latitude != '' && $longitude != '') {
653 652
 			$lat = $latitude;
654 653
 			$long = $longitude;
655
-			$latitude = $Common->convertDM($latitude,'latitude');
656
-			$longitude = $Common->convertDM($longitude,'longitude');
657
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
658
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
659
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
654
+			$latitude = $Common->convertDM($latitude, 'latitude');
655
+			$longitude = $Common->convertDM($longitude, 'longitude');
656
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
657
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
658
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
660 659
 			$w = $w1.$w2;
661 660
 			//$w = '00';
662 661
 			$custom = '';
@@ -683,25 +682,25 @@  discard block
 block discarded – undo
683 682
 			$geoid= round($GeoidClass->get($lat,$long)*3.28084,2);
684 683
 			$altitude_real = round($altitude_real + $geoid);
685 684
 			*/
686
-			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
685
+			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
687 686
 		}
688 687
 	}
689 688
 }
690 689
 class APRSMarine extends APRS {
691
-	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) {
690
+	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) {
692 691
 		$Common = new Common();
693 692
 		if ($latitude != '' && $longitude != '') {
694
-			$latitude = $Common->convertDM($latitude,'latitude');
695
-			$longitude = $Common->convertDM($longitude,'longitude');
696
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
697
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
698
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
693
+			$latitude = $Common->convertDM($latitude, 'latitude');
694
+			$longitude = $Common->convertDM($longitude, 'longitude');
695
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
696
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
697
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
699 698
 			$w = $w1.$w2;
700 699
 			//$w = '00';
701 700
 			$custom = '';
702 701
 			if ($ident != '') {
703 702
 				if ($custom != '') $custom .= '/';
704
-				$custom .= 'CS='.str_replace(' ','_',$ident);
703
+				$custom .= 'CS='.str_replace(' ', '_', $ident);
705 704
 			}
706 705
 			if ($typeid != '') {
707 706
 				if ($custom != '') $custom .= '/';
@@ -721,11 +720,11 @@  discard block
 block discarded – undo
721 720
 			}
722 721
 			if ($arrival_code != '') {
723 722
 				if ($custom != '') $custom .= '/';
724
-				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
723
+				$custom .= 'AC='.str_replace(' ', '_', $arrival_code);
725 724
 			}
726 725
 			if ($custom != '') $custom = ' '.$custom;
727 726
 			$altitude = 0;
728
-			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
727
+			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
729 728
 		}
730 729
 	}
731 730
 }
Please login to merge, or discard this patch.