Completed
Push — master ( cf2135...b184e5 )
by Yannick
28:22
created
scripts/daemon-spotter.php 1 patch
Indentation   +963 added lines, -963 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 57
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 if (isset($options['idsource'])) $id_source = $options['idsource'];
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
106
+	if ($globalDebug) echo "Using Server Mode\n";
107
+	$SI=new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
117
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
117
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 119
 }
120 120
 
121 121
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
122 122
 if (isset($globalMarine) && $globalMarine) {
123
-    $AIS = new AIS();
124
-    $MI = new MarineImport($Connection->db);
123
+	$AIS = new AIS();
124
+	$MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127 127
 $SBS=new SBS();
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
138
-        global $sockets;
139
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
-        die("Bye!\n");
141
-    });
142
-    pcntl_signal_dispatch();
137
+	pcntl_signal(SIGINT,  function() {
138
+		global $sockets;
139
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
+		die("Bye!\n");
141
+	});
142
+	pcntl_signal_dispatch();
143 143
 }
144 144
 
145 145
 // let's try and connect
@@ -149,36 +149,36 @@  discard block
 block discarded – undo
149 149
 $reset = 0;
150 150
 
151 151
 function connect_all($hosts) {
152
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
-    $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
156
-    foreach ($hosts as $id => $value) {
152
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
+	$reset++;
155
+	if ($globalDebug) echo 'Connect to all...'."\n";
156
+	foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160 160
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
162
-        	//$formats[$id] = 'deltadbtxt';
163
-        	$globalSources[$id]['format'] = 'deltadbtxt';
164
-        	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
-        	//$formats[$id] = 'vatsimtxt';
168
-        	$globalSources[$id]['format'] = 'vatsimtxt';
169
-        	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172
-        	//$formats[$id] = 'aircraftlistjson';
173
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
174
-        	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/opensky/i',$host)) {
177
-        	//$formats[$id] = 'aircraftlistjson';
178
-        	$globalSources[$id]['format'] = 'opensky';
179
-        	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
181
-    	    /*
161
+			if (preg_match('/deltadb.txt$/i',$host)) {
162
+			//$formats[$id] = 'deltadbtxt';
163
+			$globalSources[$id]['format'] = 'deltadbtxt';
164
+			//$last_exec['deltadbtxt'] = 0;
165
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
+			//$formats[$id] = 'vatsimtxt';
168
+			$globalSources[$id]['format'] = 'vatsimtxt';
169
+			//$last_exec['vatsimtxt'] = 0;
170
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
172
+			//$formats[$id] = 'aircraftlistjson';
173
+			$globalSources[$id]['format'] = 'aircraftlistjson';
174
+			//$last_exec['aircraftlistjson'] = 0;
175
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
+			} else if (preg_match('/opensky/i',$host)) {
177
+			//$formats[$id] = 'aircraftlistjson';
178
+			$globalSources[$id]['format'] = 'opensky';
179
+			//$last_exec['aircraftlistjson'] = 0;
180
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
181
+			/*
182 182
     	    // Disabled for now, site change source format
183 183
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
184 184
         	//$formats[$id] = 'radarvirtueljson';
@@ -190,120 +190,120 @@  discard block
 block discarded – undo
190 190
         	    exit(0);
191 191
         	}
192 192
     	    */
193
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
194
-        	//$formats[$id] = 'planeupdatefaa';
195
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
196
-        	//$last_exec['planeupdatefaa'] = 0;
197
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
198
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
199
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200
-        	    exit(0);
201
-        	}
202
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
203
-        	//$formats[$id] = 'phpvmacars';
204
-        	$globalSources[$id]['format'] = 'phpvmacars';
205
-        	//$last_exec['phpvmacars'] = 0;
206
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
207
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
208
-        	//$formats[$id] = 'phpvmacars';
209
-        	$globalSources[$id]['format'] = 'vam';
210
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
211
-            } else if (preg_match('/whazzup/i',$host)) {
212
-        	//$formats[$id] = 'whazzup';
213
-        	$globalSources[$id]['format'] = 'whazzup';
214
-        	//$last_exec['whazzup'] = 0;
215
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
216
-            } else if (preg_match('/blitzortung/i',$host)) {
217
-        	$globalSources[$id]['format'] = 'blitzortung';
218
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
219
-            } else if (preg_match('/airwhere/i',$host)) {
220
-        	$globalSources[$id]['format'] = 'airwhere';
221
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
222
-            } else if (preg_match('/recentpireps/i',$host)) {
223
-        	//$formats[$id] = 'pirepsjson';
224
-        	$globalSources[$id]['format'] = 'pirepsjson';
225
-        	//$last_exec['pirepsjson'] = 0;
226
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
227
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
228
-        	//$formats[$id] = 'fr24json';
229
-        	$globalSources[$id]['format'] = 'fr24json';
230
-        	//$last_exec['fr24json'] = 0;
231
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
232
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
233
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
234
-        	    exit(0);
235
-        	}
236
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
237
-        	//$formats[$id] = 'fr24json';
238
-        	$globalSources[$id]['format'] = 'myshiptracking';
239
-        	//$last_exec['fr24json'] = 0;
240
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
241
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
242
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
243
-        	    exit(0);
244
-        	}
245
-            //} else if (preg_match('/10001/',$host)) {
246
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
247
-        	//$formats[$id] = 'tsv';
248
-        	$globalSources[$id]['format'] = 'tsv';
249
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
250
-            }
251
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
252
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
253
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
254
-    		    if ($idf !== false) {
255
-    			$httpfeeds[$id] = $idf;
256
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
257
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
258
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
259
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
260
-	    $hostport = explode(':',$host);
261
-	    if (isset($hostport[1])) {
193
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
194
+			//$formats[$id] = 'planeupdatefaa';
195
+			$globalSources[$id]['format'] = 'planeupdatefaa';
196
+			//$last_exec['planeupdatefaa'] = 0;
197
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
198
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
199
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200
+				exit(0);
201
+			}
202
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
203
+			//$formats[$id] = 'phpvmacars';
204
+			$globalSources[$id]['format'] = 'phpvmacars';
205
+			//$last_exec['phpvmacars'] = 0;
206
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
207
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
208
+			//$formats[$id] = 'phpvmacars';
209
+			$globalSources[$id]['format'] = 'vam';
210
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
211
+			} else if (preg_match('/whazzup/i',$host)) {
212
+			//$formats[$id] = 'whazzup';
213
+			$globalSources[$id]['format'] = 'whazzup';
214
+			//$last_exec['whazzup'] = 0;
215
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
216
+			} else if (preg_match('/blitzortung/i',$host)) {
217
+			$globalSources[$id]['format'] = 'blitzortung';
218
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
219
+			} else if (preg_match('/airwhere/i',$host)) {
220
+			$globalSources[$id]['format'] = 'airwhere';
221
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
222
+			} else if (preg_match('/recentpireps/i',$host)) {
223
+			//$formats[$id] = 'pirepsjson';
224
+			$globalSources[$id]['format'] = 'pirepsjson';
225
+			//$last_exec['pirepsjson'] = 0;
226
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
227
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
228
+			//$formats[$id] = 'fr24json';
229
+			$globalSources[$id]['format'] = 'fr24json';
230
+			//$last_exec['fr24json'] = 0;
231
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
232
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
233
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
234
+				exit(0);
235
+			}
236
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
237
+			//$formats[$id] = 'fr24json';
238
+			$globalSources[$id]['format'] = 'myshiptracking';
239
+			//$last_exec['fr24json'] = 0;
240
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
241
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
242
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
243
+				exit(0);
244
+			}
245
+			//} else if (preg_match('/10001/',$host)) {
246
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
247
+			//$formats[$id] = 'tsv';
248
+			$globalSources[$id]['format'] = 'tsv';
249
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
250
+			}
251
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
252
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
253
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
254
+				if ($idf !== false) {
255
+				$httpfeeds[$id] = $idf;
256
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
257
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
258
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
259
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
260
+		$hostport = explode(':',$host);
261
+		if (isset($hostport[1])) {
262 262
 		$port = $hostport[1];
263 263
 		$hostn = $hostport[0];
264
-	    } else {
264
+		} else {
265 265
 		$port = $globalSources[$id]['port'];
266 266
 		$hostn = $globalSources[$id]['host'];
267
-	    }
268
-	    $Common = new Common();
269
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
270
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
271
-    	    } else {
272
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
273
-	    }
274
-	    if ($s) {
275
-    	        $sockets[$id] = $s;
276
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
277
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
267
+		}
268
+		$Common = new Common();
269
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
270
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
271
+			} else {
272
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
273
+		}
274
+		if ($s) {
275
+				$sockets[$id] = $s;
276
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
277
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
278 278
 			//$formats[$id] = 'aprs';
279 279
 			$globalSources[$id]['format'] = 'aprs';
280 280
 			//$aprs_connect = 0;
281 281
 			//$use_aprs = true;
282
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
282
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
283 283
 			$globalSources[$id]['format'] = 'vrstcp';
284
-    		    } elseif ($port == '10001') {
285
-        		//$formats[$id] = 'tsv';
286
-        		$globalSources[$id]['format'] = 'tsv';
287
-		    } elseif ($port == '30002') {
288
-        		//$formats[$id] = 'raw';
289
-        		$globalSources[$id]['format'] = 'raw';
290
-		    } elseif ($port == '5001') {
291
-        		//$formats[$id] = 'raw';
292
-        		$globalSources[$id]['format'] = 'flightgearmp';
293
-		    } elseif ($port == '30005') {
284
+				} elseif ($port == '10001') {
285
+				//$formats[$id] = 'tsv';
286
+				$globalSources[$id]['format'] = 'tsv';
287
+			} elseif ($port == '30002') {
288
+				//$formats[$id] = 'raw';
289
+				$globalSources[$id]['format'] = 'raw';
290
+			} elseif ($port == '5001') {
291
+				//$formats[$id] = 'raw';
292
+				$globalSources[$id]['format'] = 'flightgearmp';
293
+			} elseif ($port == '30005') {
294 294
 			// Not yet supported
295
-        		//$formats[$id] = 'beast';
296
-        		$globalSources[$id]['format'] = 'beast';
297
-		    //} else $formats[$id] = 'sbs';
298
-		    } else $globalSources[$id]['format'] = 'sbs';
299
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
295
+				//$formats[$id] = 'beast';
296
+				$globalSources[$id]['format'] = 'beast';
297
+			//} else $formats[$id] = 'sbs';
298
+			} else $globalSources[$id]['format'] = 'sbs';
299
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
300 300
 		}
301 301
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
302
-            } else {
302
+			} else {
303 303
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
304
-    	    }
305
-        }
306
-    }
304
+			}
305
+		}
306
+	}
307 307
 }
308 308
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
309 309
 
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
 //connect_all($globalSources);
327 327
 
328 328
 if (isset($globalProxy) && $globalProxy) {
329
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
329
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
330 330
 } else {
331
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
331
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
332 332
 }
333 333
 
334 334
 // APRS Configuration
@@ -337,21 +337,21 @@  discard block
 block discarded – undo
337 337
 	die;
338 338
 }
339 339
 foreach ($globalSources as $key => $source) {
340
-    if (!isset($source['format'])) {
341
-        $globalSources[$key]['format'] = 'auto';
342
-    }
343
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
344
-        unset($globalSources[$key]);
345
-    }
340
+	if (!isset($source['format'])) {
341
+		$globalSources[$key]['format'] = 'auto';
342
+	}
343
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
344
+		unset($globalSources[$key]);
345
+	}
346 346
 }
347 347
 connect_all($globalSources);
348 348
 foreach ($globalSources as $key => $source) {
349
-    if (isset($source['format']) && $source['format'] == 'aprs') {
349
+	if (isset($source['format']) && $source['format'] == 'aprs') {
350 350
 	$aprs_connect = 0;
351 351
 	$use_aprs = true;
352 352
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
353 353
 	break;
354
-    }
354
+	}
355 355
 }
356 356
 
357 357
 if ($use_aprs) {
@@ -392,129 +392,129 @@  discard block
 block discarded – undo
392 392
 
393 393
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
394 394
 while ($i > 0) {
395
-    if (!$globalDaemon) $i = $endtime-time();
396
-    // Delete old ATC
397
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
395
+	if (!$globalDaemon) $i = $endtime-time();
396
+	// Delete old ATC
397
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
398 398
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
399
-        $ATC->deleteOldATC();
400
-    }
399
+		$ATC->deleteOldATC();
400
+	}
401 401
     
402
-    if (count($last_exec) == count($globalSources)) {
402
+	if (count($last_exec) == count($globalSources)) {
403 403
 	$max = $globalMinFetch;
404 404
 	foreach ($last_exec as $last) {
405
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
405
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
406 406
 	}
407 407
 	if ($max != $globalMinFetch) {
408
-	    if ($globalDebug) echo 'Sleeping...'."\n";
409
-	    sleep($globalMinFetch-$max+2);
408
+		if ($globalDebug) echo 'Sleeping...'."\n";
409
+		sleep($globalMinFetch-$max+2);
410
+	}
410 411
 	}
411
-    }
412 412
 
413 413
     
414
-    //foreach ($formats as $id => $value) {
415
-    foreach ($globalSources as $id => $value) {
414
+	//foreach ($formats as $id => $value) {
415
+	foreach ($globalSources as $id => $value) {
416 416
 	date_default_timezone_set('UTC');
417 417
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
418 418
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
419 419
 	if ($value['format'] == 'deltadbtxt' && 
420
-	    (
420
+		(
421 421
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
422 422
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
423
-	    )
423
+		)
424 424
 	) {
425
-	    //$buffer = $Common->getData($hosts[$id]);
426
-	    $buffer = $Common->getData($value['host']);
427
-	    if ($buffer != '') $reset = 0;
428
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
429
-	    $buffer = explode('\n',$buffer);
430
-	    foreach ($buffer as $line) {
431
-    		if ($line != '' && count($line) > 7) {
432
-    		    $line = explode(',', $line);
433
-	            $data = array();
434
-	            $data['hex'] = $line[1]; // hex
435
-	            $data['ident'] = $line[2]; // ident
436
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
437
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
438
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
439
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
440
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
441
-	            $data['verticalrate'] = ''; // vertical rate
442
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
443
-	            $data['emergency'] = ''; // emergency
444
-		    $data['datetime'] = date('Y-m-d H:i:s');
445
-		    $data['format_source'] = 'deltadbtxt';
446
-    		    $data['id_source'] = $id_source;
447
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
448
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
449
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
450
-    		    $SI->add($data);
451
-		    unset($data);
452
-    		}
453
-    	    }
454
-    	    $last_exec[$id]['last'] = time();
425
+		//$buffer = $Common->getData($hosts[$id]);
426
+		$buffer = $Common->getData($value['host']);
427
+		if ($buffer != '') $reset = 0;
428
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
429
+		$buffer = explode('\n',$buffer);
430
+		foreach ($buffer as $line) {
431
+			if ($line != '' && count($line) > 7) {
432
+				$line = explode(',', $line);
433
+				$data = array();
434
+				$data['hex'] = $line[1]; // hex
435
+				$data['ident'] = $line[2]; // ident
436
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
437
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
438
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
439
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
440
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
441
+				$data['verticalrate'] = ''; // vertical rate
442
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
443
+				$data['emergency'] = ''; // emergency
444
+			$data['datetime'] = date('Y-m-d H:i:s');
445
+			$data['format_source'] = 'deltadbtxt';
446
+				$data['id_source'] = $id_source;
447
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
448
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
449
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
450
+				$SI->add($data);
451
+			unset($data);
452
+			}
453
+			}
454
+			$last_exec[$id]['last'] = time();
455 455
 	} elseif ($value['format'] == 'aisnmeatxt' && 
456
-	    (
456
+		(
457 457
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
458 458
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
459
-	    )
459
+		)
460 460
 	) {
461
-	    date_default_timezone_set('CET');
462
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
463
-	    date_default_timezone_set('UTC');
464
-	    if ($buffer != '') $reset = 0;
465
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
466
-	    $buffer = explode('\n',$buffer);
467
-	    foreach ($buffer as $line) {
461
+		date_default_timezone_set('CET');
462
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
463
+		date_default_timezone_set('UTC');
464
+		if ($buffer != '') $reset = 0;
465
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
466
+		$buffer = explode('\n',$buffer);
467
+		foreach ($buffer as $line) {
468 468
 		if ($line != '') {
469
-		    //echo "'".$line."'\n";
470
-		    $add = false;
471
-		    $ais_data = $AIS->parse_line(trim($line));
472
-		    $data = array();
473
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
474
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
475
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
476
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
477
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
478
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
479
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
480
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
481
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
482
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
483
-		    if (isset($ais_data['timestamp'])) {
469
+			//echo "'".$line."'\n";
470
+			$add = false;
471
+			$ais_data = $AIS->parse_line(trim($line));
472
+			$data = array();
473
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
474
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
475
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
476
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
477
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
478
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
479
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
480
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
481
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
482
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
483
+			if (isset($ais_data['timestamp'])) {
484 484
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
485 485
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
486
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
487
-			    $add = true;
486
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
487
+				$add = true;
488 488
 			}
489
-		    } else {
489
+			} else {
490 490
 			$data['datetime'] = date('Y-m-d H:i:s');
491 491
 			$add = true;
492
-		    }
493
-		    $data['format_source'] = 'aisnmeatxt';
494
-    		    $data['id_source'] = $id_source;
495
-		    //print_r($data);
496
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
497
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
498
-		    unset($data);
492
+			}
493
+			$data['format_source'] = 'aisnmeatxt';
494
+				$data['id_source'] = $id_source;
495
+			//print_r($data);
496
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
497
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
498
+			unset($data);
499 499
 		}
500
-    	    }
501
-    	    $last_exec[$id]['last'] = time();
500
+			}
501
+			$last_exec[$id]['last'] = time();
502 502
 	} elseif ($value['format'] == 'aisnmeahttp') {
503
-	    $arr = $httpfeeds;
504
-	    $w = $e = null;
503
+		$arr = $httpfeeds;
504
+		$w = $e = null;
505 505
 	    
506
-	    if (isset($arr[$id])) {
506
+		if (isset($arr[$id])) {
507 507
 		$nn = stream_select($arr,$w,$e,$timeout);
508 508
 		if ($nn > 0) {
509
-		    foreach ($httpfeeds as $feed) {
509
+			foreach ($httpfeeds as $feed) {
510 510
 			$buffer = stream_get_line($feed,2000,"\n");
511 511
 			if ($buffer === FALSE) {
512
-			    connect_all($globalSources);
512
+				connect_all($globalSources);
513 513
 			}
514 514
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
515 515
 			$buffer = explode('\n',$buffer);
516 516
 			foreach ($buffer as $line) {
517
-			    if ($line != '') {
517
+				if ($line != '') {
518 518
 				$ais_data = $AIS->parse_line(trim($line));
519 519
 				$data = array();
520 520
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -532,115 +532,115 @@  discard block
 block discarded – undo
532 532
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
533 533
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
534 534
 				if (isset($ais_data['timestamp'])) {
535
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
535
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
536 536
 				} else {
537
-				    $data['datetime'] = date('Y-m-d H:i:s');
537
+					$data['datetime'] = date('Y-m-d H:i:s');
538 538
 				}
539 539
 				$data['format_source'] = 'aisnmeahttp';
540 540
 				$data['id_source'] = $id_source;
541 541
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
542 542
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
543 543
 				unset($data);
544
-			    }
544
+				}
545
+			}
545 546
 			}
546
-		    }
547 547
 		} else {
548
-		    $format = $value['format'];
549
-		    if (isset($tt[$format])) $tt[$format]++;
550
-		    else $tt[$format] = 0;
551
-		    if ($tt[$format] > 30) {
548
+			$format = $value['format'];
549
+			if (isset($tt[$format])) $tt[$format]++;
550
+			else $tt[$format] = 0;
551
+			if ($tt[$format] > 30) {
552 552
 			if ($globalDebug) echo 'Reconnect...'."\n";
553 553
 			sleep(2);
554 554
 			//$sourceeen[] = $value;
555 555
 			//connect_all($sourceeen);
556 556
 			//$sourceeen = array();
557 557
 			connect_all($globalSources);
558
-		    }
558
+			}
559
+		}
559 560
 		}
560
-	    }
561 561
 	} elseif ($value['format'] == 'myshiptracking' && 
562
-	    (
562
+		(
563 563
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
564 564
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
565
-	    )
565
+		)
566 566
 	) {
567
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
568
-	    if ($buffer != '') {
567
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
568
+		if ($buffer != '') {
569 569
 		//echo $buffer;
570 570
 		$all_data = json_decode($buffer,true);
571 571
 		//print_r($all_data);
572 572
 		if (isset($all_data[0]['DATA'])) {
573
-		    foreach ($all_data[0]['DATA'] as $line) {
573
+			foreach ($all_data[0]['DATA'] as $line) {
574 574
 			if ($line != '') {
575
-			    $data = array();
576
-			    $data['ident'] = $line['NAME'];
577
-			    $data['mmsi'] = $line['MMSI'];
578
-			    if (strlen($data['mmsi']) > 9) {
575
+				$data = array();
576
+				$data['ident'] = $line['NAME'];
577
+				$data['mmsi'] = $line['MMSI'];
578
+				if (strlen($data['mmsi']) > 9) {
579 579
 				$data['mmsi'] = substr($data['mmsi'],-9);
580
-			    }
581
-			    $data['speed'] = $line['SOG'];
582
-			    $data['heading'] = $line['COG'];
583
-			    $data['latitude'] = $line['LAT'];
584
-			    $data['longitude'] = $line['LNG'];
585
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
586
-			    $data['imo'] = $line['IMO'];
587
-			    //$data['arrival_code'] = $ais_data['destination'];
588
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
589
-			    $data['format_source'] = 'myshiptracking';
590
-			    $data['id_source'] = $id_source;
591
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
592
-			    $MI->add($data);
593
-			    unset($data);
580
+				}
581
+				$data['speed'] = $line['SOG'];
582
+				$data['heading'] = $line['COG'];
583
+				$data['latitude'] = $line['LAT'];
584
+				$data['longitude'] = $line['LNG'];
585
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
586
+				$data['imo'] = $line['IMO'];
587
+				//$data['arrival_code'] = $ais_data['destination'];
588
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
589
+				$data['format_source'] = 'myshiptracking';
590
+				$data['id_source'] = $id_source;
591
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
592
+				$MI->add($data);
593
+				unset($data);
594
+			}
594 595
 			}
595
-		    }
596 596
 		}
597
-	    }
598
-	    $last_exec[$id]['last'] = time();
597
+		}
598
+		$last_exec[$id]['last'] = time();
599 599
 	} elseif ($value['format'] == 'boatbeaconapp' && 
600
-	    (
600
+		(
601 601
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
602 602
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
603
-	    )
603
+		)
604 604
 	) {
605
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
606
-	    if ($buffer != '') {
605
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
606
+		if ($buffer != '') {
607 607
 		$all_data = json_decode($buffer,true);
608 608
 		if (isset($all_data[0]['mmsi'])) {
609
-		    foreach ($all_data as $line) {
609
+			foreach ($all_data as $line) {
610 610
 			if ($line != '') {
611
-			    $data = array();
612
-			    $data['ident'] = $line['shipname'];
613
-			    $data['callsign'] = $line['callsign'];
614
-			    $data['mmsi'] = $line['mmsi'];
615
-			    $data['speed'] = $line['sog'];
616
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
617
-			    $data['latitude'] = $line['latitude'];
618
-			    $data['longitude'] = $line['longitude'];
619
-			    $data['type_id'] = $line['shiptype'];
620
-			    $data['arrival_code'] = $line['destination'];
621
-			    $data['datetime'] = $line['time'];
622
-			    $data['format_source'] = 'boatbeaconapp';
623
-			    $data['id_source'] = $id_source;
624
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
625
-			    $MI->add($data);
626
-			    unset($data);
611
+				$data = array();
612
+				$data['ident'] = $line['shipname'];
613
+				$data['callsign'] = $line['callsign'];
614
+				$data['mmsi'] = $line['mmsi'];
615
+				$data['speed'] = $line['sog'];
616
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
617
+				$data['latitude'] = $line['latitude'];
618
+				$data['longitude'] = $line['longitude'];
619
+				$data['type_id'] = $line['shiptype'];
620
+				$data['arrival_code'] = $line['destination'];
621
+				$data['datetime'] = $line['time'];
622
+				$data['format_source'] = 'boatbeaconapp';
623
+				$data['id_source'] = $id_source;
624
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
625
+				$MI->add($data);
626
+				unset($data);
627
+			}
627 628
 			}
628
-		    }
629 629
 		}
630 630
 		
631
-	    }
632
-    	    $last_exec[$id]['last'] = time();
631
+		}
632
+			$last_exec[$id]['last'] = time();
633 633
 	} elseif ($value['format'] == 'boatnerd' && 
634
-	    (
634
+		(
635 635
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
636 636
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
637
-	    )
637
+		)
638 638
 	) {
639
-	    $buffer = $Common->getData($value['host']);
640
-	    if ($buffer != '') {
639
+		$buffer = $Common->getData($value['host']);
640
+		if ($buffer != '') {
641 641
 		$all_data = json_decode($buffer,true);
642 642
 		if (isset($all_data['features'][0]['id'])) {
643
-		    foreach ($all_data['features'] as $line) {
643
+			foreach ($all_data['features'] as $line) {
644 644
 			$data = array();
645 645
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
646 646
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -659,78 +659,78 @@  discard block
 block discarded – undo
659 659
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
660 660
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
661 661
 			unset($data);
662
-		    }
662
+			}
663 663
 		}
664 664
 		
665
-	    }
666
-    	    $last_exec[$id]['last'] = time();
665
+		}
666
+			$last_exec[$id]['last'] = time();
667 667
 	} elseif ($value['format'] == 'shipplotter' && 
668
-	    (
668
+		(
669 669
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
670 670
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
671
-	    )
671
+		)
672 672
 	) {
673
-	    echo 'download...';
674
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
675
-	    echo 'done !'."\n";
676
-	    if ($buffer != '') $reset = 0;
677
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
678
-	    $buffer = explode('\n',$buffer);
679
-	    foreach ($buffer as $line) {
673
+		echo 'download...';
674
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
675
+		echo 'done !'."\n";
676
+		if ($buffer != '') $reset = 0;
677
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
678
+		$buffer = explode('\n',$buffer);
679
+		foreach ($buffer as $line) {
680 680
 		if ($line != '') {
681
-		    $data = array();
682
-		    $data['mmsi'] = (int)substr($line,0,9);
683
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
684
-		    //$data['status'] = substr($line,21,2);
685
-		    //$data['type'] = substr($line,24,3);
686
-		    $data['latitude'] = substr($line,29,9);
687
-		    $data['longitude'] = substr($line,41,9);
688
-		    $data['speed'] = round(substr($line,51,5));
689
-		    //$data['course'] = substr($line,57,5);
690
-		    $data['heading'] = round(substr($line,63,3));
691
-		    //$data['draft'] = substr($line,67,4);
692
-		    //$data['length'] = substr($line,72,3);
693
-		    //$data['beam'] = substr($line,76,2);
694
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
695
-		    //$data['callsign'] = trim(substr($line,100,7);
696
-		    //$data['dest'] = substr($line,108,20);
697
-		    //$data['etaDate'] = substr($line,129,5);
698
-		    //$data['etaTime'] = substr($line,135,5);
699
-		    $data['format_source'] = 'shipplotter';
700
-    		    $data['id_source'] = $id_source;
701
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
702
-		    //print_r($data);
703
-		    echo 'Add...'."\n";
704
-		    $MI->add($data);
705
-		    unset($data);
681
+			$data = array();
682
+			$data['mmsi'] = (int)substr($line,0,9);
683
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
684
+			//$data['status'] = substr($line,21,2);
685
+			//$data['type'] = substr($line,24,3);
686
+			$data['latitude'] = substr($line,29,9);
687
+			$data['longitude'] = substr($line,41,9);
688
+			$data['speed'] = round(substr($line,51,5));
689
+			//$data['course'] = substr($line,57,5);
690
+			$data['heading'] = round(substr($line,63,3));
691
+			//$data['draft'] = substr($line,67,4);
692
+			//$data['length'] = substr($line,72,3);
693
+			//$data['beam'] = substr($line,76,2);
694
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
695
+			//$data['callsign'] = trim(substr($line,100,7);
696
+			//$data['dest'] = substr($line,108,20);
697
+			//$data['etaDate'] = substr($line,129,5);
698
+			//$data['etaTime'] = substr($line,135,5);
699
+			$data['format_source'] = 'shipplotter';
700
+				$data['id_source'] = $id_source;
701
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
702
+			//print_r($data);
703
+			echo 'Add...'."\n";
704
+			$MI->add($data);
705
+			unset($data);
706 706
 		}
707
-    	    }
708
-    	    $last_exec[$id]['last'] = time();
707
+			}
708
+			$last_exec[$id]['last'] = time();
709 709
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
710 710
 	} elseif (
711
-	    (
711
+		(
712 712
 		$value['format'] == 'whazzup' && 
713 713
 		(
714
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
715
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
714
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
715
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
716 716
 		)
717
-	    ) || (
717
+		) || (
718 718
 		$value['format'] == 'vatsimtxt' && 
719 719
 		(
720
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
721
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
720
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
721
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
722
+		)
722 723
 		)
723
-	    )
724 724
 	) {
725
-	    //$buffer = $Common->getData($hosts[$id]);
726
-	    $buffer = $Common->getData($value['host']);
727
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
728
-	    $buffer = explode('\n',$buffer);
729
-	    $reset = 0;
730
-	    foreach ($buffer as $line) {
731
-    		if ($line != '') {
732
-    		    $line = explode(':', $line);
733
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
725
+		//$buffer = $Common->getData($hosts[$id]);
726
+		$buffer = $Common->getData($value['host']);
727
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
728
+		$buffer = explode('\n',$buffer);
729
+		$reset = 0;
730
+		foreach ($buffer as $line) {
731
+			if ($line != '') {
732
+				$line = explode(':', $line);
733
+				if (count($line) > 30 && $line[0] != 'callsign') {
734 734
 			$data = array();
735 735
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
736 736
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -743,37 +743,37 @@  discard block
 block discarded – undo
743 743
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
744 744
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
745 745
 			$data['latitude'] = $line[5]; // lat
746
-	        	$data['longitude'] = $line[6]; // long
747
-	        	$data['verticalrate'] = ''; // vertical rate
748
-	        	$data['squawk'] = ''; // squawk
749
-	        	$data['emergency'] = ''; // emergency
750
-	        	$data['waypoints'] = $line[30];
746
+				$data['longitude'] = $line[6]; // long
747
+				$data['verticalrate'] = ''; // vertical rate
748
+				$data['squawk'] = ''; // squawk
749
+				$data['emergency'] = ''; // emergency
750
+				$data['waypoints'] = $line[30];
751 751
 			$data['datetime'] = date('Y-m-d H:i:s');
752 752
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
753 753
 			//if (isset($line[37])) $data['last_update'] = $line[37];
754
-		        $data['departure_airport_icao'] = $line[11];
755
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
756
-		        $data['arrival_airport_icao'] = $line[13];
754
+				$data['departure_airport_icao'] = $line[11];
755
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
756
+				$data['arrival_airport_icao'] = $line[13];
757 757
 			$data['frequency'] = $line[4];
758 758
 			$data['type'] = $line[18];
759 759
 			$data['range'] = $line[19];
760 760
 			if (isset($line[35])) $data['info'] = $line[35];
761
-    			$data['id_source'] = $id_source;
762
-	    		//$data['arrival_airport_time'] = ;
763
-	    		if ($line[9] != '') {
764
-	    		    $aircraft_data = explode('/',$line[9]);
765
-	    		    if (isset($aircraft_data[1])) {
766
-	    			$data['aircraft_icao'] = $aircraft_data[1];
767
-	    		    }
768
-        		}
769
-	    		/*
761
+				$data['id_source'] = $id_source;
762
+				//$data['arrival_airport_time'] = ;
763
+				if ($line[9] != '') {
764
+					$aircraft_data = explode('/',$line[9]);
765
+					if (isset($aircraft_data[1])) {
766
+					$data['aircraft_icao'] = $aircraft_data[1];
767
+					}
768
+				}
769
+				/*
770 770
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
771 771
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
772 772
 	    		*/
773
-	    		$data['format_source'] = $value['format'];
773
+				$data['format_source'] = $value['format'];
774 774
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
775 775
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
776
-    			if ($line[3] == 'PILOT') $SI->add($data);
776
+				if ($line[3] == 'PILOT') $SI->add($data);
777 777
 			elseif ($line[3] == 'ATC') {
778 778
 				//print_r($data);
779 779
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -794,21 +794,21 @@  discard block
 block discarded – undo
794 794
 					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']);
795 795
 				}
796 796
 			}
797
-    			unset($data);
798
-    		    }
799
-    		}
800
-    	    }
801
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
802
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
803
-    	    $last_exec[$id]['last'] = time();
804
-    	} elseif ($value['format'] == 'airwhere' && 
805
-    	    (
806
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
807
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
808
-    	    )
809
-    	) {
810
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
811
-	    if ($buffer != '') {
797
+				unset($data);
798
+				}
799
+			}
800
+			}
801
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
802
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
803
+			$last_exec[$id]['last'] = time();
804
+		} elseif ($value['format'] == 'airwhere' && 
805
+			(
806
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
807
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
808
+			)
809
+		) {
810
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
811
+		if ($buffer != '') {
812 812
 		$all_data = simplexml_load_string($buffer);
813 813
 		foreach($all_data->children() as $childdata) {
814 814
 			$data = array();
@@ -830,10 +830,10 @@  discard block
 block discarded – undo
830 830
 			$SI->add($data);
831 831
 			unset($data);
832 832
 		}
833
-	    }
834
-	    $Source->deleteOldLocationByType('gs');
835
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
836
-	    if ($buffer != '') {
833
+		}
834
+		$Source->deleteOldLocationByType('gs');
835
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
836
+		if ($buffer != '') {
837 837
 		$all_data = simplexml_load_string($buffer);
838 838
 		foreach($all_data->children() as $childdata) {
839 839
 			$data = array();
@@ -851,8 +851,8 @@  discard block
 block discarded – undo
851 851
 			}
852 852
 			unset($data);
853 853
 		}
854
-	    }
855
-	    $last_exec[$id]['last'] = time();
854
+		}
855
+		$last_exec[$id]['last'] = time();
856 856
 	/*
857 857
 	} if ($value['format'] == 'aircraftlistjson') {
858 858
 	    print_r($globalSources);
@@ -860,17 +860,17 @@  discard block
 block discarded – undo
860 860
 	    echo $globalMinFetch;
861 861
 	*/
862 862
 	} elseif ($value['format'] == 'aircraftlistjson' && 
863
-	    (
863
+		(
864 864
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
865 865
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
866
-	    )
866
+		)
867 867
 	) {
868
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
869
-	    if ($buffer != '') {
870
-	        $all_data = json_decode($buffer,true);
868
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
869
+		if ($buffer != '') {
870
+			$all_data = json_decode($buffer,true);
871 871
 		if (isset($all_data['acList'])) {
872
-		    $reset = 0;
873
-		    foreach ($all_data['acList'] as $line) {
872
+			$reset = 0;
873
+			foreach ($all_data['acList'] as $line) {
874 874
 			$data = array();
875 875
 			$data['hex'] = $line['Icao']; // hex
876 876
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -893,10 +893,10 @@  discard block
 block discarded – undo
893 893
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
894 894
 			if (isset($data['latitude'])) $SI->add($data);
895 895
 			unset($data);
896
-		    }
896
+			}
897 897
 		} elseif (is_array($all_data)) {
898
-		    $reset = 0;
899
-		    foreach ($all_data as $line) {
898
+			$reset = 0;
899
+			foreach ($all_data as $line) {
900 900
 			$data = array();
901 901
 			$data['hex'] = $line['hex']; // hex
902 902
 			$data['ident'] = $line['flight']; // ident
@@ -916,218 +916,218 @@  discard block
 block discarded – undo
916 916
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
917 917
 			$SI->add($data);
918 918
 			unset($data);
919
-		    }
919
+			}
920 920
 		}
921
-	    } elseif ($globalDebug) echo 'No data'."\n";
922
-    	    //$last_exec['aircraftlistjson'] = time();
923
-    	    $last_exec[$id]['last'] = time();
924
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
925
-    	} elseif ($value['format'] == 'planeupdatefaa' && 
926
-    	    (
927
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
928
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
929
-    	    )
930
-    	) {
931
-	    $buffer = $Common->getData($value['host']);
932
-	    $all_data = json_decode($buffer,true);
933
-	    if (isset($all_data['planes'])) {
921
+		} elseif ($globalDebug) echo 'No data'."\n";
922
+			//$last_exec['aircraftlistjson'] = time();
923
+			$last_exec[$id]['last'] = time();
924
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
925
+		} elseif ($value['format'] == 'planeupdatefaa' && 
926
+			(
927
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
928
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
929
+			)
930
+		) {
931
+		$buffer = $Common->getData($value['host']);
932
+		$all_data = json_decode($buffer,true);
933
+		if (isset($all_data['planes'])) {
934 934
 		$reset = 0;
935 935
 		foreach ($all_data['planes'] as $key => $line) {
936
-		    $data = array();
937
-		    $data['hex'] = $key; // hex
938
-		    $data['ident'] = $line[3]; // ident
939
-		    $data['altitude'] = $line[6]; // altitude
940
-		    $data['speed'] = $line[8]; // speed
941
-		    $data['heading'] = $line[7]; // heading
942
-		    $data['latitude'] = $line[4]; // lat
943
-		    $data['longitude'] = $line[5]; // long
944
-		    //$data['verticalrate'] = $line[]; // verticale rate
945
-		    $data['squawk'] = $line[10]; // squawk
946
-		    $data['emergency'] = ''; // emergency
947
-		    $data['registration'] = $line[2];
948
-		    $data['aircraft_icao'] = $line[0];
949
-		    $deparr = explode('-',$line[1]);
950
-		    if (count($deparr) == 2) {
936
+			$data = array();
937
+			$data['hex'] = $key; // hex
938
+			$data['ident'] = $line[3]; // ident
939
+			$data['altitude'] = $line[6]; // altitude
940
+			$data['speed'] = $line[8]; // speed
941
+			$data['heading'] = $line[7]; // heading
942
+			$data['latitude'] = $line[4]; // lat
943
+			$data['longitude'] = $line[5]; // long
944
+			//$data['verticalrate'] = $line[]; // verticale rate
945
+			$data['squawk'] = $line[10]; // squawk
946
+			$data['emergency'] = ''; // emergency
947
+			$data['registration'] = $line[2];
948
+			$data['aircraft_icao'] = $line[0];
949
+			$deparr = explode('-',$line[1]);
950
+			if (count($deparr) == 2) {
951 951
 			$data['departure_airport_icao'] = $deparr[0];
952 952
 			$data['arrival_airport_icao'] = $deparr[1];
953
-		    }
954
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
955
-	    	    $data['format_source'] = 'planeupdatefaa';
956
-    		    $data['id_source'] = $id_source;
957
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
958
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
959
-		    $SI->add($data);
960
-		    unset($data);
953
+			}
954
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
955
+				$data['format_source'] = 'planeupdatefaa';
956
+				$data['id_source'] = $id_source;
957
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
958
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
959
+			$SI->add($data);
960
+			unset($data);
961
+		}
961 962
 		}
962
-	    }
963
-	    //$last_exec['planeupdatefaa'] = time();
964
-	    $last_exec[$id]['last'] = time();
963
+		//$last_exec['planeupdatefaa'] = time();
964
+		$last_exec[$id]['last'] = time();
965 965
 	} elseif ($value['format'] == 'opensky' && 
966
-	    (
966
+		(
967 967
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
968 968
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
969
-	    )
969
+		)
970 970
 	) {
971
-	    $buffer = $Common->getData($value['host']);
972
-	    $all_data = json_decode($buffer,true);
973
-	    if (isset($all_data['states'])) {
971
+		$buffer = $Common->getData($value['host']);
972
+		$all_data = json_decode($buffer,true);
973
+		if (isset($all_data['states'])) {
974 974
 		$reset = 0;
975 975
 		foreach ($all_data['states'] as $key => $line) {
976
-		    $data = array();
977
-		    $data['hex'] = $line[0]; // hex
978
-		    $data['ident'] = trim($line[1]); // ident
979
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
980
-		    $data['speed'] = round($line[9]*1.94384); // speed
981
-		    $data['heading'] = round($line[10]); // heading
982
-		    $data['latitude'] = $line[6]; // lat
983
-		    $data['longitude'] = $line[5]; // long
984
-		    $data['verticalrate'] = $line[11]; // verticale rate
985
-		    //$data['squawk'] = $line[10]; // squawk
986
-		    //$data['emergency'] = ''; // emergency
987
-		    //$data['registration'] = $line[2];
988
-		    //$data['aircraft_icao'] = $line[0];
989
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
990
-		    $data['format_source'] = 'opensky';
991
-		    $data['id_source'] = $id_source;
992
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
993
-		    $SI->add($data);
994
-		    unset($data);
976
+			$data = array();
977
+			$data['hex'] = $line[0]; // hex
978
+			$data['ident'] = trim($line[1]); // ident
979
+			$data['altitude'] = round($line[7]*3.28084); // altitude
980
+			$data['speed'] = round($line[9]*1.94384); // speed
981
+			$data['heading'] = round($line[10]); // heading
982
+			$data['latitude'] = $line[6]; // lat
983
+			$data['longitude'] = $line[5]; // long
984
+			$data['verticalrate'] = $line[11]; // verticale rate
985
+			//$data['squawk'] = $line[10]; // squawk
986
+			//$data['emergency'] = ''; // emergency
987
+			//$data['registration'] = $line[2];
988
+			//$data['aircraft_icao'] = $line[0];
989
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
990
+			$data['format_source'] = 'opensky';
991
+			$data['id_source'] = $id_source;
992
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
993
+			$SI->add($data);
994
+			unset($data);
995 995
 		}
996
-	    }
997
-	    //$last_exec['planeupdatefaa'] = time();
998
-	    $last_exec[$id]['last'] = time();
996
+		}
997
+		//$last_exec['planeupdatefaa'] = time();
998
+		$last_exec[$id]['last'] = time();
999 999
 	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1000 1000
 	} elseif ($value['format'] == 'fr24json' && 
1001
-	    (
1001
+		(
1002 1002
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1003 1003
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1004
-	    )
1004
+		)
1005 1005
 	) {
1006
-	    //$buffer = $Common->getData($hosts[$id]);
1007
-	    $buffer = $Common->getData($value['host']);
1008
-	    $all_data = json_decode($buffer,true);
1009
-	    if (!empty($all_data)) $reset = 0;
1010
-	    foreach ($all_data as $key => $line) {
1006
+		//$buffer = $Common->getData($hosts[$id]);
1007
+		$buffer = $Common->getData($value['host']);
1008
+		$all_data = json_decode($buffer,true);
1009
+		if (!empty($all_data)) $reset = 0;
1010
+		foreach ($all_data as $key => $line) {
1011 1011
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1012
-		    $data = array();
1013
-		    $data['hex'] = $line[0];
1014
-		    $data['ident'] = $line[16]; //$line[13]
1015
-	    	    $data['altitude'] = $line[4]; // altitude
1016
-	    	    $data['speed'] = $line[5]; // speed
1017
-	    	    $data['heading'] = $line[3]; // heading
1018
-	    	    $data['latitude'] = $line[1]; // lat
1019
-	    	    $data['longitude'] = $line[2]; // long
1020
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1021
-	    	    $data['squawk'] = $line[6]; // squawk
1022
-	    	    $data['aircraft_icao'] = $line[8];
1023
-	    	    $data['registration'] = $line[9];
1024
-		    $data['departure_airport_iata'] = $line[11];
1025
-		    $data['arrival_airport_iata'] = $line[12];
1026
-	    	    $data['emergency'] = ''; // emergency
1027
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1028
-	    	    $data['format_source'] = 'fr24json';
1029
-    		    $data['id_source'] = $id_source;
1030
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1031
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1032
-		    $SI->add($data);
1033
-		    unset($data);
1012
+			$data = array();
1013
+			$data['hex'] = $line[0];
1014
+			$data['ident'] = $line[16]; //$line[13]
1015
+				$data['altitude'] = $line[4]; // altitude
1016
+				$data['speed'] = $line[5]; // speed
1017
+				$data['heading'] = $line[3]; // heading
1018
+				$data['latitude'] = $line[1]; // lat
1019
+				$data['longitude'] = $line[2]; // long
1020
+				$data['verticalrate'] = $line[15]; // verticale rate
1021
+				$data['squawk'] = $line[6]; // squawk
1022
+				$data['aircraft_icao'] = $line[8];
1023
+				$data['registration'] = $line[9];
1024
+			$data['departure_airport_iata'] = $line[11];
1025
+			$data['arrival_airport_iata'] = $line[12];
1026
+				$data['emergency'] = ''; // emergency
1027
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1028
+				$data['format_source'] = 'fr24json';
1029
+				$data['id_source'] = $id_source;
1030
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1031
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1032
+			$SI->add($data);
1033
+			unset($data);
1034 1034
 		}
1035
-	    }
1036
-	    //$last_exec['fr24json'] = time();
1037
-	    $last_exec[$id]['last'] = time();
1035
+		}
1036
+		//$last_exec['fr24json'] = time();
1037
+		$last_exec[$id]['last'] = time();
1038 1038
 	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1039 1039
 	} elseif ($value['format'] == 'radarvirtueljson' && 
1040
-	    (
1040
+		(
1041 1041
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1042 1042
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1043
-	    )
1043
+		)
1044 1044
 	) {
1045
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1046
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1047
-	    //echo $buffer;
1048
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1049
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1050
-	    $all_data = json_decode($buffer,true);
1051
-	    if (json_last_error() != JSON_ERROR_NONE) {
1045
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1046
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1047
+		//echo $buffer;
1048
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1049
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1050
+		$all_data = json_decode($buffer,true);
1051
+		if (json_last_error() != JSON_ERROR_NONE) {
1052 1052
 		die(json_last_error_msg());
1053
-	    }
1054
-	    if (isset($all_data['mrkrs'])) {
1053
+		}
1054
+		if (isset($all_data['mrkrs'])) {
1055 1055
 		$reset = 0;
1056 1056
 		foreach ($all_data['mrkrs'] as $key => $line) {
1057
-		    if (isset($line['inf'])) {
1057
+			if (isset($line['inf'])) {
1058 1058
 			$data = array();
1059 1059
 			$data['hex'] = $line['inf']['ia'];
1060 1060
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1061
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1062
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1063
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1064
-	    		$data['latitude'] = $line['pt'][0]; // lat
1065
-	    		$data['longitude'] = $line['pt'][1]; // long
1066
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1067
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1068
-	    		//$data['aircraft_icao'] = $line[8];
1069
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1061
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1062
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1063
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1064
+				$data['latitude'] = $line['pt'][0]; // lat
1065
+				$data['longitude'] = $line['pt'][1]; // long
1066
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1067
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1068
+				//$data['aircraft_icao'] = $line[8];
1069
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1070 1070
 			//$data['departure_airport_iata'] = $line[11];
1071 1071
 			//$data['arrival_airport_iata'] = $line[12];
1072
-	    		//$data['emergency'] = ''; // emergency
1072
+				//$data['emergency'] = ''; // emergency
1073 1073
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1074
-	    		$data['format_source'] = 'radarvirtueljson';
1075
-    			$data['id_source'] = $id_source;
1074
+				$data['format_source'] = 'radarvirtueljson';
1075
+				$data['id_source'] = $id_source;
1076 1076
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1077 1077
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1078 1078
 			$SI->add($data);
1079 1079
 			unset($data);
1080
-		    }
1080
+			}
1081
+		}
1081 1082
 		}
1082
-	    }
1083
-	    //$last_exec['radarvirtueljson'] = time();
1084
-	    $last_exec[$id]['last'] = time();
1083
+		//$last_exec['radarvirtueljson'] = time();
1084
+		$last_exec[$id]['last'] = time();
1085 1085
 	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1086 1086
 	} elseif ($value['format'] == 'pirepsjson' && 
1087
-	    (
1087
+		(
1088 1088
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1089 1089
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1090
-	    )
1090
+		)
1091 1091
 	) {
1092
-	    //$buffer = $Common->getData($hosts[$id]);
1093
-	    $buffer = $Common->getData($value['host'].'?'.time());
1094
-	    $all_data = json_decode(utf8_encode($buffer),true);
1092
+		//$buffer = $Common->getData($hosts[$id]);
1093
+		$buffer = $Common->getData($value['host'].'?'.time());
1094
+		$all_data = json_decode(utf8_encode($buffer),true);
1095 1095
 	    
1096
-	    if (isset($all_data['pireps'])) {
1096
+		if (isset($all_data['pireps'])) {
1097 1097
 		$reset = 0;
1098
-	        foreach ($all_data['pireps'] as $line) {
1099
-		    $data = array();
1100
-		    $data['id'] = $line['id'];
1101
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1102
-		    $data['ident'] = $line['callsign']; // ident
1103
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1104
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1105
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1106
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1107
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1108
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1109
-		    $data['latitude'] = $line['lat']; // lat
1110
-		    $data['longitude'] = $line['lon']; // long
1111
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1112
-		    //$data['squawk'] = $line['squawk']; // squawk
1113
-		    //$data['emergency'] = ''; // emergency
1114
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1115
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1116
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1117
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1118
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1119
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1120
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1121
-		    else $data['info'] = '';
1122
-		    $data['format_source'] = 'pireps';
1123
-    		    $data['id_source'] = $id_source;
1124
-		    $data['datetime'] = date('Y-m-d H:i:s');
1125
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1126
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1127
-		    if ($line['icon'] == 'plane') {
1098
+			foreach ($all_data['pireps'] as $line) {
1099
+			$data = array();
1100
+			$data['id'] = $line['id'];
1101
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1102
+			$data['ident'] = $line['callsign']; // ident
1103
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1104
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1105
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1106
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1107
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1108
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1109
+			$data['latitude'] = $line['lat']; // lat
1110
+			$data['longitude'] = $line['lon']; // long
1111
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1112
+			//$data['squawk'] = $line['squawk']; // squawk
1113
+			//$data['emergency'] = ''; // emergency
1114
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1115
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1116
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1117
+			//$data['arrival_airport_time'] = $line['arrtime'];
1118
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1119
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1120
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1121
+			else $data['info'] = '';
1122
+			$data['format_source'] = 'pireps';
1123
+				$data['id_source'] = $id_source;
1124
+			$data['datetime'] = date('Y-m-d H:i:s');
1125
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1126
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1127
+			if ($line['icon'] == 'plane') {
1128 1128
 			$SI->add($data);
1129
-		    //    print_r($data);
1130
-    		    } elseif ($line['icon'] == 'ct') {
1129
+			//    print_r($data);
1130
+				} elseif ($line['icon'] == 'ct') {
1131 1131
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1132 1132
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1133 1133
 			$typec = substr($data['ident'],-3);
@@ -1142,148 +1142,148 @@  discard block
 block discarded – undo
1142 1142
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1143 1143
 			else $data['type'] = 'Observer';
1144 1144
 			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']);
1145
-		    }
1146
-		    unset($data);
1145
+			}
1146
+			unset($data);
1147
+		}
1147 1148
 		}
1148
-	    }
1149
-	    //$last_exec['pirepsjson'] = time();
1150
-	    $last_exec[$id]['last'] = time();
1149
+		//$last_exec['pirepsjson'] = time();
1150
+		$last_exec[$id]['last'] = time();
1151 1151
 	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1152 1152
 	} elseif ($value['format'] == 'phpvmacars' && 
1153
-	    (
1153
+		(
1154 1154
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1155 1155
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1156
-	    )
1156
+		)
1157 1157
 	) {
1158
-	    //$buffer = $Common->getData($hosts[$id]);
1159
-	    if ($globalDebug) echo 'Get Data...'."\n";
1160
-	    $buffer = $Common->getData($value['host']);
1161
-	    $all_data = json_decode($buffer,true);
1162
-	    if ($buffer != '' && is_array($all_data)) {
1158
+		//$buffer = $Common->getData($hosts[$id]);
1159
+		if ($globalDebug) echo 'Get Data...'."\n";
1160
+		$buffer = $Common->getData($value['host']);
1161
+		$all_data = json_decode($buffer,true);
1162
+		if ($buffer != '' && is_array($all_data)) {
1163 1163
 		$reset = 0;
1164 1164
 		foreach ($all_data as $line) {
1165
-	    	    $data = array();
1166
-	    	    //$data['id'] = $line['id']; // id not usable
1167
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1168
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1169
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1170
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1171
-	    	    $data['ident'] = $line['flightnum']; // ident
1172
-	    	    $data['altitude'] = $line['alt']; // altitude
1173
-	    	    $data['speed'] = $line['gs']; // speed
1174
-	    	    $data['heading'] = $line['heading']; // heading
1175
-	    	    $data['latitude'] = $line['lat']; // lat
1176
-	    	    $data['longitude'] = $line['lng']; // long
1177
-	    	    $data['verticalrate'] = ''; // verticale rate
1178
-	    	    $data['squawk'] = ''; // squawk
1179
-	    	    $data['emergency'] = ''; // emergency
1180
-	    	    //$data['datetime'] = $line['lastupdate'];
1181
-	    	    //$data['last_update'] = $line['lastupdate'];
1182
-	    	    if (isset($value['timezone'])) {
1183
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1184
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1185
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1186
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1187
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1188
-	    	    $data['departure_airport_time'] = $line['deptime'];
1189
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1190
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1191
-    		    $data['registration'] = $line['aircraft'];
1192
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1193
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1194
-		    if (isset($line['aircraftname'])) {
1165
+				$data = array();
1166
+				//$data['id'] = $line['id']; // id not usable
1167
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1168
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1169
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1170
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1171
+				$data['ident'] = $line['flightnum']; // ident
1172
+				$data['altitude'] = $line['alt']; // altitude
1173
+				$data['speed'] = $line['gs']; // speed
1174
+				$data['heading'] = $line['heading']; // heading
1175
+				$data['latitude'] = $line['lat']; // lat
1176
+				$data['longitude'] = $line['lng']; // long
1177
+				$data['verticalrate'] = ''; // verticale rate
1178
+				$data['squawk'] = ''; // squawk
1179
+				$data['emergency'] = ''; // emergency
1180
+				//$data['datetime'] = $line['lastupdate'];
1181
+				//$data['last_update'] = $line['lastupdate'];
1182
+				if (isset($value['timezone'])) {
1183
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1184
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1185
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1186
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1187
+				$data['departure_airport_icao'] = $line['depicao'];
1188
+				$data['departure_airport_time'] = $line['deptime'];
1189
+				$data['arrival_airport_icao'] = $line['arricao'];
1190
+				$data['arrival_airport_time'] = $line['arrtime'];
1191
+				$data['registration'] = $line['aircraft'];
1192
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1193
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1194
+			if (isset($line['aircraftname'])) {
1195 1195
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1196 1196
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1197
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1198
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1199
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1200
-	    		else {
1201
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1202
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1203
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1204
-	    		}
1205
-	    	    }
1206
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1207
-    		    $data['id_source'] = $id_source;
1208
-	    	    $data['format_source'] = 'phpvmacars';
1209
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1210
-		    $SI->add($data);
1211
-		    unset($data);
1197
+				$aircraft_data = explode('-',$line['aircraftname']);
1198
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1199
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1200
+				else {
1201
+					$aircraft_data = explode(' ',$line['aircraftname']);
1202
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1203
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1204
+				}
1205
+				}
1206
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1207
+				$data['id_source'] = $id_source;
1208
+				$data['format_source'] = 'phpvmacars';
1209
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1210
+			$SI->add($data);
1211
+			unset($data);
1212 1212
 		}
1213 1213
 		if ($globalDebug) echo 'No more data...'."\n";
1214 1214
 		unset($buffer);
1215 1215
 		unset($all_data);
1216
-	    }
1217
-	    //$last_exec['phpvmacars'] = time();
1218
-	    $last_exec[$id]['last'] = time();
1216
+		}
1217
+		//$last_exec['phpvmacars'] = time();
1218
+		$last_exec[$id]['last'] = time();
1219 1219
 	} elseif ($value['format'] == 'vam' && 
1220
-	    (
1220
+		(
1221 1221
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1222 1222
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1223
-	    )
1223
+		)
1224 1224
 	) {
1225
-	    //$buffer = $Common->getData($hosts[$id]);
1226
-	    if ($globalDebug) echo 'Get Data...'."\n";
1227
-	    $buffer = $Common->getData($value['host']);
1228
-	    $all_data = json_decode($buffer,true);
1229
-	    if ($buffer != '' && is_array($all_data)) {
1225
+		//$buffer = $Common->getData($hosts[$id]);
1226
+		if ($globalDebug) echo 'Get Data...'."\n";
1227
+		$buffer = $Common->getData($value['host']);
1228
+		$all_data = json_decode($buffer,true);
1229
+		if ($buffer != '' && is_array($all_data)) {
1230 1230
 		$reset = 0;
1231 1231
 		foreach ($all_data as $line) {
1232
-	    	    $data = array();
1233
-	    	    //$data['id'] = $line['id']; // id not usable
1234
-	    	    $data['id'] = trim($line['flight_id']);
1235
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1236
-	    	    $data['pilot_name'] = $line['pilot_name'];
1237
-	    	    $data['pilot_id'] = $line['pilot_id'];
1238
-	    	    $data['ident'] = trim($line['callsign']); // ident
1239
-	    	    $data['altitude'] = $line['altitude']; // altitude
1240
-	    	    $data['speed'] = $line['gs']; // speed
1241
-	    	    $data['heading'] = $line['heading']; // heading
1242
-	    	    $data['latitude'] = $line['latitude']; // lat
1243
-	    	    $data['longitude'] = $line['longitude']; // long
1244
-	    	    $data['verticalrate'] = ''; // verticale rate
1245
-	    	    $data['squawk'] = ''; // squawk
1246
-	    	    $data['emergency'] = ''; // emergency
1247
-	    	    //$data['datetime'] = $line['lastupdate'];
1248
-	    	    $data['last_update'] = $line['last_update'];
1249
-		    $data['datetime'] = date('Y-m-d H:i:s');
1250
-	    	    $data['departure_airport_icao'] = $line['departure'];
1251
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1252
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1253
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1254
-    		    //$data['registration'] = $line['aircraft'];
1255
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1256
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1257
-    		    $data['id_source'] = $id_source;
1258
-	    	    $data['format_source'] = 'vam';
1259
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1260
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1261
-		    $SI->add($data);
1262
-		    unset($data);
1232
+				$data = array();
1233
+				//$data['id'] = $line['id']; // id not usable
1234
+				$data['id'] = trim($line['flight_id']);
1235
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1236
+				$data['pilot_name'] = $line['pilot_name'];
1237
+				$data['pilot_id'] = $line['pilot_id'];
1238
+				$data['ident'] = trim($line['callsign']); // ident
1239
+				$data['altitude'] = $line['altitude']; // altitude
1240
+				$data['speed'] = $line['gs']; // speed
1241
+				$data['heading'] = $line['heading']; // heading
1242
+				$data['latitude'] = $line['latitude']; // lat
1243
+				$data['longitude'] = $line['longitude']; // long
1244
+				$data['verticalrate'] = ''; // verticale rate
1245
+				$data['squawk'] = ''; // squawk
1246
+				$data['emergency'] = ''; // emergency
1247
+				//$data['datetime'] = $line['lastupdate'];
1248
+				$data['last_update'] = $line['last_update'];
1249
+			$data['datetime'] = date('Y-m-d H:i:s');
1250
+				$data['departure_airport_icao'] = $line['departure'];
1251
+				//$data['departure_airport_time'] = $line['departure_time'];
1252
+				$data['arrival_airport_icao'] = $line['arrival'];
1253
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1254
+				//$data['registration'] = $line['aircraft'];
1255
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1256
+				$data['aircraft_icao'] = $line['plane_type'];
1257
+				$data['id_source'] = $id_source;
1258
+				$data['format_source'] = 'vam';
1259
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1260
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1261
+			$SI->add($data);
1262
+			unset($data);
1263 1263
 		}
1264 1264
 		if ($globalDebug) echo 'No more data...'."\n";
1265 1265
 		unset($buffer);
1266 1266
 		unset($all_data);
1267
-	    }
1268
-	    //$last_exec['phpvmacars'] = time();
1269
-	    $last_exec[$id]['last'] = time();
1267
+		}
1268
+		//$last_exec['phpvmacars'] = time();
1269
+		$last_exec[$id]['last'] = time();
1270 1270
 	} elseif ($value['format'] == 'blitzortung' && 
1271
-	    (
1271
+		(
1272 1272
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1273 1273
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1274
-	    )
1274
+		)
1275 1275
 	) {
1276
-	    //$buffer = $Common->getData($hosts[$id]);
1277
-	    if ($globalDebug) echo 'Get Data...'."\n";
1278
-	    $buffer = $Common->getData($value['host']);
1279
-	    $all_data = json_decode($buffer,true);
1280
-	    if ($buffer != '') {
1276
+		//$buffer = $Common->getData($hosts[$id]);
1277
+		if ($globalDebug) echo 'Get Data...'."\n";
1278
+		$buffer = $Common->getData($value['host']);
1279
+		$all_data = json_decode($buffer,true);
1280
+		if ($buffer != '') {
1281 1281
 		$Source->deleteLocationBySource('blitzortung');
1282 1282
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1283 1283
 		$buffer = explode('\n',$buffer);
1284 1284
 		foreach ($buffer as $buffer_line) {
1285
-		    $line = json_decode($buffer_line,true);
1286
-		    if (isset($line['time'])) {
1285
+			$line = json_decode($buffer_line,true);
1286
+			if (isset($line['time'])) {
1287 1287
 			$data = array();
1288 1288
 			$data['altitude'] = $line['alt']; // altitude
1289 1289
 			$data['latitude'] = $line['lat']; // lat
@@ -1295,96 +1295,96 @@  discard block
 block discarded – undo
1295 1295
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1296 1296
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1297 1297
 			unset($data);
1298
-		    }
1298
+			}
1299 1299
 		}
1300 1300
 		if ($globalDebug) echo 'No more data...'."\n";
1301 1301
 		unset($buffer);
1302
-	    }
1303
-	    $last_exec[$id]['last'] = time();
1302
+		}
1303
+		$last_exec[$id]['last'] = time();
1304 1304
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1305 1305
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1306
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1307
-    	    //$last_exec[$id]['last'] = time();
1306
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1307
+			//$last_exec[$id]['last'] = time();
1308 1308
 
1309
-	    //$read = array( $sockets[$id] );
1310
-	    $read = $sockets;
1311
-	    $write = NULL;
1312
-	    $e = NULL;
1313
-	    $n = socket_select($read, $write, $e, $timeout);
1314
-	    if ($e != NULL) var_dump($e);
1315
-	    if ($n > 0) {
1309
+		//$read = array( $sockets[$id] );
1310
+		$read = $sockets;
1311
+		$write = NULL;
1312
+		$e = NULL;
1313
+		$n = socket_select($read, $write, $e, $timeout);
1314
+		if ($e != NULL) var_dump($e);
1315
+		if ($n > 0) {
1316 1316
 		$reset = 0;
1317 1317
 		foreach ($read as $nb => $r) {
1318
-		    //$value = $formats[$nb];
1319
-		    $format = $globalSources[$nb]['format'];
1320
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1318
+			//$value = $formats[$nb];
1319
+			$format = $globalSources[$nb]['format'];
1320
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1321 1321
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1322
-		    } elseif ($format == 'vrstcp') {
1322
+			} elseif ($format == 'vrstcp') {
1323 1323
 			$buffer = @socket_read($r, 6000);
1324
-		    } else {
1324
+			} else {
1325 1325
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1326
-		    }
1327
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1328
-		    //echo $buffer."\n";
1329
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1330
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1331
-		    $error = false;
1332
-		    //$SI::del();
1333
-		    if ($buffer !== FALSE) {
1326
+			}
1327
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1328
+			//echo $buffer."\n";
1329
+			// lets play nice and handle signals such as ctrl-c/kill properly
1330
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1331
+			$error = false;
1332
+			//$SI::del();
1333
+			if ($buffer !== FALSE) {
1334 1334
 			if ($format == 'vrstcp') {
1335
-			    $buffer = explode('},{',$buffer);
1335
+				$buffer = explode('},{',$buffer);
1336 1336
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1337
-		    }
1338
-		    // SBS format is CSV format
1339
-		    if ($buffer !== FALSE && $buffer !== '') {
1337
+			}
1338
+			// SBS format is CSV format
1339
+			if ($buffer !== FALSE && $buffer !== '') {
1340 1340
 			$tt[$format] = 0;
1341 1341
 			if ($format == 'acarssbs3') {
1342
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1343
-			    $ACARS->add(trim($buffer));
1344
-			    $ACARS->deleteLiveAcarsData();
1342
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1343
+				$ACARS->add(trim($buffer));
1344
+				$ACARS->deleteLiveAcarsData();
1345 1345
 			} elseif ($format == 'raw') {
1346
-			    // AVR format
1347
-			    $data = $SBS->parse($buffer);
1348
-			    if (is_array($data)) {
1346
+				// AVR format
1347
+				$data = $SBS->parse($buffer);
1348
+				if (is_array($data)) {
1349 1349
 				$data['datetime'] = date('Y-m-d H:i:s');
1350 1350
 				$data['format_source'] = 'raw';
1351 1351
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1352 1352
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1353 1353
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1354 1354
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1355
-			    }
1355
+				}
1356 1356
 			} elseif ($format == 'ais') {
1357
-			    $ais_data = $AIS->parse_line(trim($buffer));
1358
-			    $data = array();
1359
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1360
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1361
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1362
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1363
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1364
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1365
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1366
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1367
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1368
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1369
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1370
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1371
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1372
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1373
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1374
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1357
+				$ais_data = $AIS->parse_line(trim($buffer));
1358
+				$data = array();
1359
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1360
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1361
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1362
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1363
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1364
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1365
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1366
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1367
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1368
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1369
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1370
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1371
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1372
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1373
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1374
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1375 1375
 
1376
-			    if (isset($ais_data['timestamp'])) {
1376
+				if (isset($ais_data['timestamp'])) {
1377 1377
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1378
-			    } else {
1378
+				} else {
1379 1379
 				$data['datetime'] = date('Y-m-d H:i:s');
1380
-			    }
1381
-			    $data['format_source'] = 'aisnmea';
1382
-    			    $data['id_source'] = $id_source;
1383
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1384
-			    unset($data);
1385
-                        } elseif ($format == 'flightgearsp') {
1386
-                    	    //echo $buffer."\n";
1387
-                    	    if (strlen($buffer) > 5) {
1380
+				}
1381
+				$data['format_source'] = 'aisnmea';
1382
+					$data['id_source'] = $id_source;
1383
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1384
+				unset($data);
1385
+						} elseif ($format == 'flightgearsp') {
1386
+							//echo $buffer."\n";
1387
+							if (strlen($buffer) > 5) {
1388 1388
 				$line = explode(',',$buffer);
1389 1389
 				$data = array();
1390 1390
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1401,38 +1401,38 @@  discard block
 block discarded – undo
1401 1401
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1402 1402
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1403 1403
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1404
-			    }
1405
-                        } elseif ($format == 'acars') {
1406
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1407
-			    $ACARS->add(trim($buffer));
1408
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1409
-			    $ACARS->deleteLiveAcarsData();
1404
+				}
1405
+						} elseif ($format == 'acars') {
1406
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1407
+				$ACARS->add(trim($buffer));
1408
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1409
+				$ACARS->deleteLiveAcarsData();
1410 1410
 			} elseif ($format == 'flightgearmp') {
1411
-			    if (substr($buffer,0,1) != '#') {
1411
+				if (substr($buffer,0,1) != '#') {
1412 1412
 				$data = array();
1413 1413
 				//echo $buffer."\n";
1414 1414
 				$line = explode(' ',$buffer);
1415 1415
 				if (count($line) == 11) {
1416
-				    $userserver = explode('@',$line[0]);
1417
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1418
-				    $data['ident'] = $userserver[0];
1419
-				    $data['registration'] = $userserver[0];
1420
-				    $data['latitude'] = $line[4];
1421
-				    $data['longitude'] = $line[5];
1422
-				    $data['altitude'] = $line[6];
1423
-				    $data['datetime'] = date('Y-m-d H:i:s');
1424
-				    $aircraft_type = $line[10];
1425
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1426
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1427
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1428
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1416
+					$userserver = explode('@',$line[0]);
1417
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1418
+					$data['ident'] = $userserver[0];
1419
+					$data['registration'] = $userserver[0];
1420
+					$data['latitude'] = $line[4];
1421
+					$data['longitude'] = $line[5];
1422
+					$data['altitude'] = $line[6];
1423
+					$data['datetime'] = date('Y-m-d H:i:s');
1424
+					$aircraft_type = $line[10];
1425
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1426
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1427
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1428
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1429
+				}
1429 1430
 				}
1430
-			    }
1431 1431
 			} elseif ($format == 'beast') {
1432
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1433
-			    die;
1432
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1433
+				die;
1434 1434
 			} elseif ($format == 'vrstcp') {
1435
-			    foreach($buffer as $all_data) {
1435
+				foreach($buffer as $all_data) {
1436 1436
 				$line = json_decode('{'.$all_data.'}',true);
1437 1437
 				$data = array();
1438 1438
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1452,153 +1452,153 @@  discard block
 block discarded – undo
1452 1452
 				*/
1453 1453
 				$data['datetime'] = date('Y-m-d H:i:s');
1454 1454
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1455
-		    		$data['format_source'] = 'vrstcp';
1455
+					$data['format_source'] = 'vrstcp';
1456 1456
 				$data['id_source'] = $id_source;
1457 1457
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1458 1458
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1459 1459
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1460 1460
 				unset($data);
1461
-			    }
1461
+				}
1462 1462
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1463
-			    $line = explode("\t", $buffer);
1464
-			    for($k = 0; $k < count($line); $k=$k+2) {
1463
+				$line = explode("\t", $buffer);
1464
+				for($k = 0; $k < count($line); $k=$k+2) {
1465 1465
 				$key = $line[$k];
1466
-			        $lined[$key] = $line[$k+1];
1467
-			    }
1468
-    			    if (count($lined) > 3) {
1469
-    				$data['hex'] = $lined['hexid'];
1470
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1471
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1472
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1473
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1474
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1475
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1476
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1477
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1478
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1479
-    				$data['id_source'] = $id_source;
1480
-    				$data['format_source'] = 'tsv';
1481
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1482
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1466
+					$lined[$key] = $line[$k+1];
1467
+				}
1468
+					if (count($lined) > 3) {
1469
+					$data['hex'] = $lined['hexid'];
1470
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1471
+					$data['datetime'] = date('Y-m-d H:i:s');;
1472
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1473
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1474
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1475
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1476
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1477
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1478
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1479
+					$data['id_source'] = $id_source;
1480
+					$data['format_source'] = 'tsv';
1481
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1482
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1483 1483
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1484
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1485
-    				unset($lined);
1486
-    				unset($data);
1487
-    			    } else $error = true;
1484
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1485
+					unset($lined);
1486
+					unset($data);
1487
+					} else $error = true;
1488 1488
 			} elseif ($format == 'aprs' && $use_aprs) {
1489
-			    if ($aprs_connect == 0) {
1489
+				if ($aprs_connect == 0) {
1490 1490
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1491 1491
 				$aprs_connect = 1;
1492
-			    }
1492
+				}
1493 1493
 			    
1494
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1494
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1495 1495
 				$aprs_last_tx = time();
1496 1496
 				$data_aprs = "# Keep alive";
1497 1497
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1498
-			    }
1498
+				}
1499 1499
 			    
1500
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1501
-			    //echo 'APRS data : '.$buffer."\n";
1502
-			    $buffer = str_replace('APRS <- ','',$buffer);
1503
-			    $buffer = str_replace('APRS -> ','',$buffer);
1504
-			    //echo $buffer."\n";
1505
-			    date_default_timezone_set('UTC');
1506
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1500
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1501
+				//echo 'APRS data : '.$buffer."\n";
1502
+				$buffer = str_replace('APRS <- ','',$buffer);
1503
+				$buffer = str_replace('APRS -> ','',$buffer);
1504
+				//echo $buffer."\n";
1505
+				date_default_timezone_set('UTC');
1506
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1507 1507
 				$line = $APRS->parse($buffer);
1508 1508
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1509 1509
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1510
-				    $aprs_last_tx = time();
1511
-				    $data = array();
1512
-				    //print_r($line);
1513
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1514
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1515
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1516
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1517
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1518
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1519
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1520
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1521
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1522
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1523
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1524
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1525
-				    $data['latitude'] = $line['latitude'];
1526
-				    $data['longitude'] = $line['longitude'];
1527
-				    //$data['verticalrate'] = $line[16];
1528
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1529
-				    //else $data['speed'] = 0;
1530
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1531
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1532
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1533
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1510
+					$aprs_last_tx = time();
1511
+					$data = array();
1512
+					//print_r($line);
1513
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1514
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1515
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1516
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1517
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1518
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1519
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1520
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1521
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1522
+					else $data['datetime'] = date('Y-m-d H:i:s');
1523
+					//$data['datetime'] = date('Y-m-d H:i:s');
1524
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1525
+					$data['latitude'] = $line['latitude'];
1526
+					$data['longitude'] = $line['longitude'];
1527
+					//$data['verticalrate'] = $line[16];
1528
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1529
+					//else $data['speed'] = 0;
1530
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1531
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1532
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1533
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1534 1534
 				    
1535
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1536
-				    //else echo 'No heading...'."\n";
1537
-				    //else $data['heading'] = 0;
1538
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1539
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1540
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1541
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1542
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1543
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1544
-    				    $data['id_source'] = $id_source;
1545
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1546
-				    else $data['format_source'] = 'aprs';
1547
-				    $data['source_name'] = $line['source'];
1548
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1549
-				    else $data['source_type'] = 'flarm';
1550
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1551
-				    $currentdate = date('Y-m-d H:i:s');
1552
-				    $aprsdate = strtotime($data['datetime']);
1553
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1554
-				    // Accept data if time <= system time + 20s
1555
-				    //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1556
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1535
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1536
+					//else echo 'No heading...'."\n";
1537
+					//else $data['heading'] = 0;
1538
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1539
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1540
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1541
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1542
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1543
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1544
+						$data['id_source'] = $id_source;
1545
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1546
+					else $data['format_source'] = 'aprs';
1547
+					$data['source_name'] = $line['source'];
1548
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1549
+					else $data['source_type'] = 'flarm';
1550
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1551
+					$currentdate = date('Y-m-d H:i:s');
1552
+					$aprsdate = strtotime($data['datetime']);
1553
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1554
+					// Accept data if time <= system time + 20s
1555
+					//if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1556
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1557 1557
 					$send = $SI->add($data);
1558
-				    } elseif ($data['source_type'] == 'ais') {
1558
+					} elseif ($data['source_type'] == 'ais') {
1559 1559
 					$data['type'] = '';
1560 1560
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1561
-				    } elseif (isset($line['stealth'])) {
1561
+					} elseif (isset($line['stealth'])) {
1562 1562
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1563 1563
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1564
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1565
-					    //$line['symbol'] == 'Balloon' ||
1566
-					    $line['symbol'] == 'Glider' || 
1567
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1568
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1569
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1570
-					    $send = $SI->add($data);
1571
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1572
-					    $line['symbol'] == 'Yacht (Sail)' || 
1573
-					    $line['symbol'] == 'Ship (Power Boat)')) {
1574
-					    $send = $MI->add($data);
1575
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1576
-					    $line['symbol'] == 'Car' || 
1577
-					    $line['symbol'] == 'Ambulance' || 
1578
-					    $line['symbol'] == 'Van' || 
1579
-					    $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1580
-					    $line['symbol'] == 'Motorcycle' || 
1581
-					    $line['symbol'] == 'Tractor' || 
1582
-					    $line['symbol'] == 'Police' || 
1583
-					    $line['symbol'] == 'Bike' || 
1584
-					    $line['symbol'] == 'Jogger' || 
1585
-					    $line['symbol'] == 'Horse' || 
1586
-					    $line['symbol'] == 'Bus' || 
1587
-					    $line['symbol'] == 'Jeep' || 
1588
-					    $line['symbol'] == 'Recreational Vehicle' || 
1589
-					    $line['symbol'] == 'Yacht (Sail)' || 
1590
-					    $line['symbol'] == 'Ship (Power Boat)' || 
1591
-					    $line['symbol'] == 'Firetruck' || 
1592
-					    $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1593
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1594
-					    $line['symbol'] == 'SUV' ||
1595
-					    $line['symbol'] == 'Snowmobile' ||
1596
-					    $line['symbol'] == 'Mobile Satellite Station')) {
1597
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1564
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1565
+						//$line['symbol'] == 'Balloon' ||
1566
+						$line['symbol'] == 'Glider' || 
1567
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1568
+						if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1569
+						if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1570
+						$send = $SI->add($data);
1571
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1572
+						$line['symbol'] == 'Yacht (Sail)' || 
1573
+						$line['symbol'] == 'Ship (Power Boat)')) {
1574
+						$send = $MI->add($data);
1575
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1576
+						$line['symbol'] == 'Car' || 
1577
+						$line['symbol'] == 'Ambulance' || 
1578
+						$line['symbol'] == 'Van' || 
1579
+						$line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1580
+						$line['symbol'] == 'Motorcycle' || 
1581
+						$line['symbol'] == 'Tractor' || 
1582
+						$line['symbol'] == 'Police' || 
1583
+						$line['symbol'] == 'Bike' || 
1584
+						$line['symbol'] == 'Jogger' || 
1585
+						$line['symbol'] == 'Horse' || 
1586
+						$line['symbol'] == 'Bus' || 
1587
+						$line['symbol'] == 'Jeep' || 
1588
+						$line['symbol'] == 'Recreational Vehicle' || 
1589
+						$line['symbol'] == 'Yacht (Sail)' || 
1590
+						$line['symbol'] == 'Ship (Power Boat)' || 
1591
+						$line['symbol'] == 'Firetruck' || 
1592
+						$line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1593
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1594
+						$line['symbol'] == 'SUV' ||
1595
+						$line['symbol'] == 'Snowmobile' ||
1596
+						$line['symbol'] == 'Mobile Satellite Station')) {
1597
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1598 1598
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1599 1599
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1600 1600
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1601
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1601
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1602 1602
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1603 1603
 					$Source->deleteOldLocationByType('gs');
1604 1604
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
 					} else {
1607 1607
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1608 1608
 					}
1609
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1609
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1610 1610
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1611 1611
 					if ($globalDebug) echo '# Weather Station added'."\n";
1612 1612
 					$Source->deleteOldLocationByType('wx');
@@ -1616,7 +1616,7 @@  discard block
 block discarded – undo
1616 1616
 					} else {
1617 1617
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1618 1618
 					}
1619
-				    } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1619
+					} elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1620 1620
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1621 1621
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1622 1622
 					$Source->deleteOldLocationByType('lightning');
@@ -1625,11 +1625,11 @@  discard block
 block discarded – undo
1625 1625
 					} else {
1626 1626
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1627 1627
 					}
1628
-				    } elseif ($globalDebug) {
1629
-				    	echo '/!\ Not added: '.$buffer."\n";
1630
-				    	print_r($line);
1631
-				    }
1632
-				    unset($data);
1628
+					} elseif ($globalDebug) {
1629
+						echo '/!\ Not added: '.$buffer."\n";
1630
+						print_r($line);
1631
+					}
1632
+					unset($data);
1633 1633
 				}
1634 1634
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1635 1635
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1648,12 +1648,12 @@  discard block
 block discarded – undo
1648 1648
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1649 1649
 					$globalSources[$nb]['last_weather_clean'] = time();
1650 1650
 				}
1651
-			    }
1651
+				}
1652 1652
 			} else {
1653
-			    $line = explode(',', $buffer);
1654
-    			    if (count($line) > 20) {
1655
-    			    	$data['hex'] = $line[4];
1656
-    				/*
1653
+				$line = explode(',', $buffer);
1654
+					if (count($line) > 20) {
1655
+						$data['hex'] = $line[4];
1656
+					/*
1657 1657
     				$data['datetime'] = $line[6].' '.$line[7];
1658 1658
     					date_default_timezone_set($globalTimezone);
1659 1659
     					$datetime = new DateTime($data['datetime']);
@@ -1661,30 +1661,30 @@  discard block
 block discarded – undo
1661 1661
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1662 1662
     					date_default_timezone_set('UTC');
1663 1663
     				*/
1664
-    				// Force datetime to current UTC datetime
1665
-    				date_default_timezone_set('UTC');
1666
-    				$data['datetime'] = date('Y-m-d H:i:s');
1667
-    				$data['ident'] = trim($line[10]);
1668
-    				$data['latitude'] = $line[14];
1669
-    				$data['longitude'] = $line[15];
1670
-    				$data['verticalrate'] = $line[16];
1671
-    				$data['emergency'] = $line[20];
1672
-    				$data['speed'] = $line[12];
1673
-    				$data['squawk'] = $line[17];
1674
-    				$data['altitude'] = $line[11];
1675
-    				$data['heading'] = $line[13];
1676
-    				$data['ground'] = $line[21];
1677
-    				$data['emergency'] = $line[19];
1678
-    				$data['format_source'] = 'sbs';
1664
+					// Force datetime to current UTC datetime
1665
+					date_default_timezone_set('UTC');
1666
+					$data['datetime'] = date('Y-m-d H:i:s');
1667
+					$data['ident'] = trim($line[10]);
1668
+					$data['latitude'] = $line[14];
1669
+					$data['longitude'] = $line[15];
1670
+					$data['verticalrate'] = $line[16];
1671
+					$data['emergency'] = $line[20];
1672
+					$data['speed'] = $line[12];
1673
+					$data['squawk'] = $line[17];
1674
+					$data['altitude'] = $line[11];
1675
+					$data['heading'] = $line[13];
1676
+					$data['ground'] = $line[21];
1677
+					$data['emergency'] = $line[19];
1678
+					$data['format_source'] = 'sbs';
1679 1679
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1680
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1680
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1681 1681
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1682
-    				$data['id_source'] = $id_source;
1683
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1684
-    				else $error = true;
1685
-    				unset($data);
1686
-    			    } else $error = true;
1687
-			    if ($error) {
1682
+					$data['id_source'] = $id_source;
1683
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1684
+					else $error = true;
1685
+					unset($data);
1686
+					} else $error = true;
1687
+				if ($error) {
1688 1688
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1689 1689
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1690 1690
 				} else {
@@ -1700,13 +1700,13 @@  discard block
 block discarded – undo
1700 1700
 					connect_all($sourceer);
1701 1701
 					$sourceer = array();
1702 1702
 				}
1703
-			    }
1703
+				}
1704 1704
 			}
1705 1705
 			// Sleep for xxx microseconds
1706 1706
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1707
-		    } else {
1707
+			} else {
1708 1708
 			if ($format == 'flightgearmp') {
1709
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1709
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1710 1710
 				//@socket_close($r);
1711 1711
 				sleep($globalMinFetch);
1712 1712
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1715,9 +1715,9 @@  discard block
 block discarded – undo
1715 1715
 				break;
1716 1716
 				
1717 1717
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1718
-			    if (isset($tt[$format])) $tt[$format]++;
1719
-			    else $tt[$format] = 0;
1720
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
1718
+				if (isset($tt[$format])) $tt[$format]++;
1719
+				else $tt[$format] = 0;
1720
+				if ($tt[$format] > 30 || $buffer === FALSE) {
1721 1721
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1722 1722
 				//@socket_close($r);
1723 1723
 				sleep(2);
@@ -1728,24 +1728,24 @@  discard block
 block discarded – undo
1728 1728
 				//connect_all($globalSources);
1729 1729
 				$tt[$format]=0;
1730 1730
 				break;
1731
-			    } 
1732
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1731
+				} 
1732
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1733
+			}
1733 1734
 			}
1734
-		    }
1735 1735
 		}
1736
-	    } else {
1736
+		} else {
1737 1737
 		$error = socket_strerror(socket_last_error());
1738 1738
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1739 1739
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1740 1740
 			if (isset($globalDebug)) echo "Restarting...\n";
1741 1741
 			// Restart the script if possible
1742 1742
 			if (is_array($sockets)) {
1743
-			    if ($globalDebug) echo "Shutdown all sockets...";
1743
+				if ($globalDebug) echo "Shutdown all sockets...";
1744 1744
 			    
1745
-			    foreach ($sockets as $sock) {
1745
+				foreach ($sockets as $sock) {
1746 1746
 				@socket_shutdown($sock,2);
1747 1747
 				@socket_close($sock);
1748
-			    }
1748
+				}
1749 1749
 			    
1750 1750
 			}
1751 1751
 			if ($globalDebug) echo "Waiting...";
@@ -1760,15 +1760,15 @@  discard block
 block discarded – undo
1760 1760
 			if ($globalDebug) echo "Restart all connections...";
1761 1761
 			connect_all($globalSources);
1762 1762
 		}
1763
-	    }
1763
+		}
1764 1764
 	}
1765 1765
 	if ($globalDaemon === false) {
1766
-	    if ($globalDebug) echo 'Check all...'."\n";
1767
-	    if (isset($SI)) $SI->checkAll();
1768
-	    if (isset($TI)) $TI->checkAll();
1769
-	    if (isset($MI)) $MI->checkAll();
1766
+		if ($globalDebug) echo 'Check all...'."\n";
1767
+		if (isset($SI)) $SI->checkAll();
1768
+		if (isset($TI)) $TI->checkAll();
1769
+		if (isset($MI)) $MI->checkAll();
1770
+	}
1770 1771
 	}
1771
-    }
1772 1772
 }
1773 1773
 
1774 1774
 ?>
Please login to merge, or discard this patch.